Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gabriel Monnerat
erp5
Commits
0ef0a611
Commit
0ef0a611
authored
Feb 16, 2020
by
Gabriel Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_document_scanner: Improve Cropper renderization
parent
c29ff42a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
34 deletions
+52
-34
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/rjs_gadget_document_scanner_css.css
...eItem/web_page_module/rjs_gadget_document_scanner_css.css
+16
-2
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/rjs_gadget_document_scanner_css.xml
...eItem/web_page_module/rjs_gadget_document_scanner_css.xml
+2
-2
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/rjs_gadget_document_scanner_js.js
...ateItem/web_page_module/rjs_gadget_document_scanner_js.js
+32
-28
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/rjs_gadget_document_scanner_js.xml
...teItem/web_page_module/rjs_gadget_document_scanner_js.xml
+2
-2
No files found.
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/rjs_gadget_document_scanner_css.css
View file @
0ef0a611
...
@@ -2,6 +2,15 @@ div[data-gadget-url$="gadget_document_scanner.html"] {
...
@@ -2,6 +2,15 @@ div[data-gadget-url$="gadget_document_scanner.html"] {
text-align
:
center
;
text-align
:
center
;
}
}
@media
only
screen
and
(
max-width
:
750px
)
{
div
[
data-gadget-url
$
=
"gadget_document_scanner.html"
]
.camera
{
max-width
:
90%
;
}
div
[
data-gadget-url
$
=
"gadget_document_scanner.html"
]
.new-btn
{
min-width
:
35%
;
}
}
div
[
data-gadget-url
$
=
"gadget_document_scanner.html"
]
.photo
,
div
[
data-gadget-url
$
=
"gadget_document_scanner.html"
]
.photo
,
div
[
data-gadget-url
$
=
"gadget_document_scanner.html"
]
.video
,
div
[
data-gadget-url
$
=
"gadget_document_scanner.html"
]
.video
,
div
[
data-gadget-url
$
=
"gadget_document_scanner.html"
]
.camera-output
,
div
[
data-gadget-url
$
=
"gadget_document_scanner.html"
]
.camera-output
,
...
@@ -85,5 +94,10 @@ div[data-gadget-url$="gadget_document_scanner.html"] .upload-error {
...
@@ -85,5 +94,10 @@ div[data-gadget-url$="gadget_document_scanner.html"] .upload-error {
}
}
div
[
data-gadget-url
$
=
"gadget_document_scanner.html"
]
.new-btn
{
div
[
data-gadget-url
$
=
"gadget_document_scanner.html"
]
.new-btn
{
font-size
:
26pt
;
font-size
:
13pt
;
display
:
inline-grid
!important
;
padding
:
18pt
;
margin-left
:
0.2em
;
border
:
1px
solid
rgba
(
0
,
0
,
0
,
0.14
);
border-radius
:
0.325em
;
}
}
\ No newline at end of file
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/rjs_gadget_document_scanner_css.xml
View file @
0ef0a611
...
@@ -244,7 +244,7 @@
...
@@ -244,7 +244,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
981.5
3994.46343.31095
</string>
</value>
<value>
<string>
981.5
7889.14448.17681
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -262,7 +262,7 @@
...
@@ -262,7 +262,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
1581
629502.14
</float>
<float>
1581
863137.03
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/rjs_gadget_document_scanner_js.js
View file @
0ef0a611
...
@@ -142,9 +142,7 @@
...
@@ -142,9 +142,7 @@
var
j
,
var
j
,
device
,
device
,
len
=
info_list
.
length
;
len
=
info_list
.
length
;
for
(
j
=
0
;
j
<
len
;
j
+=
1
)
{
for
(
j
=
len
-
1
;
j
>=
0
;
j
-=
1
)
{
// trick to select back camera in mobile
device
=
info_list
[
j
];
device
=
info_list
[
j
];
if
(
device
.
kind
===
'
videoinput
'
)
{
if
(
device
.
kind
===
'
videoinput
'
)
{
if
((
!
current_device_id
)
||
if
((
!
current_device_id
)
||
...
@@ -209,13 +207,13 @@
...
@@ -209,13 +207,13 @@
src
:
gadget
.
state
[
'
blob_url_
'
+
i
]})]));
src
:
gadget
.
state
[
'
blob_url_
'
+
i
]})]));
}
}
}
}
return
domsugar
(
"
div
"
,
{
"
class
"
:
"
thumbnail-area
"
},
[
thumbnail_dom_list
.
push
(
domsugar
(
'
button
'
,
{
type
:
'
button
'
,
domsugar
(
'
button
'
,
{
type
:
'
button
'
,
text
:
'
New Page
'
,
// Do not allow to show again the current image
// Do not allow to show again the current image
disabled
:
(
len
===
gadget
.
state
.
page
-
1
),
disabled
:
(
len
===
gadget
.
state
.
page
-
1
),
'
class
'
:
'
new-btn ui-btn-icon-left ui-icon-plus
'
}),
class
:
'
new-btn ui-btn-icon-left ui-icon-plus
'
domsugar
(
'
ol
'
,
{
"
class
"
:
"
thumbnail-list
"
},
thumbnail_dom_list
)
}));
]
);
return
domsugar
(
'
ol
'
,
{
"
class
"
:
"
thumbnail-list
"
},
thumbnail_dom_list
);
});
});
}
}
...
@@ -305,17 +303,28 @@
...
@@ -305,17 +303,28 @@
return
image_capture
.
takePhoto
({
imageWidth
:
capabilities
.
imageWidth
.
max
});
return
image_capture
.
takePhoto
({
imageWidth
:
capabilities
.
imageWidth
.
max
});
})
})
.
push
(
function
(
blob
)
{
.
push
(
function
(
blob
)
{
return
createImageBitmap
(
blob
);
})
.
push
(
function
(
bitmap
)
{
var
canvas
=
domsugar
(
'
canvas
'
,
{
'
class
'
:
'
canvas
'
});
canvas
.
width
=
bitmap
.
width
;
canvas
.
height
=
bitmap
.
height
;
canvas
.
getContext
(
'
2d
'
).
drawImage
(
bitmap
,
0
,
0
);
return
canvas
;
})
.
push
(
function
(
canvas
)
{
var
new_canvas
;
gadget
.
detached_promise_dict
.
media_stream
.
cancel
(
'
Not needed anymore, as captured
'
);
gadget
.
detached_promise_dict
.
media_stream
.
cancel
(
'
Not needed anymore, as captured
'
);
if
(
settings
.
brightness
||
settings
.
contrast
||
settings
.
enable_greyscale
||
settings
.
compression
)
{
if
(
settings
.
brightness
||
settings
.
contrast
||
settings
.
enable_greyscale
||
settings
.
compression
)
{
new_canvas
=
domsugar
(
'
canvas
'
,
{
'
class
'
:
'
canvas
'
,
'
width
'
:
canvas
.
width
,
'
height
'
:
canvas
.
height
});
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
jIO
.
util
.
readBlobAsDataURL
(
blob
);
})
.
push
(
function
(
result
)
{
.
push
(
function
(
result
)
{
var
canvas
=
domsugar
(
'
canvas
'
,
{
'
class
'
:
'
canvas
'
});
return
new
Promise
(
function
(
resolve
)
{
return
new
Promise
(
function
(
resolve
)
{
// XXX the correct usage is `new Caman()` but the library does not support it
// XXX the correct usage is `new Caman()` but the library does not support it
caman
(
canvas
,
result
.
target
.
result
,
function
()
{
caman
(
new_canvas
,
canvas
.
toDataURL
()
,
function
()
{
if
(
settings
.
brightness
&&
settings
.
brightness
!==
0
)
{
if
(
settings
.
brightness
&&
settings
.
brightness
!==
0
)
{
this
.
brightness
(
settings
.
brightness
);
this
.
brightness
(
settings
.
brightness
);
}
}
...
@@ -326,31 +335,27 @@
...
@@ -326,31 +335,27 @@
this
.
greyscale
();
this
.
greyscale
();
}
}
this
.
render
(
function
()
{
this
.
render
(
function
()
{
canvas
.
toBlob
(
function
(
blob
)
{
resolve
(
new_canvas
);
resolve
(
blob
);
});
});
});
});
});
});
});
});
});
}
}
return
blob
;
return
canvas
;
})
})
.
push
(
function
(
blob
)
{
.
push
(
function
(
canvas
)
{
return
RSVP
.
all
([
return
RSVP
.
all
([
gadget
.
getTranslationList
([
"
Delete
"
,
"
Save
"
]),
gadget
.
getTranslationList
([
"
Delete
"
,
"
Save
"
]),
createImageBitmap
(
blob
),
new
Promise
(
function
(
resolve
)
{
resolve
(
canvas
);
}),
buildPreviousThumbnailDom
(
gadget
)
buildPreviousThumbnailDom
(
gadget
)
]);
]);
})
})
.
push
(
function
(
result_list
)
{
.
push
(
function
(
result_list
)
{
var
bitmap
=
result_list
[
1
],
var
canvas
=
result_list
[
1
],
canvas
=
domsugar
(
'
canvas
'
,
{
'
class
'
:
'
canvas
'
}),
defer
=
RSVP
.
defer
();
defer
=
RSVP
.
defer
();
// Prepare the cropper canvas
// Prepare the cropper canvas
canvas
.
width
=
bitmap
.
width
;
canvas
.
height
=
bitmap
.
height
;
canvas
.
getContext
(
'
2d
'
).
drawImage
(
bitmap
,
0
,
0
);
div
=
domsugar
(
'
div
'
,
{
'
class
'
:
'
camera
'
},
[
div
=
domsugar
(
'
div
'
,
{
'
class
'
:
'
camera
'
},
[
domsugar
(
'
div
'
,
{
'
class
'
:
'
camera-header
'
},
[
domsugar
(
'
div
'
,
{
'
class
'
:
'
camera-header
'
},
[
...
@@ -376,7 +381,6 @@
...
@@ -376,7 +381,6 @@
// XXX How to change the dom only when cropper is ready?
// XXX How to change the dom only when cropper is ready?
// For now, it needs to access dom element size
// For now, it needs to access dom element size
gadget
.
element
.
replaceChild
(
div
,
gadget
.
element
.
firstElementChild
);
gadget
.
element
.
replaceChild
(
div
,
gadget
.
element
.
firstElementChild
);
addDetachedPromise
(
gadget
,
'
cropper
'
,
addDetachedPromise
(
gadget
,
'
cropper
'
,
handleCropper
(
canvas
,
handleCropper
(
canvas
,
gadget
.
state
.
preferred_cropped_canvas_data
,
gadget
.
state
.
preferred_cropped_canvas_data
,
...
@@ -519,7 +523,7 @@
...
@@ -519,7 +523,7 @@
// if display_step is not modified
// if display_step is not modified
return
buildPreviousThumbnailDom
(
gadget
)
return
buildPreviousThumbnailDom
(
gadget
)
.
push
(
function
(
result
)
{
.
push
(
function
(
result
)
{
thumbnail_container
=
gadget
.
element
.
querySelector
(
'
.thumbnail-
area
'
);
thumbnail_container
=
gadget
.
element
.
querySelector
(
'
.thumbnail-
list
'
);
thumbnail_container
.
parentElement
.
replaceChild
(
thumbnail_container
.
parentElement
.
replaceChild
(
result
,
result
,
thumbnail_container
thumbnail_container
...
...
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/rjs_gadget_document_scanner_js.xml
View file @
0ef0a611
...
@@ -244,7 +244,7 @@
...
@@ -244,7 +244,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
981.5
4005.25628.18841
</string>
</value>
<value>
<string>
981.5
7848.5692.33382
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -262,7 +262,7 @@
...
@@ -262,7 +262,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
1581
630274.1
</float>
<float>
1581
860732.16
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment