mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-14 12:19:58 +01:00
thorough rework of API
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user