diff --git a/examples/demo.js b/examples/demo.js index 93d8b3a5..af298f8b 100644 --- a/examples/demo.js +++ b/examples/demo.js @@ -84,11 +84,6 @@ window.onload = function() { $(this).removeClass('selected'); }); - $('#download-btn').click(function() { - $('.step-thumbnail:last()').trigger('click'); - return false; - }); - function displayMessageOnSaveSequence(){ $('.savesequencemsg').fadeIn(); setTimeout(function() { diff --git a/examples/lib/defaultHtmlStepUi.js b/examples/lib/defaultHtmlStepUi.js index d3b1fd7c..ae501ea0 100644 --- a/examples/lib/defaultHtmlStepUi.js +++ b/examples/lib/defaultHtmlStepUi.js @@ -134,7 +134,9 @@ function DefaultHtmlStepUi(_sequencer, options) { ); $(step.ui.querySelector('div.panel-footer')).prepend( '\ + ' ); } @@ -166,6 +168,7 @@ function DefaultHtmlStepUi(_sequencer, options) { }); $(step.imgElement).on('mousemove', _.debounce(() => imageHover(step), 150)); + $(step.imgElement).on('click', (e) => {e.preventDefault(); }); function saveOptions(e) { e.preventDefault(); @@ -250,11 +253,21 @@ function DefaultHtmlStepUi(_sequencer, options) { return output.split('/')[1].split(';')[0]; } - for (let index = 0; index < step.linkElements.length; index++) { + $(step.ui.querySelectorAll('.download-btn')).on('click', () => { - step.linkElements[index].download = step.name + '.' + fileExtension(step.imgElement.src); - step.linkElements[index].target = '_blank'; - } + for (let index = 0; index < step.linkElements.length; index++){ + + var element = document.createElement('a'); + element.setAttribute('href', step.linkElements[index].href); + element.setAttribute('download', step.name + '.' + fileExtension(step.imgElement.src)); + element.style.display = 'none'; + document.body.appendChild(element); + + element.click(); + + document.body.removeChild(element); + } + }); // fill inputs with stored step options if (_sequencer.modulesInfo().hasOwnProperty(step.name)) {