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

@@ -1,36 +1,38 @@
/*
* Default UI for ImageBoard
* Default UI for each image-sequencer module
*/
module.exports = function UserInterface(options) {
options = options || {};
options.container = options.container || ".panels";
// method to create a UI for a given module
function create(o) {
o.random = o.random || parseInt(Math.random() * (new Date()).getTime() / 1000000);
o.uniqueSelector = o.uniqueSelector || o.selector + '-' + o.random;
$(options.container).append('<div class="panel ' + o.selector + ' ' + o.uniqueSelector + '"></div>');
o.el = o.el || $('.' + o.uniqueSelector);
return {
el: o.el,
uniqueSelector: o.uniqueSelector,
selector: o.selector
}
options.random = options.random || parseInt(Math.random() * (new Date()).getTime() / 1000000);
options.uniqueSelector = options.uniqueSelector || options.selector + '-' + options.random;
$(options.container).append('<div class="panel ' + options.selector + ' ' + options.uniqueSelector + '"></div>');
options.el = options.el || $('.' + options.uniqueSelector);
createLabel(options.el);
// method to remove the UI for a given method, and remove the step
function display(image) {
options.el.html(image);
}
// method to remove the UI for a given method, and remove the step
function remove() {
}
function remove() {}
// method to reorder steps, and update the UI
//function move() {
//function move() {}
//}
function createLabel(el) {
console.log("createLabel", module.title)
el.append('<h3 class="title">' + module.title + '</h3>');
}
return {
create: create,
el: options.el,
uniqueSelector: options.uniqueSelector,
selector: options.selector,
display: display,
remove: remove
}