thorough rework of API

This commit is contained in:
jywarren
2017-03-03 10:51:58 -05:00
parent f56e833540
commit fc63c88d5a
11 changed files with 202 additions and 228 deletions

View File

@@ -4,7 +4,7 @@
*/
module.exports = function ImageSelect(options) {
//window.$ = window.jQuery = require('jquery');
if (!window.hasOwnProperty('$')) window.$ = window.jQuery = require('jquery');
options = options || {};
options.selector = options.selector || "#drop";
@@ -12,11 +12,11 @@ module.exports = function ImageSelect(options) {
options.ui = options.ui || {};
options.ui.el = options.ui.el || $(options.selector);
if (options.ui.el.length === 0) console.log('No UI element found with given selector: ', options.selector);
var image,
el = options.ui.el;
console.log(el,$('body'));
function setup() {
// CSS UI
@@ -50,7 +50,7 @@ console.log(el,$('body'));
el.html(image); // may be redundant
// this is done once per image:
options.onComplete(image);
options.output(image);
}
reader.readAsDataURL(f);
@@ -69,8 +69,10 @@ console.log(el,$('body'));
}
function draw(_image) {
if (options.onComplete) options.onComplete(image);
// this module is unique because it creates the image
function draw(image) {
options.ui.display(image);
if (options.output) options.output(image);
}
function get() {