From 38a569b958363159ff447b3149dd5091a71a0708 Mon Sep 17 00:00:00 2001 From: "Chinmay Pandhare (CCD)" <1000011C1010000@gmail.com> Date: Wed, 15 Mar 2017 02:03:55 +0530 Subject: [PATCH] Fix for Issue9 : Error while adding a new step from HTML UI, A small fix for #7 (#16) * Fix : add a step in the demo * Change global variable to document.sequencer_image * Change global variable to document.sequencer_image * Small fix for FireFox; Ref: Issue #7 * Change document.sequencer_image to options.image * Change document.sequencer_image to options.initial_image * Completed the addStep issue. * Completed the addStep issue. * Change options.initial_image to options.initialImage * Added Crop Module * lowercase parameters * Merging Crop.js * Merging Crop.js * Merging Crop.js --- dist/image-sequencer.js | 9 +++++++-- index.html | 3 +-- src/ImageSequencer.js | 5 ++++- src/modules/ImageSelect.js | 5 +++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/dist/image-sequencer.js b/dist/image-sequencer.js index a879db02..f452972e 100644 --- a/dist/image-sequencer.js +++ b/dist/image-sequencer.js @@ -184197,6 +184197,9 @@ ImageSequencer = function ImageSequencer(options) { if (previousStep) { // connect output of last step to input of this step previousStep.options.output = function output(image) { + if (sequencer.steps[0].options.initialImage) { + options.initialImage = sequencer.steps[0].options.initialImage; + } log('running module "' + name + '"'); // display the image in any available ui if (previousStep.options.ui && previousStep.options.ui.display) previousStep.options.ui.display(image); @@ -184235,6 +184238,7 @@ ImageSequencer = function ImageSequencer(options) { image.onload = function() { run(image); if (callback) callback(image); + options.initialImage = image; } image.src = src; } @@ -184443,8 +184447,8 @@ module.exports = function ImageSelect(options) { // we should trigger "load" event here image = new Image(); - image.src = event.target.result; - + image.src = e.target.result; + options.initialImage = image; el.html(image); // may be redundant // this is done once per image: @@ -184470,6 +184474,7 @@ module.exports = function ImageSelect(options) { // this module is unique because it creates the image function draw(image) { el.html(image); + options.initialImage = image; if (options.output) options.output(image); } diff --git a/index.html b/index.html index 61b7a5e9..7b410446 100644 --- a/index.html +++ b/index.html @@ -73,10 +73,9 @@ //sequencer.addStep('plot'); $('.add-step').click(function(e) { - e.preventDefault(); sequencer.addStep($('.select-module').val()); - sequencer.run(); // later we might only run this step, if we can fetch the image output from the previous + sequencer.run(sequencer.options.initialImage); // later we might only run this step, if we can fetch the image output from the previous }); diff --git a/src/ImageSequencer.js b/src/ImageSequencer.js index 828eaf9e..a48096cf 100644 --- a/src/ImageSequencer.js +++ b/src/ImageSequencer.js @@ -51,6 +51,9 @@ ImageSequencer = function ImageSequencer(options) { if (previousStep) { // connect output of last step to input of this step previousStep.options.output = function output(image) { + if (sequencer.steps[0].options.initialImage) { + options.initialImage = sequencer.steps[0].options.initialImage; + } log('running module "' + name + '"'); // display the image in any available ui if (previousStep.options.ui && previousStep.options.ui.display) previousStep.options.ui.display(image); @@ -83,12 +86,12 @@ ImageSequencer = function ImageSequencer(options) { // load default starting image // i.e. from parameter // this could send the image to ImageSelect, or something? -// not currently working function loadImage(src, callback) { image = new Image(); image.onload = function() { run(image); if (callback) callback(image); + options.initialImage = image; } image.src = src; } diff --git a/src/modules/ImageSelect.js b/src/modules/ImageSelect.js index d375fd79..a4d14251 100644 --- a/src/modules/ImageSelect.js +++ b/src/modules/ImageSelect.js @@ -41,8 +41,8 @@ module.exports = function ImageSelect(options) { // we should trigger "load" event here image = new Image(); - image.src = event.target.result; - + image.src = e.target.result; + options.initialImage = image; el.html(image); // may be redundant // this is done once per image: @@ -68,6 +68,7 @@ module.exports = function ImageSelect(options) { // this module is unique because it creates the image function draw(image) { el.html(image); + options.initialImage = image; if (options.output) options.output(image); }