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
Labels
Merge Requests
138
Merge Requests
138
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
ecb90eb6
Commit
ecb90eb6
authored
Sep 24, 2019
by
Gabriel Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_document_scanner: Use promises properly in order to handle promise cancellation
parent
a3c78a4d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
10 deletions
+20
-10
erp5_document_scanner/SkinTemplateItem/portal_skins/erp5_document_scanner/gadget_document_scanner.js.js
...skins/erp5_document_scanner/gadget_document_scanner.js.js
+20
-10
No files found.
erp5_document_scanner/SkinTemplateItem/portal_skins/erp5_document_scanner/gadget_document_scanner.js.js
View file @
ecb90eb6
/*jslint indent: 2 */
/*global rJS, RSVP, window, document, navigator, Cropper, console, FileReader, jIO
*/
(
function
(
rJS
,
RSVP
,
window
,
document
,
navigator
,
Cropper
,
console
,
FileReader
,
jIO
)
{
/*global rJS, RSVP, window, document, navigator, Cropper, console, FileReader, jIO
, Promise
*/
(
function
(
rJS
,
RSVP
,
window
,
document
,
navigator
,
Cropper
,
console
,
FileReader
,
jIO
,
Promise
)
{
"
use strict
"
;
var
imageWidth
,
...
...
@@ -206,11 +206,22 @@
if
(
evt
.
target
.
className
==
"
capture-button
"
)
{
canvasData
=
cropper
.
getCanvasData
();
storage
.
put
(
"
settings
"
,
cropper
.
getData
());
cropper
.
getCroppedCanvas
().
toBlob
(
function
(
blob
)
{
var
reader
=
new
window
.
FileReader
();
reader
.
readAsDataURL
(
blob
);
reader
.
onloadend
=
function
()
{
var
base64data
=
reader
.
result
,
return
RSVP
.
Queue
()
.
push
(
function
()
{
return
cropper
.
getCroppedCanvas
();
})
.
push
(
function
(
canvas
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
canvas
.
toBlob
(
function
(
blob
)
{
resolve
(
blob
);
});
});
})
.
push
(
function
(
blob
)
{
return
jIO
.
util
.
readBlobAsDataURL
(
blob
);
})
.
push
(
function
(
evt
)
{
var
base64data
=
evt
.
target
.
result
,
block
=
base64data
.
split
(
"
;
"
),
realData
=
block
[
1
].
split
(
"
,
"
)[
1
];
...
...
@@ -220,9 +231,8 @@
photo
.
src
=
base64data
;
photoInput
.
value
=
realData
;
cropper
.
destroy
();
};
});
});
}
},
false
,
true
);
}(
rJS
,
RSVP
,
window
,
document
,
navigator
,
Cropper
,
console
,
FileReader
,
jIO
));
\ No newline at end of file
}(
rJS
,
RSVP
,
window
,
document
,
navigator
,
Cropper
,
console
,
FileReader
,
jIO
,
Promise
));
\ No newline at end of file
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