From 7e76fc8d6a67d56fc000066909f6ea0b2d130218 Mon Sep 17 00:00:00 2001 From: Leon Gersen Date: Sun, 22 Sep 2013 21:40:48 +0200 Subject: [PATCH] Cleaned some debugging code --- jquery.nouislider.js | 9 ++++----- jquery.nouislider.min.js | 26 +++++++++++++------------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/jquery.nouislider.js b/jquery.nouislider.js index e615a0df..9f74f691 100644 --- a/jquery.nouislider.js +++ b/jquery.nouislider.js @@ -531,17 +531,18 @@ ,style = base.data('style') ,eventXY = event[style === 'left' ? 'x' : 'y'] ,baseSize = style === 'left' ? base.width() : base.height() + // Create a standard set off offsets compensated with the // scroll distance. When required, correct for scrolling. + // This is a bug, as far as I can see, in IE(10?). ,correction = { x: ( event.t[2] ? window.pageXOffset : 0 ) - ,y: ( event.t[2] ? window.pageYOffset : 0 ) } ,offset = { handles: [] ,base: { left: base.offset().left - correction.x - ,top: base.offset().top// - correction.y + ,top: base.offset().top } }; @@ -549,12 +550,10 @@ for (i = 0; i < handles.length; i++ ) { offset.handles.push({ left: handles[i].offset().left - correction.x - ,top: handles[i].offset().top// - correction.y + ,top: handles[i].offset().top }); } - console.log('Correction: ' + correction.y + ' Handle offset: ' + offset.handles[0].top, ' Event: ' + eventXY + ' Base offset: ' + offset.base.top); - // Calculate the central point between the handles; var handleCenter = handles.length === 1 ? 0 : (( offset.handles[0][style] + offset.handles[1][style] ) / 2 ); diff --git a/jquery.nouislider.min.js b/jquery.nouislider.min.js index 4c93ccd6..6c9fbac9 100644 --- a/jquery.nouislider.min.js +++ b/jquery.nouislider.min.js @@ -1,16 +1,16 @@ /** noUiSlider 4.0.0 */ -(function(f,u){f.fn.noUiSlider=function(l){function z(a){a.stopPropagation()}function v(a,c,d){f.each(a,function(a,k){"function"===typeof k&&k.call(c,d)})}function q(a){return a.data.base.data("target").is('[class*="noUi-state-"], [disabled]')}function s(a,c){c&&a.preventDefault();var d=a,h=0===a.type.indexOf("touch"),k=0===a.type.indexOf("mouse"),b=0===a.type.indexOf("MSPointer"),r,e;a=a.originalEvent;h&&(r=a.changedTouches[0].pageX,e=a.changedTouches[0].pageY);k&&(window.pageXOffset===u&&(window.pageXOffset= -document.documentElement.scrollLeft,window.pageYOffset=document.documentElement.scrollTop),r=a.clientX+window.pageXOffset,e=a.clientY+window.pageYOffset);b&&(r=a.pageX,e=a.pageY);return{pass:d.data,e:a,x:r,y:e,t:[h,k,b]}}function A(a){return parseFloat(this.style[a])}function B(a,c){function d(a){return a instanceof f||"string"===typeof a||!1===a}var h={handles:{r:!0,t:function(a,b){b=parseInt(b,10);return 1===b||2===b}},range:{r:!0,t:function(a,b,c){if(2!==b.length)return!1;b=[parseFloat(b[0]),parseFloat(b[1])]; +(function(f,u){f.fn.noUiSlider=function(k){function z(a){a.stopPropagation()}function v(a,c,d){f.each(a,function(a,l){"function"===typeof l&&l.call(c,d)})}function p(a){return a.data.base.data("target").is('[class*="noUi-state-"], [disabled]')}function r(a,c){c&&a.preventDefault();var d=a,h=0===a.type.indexOf("touch"),l=0===a.type.indexOf("mouse"),b=0===a.type.indexOf("MSPointer"),q,e;a=a.originalEvent;h&&(q=a.changedTouches[0].pageX,e=a.changedTouches[0].pageY);l&&(window.pageXOffset===u&&(window.pageXOffset= +document.documentElement.scrollLeft,window.pageYOffset=document.documentElement.scrollTop),q=a.clientX+window.pageXOffset,e=a.clientY+window.pageYOffset);b&&(q=a.pageX,e=a.pageY);return{pass:d.data,e:a,x:q,y:e,t:[h,l,b]}}function A(a){return parseFloat(this.style[a])}function B(a,c){function d(a){return a instanceof f||"string"===typeof a||!1===a}var h={handles:{r:!0,t:function(a,b){b=parseInt(b,10);return 1===b||2===b}},range:{r:!0,t:function(a,b,c){if(2!==b.length)return!1;b=[parseFloat(b[0]),parseFloat(b[1])]; if(isNaN(b[0])||!isFinite(b[0])||isNaN(b[1])||!isFinite(b[1]))return!1;a[c]=b;return!0}},start:{r:!0,t:function(a,b,c){return 1===a.handles?(f.isArray(b)&&(b=b[0]),b=parseFloat(b),a.start=[b],!isNaN(b)&&isFinite(b)):this.parent.range.t(a,b,c)}},connect:{t:function(a,b){return!0===b||!1===b||"lower"===b&&1===a.handles||"upper"===b&&1===a.handles}},orientation:{t:function(a,b){return"horizontal"===b||"vertical"===b}},margin:{r:!0,t:function(a,b,c){b=parseFloat(b);a[c]=b;return!isNaN(b)&&isFinite(b)}}, serialization:{r:!0,t:function(a,b){if(b.resolution)switch(b.resolution){case 1:case 0.1:case 0.01:case 0.001:case 1E-4:case 1E-5:break;default:return!1}else a.serialization.resolution=0.01;return b.to?1===a.handles?(f.isArray(b.to)||(b.to=[b.to]),a.serialization.to=b.to,d(b.to[0])):2===b.to.length&&d(b.to[0])&&d(b.to[1]):!1}},slide:{t:function(a,b){return"function"===typeof b}},step:{t:function(a,b,c){return this.parent.margin.t(a,b,c)}},init:function(){var a=this;f.each(a,function(b,c){c.parent= -a});delete this.init;return this}}.init();f.each(h,function(d,b){if(b.r&&!a[d]&&0!==a[d]||(a[d]||0===a[d])&&!b.t(a,a[d],d))return console&&console.log&&console.log("Slider:\t\t\t",c,"\nOption:\t\t\t",d,"\nValue:\t\t\t",a[d]),f.error("Error on noUiSlider initialisation."),!1})}function t(a,c,d){var h=a.data("nui").options,k=a.data("nui").base.data(e[12]),b=a.data("nui").style,r=a.data("nui").decimals;if(c===a[0].getPercentage(b))return!1;c=0>c?0:100d?d:c),c===a[0].getPercentage(b)))return!1;0===a.data("nui").number&&95').appendTo(a).change(z);if(!1===c.to[d])return{val:function(a){if(a===u)return this._handle.data("nui-val");this._handle.data("nui-val",a)},hasClass:function(){return!1},_handle:a}}function D(a){if(a=s(a,!0)){var c=a.pass.base,d=c.data("style"),e=a.x-a.pass.startEvent.x,c="left"===d?c.width():c.height();"top"===d&&(e=a.y-a.pass.startEvent.y); -e=a.pass.position+100*e/c;t(a.pass.handle,e);v([a.pass.base.data("options").slide],a.pass.base.data("target"))}}function w(a){q(a)||(a.data.handle.children().removeClass(e[4]),p.off(m.move),p.off(m.end),f("body").off(g),a.data.base.data("target").change())}function E(a){if(!q(a)&&(a=s(a))){var c=a.pass.handle,d=c[0].getPercentage(c.data("nui").style);c.children().addClass("noUi-active");p.on(m.move,{startEvent:a,position:d,base:a.pass.base,handle:c},D);p.on(m.end,{base:a.pass.base,handle:c},w);f("body").on("selectstart"+ -g,function(){return!1})}}function F(a){w({data:{base:a.data.base,handle:a.data.handle}});a.stopPropagation()}function G(a){if(!q(a)&&!a.data.base.find("."+e[4]).length&&(a=s(a))){var c,d,h=a.pass.base;d=a.pass.handles;var k=h.data("style"),b=a["left"===k?"x":"y"],f="left"===k?h.width():h.height(),g=a.t[2]?window.pageXOffset:0,m=a.t[2]?window.pageYOffset:0,n=[];a={left:h.offset().left-g,top:h.offset().top-m};for(c=0;ca[0]?c+Math.abs(a[0]):c-a[0];return 100*c/this._length(a)},from:function(a,c){return 100*c/this._length(a)},is:function(a,c){return c*this._length(a)/100+a[0]},_length:function(a){return a[0]>a[1]?a[0]-a[1]:a[1]-a[0]}};window.navigator.msPointerEnabled&&(m={start:"MSPointerDown"+g,move:"MSPointerMove"+g,end:"MSPointerUp"+g});f.fn.val=function(){return this.hasClass(e[6])?H.apply(this,arguments):I.apply(this,arguments)};return function(){return this.each(function(a, -c){c=f(c);c.addClass(e[6]);var d,h,k,b,g=f("
").appendTo(c),p=[];d=J;var q=[x.concat([e[1]+e[7]]),x.concat([e[1]+e[8]])],s=[y.concat([e[2]+e[7]]),y.concat([e[2]+e[8]])];l=f.extend({handles:2,margin:0,orientation:"horizontal"},l)||{};l.serialization||(l.serialization={to:[!1,!1],resolution:0.01});B(l,c);l.S=l.serialization;l.connect&&(q[0].push(e[9]),"lower"===l.connect?(d.push(e[9],e[9]+e[7]),q[0].push(e[13])):d.push(e[9]+e[8]));h="vertical"===l.orientation?"top":"left";k=l.S.resolution.toString().split("."); -k=1==k[0]?0:k[1].length;"vertical"===l.orientation?d.push(e[10]):d.push(e[11]);g.addClass(d.join(" ")).data("target",c);for(d=0;d
").appendTo(g),b.addClass(q[d].join(" ")),b.children().addClass(s[d].join(" ")),b.children().on(m.start,{base:g,handle:b},E).on(m.end,{base:g,handle:b},F),b.data("nui",{target:c,decimals:k,options:l,base:g,style:h,number:d}).data("store",C(b,l.S)),b[0].getPercentage=A,p.push(b),t(b,n.to(l.range,l.start[d]));g.data({options:l,handles:p, -style:h});c.data({base:g,handles:p});g.on(m.end,{base:g,handles:p},G)})}.apply(this,arguments)}})(jQuery); +a});delete this.init;return this}}.init();f.each(h,function(d,b){if(b.r&&!a[d]&&0!==a[d]||(a[d]||0===a[d])&&!b.t(a,a[d],d))return console&&console.log&&console.log("Slider:\t\t\t",c,"\nOption:\t\t\t",d,"\nValue:\t\t\t",a[d]),f.error("Error on noUiSlider initialisation."),!1})}function t(a,c,d){var h=a.data("nui").options,l=a.data("nui").base.data(e[12]),b=a.data("nui").style,q=a.data("nui").decimals;if(c===a[0].getPercentage(b))return!1;c=0>c?0:100d?d:c),c===a[0].getPercentage(b)))return!1;0===a.data("nui").number&&95').appendTo(a).change(z);if(!1===c.to[d])return{val:function(a){if(a===u)return this._handle.data("nui-val");this._handle.data("nui-val",a)},hasClass:function(){return!1},_handle:a}}function D(a){if(a=r(a,!0)){var c=a.pass.base,d=c.data("style"),e=a.x-a.pass.startEvent.x,c="left"===d?c.width():c.height();"top"===d&&(e=a.y-a.pass.startEvent.y); +e=a.pass.position+100*e/c;t(a.pass.handle,e);v([a.pass.base.data("options").slide],a.pass.base.data("target"))}}function w(a){p(a)||(a.data.handle.children().removeClass(e[4]),m.off(n.move),m.off(n.end),f("body").off(g),a.data.base.data("target").change())}function E(a){if(!p(a)&&(a=r(a))){var c=a.pass.handle,d=c[0].getPercentage(c.data("nui").style);c.children().addClass("noUi-active");m.on(n.move,{startEvent:a,position:d,base:a.pass.base,handle:c},D);m.on(n.end,{base:a.pass.base,handle:c},w);f("body").on("selectstart"+ +g,function(){return!1})}}function F(a){w({data:{base:a.data.base,handle:a.data.handle}});a.stopPropagation()}function G(a){if(!p(a)&&!a.data.base.find("."+e[4]).length&&(a=r(a))){var c,d,h=a.pass.base;d=a.pass.handles;var l=h.data("style"),b=a["left"===l?"x":"y"],f="left"===l?h.width():h.height(),k=a.t[2]?window.pageXOffset:0,g=[];a={left:h.offset().left-k,top:h.offset().top};for(c=0;ca[0]?c+Math.abs(a[0]):c-a[0];return 100*c/this._length(a)},from:function(a,c){return 100*c/this._length(a)},is:function(a,c){return c*this._length(a)/100+a[0]},_length:function(a){return a[0]>a[1]?a[0]-a[1]:a[1]-a[0]}};window.navigator.msPointerEnabled&&(n={start:"MSPointerDown"+g,move:"MSPointerMove"+g,end:"MSPointerUp"+g});f.fn.val=function(){return this.hasClass(e[6])?H.apply(this,arguments):I.apply(this,arguments)};return function(){return this.each(function(a,c){c=f(c); +c.addClass(e[6]);var d,h,l,b,g=f("
").appendTo(c),m=[];d=J;var p=[x.concat([e[1]+e[7]]),x.concat([e[1]+e[8]])],r=[y.concat([e[2]+e[7]]),y.concat([e[2]+e[8]])];k=f.extend({handles:2,margin:0,orientation:"horizontal"},k)||{};k.serialization||(k.serialization={to:[!1,!1],resolution:0.01});B(k,c);k.S=k.serialization;k.connect&&(p[0].push(e[9]),"lower"===k.connect?(d.push(e[9],e[9]+e[7]),p[0].push(e[13])):d.push(e[9]+e[8]));h="vertical"===k.orientation?"top":"left";l=k.S.resolution.toString().split("."); +l=1==l[0]?0:l[1].length;"vertical"===k.orientation?d.push(e[10]):d.push(e[11]);g.addClass(d.join(" ")).data("target",c);for(d=0;d
").appendTo(g),b.addClass(p[d].join(" ")),b.children().addClass(r[d].join(" ")),b.children().on(n.start,{base:g,handle:b},E).on(n.end,{base:g,handle:b},F),b.data("nui",{target:c,decimals:l,options:k,base:g,style:h,number:d}).data("store",C(b,k.S)),b[0].getPercentage=A,m.push(b),t(b,s.to(k.range,k.start[d]));g.data({options:k,handles:m, +style:h});c.data({base:g,handles:m});g.on(n.end,{base:g,handles:m},G)})}.apply(this,arguments)}})(jQuery);