From fdb38f7fdfc38b355f079e2ecbd58b933e702d86 Mon Sep 17 00:00:00 2001 From: Harshith pabbati Date: Mon, 18 Feb 2019 05:46:15 +0530 Subject: [PATCH] Added the resize quick button (#782) * Added the resize module * Added the resize quick button * Made the icon to fit into the box * Added the footer to the main page * Added the resize quick button * Added the resize quick button * Added the resize quick button --- dist/image-sequencer-ui.js | 7 +++++++ dist/image-sequencer-ui.min.js | 2 +- examples/demo.css | 2 +- examples/index.html | 6 ++++++ examples/lib/insertPreview.js | 1 + examples/lib/intermediateHtmlStepUi.js | 6 ++++++ 6 files changed, 22 insertions(+), 2 deletions(-) diff --git a/dist/image-sequencer-ui.js b/dist/image-sequencer-ui.js index 0e2a660f..84298ee1 100644 --- a/dist/image-sequencer-ui.js +++ b/dist/image-sequencer-ui.js @@ -694,6 +694,7 @@ function generatePreview(previewStepName, customValues, path, selector) { $('#'+selector+' img').remove(); var previewSequencerSteps = { + "resize": "125%", "brightness": "20", "saturation": "5", "rotate": 90, @@ -729,6 +730,12 @@ function IntermediateHtmlStepUi(_sequencer, step, options) {
\

Select a new module to add to your sequence.

\
\ +
\ +
\ + \ +
\ +

Resize

\ +
\
\
\ \ diff --git a/dist/image-sequencer-ui.min.js b/dist/image-sequencer-ui.min.js index 2f5cc42e..676ed940 100644 --- a/dist/image-sequencer-ui.min.js +++ b/dist/image-sequencer-ui.min.js @@ -1 +1 @@ -!function(){return function e(t,n,i){function a(o,r){if(!n[o]){if(!t[o]){var l="function"==typeof require&&require;if(!r&&l)return l(o,!0);if(s)return s(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var d=n[o]={exports:{}};t[o][0].call(d.exports,function(e){return a(t[o][1][e]||e)},d,d.exports,e,t,n,i)}return n[o].exports}for(var s="function"==typeof require&&require,o=0;o'+e[n].name+"");t.append('')}sequencer=ImageSequencer(),e(),$(window).on("scroll",function(){var e=$("body").scrollTop()>20||$(":root").scrollTop()>20;$("#move-up").css({display:e?"block":"none"})}),$("#move-up").on("click",function(){$("body").animate({scrollTop:0}),$(":root").animate({scrollTop:0})}),sequencer.setUI(o(sequencer));var t=i(sequencer);r.getUrlHashParameter("src")?sequencer.loadImage(r.getUrlHashParameter("src"),t.onLoad):sequencer.loadImage("images/tulips.png",t.onLoad);$("#addStep select").on("change",t.selectNewStepUi),$("#addStep #add-step-btn").on("click",t.addStepUi),$("#resetButton").on("click",function(){confirm("Do you want to reset the sequence?")&&(window.location="/")}),$(".radio-group .radio").on("click",function(){$(this).parent().find(".radio").removeClass("selected"),$(this).addClass("selected"),newStep=$(this).attr("data-value"),$("#addStep select").val(newStep),t.selectNewStepUi(),t.addStepUi(),$(this).removeClass("selected")}),$("#download-btn").click(function(){return $(".step-thumbnail:last()").trigger("click"),!1}),$("body").on("click","button.remove",t.removeStepUi),$("#save-seq").click(()=>{var t=window.prompt("Please give a name to your sequence... (Saved sequence will only be available in this browser).");t&&(t+=" (local)",sequencer.saveSequence(t,sequencer.toString()),sequencer.loadModules(),$(".savesequencemsg").fadeIn(),setTimeout(function(){$(".savesequencemsg").fadeOut()},1e3),e())});var n=!1;$(".js-view-as-gif").on("click",function(e){if(!n){n=!0;var t=e.target;t.disabled=!0;try{for(var i=document.getElementsByClassName("step-thumbnail"),a=[],s=0;s{console.log(t),"installed"===t.state&&location.reload()}),console.log("Registration successful, scope is:",e.scope)}).catch(function(e){console.log("Service worker registration failed, error:",e)}),"serviceWorker"in navigator&&caches.keys().then(function(e){e.forEach(function(e){$("#clear-cache").append(" "+e)})}),$("#clear-cache").click(function(){"serviceWorker"in navigator&&caches.keys().then(function(e){e.forEach(function(e){caches.delete(e)})}),location.reload()})}},{}],3:[function(e,t,n){var i=e("./urlHash.js");t.exports=function(e,t){var n=(t=t||{}).addStepSel=t.addStepSel||"#addStep",a=t.removeStepSel=t.removeStepSel||"button.remove";function s(){var t=i.getUrlHashParameter("steps");t&&(e.importString(t),e.run({index:0})),i.setUrlHashParameter("steps",sequencer.toString())}function o(){sequencer.images.image1.steps.length<2?$(" #save-seq").prop("disabled",!0):$(" #save-seq").prop("disabled",!1)}return t.selectStepSel=t.selectStepSel||"#selectStep",{onLoad:function(){s(),$("#selectStep").val()||$(n+" #add-step-btn").prop("disabled",!0),o()},importStepsFromUrlHash:s,selectNewStepUi:function(){var t=$(n+" select").val();$(n+" .info").html(e.modulesInfo(t).description),$(n+" #add-step-btn").prop("disabled",!1)},removeStepUi:function(){var e=$(a).index(this)+1;sequencer.removeSteps(e).run({index:e-1}),i.setUrlHashParameter("steps",sequencer.toString()),o()},addStepUi:function(){if("none"!=$(n+" select").val()){var a=$(n+" select").val(),s=1;sequencer.sequences[a]?s=sequencer.sequences[a].length:sequencer.modules[a][1].length&&(s=sequencer.modules[a][1].length),e.addSteps(a,t).run({index:e.images.image1.steps.length-s-1}),$(n+" .info").html("Select a new module to add to your sequence."),$(n+" select").val("none"),o(),i.setUrlHashParameter("steps",e.toString())}}}}},{"./urlHash.js":7}],4:[function(e,t,n){var i=e("./intermediateHtmlStepUi.js"),a=e("./urlHash.js");function s(e,t){var n=(t=t||{}).stepsEl||document.querySelector("#steps");t.selectStepSel=t.selectStepSel||"#selectStep";function s(e,t){if(0==$("#"+t).length){var n=document.createElement("span");n.innerHTML=' '+e,n.id=t,n.classList.add("notification"),$("body").append(n)}$("#"+t).fadeIn(500).delay(200).fadeOut(500)}return{getPreview:function(){return step.imgElement},onSetup:function(t,o){t.options&&t.options.description&&(t.description=t.options.description),t.ui='

'+t.name+'

"'+(t.description||"")+'

';var r=i(e,t),l=new DOMParser;if(t.ui=l.parseFromString(t.ui,"text/html"),t.ui=t.ui.querySelector("div.container"),t.linkElements=t.ui.querySelectorAll("a"),t.imgElement=t.ui.querySelector("a img"),e.modulesInfo().hasOwnProperty(t.name)){var c=e.modulesInfo(t.name).inputs,d=e.modulesInfo(t.name).outputs,u=Object.assign(c,d);for(var p in u){var v=c.hasOwnProperty(p),m="",f=v?c[p]:{};if(v)if("select"==f.type.toLowerCase()){for(var h in m+='"}else{let e=t.options[p]||f.default;m=''+e+"":m+='">'}else m+='';var g=document.createElement("div");g.className="row",g.setAttribute("name",p);var S=c[p].desc||p;g.innerHTML="
"+m+"
",t.ui.querySelector("div.details").appendChild(g)}$(t.ui.querySelector("div.details")).append('

Press apply to see changes

')}"load-image"!=t.name?(t.ui.querySelector("div.details").appendChild(l.parseFromString('
',"text/html").querySelector("div")),$(t.ui.querySelectorAll(".remove")).on("click",function(){s("Step Removed","remove-notification")}),$(t.ui.querySelectorAll(".insert-step")).on("click",function(){r.insertStep(t.ID)}),o.index==e.images.image1.steps.length?(n.appendChild(t.ui),$("#steps .container:nth-last-child(1) .insert-step").prop("disabled",!0),$("#steps .container:nth-last-child(2)")&&$("#steps .container:nth-last-child(2) .insert-step").prop("disabled",!1)):n.insertBefore(t.ui,$(n).children()[o.index])):$("#load-image").append(t.ui),$(t.ui.querySelector(".toggle")).on("click",()=>{$(t.ui.querySelector(".toggleIcon")).toggleClass("fa-caret-up").toggleClass("fa-caret-down"),$(t.ui.querySelectorAll(".cal")).toggleClass("collapse")});var b=0,q=!1;$(t.ui.querySelector(".input-form")).on("submit",function(n){n.preventDefault(),q&&($(t.ui.querySelector("div.details")).find("input,select").each(function(e,n){$(n).data("initValue",$(n).val()).data("hasChangedBefore",!1),t.options[$(n).attr("name")]=$(n).val()}),e.run({index:t.index-1}),a.setUrlHashParameter("steps",e.toString()),$(t.ui.querySelector(".btn-save")).prop("disabled",!0),q=!1,b=0)}),$(t.ui.querySelectorAll(".target")).each(function(e,n){$(n).data("initValue",$(n).val()).data("hasChangedBefore",!1).on("input",function(){var e,n,i,a;$(this).focus().data("hasChangedBefore",(e=$(this).val(),n=$(this).data("initValue"),i=$(this).data("hasChangedBefore"),a=!(isNaN(n)||isNaN(e)?e===n:e-n==0),q=(b+=i?a?0:-1:a?1:0)>0,$(t.ui.querySelector(".btn-save")).prop("disabled",!q),a))})}),$('input[type="range"]').on("input",function(){$(this).next().html($(this).val())})},onComplete:function(t){$(t.ui.querySelector(".load")).hide(),$(t.ui.querySelector("img")).show(),$(t.ui.querySelector(".load-spin")).hide(),t.imgElement.src=t.output;var n=t.ui.querySelector(".img-thumbnail");for(let e=0;e

Select a new module to add to your sequence.

Brightness

Contrast

Saturation

Rotate

Crop

';r=(new DOMParser).parseFromString(r,"text/html").querySelector("div"),t.ui.querySelector("div.step").insertAdjacentElement("afterend",r),a.updatePreviews(t.output,"insertStep");var l=$("#insertStep select");for(var c in l.html(""),i)void 0!==i[c]&&l.append('");$("#insertStep #add-step-btn").prop("disabled",!0),l.append(''),$("#insertStep .radio-group .radio").on("click",function(){$(this).parent().find(".radio").removeClass("selected"),$(this).addClass("selected"),newStep=$(this).attr("data-value"),l.val(newStep),s(),o(n),$(this).removeClass("selected")}),$(t.ui.querySelector("#insertStep select")).on("change",s),$(t.ui.querySelector("#insertStep #add-step-btn")).on("click",function(){o(n)})},{insertStep:insertStep}}},{"./insertPreview.js":5,"./urlHash.js":7}],7:[function(e,t,n){function i(){var e=window.location.hash;e&&(e=e.split("#")[1]);var t={};return e.split("&").forEach(function(e,n){""!=(e=e.split("="))[0]&&(t[e[0]]=e[1])}),t}function a(e){var t=Object.keys(e),n=Object.values(e),i=[];t.forEach(function(e,a){""!=e&&i.push(t[a]+"="+n[a])});var a=i.join("&");window.location.hash=a}t.exports={getUrlHashParameter:function(e){return i()[e]},setUrlHashParameter:function(e,t){var n=i();n[e]=t,a(n)},getUrlHashParameters:i,setUrlHashParameters:a}},{}]},{},[1]); \ No newline at end of file +!function(){return function e(t,n,i){function a(r,o){if(!n[r]){if(!t[r]){var l="function"==typeof require&&require;if(!o&&l)return l(r,!0);if(s)return s(r,!0);var c=new Error("Cannot find module '"+r+"'");throw c.code="MODULE_NOT_FOUND",c}var d=n[r]={exports:{}};t[r][0].call(d.exports,function(e){return a(t[r][1][e]||e)},d,d.exports,e,t,n,i)}return n[r].exports}for(var s="function"==typeof require&&require,r=0;r'+e[n].name+"");t.append('')}sequencer=ImageSequencer(),e(),$(window).on("scroll",function(){var e=$("body").scrollTop()>20||$(":root").scrollTop()>20;$("#move-up").css({display:e?"block":"none"})}),$("#move-up").on("click",function(){$("body").animate({scrollTop:0}),$(":root").animate({scrollTop:0})}),sequencer.setUI(r(sequencer));var t=i(sequencer);o.getUrlHashParameter("src")?sequencer.loadImage(o.getUrlHashParameter("src"),t.onLoad):sequencer.loadImage("images/tulips.png",t.onLoad);$("#addStep select").on("change",t.selectNewStepUi),$("#addStep #add-step-btn").on("click",t.addStepUi),$("#resetButton").on("click",function(){confirm("Do you want to reset the sequence?")&&(window.location="/")}),$(".radio-group .radio").on("click",function(){$(this).parent().find(".radio").removeClass("selected"),$(this).addClass("selected"),newStep=$(this).attr("data-value"),$("#addStep select").val(newStep),t.selectNewStepUi(),t.addStepUi(),$(this).removeClass("selected")}),$("#download-btn").click(function(){return $(".step-thumbnail:last()").trigger("click"),!1}),$("body").on("click","button.remove",t.removeStepUi),$("#save-seq").click(()=>{var t=window.prompt("Please give a name to your sequence... (Saved sequence will only be available in this browser).");t&&(t+=" (local)",sequencer.saveSequence(t,sequencer.toString()),sequencer.loadModules(),$(".savesequencemsg").fadeIn(),setTimeout(function(){$(".savesequencemsg").fadeOut()},1e3),e())});var n=!1;$(".js-view-as-gif").on("click",function(e){if(!n){n=!0;var t=e.target;t.disabled=!0;try{for(var i=document.getElementsByClassName("step-thumbnail"),a=[],s=0;s{console.log(t),"installed"===t.state&&location.reload()}),console.log("Registration successful, scope is:",e.scope)}).catch(function(e){console.log("Service worker registration failed, error:",e)}),"serviceWorker"in navigator&&caches.keys().then(function(e){e.forEach(function(e){$("#clear-cache").append(" "+e)})}),$("#clear-cache").click(function(){"serviceWorker"in navigator&&caches.keys().then(function(e){e.forEach(function(e){caches.delete(e)})}),location.reload()})}},{}],3:[function(e,t,n){var i=e("./urlHash.js");t.exports=function(e,t){var n=(t=t||{}).addStepSel=t.addStepSel||"#addStep",a=t.removeStepSel=t.removeStepSel||"button.remove";function s(){var t=i.getUrlHashParameter("steps");t&&(e.importString(t),e.run({index:0})),i.setUrlHashParameter("steps",sequencer.toString())}function r(){sequencer.images.image1.steps.length<2?$(" #save-seq").prop("disabled",!0):$(" #save-seq").prop("disabled",!1)}return t.selectStepSel=t.selectStepSel||"#selectStep",{onLoad:function(){s(),$("#selectStep").val()||$(n+" #add-step-btn").prop("disabled",!0),r()},importStepsFromUrlHash:s,selectNewStepUi:function(){var t=$(n+" select").val();$(n+" .info").html(e.modulesInfo(t).description),$(n+" #add-step-btn").prop("disabled",!1)},removeStepUi:function(){var e=$(a).index(this)+1;sequencer.removeSteps(e).run({index:e-1}),i.setUrlHashParameter("steps",sequencer.toString()),r()},addStepUi:function(){if("none"!=$(n+" select").val()){var a=$(n+" select").val(),s=1;sequencer.sequences[a]?s=sequencer.sequences[a].length:sequencer.modules[a][1].length&&(s=sequencer.modules[a][1].length),e.addSteps(a,t).run({index:e.images.image1.steps.length-s-1}),$(n+" .info").html("Select a new module to add to your sequence."),$(n+" select").val("none"),r(),i.setUrlHashParameter("steps",e.toString())}}}}},{"./urlHash.js":7}],4:[function(e,t,n){var i=e("./intermediateHtmlStepUi.js"),a=e("./urlHash.js");function s(e,t){var n=(t=t||{}).stepsEl||document.querySelector("#steps");t.selectStepSel=t.selectStepSel||"#selectStep";function s(e,t){if(0==$("#"+t).length){var n=document.createElement("span");n.innerHTML=' '+e,n.id=t,n.classList.add("notification"),$("body").append(n)}$("#"+t).fadeIn(500).delay(200).fadeOut(500)}return{getPreview:function(){return step.imgElement},onSetup:function(t,r){t.options&&t.options.description&&(t.description=t.options.description),t.ui='

'+t.name+'

"'+(t.description||"")+'

';var o=i(e,t),l=new DOMParser;if(t.ui=l.parseFromString(t.ui,"text/html"),t.ui=t.ui.querySelector("div.container"),t.linkElements=t.ui.querySelectorAll("a"),t.imgElement=t.ui.querySelector("a img"),e.modulesInfo().hasOwnProperty(t.name)){var c=e.modulesInfo(t.name).inputs,d=e.modulesInfo(t.name).outputs,u=Object.assign(c,d);for(var p in u){var v=c.hasOwnProperty(p),m="",f=v?c[p]:{};if(v)if("select"==f.type.toLowerCase()){for(var h in m+='"}else{let e=t.options[p]||f.default;m=''+e+"":m+='">'}else m+='';var g=document.createElement("div");g.className="row",g.setAttribute("name",p);var S=c[p].desc||p;g.innerHTML="
"+m+"
",t.ui.querySelector("div.details").appendChild(g)}$(t.ui.querySelector("div.details")).append('

Press apply to see changes

')}"load-image"!=t.name?(t.ui.querySelector("div.details").appendChild(l.parseFromString('
',"text/html").querySelector("div")),$(t.ui.querySelectorAll(".remove")).on("click",function(){s("Step Removed","remove-notification")}),$(t.ui.querySelectorAll(".insert-step")).on("click",function(){o.insertStep(t.ID)}),r.index==e.images.image1.steps.length?(n.appendChild(t.ui),$("#steps .container:nth-last-child(1) .insert-step").prop("disabled",!0),$("#steps .container:nth-last-child(2)")&&$("#steps .container:nth-last-child(2) .insert-step").prop("disabled",!1)):n.insertBefore(t.ui,$(n).children()[r.index])):$("#load-image").append(t.ui),$(t.ui.querySelector(".toggle")).on("click",()=>{$(t.ui.querySelector(".toggleIcon")).toggleClass("fa-caret-up").toggleClass("fa-caret-down"),$(t.ui.querySelectorAll(".cal")).toggleClass("collapse")});var b=0,q=!1;$(t.ui.querySelector(".input-form")).on("submit",function(n){n.preventDefault(),q&&($(t.ui.querySelector("div.details")).find("input,select").each(function(e,n){$(n).data("initValue",$(n).val()).data("hasChangedBefore",!1),t.options[$(n).attr("name")]=$(n).val()}),e.run({index:t.index-1}),a.setUrlHashParameter("steps",e.toString()),$(t.ui.querySelector(".btn-save")).prop("disabled",!0),q=!1,b=0)}),$(t.ui.querySelectorAll(".target")).each(function(e,n){$(n).data("initValue",$(n).val()).data("hasChangedBefore",!1).on("input",function(){var e,n,i,a;$(this).focus().data("hasChangedBefore",(e=$(this).val(),n=$(this).data("initValue"),i=$(this).data("hasChangedBefore"),a=!(isNaN(n)||isNaN(e)?e===n:e-n==0),q=(b+=i?a?0:-1:a?1:0)>0,$(t.ui.querySelector(".btn-save")).prop("disabled",!q),a))})}),$('input[type="range"]').on("input",function(){$(this).next().html($(this).val())})},onComplete:function(t){$(t.ui.querySelector(".load")).hide(),$(t.ui.querySelector("img")).show(),$(t.ui.querySelector(".load-spin")).hide(),t.imgElement.src=t.output;var n=t.ui.querySelector(".img-thumbnail");for(let e=0;e

Select a new module to add to your sequence.

Resize

Brightness

Contrast

Saturation

Rotate

Crop

';o=(new DOMParser).parseFromString(o,"text/html").querySelector("div"),t.ui.querySelector("div.step").insertAdjacentElement("afterend",o),a.updatePreviews(t.output,"insertStep");var l=$("#insertStep select");for(var c in l.html(""),i)void 0!==i[c]&&l.append('");$("#insertStep #add-step-btn").prop("disabled",!0),l.append(''),$("#insertStep .radio-group .radio").on("click",function(){$(this).parent().find(".radio").removeClass("selected"),$(this).addClass("selected"),newStep=$(this).attr("data-value"),l.val(newStep),s(),r(n),$(this).removeClass("selected")}),$(t.ui.querySelector("#insertStep select")).on("change",s),$(t.ui.querySelector("#insertStep #add-step-btn")).on("click",function(){r(n)})},{insertStep:insertStep}}},{"./insertPreview.js":5,"./urlHash.js":7}],7:[function(e,t,n){function i(){var e=window.location.hash;e&&(e=e.split("#")[1]);var t={};return e.split("&").forEach(function(e,n){""!=(e=e.split("="))[0]&&(t[e[0]]=e[1])}),t}function a(e){var t=Object.keys(e),n=Object.values(e),i=[];t.forEach(function(e,a){""!=e&&i.push(t[a]+"="+n[a])});var a=i.join("&");window.location.hash=a}t.exports={getUrlHashParameter:function(e){return i()[e]},setUrlHashParameter:function(e,t){var n=i();n[e]=t,a(n)},getUrlHashParameters:i,setUrlHashParameters:a}},{}]},{},[1]); \ No newline at end of file diff --git a/examples/demo.css b/examples/demo.css index dad2495e..b1c57ebc 100644 --- a/examples/demo.css +++ b/examples/demo.css @@ -249,4 +249,4 @@ h1 { a.name-header{ text-decoration: none; color: #445; -} +} \ No newline at end of file diff --git a/examples/index.html b/examples/index.html index a2aa37b7..1830b17c 100644 --- a/examples/index.html +++ b/examples/index.html @@ -86,6 +86,12 @@

Select a new module to add to your sequence.

+
+
+ +
+

Resize

+
diff --git a/examples/lib/insertPreview.js b/examples/lib/insertPreview.js index f5a474ad..26b8cfca 100644 --- a/examples/lib/insertPreview.js +++ b/examples/lib/insertPreview.js @@ -31,6 +31,7 @@ function generatePreview(previewStepName, customValues, path, selector) { $('#'+selector+' img').remove(); var previewSequencerSteps = { + "resize": "125%", "brightness": "20", "saturation": "5", "rotate": 90, diff --git a/examples/lib/intermediateHtmlStepUi.js b/examples/lib/intermediateHtmlStepUi.js index 591c0b4c..1431b381 100644 --- a/examples/lib/intermediateHtmlStepUi.js +++ b/examples/lib/intermediateHtmlStepUi.js @@ -10,6 +10,12 @@ function IntermediateHtmlStepUi(_sequencer, step, options) {
\

Select a new module to add to your sequence.

\
\ +
\ +
\ + \ +
\ +

Resize

\ +
\
\
\ \