Commit bada7ea6 authored by Gabriel Monnerat's avatar Gabriel Monnerat

erp5_document_scanner: stop using addEventListener and alert

Use onEvent instead of addEventListener
parent 2be9ce06
/*jslint indent: 2 */ /*jslint indent: 2 */
/*global rJS, RSVP, window, document, navigator, Cropper, alert, FileReader, jIO */ /*global rJS, RSVP, window, document, navigator, Cropper, console, FileReader, jIO */
(function (rJS, RSVP, window, document, navigator, Cropper, alert, FileReader, jIO) { (function (rJS, RSVP, window, document, navigator, Cropper, console, FileReader, jIO) {
"use strict"; "use strict";
var imageWidth, var imageWidth,
...@@ -141,17 +141,6 @@ ...@@ -141,17 +141,6 @@
imageHeight = photoCapabilities.imageHeight.max; imageHeight = photoCapabilities.imageHeight.max;
document.querySelector("textarea[name='field_your_description']").value = "Max => " + imageWidth + "x" + imageHeight; document.querySelector("textarea[name='field_your_description']").value = "Max => " + imageWidth + "x" + imageHeight;
video.play(); video.play();
})
.push(function () {
/*
XXX remove addEventListener. Instead, use renderJS declareService / onEvent,
which will handle unloading the listener and correctly catching errors
Remove soon
*/
startbutton.addEventListener("click", function (evt) {
evt.preventDefault();
takePicture(gadget);
}, false);
}); });
} }
...@@ -216,16 +205,22 @@ ...@@ -216,16 +205,22 @@
return startup(root, evt.target.value); return startup(root, evt.target.value);
} }
}); });
})
.then(undefined, function (e) {
alert(e);
}); });
}) })
.declareMethod('getContent', function () { .declareMethod('getContent', function () {
var input = this.element.querySelector('.photoInput'), var input = this.element.querySelector('.photoInput'),
result = {}; result = {};
result.field_your_document_scanner_gadget = input.value; result.field_your_document_scanner_gadget = input.value;
return result; return result;
}); })
.onEvent("click", function (evt) {
if (evt.target.className == "startbutton") {
return this.getElement()
.push(function (gadget) {
return takePicture(gadget);
});
}
}, false, true);
}(rJS, RSVP, window, document, navigator, Cropper, alert, FileReader, jIO)); }(rJS, RSVP, window, document, navigator, Cropper, console, FileReader, jIO));
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment