mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-12 03:10:03 +01:00
fixes insert-step functionality (#1266)
This commit is contained in:
committed by
Jeffrey Warren
parent
43e81c3847
commit
b1600af374
@@ -64,15 +64,6 @@ function IntermediateHtmlStepUi(_sequencer, step, options) {
|
|||||||
</div>';
|
</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function selectNewStepUi($step) {
|
|
||||||
var insertSelect = $step('.insert-step-select');
|
|
||||||
var m = insertSelect.val();
|
|
||||||
$step('.insertDiv .info').html(_sequencer.modulesInfo(m).description);
|
|
||||||
$step('.insertDiv .add-step-btn').prop('disabled', false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var toggleDiv = function($step, callback = function(){}){
|
var toggleDiv = function($step, callback = function(){}){
|
||||||
$step('.insertDiv').collapse('toggle');
|
$step('.insertDiv').collapse('toggle');
|
||||||
if ($step('.insert-text').css('display') != 'none'){
|
if ($step('.insert-text').css('display') != 'none'){
|
||||||
@@ -104,13 +95,16 @@ function IntermediateHtmlStepUi(_sequencer, step, options) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$step('.insertDiv .close-insert-box').off('click').on('click', function(){toggleDiv(function(){});});
|
$step('.insertDiv .close-insert-box').off('click').on('click', function(){
|
||||||
|
toggleDiv($step);
|
||||||
|
$step('.insertDiv').removeClass('insertDiv');
|
||||||
|
});
|
||||||
|
|
||||||
var insertStepSelect = $step('.insert-step-select');
|
var insertStepSelect = $step('.insert-step-select');
|
||||||
insertStepSelect.html('');
|
insertStepSelect.html('');
|
||||||
// Add modules to the insertStep dropdown
|
// Add modules to the insertStep dropdown
|
||||||
for (var m in modulesInfo) {
|
for (var m in modulesInfo) {
|
||||||
if (modulesInfo[m] !== undefined)
|
if (modulesInfo[m] && modulesInfo[m].name)
|
||||||
insertStepSelect.append(
|
insertStepSelect.append(
|
||||||
'<option value="' + m + '">' + modulesInfo[m].name + '</option>'
|
'<option value="' + m + '">' + modulesInfo[m].name + '</option>'
|
||||||
);
|
);
|
||||||
@@ -118,47 +112,26 @@ function IntermediateHtmlStepUi(_sequencer, step, options) {
|
|||||||
insertStepSelect.selectize({
|
insertStepSelect.selectize({
|
||||||
sortField: 'text'
|
sortField: 'text'
|
||||||
});
|
});
|
||||||
$step('.inserDiv .add-step-btn').prop('disabled', true);
|
$('.insertDiv .radio-group .radio').on('click', function () {
|
||||||
|
var newStepName = $(this).attr('data-value');
|
||||||
insertStepSelect.append('<option value="" disabled selected>Select a Module</option>');
|
id = $($step('.insertDiv').parents()[3]).prevAll().length;
|
||||||
$step('.insertDiv .radio-group .radio').on('click', function () {
|
insert(id, $step, newStepName);
|
||||||
$(this).parent().find('.radio').removeClass('selected');
|
|
||||||
$(this).addClass('selected');
|
|
||||||
newStep = $(this).attr('data-value');
|
|
||||||
$step('.insert-step-select').val(newStep);
|
|
||||||
selectNewStepUi($step);
|
|
||||||
insert(id, $step);
|
|
||||||
$(this).removeClass('selected');
|
|
||||||
});
|
});
|
||||||
insertStepSelect.on('change', () => {selectNewStepUi($step);});
|
$step('.insertDiv .add-step-btn').on('click', function () {
|
||||||
$step('.insertDiv .add-step-btn').on('click', function () { insert(id, $step); });
|
var newStepName = insertStepSelect.val();
|
||||||
|
id = $($step('.insertDiv').parents()[3]).prevAll().length;
|
||||||
|
insert(id, $step, newStepName); });
|
||||||
};
|
};
|
||||||
|
|
||||||
function insert(id, $step) {
|
function insert(id, $step, newStepName) {
|
||||||
|
|
||||||
options = options || {};
|
|
||||||
var insertStepSelect = $step('.insert-step-select');
|
|
||||||
if (insertStepSelect.val() == 'none') return;
|
|
||||||
|
|
||||||
var newStepName = insertStepSelect.val();
|
|
||||||
toggleDiv($step);
|
toggleDiv($step);
|
||||||
var sequenceLength = 1;
|
$step('.insertDiv').removeClass('insertDiv');
|
||||||
if (sequencer.sequences[newStepName]) {
|
_sequencer.insertSteps(id + 1, newStepName).run({ index: id });
|
||||||
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());
|
urlHash.setUrlHashParameter('steps', _sequencer.toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
insertStep
|
insertStep
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
module.exports = IntermediateHtmlStepUi;
|
module.exports = IntermediateHtmlStepUi;
|
||||||
|
|
||||||
Reference in New Issue
Block a user