diff --git a/inc/_notes/dwsync.xml b/inc/_notes/dwsync.xml index 8e75e94..88fa0b3 100644 --- a/inc/_notes/dwsync.xml +++ b/inc/_notes/dwsync.xml @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/js/layoutbuilder.js b/js/layoutbuilder.js index 6e310ba..6dc923d 100644 --- a/js/layoutbuilder.js +++ b/js/layoutbuilder.js @@ -1,162 +1,162 @@ -jQuery(document).ready(function($) { - - //Slider - $(function() { - - var currentHandle = -1; - var canDelete = -1; - var rows = 0; - wp.customize('homepagerows', function(obj) { - - rows = obj.get(); - - } ); - var addRow = function(i){ - $('.sliders').append('
'); - $('#addColumn'+i).click(function(){ - addColumnButton(this); - }); - var myarr = []; - var widths = []; - wp.customize('homepage_'+i, function(obj) { - - widths = new String(obj.get()); - - } ); - widths = widths.split(','); - for(var j in widths){ - if(myarr.length == 0){ - myarr[myarr.length] = parseInt(widths[j]); - } - else{ - myarr[myarr.length] = parseInt(widths[j])+myarr[myarr.length-1]; - } - - } - if(myarr.length == 0) myarr[0] = 12; - $( "#slider"+i ).slider({ - min: 0, - max: 12, - step: 1, - values: myarr, - change: function(event, ui){onSliderChange(event, ui, i);} - }); - $( "#slider"+i ).children().last().css('display','none'); - } - - var addColumnButton = function(button){ - var row = $(button).attr('id').substr(-1); - var myarr = $( "#slider"+row ).slider( "option", "values" ); - if(myarr.length == 11) return; - myarr[myarr.length] = 12; - myarr.sort(function(a,b){return a - b}); - $( "#slider"+row ).slider( "destroy" ); - $( "#slider"+row ).slider({ - min: 0, - max: 12, - step: 1, - values: myarr, - change: function(event, ui){onSliderChange(event, ui, row);} - }); - $( "#slider"+row ).children().last().css('display','none'); - } - - var deleteColumn = function(){ - if(!currentHandle) return; - var row = canDelete; - //if(!$(':focus').hasClass('ui-slider-handle')) return; - var count = 0; - var widths = 0; - var values = $.unique($('#slider'+row).slider( "values" )); - if(values.indexOf(currentHandle) == -1) return; - values.splice(values.indexOf(currentHandle),1); - values.sort(function(a,b){return a - b}); - $( "#slider"+row ).slider( "destroy" ); - $( "#slider"+row ).slider({ - min: 0, - max: 12, - step: 1, - values: values, - change: function(event, ui){onSliderChange(event, ui, row);} - }); - $( "#slider"+row ).children().last().css('display','none'); - for(var j in values){ - if(values[j] != 0){ - if(widths == 0) widths = values[j]; - else { - var dif = parseInt(values[j])-parseInt(values[j-1]); - widths = widths+','+dif - } - } - } - wp.customize('homepage_'+row, function(obj) { - - obj.set(widths); - - } ); - $('.sliderDeleteColumn').addClass('disabled'); - } - - var onSliderChange = function(event, ui, row){ - var widths = 0; - var values = $.unique(ui.values); - values.sort(function(a,b){return a - b}); - for(var j in values){ - if(values[j] != 0){ - if(widths == 0) widths = values[j]; - else { - var dif = parseInt(values[j])-parseInt(values[j-1]); - widths = widths+','+dif - } - } - } - wp.customize('homepage_'+row, function(obj) { - - obj.set(widths); - - } ); - currentHandle = parseInt($(':focus').css('left').split('px')[0])/20; - canDelete = row; - $('.sliderDeleteColumn').removeClass('disabled'); - } - - - for(var i=0; i
'); + $('#addColumn'+i).click(function(){ + addColumnButton(this); + }); + var myarr = []; + var widths = []; + wp.customize('homepage_'+i, function(obj) { + + widths = new String(obj.get()); + + } ); + widths = widths.split(','); + for(var j in widths){ + if(myarr.length == 0){ + myarr[myarr.length] = parseInt(widths[j]); + } + else{ + myarr[myarr.length] = parseInt(widths[j])+myarr[myarr.length-1]; + } + + } + if(myarr.length == 0) myarr[0] = 12; + $( "#slider"+i ).slider({ + min: 0, + max: 12, + step: 1, + values: myarr, + change: function(event, ui){onSliderChange(event, ui, i);} + }); + $( "#slider"+i ).children().last().css('display','none'); + } + + var addColumnButton = function(button){ + var row = $(button).attr('id').substr(-1); + var myarr = $( "#slider"+row ).slider( "option", "values" ); + if(myarr.length == 11) return; + myarr[myarr.length] = 12; + myarr.sort(function(a,b){return a - b}); + $( "#slider"+row ).slider( "destroy" ); + $( "#slider"+row ).slider({ + min: 0, + max: 12, + step: 1, + values: myarr, + change: function(event, ui){onSliderChange(event, ui, row);} + }); + $( "#slider"+row ).children().last().css('display','none'); + } + + var deleteColumn = function(){ + if(!currentHandle) return; + var row = canDelete; + //if(!$(':focus').hasClass('ui-slider-handle')) return; + var count = 0; + var widths = 0; + var values = $.unique($('#slider'+row).slider( "values" )); + if(values.indexOf(currentHandle) == -1) return; + values.splice(values.indexOf(currentHandle),1); + values.sort(function(a,b){return a - b}); + $( "#slider"+row ).slider( "destroy" ); + $( "#slider"+row ).slider({ + min: 0, + max: 12, + step: 1, + values: values, + change: function(event, ui){onSliderChange(event, ui, row);} + }); + $( "#slider"+row ).children().last().css('display','none'); + for(var j in values){ + if(values[j] != 0){ + if(widths == 0) widths = values[j]; + else { + var dif = parseInt(values[j])-parseInt(values[j-1]); + widths = widths+','+dif + } + } + } + wp.customize('homepage_'+row, function(obj) { + + obj.set(widths); + + } ); + $('.sliderDeleteColumn').addClass('disabled'); + } + + var onSliderChange = function(event, ui, row){ + var widths = 0; + var values = $.unique(ui.values); + values.sort(function(a,b){return a - b}); + for(var j in values){ + if(values[j] != 0){ + if(widths == 0) widths = values[j]; + else { + var dif = parseInt(values[j])-parseInt(values[j-1]); + widths = widths+','+dif + } + } + } + wp.customize('homepage_'+row, function(obj) { + + obj.set(widths); + + } ); + currentHandle = Math.round(parseInt($(':focus').css('left').split('px')[0])/16.25); + canDelete = row; + $('.sliderDeleteColumn').removeClass('disabled'); + } + + + for(var i=0; i
'),e("#addColumn"+s).click(function(){d(this)});var i=[],n=[];wp.customize("homepage_"+s,function(e){n=new String(e.get())}),n=n.split(",");for(var l in n)i[i.length]=0==i.length?parseInt(n[l]):parseInt(n[l])+i[i.length-1];0==i.length&&(i[0]=12),e("#slider"+s).slider({min:0,max:12,step:1,values:i,change:function(e,i){t(e,i,s)}}),e("#slider"+s).children().last().css("display","none")},d=function(s){var i=e(s).attr("id").substr(-1),n=e("#slider"+i).slider("option","values");11!=n.length&&(n[n.length]=12,n.sort(function(e,s){return e-s}),e("#slider"+i).slider("destroy"),e("#slider"+i).slider({min:0,max:12,step:1,values:n,change:function(e,s){t(e,s,i)}}),e("#slider"+i).children().last().css("display","none"))},r=function(){if(s){var n=i,l=0,d=e.unique(e("#slider"+n).slider("values"));if(-1!=d.indexOf(s)){d.splice(d.indexOf(s),1),d.sort(function(e,s){return e-s}),e("#slider"+n).slider("destroy"),e("#slider"+n).slider({min:0,max:12,step:1,values:d,change:function(e,s){t(e,s,n)}}),e("#slider"+n).children().last().css("display","none");for(var r in d)if(0!=d[r])if(0==l)l=d[r];else{var o=parseInt(d[r])-parseInt(d[r-1]);l=l+","+o}wp.customize("homepage_"+n,function(e){e.set(l)}),e(".sliderDeleteColumn").addClass("disabled")}}},t=function(n,l,d){var r=0,t=e.unique(l.values);t.sort(function(e,s){return e-s});for(var o in t)if(0!=t[o])if(0==r)r=t[o];else{var a=parseInt(t[o])-parseInt(t[o-1]);r=r+","+a}wp.customize("homepage_"+d,function(e){e.set(r)}),s=parseInt(e(":focus").css("left").split("px")[0])/20,i=d,e(".sliderDeleteColumn").removeClass("disabled")},o=0;n>o;o++)l(o);e(".sliderAddRow").click(function(){5!=n&&(e(".sliderDeleteRow").removeClass("disabled"),l(n),n++,wp.customize("homepagerows",function(e){e.set(n)}))}),e(".sliderDeleteRow").click(function(){0!=n&&(n--,0==n&&e(".sliderDeleteRow").addClass("disabled"),e("#slider"+n).slider("destroy"),e("#slider"+n).remove(),e("#addColumn"+n).remove(),wp.customize("homepagerows",function(e){e.set(n)}),s=-1,i=-1,e(".sliderDeleteColumn").addClass("disabled"))}),e(".sliderDeleteColumn").click(function(){r()})})}); \ No newline at end of file +jQuery(document).ready(function(e){e(function(){var s=-1,i=-1,n=0;wp.customize("homepagerows",function(e){n=e.get()});for(var l=function(s){e(".sliders").append('
'),e("#addColumn"+s).click(function(){d(this)});var i=[],n=[];wp.customize("homepage_"+s,function(e){n=new String(e.get())}),n=n.split(",");for(var l in n)i[i.length]=0==i.length?parseInt(n[l]):parseInt(n[l])+i[i.length-1];0==i.length&&(i[0]=12),e("#slider"+s).slider({min:0,max:12,step:1,values:i,change:function(e,i){t(e,i,s)}}),e("#slider"+s).children().last().css("display","none")},d=function(s){var i=e(s).attr("id").substr(-1),n=e("#slider"+i).slider("option","values");11!=n.length&&(n[n.length]=12,n.sort(function(e,s){return e-s}),e("#slider"+i).slider("destroy"),e("#slider"+i).slider({min:0,max:12,step:1,values:n,change:function(e,s){t(e,s,i)}}),e("#slider"+i).children().last().css("display","none"))},r=function(){if(s){var n=i,l=0,d=e.unique(e("#slider"+n).slider("values"));if(-1!=d.indexOf(s)){d.splice(d.indexOf(s),1),d.sort(function(e,s){return e-s}),e("#slider"+n).slider("destroy"),e("#slider"+n).slider({min:0,max:12,step:1,values:d,change:function(e,s){t(e,s,n)}}),e("#slider"+n).children().last().css("display","none");for(var r in d)if(0!=d[r])if(0==l)l=d[r];else{var o=parseInt(d[r])-parseInt(d[r-1]);l=l+","+o}wp.customize("homepage_"+n,function(e){e.set(l)}),e(".sliderDeleteColumn").addClass("disabled")}}},t=function(n,l,d){var r=0,t=e.unique(l.values);t.sort(function(e,s){return e-s});for(var o in t)if(0!=t[o])if(0==r)r=t[o];else{var a=parseInt(t[o])-parseInt(t[o-1]);r=r+","+a}wp.customize("homepage_"+d,function(e){e.set(r)}),s=Math.round(parseInt(e(":focus").css("left").split("px")[0])/16.25),i=d,e(".sliderDeleteColumn").removeClass("disabled")},o=0;n>o;o++)l(o);e(".sliderAddRow").click(function(){5!=n&&(e(".sliderDeleteRow").removeClass("disabled"),l(n),n++,wp.customize("homepagerows",function(e){e.set(n)}))}),e(".sliderDeleteRow").click(function(){0!=n&&(n--,0==n&&e(".sliderDeleteRow").addClass("disabled"),e("#slider"+n).slider("destroy"),e("#slider"+n).remove(),e("#addColumn"+n).remove(),wp.customize("homepagerows",function(e){e.set(n)}),s=-1,i=-1,e(".sliderDeleteColumn").addClass("disabled"))}),e(".sliderDeleteColumn").click(function(){r()})})}); \ No newline at end of file