diff --git a/examples/index.html b/examples/index.html index 21362614..5c5c160e 100644 --- a/examples/index.html +++ b/examples/index.html @@ -20,6 +20,7 @@ + diff --git a/examples/lib/defaultHtmlStepUi.js b/examples/lib/defaultHtmlStepUi.js index 6a24ea38..c4b55e97 100644 --- a/examples/lib/defaultHtmlStepUi.js +++ b/examples/lib/defaultHtmlStepUi.js @@ -23,13 +23,13 @@ function DefaultHtmlStepUi(_sequencer, options) { options = options || {}; var stepsEl = options.stepsEl || document.querySelector("#steps"); var selectStepSel = options.selectStepSel = options.selectStepSel || "#selectStep"; - function onSetup(step) { if (step.options && step.options.description) step.description = step.options.description; step.ui = '\ +
\
\
\

' + @@ -44,18 +44,27 @@ function DefaultHtmlStepUi(_sequencer, options) { \

\
\ - '; +
\ + '; var tools = '
\ \ -
'; + \ + '; + var util; + setTimeout(function(){ + util=IntermediateHtmlStepUi(_sequencer,step) + },500) + var parser = new DOMParser(); step.ui = parser.parseFromString(step.ui, "text/html"); - step.ui = step.ui.querySelector("div.row"); + step.ui = step.ui.querySelector("div.container"); step.linkElements = step.ui.querySelectorAll("a"); step.imgElement = step.ui.querySelector("a img"); @@ -163,6 +172,10 @@ function DefaultHtmlStepUi(_sequencer, options) { .appendChild( parser.parseFromString(tools, "text/html").querySelector("div") ); + setTimeout(()=>{ + $(step.ui.querySelectorAll(".insert-step")).on('click',function(){util.insertStep(step.ID)}); + },500) + } stepsEl.appendChild(step.ui); } diff --git a/examples/lib/intermediateHtmlStepUi.js b/examples/lib/intermediateHtmlStepUi.js new file mode 100644 index 00000000..4a449e07 --- /dev/null +++ b/examples/lib/intermediateHtmlStepUi.js @@ -0,0 +1,119 @@ +function IntermediateHtmlStepUi(_sequencer, step, options) { + function stepUI() { + return '
\ +
\ +
\ +
\ +
\ +

Select a new module to add to your sequence.

\ +
\ +
\ + \ +

Brightness

\ +
\ +
\ + \ +

Contrast

\ +
\ +
\ + \ +

Saturation

\ +
\ +
\ + \ +

Rotate

\ +
\ +
\ + \ +

Crop

\ +
\ +
\ +
\ + \ + \ +
\ +
\ +
\ +
\ +
'; + } + function selectNewStepUi() { + var m = $("#insertStep select").val(); + $("#insertStep .info").html(_sequencer.modulesInfo(m).description); + $("#insertStep #add-step-btn").prop("disabled", false); + } + insertStep = function (id) { + var modulesInfo = _sequencer.modulesInfo(); + var parser = new DOMParser(); + var addStepUI = stepUI(); + addStepUI = parser.parseFromString(addStepUI, "text/html").querySelector("div") + step.ui + .querySelector("div.step") + .insertAdjacentElement('afterend', + addStepUI + ); + var insertStepSelect = $("#insertStep select"); + insertStepSelect.html(""); + // Add modules to the insertStep dropdown + for (var m in modulesInfo) { + if (modulesInfo[m] !== undefined) + insertStepSelect.append( + '" + ); + } + + $('#insertStep #add-step-btn').prop('disabled', true); + + insertStepSelect.append(''); + $('#insertStep .radio-group .radio').on("click", function () { + $(this).parent().find('.radio').removeClass('selected'); + $(this).addClass('selected'); + newStep = $(this).attr('data-value'); + insertStepSelect.val(newStep); + selectNewStepUi(); + doIt(id); + $(this).removeClass('selected'); + }); + $(step.ui.querySelector("#insertStep select")).on('change', selectNewStepUi); + $(step.ui.querySelector("#insertStep #add-step-btn")).on('click', function(){ doIt(id)}); + } + + function doIt(id) { + + options = options || {}; + var insertStepSelect = $("#insertStep select"); + if (insertStepSelect.val() == "none") return; + + var newStepName = insertStepSelect.val() + $('div .insertDiv').remove(); + var sequenceLength = 1; + if (sequencer.sequences[newStepName]) { + sequenceLength = sequencer.sequences[newStepName].length; + } else if (sequencer.modules[newStepName][1]["length"]) { + sequenceLength = sequencer.modules[newStepName][1]["length"]; + } + _sequencer + .insertSteps("image1", id + 1, newStepName) + .run({ index: 0 }); + + // add to URL hash too + setUrlHashParameter("steps", _sequencer.toString()); + location.reload(); + } + return { + insertStep + } +} \ No newline at end of file