var urlHash = require('./urlHash.js'), insertPreview = require('./insertPreview.js'); 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 ); insertPreview.updatePreviews(step.output,'insertStep'); 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(); insert(id); $(this).removeClass('selected'); }); $(step.ui.querySelector("#insertStep select")).on('change', selectNewStepUi); $(step.ui.querySelector("#insertStep #add-step-btn")).on('click', function () { insert(id) }); } function insert(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(id + 1, newStepName).run({ index: id }); // add to URL hash too urlHash.setUrlHashParameter("steps", _sequencer.toString()); } return { insertStep } } module.exports = IntermediateHtmlStepUi;