mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-14 12:19:58 +01:00
Final changes to removeStep
This commit is contained in:
@@ -5,6 +5,7 @@ ImageSequencer = function ImageSequencer(options) {
|
||||
options = options || {};
|
||||
options.inBrowser = options.inBrowser || typeof window !== 'undefined';
|
||||
if (options.inBrowser) options.ui = options.ui || require('./UserInterface');
|
||||
options.sequencer_counter = 0;
|
||||
options.initialImage = "";
|
||||
|
||||
var image,
|
||||
@@ -19,7 +20,13 @@ ImageSequencer = function ImageSequencer(options) {
|
||||
function addStep(name, o) {
|
||||
console.log('adding step "' + name + '"');
|
||||
|
||||
if (!(options.instanceName) && this != window)
|
||||
for(var variable in window)
|
||||
if(window[variable] == this)
|
||||
options.instanceName = variable;
|
||||
|
||||
o = o || {};
|
||||
o.id = options.sequencer_counter++; //Gives a Unique ID to each step
|
||||
o.name = o.name || name;
|
||||
o.selector = o.selector || 'ismod-' + name;
|
||||
o.container = o.container || options.selector;
|
||||
@@ -31,7 +38,9 @@ ImageSequencer = function ImageSequencer(options) {
|
||||
function defaultSetupModule() {
|
||||
if (options.ui) module.options.ui = options.ui({
|
||||
selector: o.selector,
|
||||
title: module.options.title
|
||||
title: module.options.title,
|
||||
id: o.id,
|
||||
instanceName: options.instanceName
|
||||
});
|
||||
}
|
||||
|
||||
@@ -72,6 +81,17 @@ ImageSequencer = function ImageSequencer(options) {
|
||||
|
||||
}
|
||||
|
||||
function removeStep (id) {
|
||||
for (i=0;i<steps.length;i++) {
|
||||
if (steps[i].options.id == id && steps[i].options.name != 'image-select'){
|
||||
console.log('removing step "'+steps[i].options.name+'"');
|
||||
if (options.inBrowser) $('div#sequencer-'+id).remove();
|
||||
steps.splice(i,1);
|
||||
run(options.initialImage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// passed image is optional but you can pass a
|
||||
// non-stored image through the whole steps chain
|
||||
function run(image) {
|
||||
@@ -89,6 +109,10 @@ ImageSequencer = function ImageSequencer(options) {
|
||||
// this could send the image to ImageSelect, or something?
|
||||
// not currently working
|
||||
function loadImage(src, callback) {
|
||||
if (!(options.instanceName) && this != window)
|
||||
for(var variable in window)
|
||||
if(window[variable] == this)
|
||||
options.instanceName = variable;
|
||||
image = new Image();
|
||||
image.onload = function() {
|
||||
run(image);
|
||||
@@ -102,6 +126,7 @@ ImageSequencer = function ImageSequencer(options) {
|
||||
options: options,
|
||||
loadImage: loadImage,
|
||||
addStep: addStep,
|
||||
removeStep: removeStep,
|
||||
run: run,
|
||||
modules: modules,
|
||||
steps: steps,
|
||||
|
||||
Reference in New Issue
Block a user