Commit 73439969 authored by Rafal Zajac's avatar Rafal Zajac

JsLint, use strict

parent dd7ba791
/*! jusas-angularjs-slider - v0.1.16 - (c) Rafal Zajac <rzajac@gmail.com>, Jussi Saarivirta <jusasi@gmail.com>, Angelin Sirbu <angelin.sirbu@gmail.com>, https://github.com/rzajac/angularjs-slider.git - 2015-05-26 */ /*! jusas-angularjs-slider - v0.1.16 - (c) Rafal Zajac <rzajac@gmail.com>, Jussi Saarivirta <jusasi@gmail.com>, Angelin Sirbu <angelin.sirbu@gmail.com>, https://github.com/rzajac/angularjs-slider.git - 2015-05-28 */
rzslider{position:relative;display:inline-block;width:100%;height:4px;margin:30px 0 15px 0;vertical-align:middle}rzslider span{position:absolute;display:inline-block;white-space:nowrap}rzslider span.rz-base{width:100%;height:100%;padding:0}rzslider span.rz-bar{z-index:0;width:100%;height:100%;background:#d8e0f3;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}rzslider span.rz-bar.rz-selection{z-index:1;width:0;background:#0db9f0;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}rzslider span.rz-pointer{top:-14px;z-index:2;width:32px;height:32px;cursor:pointer;background-color:#0db9f0;-webkit-border-radius:16px;-moz-border-radius:16px;border-radius:16px}rzslider span.rz-pointer:after{position:absolute;top:12px;left:12px;width:8px;height:8px;background:#fff;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;content:''}rzslider span.rz-pointer:hover:after{background-color:#fff}rzslider span.rz-pointer.rz-active:after{background-color:#451aff}rzslider span.rz-bubble{top:-32px;padding:1px 3px;color:#55637d;cursor:default}rzslider span.rz-bubble.rz-selection{top:16px}rzslider span.rz-bubble.rz-limit{color:#55637d} rzslider{position:relative;display:inline-block;width:100%;height:4px;margin:30px 0 15px 0;vertical-align:middle}rzslider span{position:absolute;display:inline-block;white-space:nowrap}rzslider span.rz-base{width:100%;height:100%;padding:0}rzslider span.rz-bar{z-index:0;width:100%;height:100%;background:#d8e0f3;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}rzslider span.rz-bar.rz-selection{z-index:1;width:0;background:#0db9f0;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}rzslider span.rz-pointer{top:-14px;z-index:2;width:32px;height:32px;cursor:pointer;background-color:#0db9f0;-webkit-border-radius:16px;-moz-border-radius:16px;border-radius:16px}rzslider span.rz-pointer:after{position:absolute;top:12px;left:12px;width:8px;height:8px;background:#fff;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;content:''}rzslider span.rz-pointer:hover:after{background-color:#fff}rzslider span.rz-pointer.rz-active:after{background-color:#451aff}rzslider span.rz-bubble{top:-32px;padding:1px 3px;color:#55637d;cursor:default}rzslider span.rz-bubble.rz-selection{top:16px}rzslider span.rz-bubble.rz-limit{color:#55637d}
\ No newline at end of file
/*! jusas-angularjs-slider - v0.1.16 - (c) Rafal Zajac <rzajac@gmail.com>, Jussi Saarivirta <jusasi@gmail.com>, Angelin Sirbu <angelin.sirbu@gmail.com>, https://github.com/rzajac/angularjs-slider.git - 2015-05-28 */ /*! jusas-angularjs-slider - v0.1.16 - (c) Rafal Zajac <rzajac@gmail.com>, Jussi Saarivirta <jusasi@gmail.com>, Angelin Sirbu <angelin.sirbu@gmail.com>, https://github.com/rzajac/angularjs-slider.git - 2015-05-28 */
angular.module("rzModule",[]).run(["$templateCache",function(a){var b='<span class="rz-bar"></span><span class="rz-bar rz-selection"></span><span class="rz-pointer"></span><span class="rz-pointer"></span><span class="rz-bubble rz-limit"></span><span class="rz-bubble rz-limit"></span><span class="rz-bubble"></span><span class="rz-bubble"></span><span class="rz-bubble"></span>';a.put("rzSliderTpl.html",b)}]).value("throttle",function(a,b,c){var d,e,f,g=Date.now||function(){return(new Date).getTime()},h=null,i=0;c=c||{};var j=function(){i=c.leading===!1?0:g(),h=null,f=a.apply(d,e),d=e=null};return function(){var k=g();i||c.leading!==!1||(i=k);var l=b-(k-i);return d=this,e=arguments,0>=l?(clearTimeout(h),h=null,i=k,f=a.apply(d,e),d=e=null):h||c.trailing===!1||(h=setTimeout(j,l)),f}}).factory("RzSlider",["$timeout","$document","$window","throttle",function(a,b,c,d){var e=function(a,b,c){this.scope=a,this.attributes=c,this.sliderElem=b,this.range=void 0!==c.rzSliderHigh&&void 0!==c.rzSliderModel,this.handleHalfWidth=0,this.alwaysShowBar=!!c.rzSliderAlwaysShowBar,this.maxLeft=0,this.precision=0,this.step=0,this.tracking="",this.minValue=0,this.maxValue=0,this.hideLimitLabels=!!c.rzSliderHideLimitLabels,this.valueRange=0,this.initHasRun=!1,this.customTrFn=this.scope.rzSliderTranslate()||function(a){return""+a},this.unbinders=[],this.fullBar=null,this.selBar=null,this.minH=null,this.maxH=null,this.flrLab=null,this.ceilLab=null,this.minLab=null,this.maxLab=null,this.cmbLab=null,this.init()};return e.prototype={init:function(){var e=this;this.initElemHandles(),this.calcViewDimensions(),this.setMinAndMax(),this.precision=void 0===this.scope.rzSliderPrecision?0:+this.scope.rzSliderPrecision,this.step=void 0===this.scope.rzSliderStep?1:+this.scope.rzSliderStep,a(function(){e.updateCeilLab(),e.updateFloorLab(),e.initHandles(),e.bindEvents()}),this.scope.$on("reCalcViewDimensions",angular.bind(this,this.calcViewDimensions)),angular.element(c).on("resize",angular.bind(this,this.calcViewDimensions)),this.initHasRun=!0;var f=d(function(){e.setMinAndMax(),e.updateLowHandle(e.valueToOffset(e.scope.rzSliderModel)),e.updateSelectionBar(),e.range&&e.updateCmbLabel()},350,{leading:!1}),g=d(function(){e.setMinAndMax(),e.updateHighHandle(e.valueToOffset(e.scope.rzSliderHigh)),e.updateSelectionBar(),e.updateCmbLabel()},350,{leading:!1});this.scope.$on("rzSliderForceRender",function(){e.resetLabelsValue(),f(),this.range&&g(),e.resetSlider()}),this.unbinders.push(this.scope.$watch("rzSliderModel",function(a,b){a!==b&&f()})),this.unbinders.push(this.scope.$watch("rzSliderHigh",function(a,b){a!==b&&g()})),this.unbinders.push(this.scope.$watch("rzSliderFloor",function(a,b){a!==b&&e.resetSlider()})),this.unbinders.push(this.scope.$watch("rzSliderCeil",function(a,b){a!==b&&e.resetSlider()})),b.on("$destroy",function(){e.minH.off(".rzslider"),e.maxH.off(".rzslider"),b.off(".rzslider"),angular.element(c).off(".rzslider")}),this.scope.$on("$destroy",function(){e.unbinders.map(function(a){a()})})},resetSlider:function(){this.setMinAndMax(),this.calcViewDimensions(),this.updateCeilLab(),this.updateFloorLab()},resetLabelsValue:function(){this.minLab.rzsv=void 0,this.maxLab.rzsv=void 0},initHandles:function(){this.updateLowHandle(this.valueToOffset(this.scope.rzSliderModel)),this.range&&(this.updateHighHandle(this.valueToOffset(this.scope.rzSliderHigh)),this.updateCmbLabel()),this.updateSelectionBar()},translateFn:function(a,b,c){c=void 0===c?!0:c;var d=c?""+this.customTrFn(a):""+a,e=!1;(void 0===b.rzsv||b.rzsv.length!=d.length||b.rzsv.length>0&&0==b.rzsw)&&(e=!0,b.rzsv=d),b.text(d),e&&this.getWidth(b)},setMinAndMax:function(){this.scope.rzSliderFloor?this.minValue=+this.scope.rzSliderFloor:this.minValue=this.scope.rzSliderFloor=0,this.scope.rzSliderCeil?this.maxValue=+this.scope.rzSliderCeil:this.scope.rzSliderCeil=this.maxValue=this.range?this.scope.rzSliderHigh:this.scope.rzSliderModel,this.scope.rzSliderStep&&(this.step=+this.scope.rzSliderStep),this.valueRange=this.maxValue-this.minValue},initElemHandles:function(){angular.forEach(this.sliderElem.children(),function(a,b){var c=angular.element(a);switch(b){case 0:this.fullBar=c;break;case 1:this.selBar=c;break;case 2:this.minH=c;break;case 3:this.maxH=c;break;case 4:this.flrLab=c;break;case 5:this.ceilLab=c;break;case 6:this.minLab=c;break;case 7:this.maxLab=c;break;case 8:this.cmbLab=c}},this),this.fullBar.rzsl=0,this.selBar.rzsl=0,this.minH.rzsl=0,this.maxH.rzsl=0,this.flrLab.rzsl=0,this.ceilLab.rzsl=0,this.minLab.rzsl=0,this.maxLab.rzsl=0,this.cmbLab.rzsl=0,this.hideLimitLabels&&(this.flrLab.rzAlwaysHide=!0,this.ceilLab.rzAlwaysHide=!0,this.hideEl(this.flrLab),this.hideEl(this.ceilLab)),this.range===!1&&(this.cmbLab.remove(),this.maxLab.remove(),this.maxH.rzAlwaysHide=!0,this.maxH[0].style.zIndex="-1000",this.hideEl(this.maxH)),this.range===!1&&this.alwaysShowBar===!1&&(this.maxH.remove(),this.selBar.remove())},calcViewDimensions:function(){var a=this.getWidth(this.minH);this.handleHalfWidth=a/2,this.barWidth=this.getWidth(this.fullBar),this.maxLeft=this.barWidth-a,this.getWidth(this.sliderElem),this.sliderElem.rzsl=this.sliderElem[0].getBoundingClientRect().left,this.initHasRun&&(this.updateCeilLab(),this.initHandles())},updateCeilLab:function(){this.translateFn(this.scope.rzSliderCeil,this.ceilLab),this.setLeft(this.ceilLab,this.barWidth-this.ceilLab.rzsw),this.getWidth(this.ceilLab)},updateFloorLab:function(){this.translateFn(this.scope.rzSliderFloor,this.flrLab),this.getWidth(this.flrLab)},updateHandles:function(a,b){return"rzSliderModel"===a?(this.updateLowHandle(b),this.updateSelectionBar(),void(this.range&&this.updateCmbLabel())):"rzSliderHigh"===a?(this.updateHighHandle(b),this.updateSelectionBar(),void(this.range&&this.updateCmbLabel())):(this.updateLowHandle(b),this.updateHighHandle(b),this.updateSelectionBar(),void this.updateCmbLabel())},updateLowHandle:function(a){var b=Math.abs(this.minH.rzsl-a);0!==b&&1!==b&&(this.setLeft(this.minH,a),this.translateFn(this.scope.rzSliderModel,this.minLab),this.setLeft(this.minLab,a-this.minLab.rzsw/2+this.handleHalfWidth),this.shFloorCeil())},updateHighHandle:function(a){this.setLeft(this.maxH,a),this.translateFn(this.scope.rzSliderHigh,this.maxLab),this.setLeft(this.maxLab,a-this.maxLab.rzsw/2+this.handleHalfWidth),this.shFloorCeil()},shFloorCeil:function(){var a=!1,b=!1;this.minLab.rzsl<=this.flrLab.rzsl+this.flrLab.rzsw+5?(a=!0,this.hideEl(this.flrLab)):(a=!1,this.showEl(this.flrLab)),this.minLab.rzsl+this.minLab.rzsw>=this.ceilLab.rzsl-this.handleHalfWidth-10?(b=!0,this.hideEl(this.ceilLab)):(b=!1,this.showEl(this.ceilLab)),this.range&&(this.maxLab.rzsl+this.maxLab.rzsw>=this.ceilLab.rzsl-10?this.hideEl(this.ceilLab):b||this.showEl(this.ceilLab),this.maxLab.rzsl<=this.flrLab.rzsl+this.flrLab.rzsw+this.handleHalfWidth?this.hideEl(this.flrLab):a||this.showEl(this.flrLab))},updateSelectionBar:function(){this.setWidth(this.selBar,Math.abs(this.maxH.rzsl-this.minH.rzsl)),this.setLeft(this.selBar,this.range?this.minH.rzsl+this.handleHalfWidth:0)},updateCmbLabel:function(){var a,b;this.minLab.rzsl+this.minLab.rzsw+10>=this.maxLab.rzsl?(this.customTrFn?(a=this.customTrFn(this.scope.rzSliderModel),b=this.customTrFn(this.scope.rzSliderHigh)):(a=this.scope.rzSliderModel,b=this.scope.rzSliderHigh),this.translateFn(a+" - "+b,this.cmbLab,!1),this.setLeft(this.cmbLab,this.selBar.rzsl+this.selBar.rzsw/2-this.cmbLab.rzsw/2),this.hideEl(this.minLab),this.hideEl(this.maxLab),this.showEl(this.cmbLab)):(this.showEl(this.maxLab),this.showEl(this.minLab),this.hideEl(this.cmbLab))},roundStep:function(a){var b=this.step/Math.pow(10,this.precision),c=(a-this.minValue)%b,d=c>b/2?a+b-c:a-c;return+d.toFixed(this.precision)},hideEl:function(a){return a.css({opacity:0})},showEl:function(a){return a.rzAlwaysHide?a:a.css({opacity:1})},setLeft:function(a,b){return a.rzsl=b,a.css({left:b+"px"}),b},getWidth:function(a){var b=a[0].getBoundingClientRect();return a.rzsw=b.right-b.left,a.rzsw},setWidth:function(a,b){return a.rzsw=b,a.css({width:b+"px"}),b},valueToOffset:function(a){return Math.round((Math.ceil(a)-this.minValue)*this.maxLeft/this.valueRange)},offsetToValue:function(a){return Math.ceil(a/this.maxLeft*this.valueRange+this.minValue)},bindEvents:function(){this.minH.on("mousedown",angular.bind(this,this.onStart,this.minH,"rzSliderModel")),this.range&&this.maxH.on("mousedown",angular.bind(this,this.onStart,this.maxH,"rzSliderHigh")),this.minH.on("touchstart",angular.bind(this,this.onStart,this.minH,"rzSliderModel")),this.range&&this.maxH.on("touchstart",angular.bind(this,this.onStart,this.maxH,"rzSliderHigh"))},onStart:function(a,c,d){d.stopPropagation(),d.preventDefault(),""===this.tracking&&(this.calcViewDimensions(),this.tracking=c,a.addClass("rz-active"),d.touches||"undefined"!=typeof d.originalEvent&&d.originalEvent.touches?(b.on("touchmove",angular.bind(this,this.onMove,a)),b.one("touchend",angular.bind(this,this.onEnd))):(b.on("mousemove",angular.bind(this,this.onMove,a)),b.one("mouseup",angular.bind(this,this.onEnd))))},onMove:function(a,b){var c,d,e,f;return c="clientX"in b?b.clientX:"undefined"!=typeof b.originalEvent?b.originalEvent.touches[0].clientX:b.touches[0].clientX,d=this.sliderElem.rzsl,e=c-d-this.handleHalfWidth,0>=e?void(0!==a.rzsl&&(this.scope[this.tracking]=this.minValue,this.updateHandles(this.tracking,0),this.scope.$apply())):e>=this.maxLeft?void(a.rzsl!==this.maxLeft&&(this.scope[this.tracking]=this.maxValue,this.updateHandles(this.tracking,this.maxLeft),this.scope.$apply())):(f=this.offsetToValue(e),f=this.roundStep(f),this.range&&("rzSliderModel"===this.tracking&&f>=this.scope.rzSliderHigh?(this.scope[this.tracking]=this.scope.rzSliderHigh,this.updateHandles(this.tracking,this.maxH.rzsl),this.tracking="rzSliderHigh",this.minH.removeClass("rz-active"),this.maxH.addClass("rz-active")):"rzSliderHigh"===this.tracking&&f<=this.scope.rzSliderModel&&(this.scope[this.tracking]=this.scope.rzSliderModel,this.updateHandles(this.tracking,this.minH.rzsl),this.tracking="rzSliderModel",this.maxH.removeClass("rz-active"),this.minH.addClass("rz-active"))),void(this.scope[this.tracking]!==f&&(this.scope[this.tracking]=f,this.updateHandles(this.tracking,e),this.scope.$apply())))},onEnd:function(a){this.minH.removeClass("rz-active"),this.maxH.removeClass("rz-active"),a.touches||"undefined"!=typeof a.originalEvent&&a.originalEvent.touches?b.off("touchmove"):b.off("mousemove"),this.scope.$emit("slideEnded"),this.tracking=""}},e}]).directive("rzslider",["RzSlider",function(a){return{restrict:"E",scope:{rzSliderFloor:"=?",rzSliderCeil:"=?",rzSliderStep:"@",rzSliderPrecision:"@",rzSliderModel:"=?",rzSliderHigh:"=?",rzSliderTranslate:"&",rzSliderHideLimitLabels:"=?",rzSliderAlwaysShowBar:"=?"},templateUrl:function(a,b){return b.rzSliderTplUrl||"rzSliderTpl.html"},link:function(b,c,d){return new a(b,c,d)}}}]); angular.module("rzModule",[]).run(["$templateCache",function(a){"use strict";var b='<span class="rz-bar"></span><span class="rz-bar rz-selection"></span><span class="rz-pointer"></span><span class="rz-pointer"></span><span class="rz-bubble rz-limit"></span><span class="rz-bubble rz-limit"></span><span class="rz-bubble"></span><span class="rz-bubble"></span><span class="rz-bubble"></span>';a.put("rzSliderTpl.html",b)}]).value("throttle",function(a,b,c){"use strict";var d,e,f,g=Date.now||function(){return(new Date).getTime()},h=null,i=0;c=c||{};var j=function(){i=c.leading===!1?0:g(),h=null,f=a.apply(d,e),d=e=null};return function(){var k=g();i||c.leading!==!1||(i=k);var l=b-(k-i);return d=this,e=arguments,0>=l?(clearTimeout(h),h=null,i=k,f=a.apply(d,e),d=e=null):h||c.trailing===!1||(h=setTimeout(j,l)),f}}).factory("RzSlider",["$timeout","$document","$window","throttle",function(a,b,c,d){"use strict";var e=function(a,b,c){this.scope=a,this.attributes=c,this.sliderElem=b,this.range=void 0!==c.rzSliderHigh&&void 0!==c.rzSliderModel,this.handleHalfWidth=0,this.alwaysShowBar=!!c.rzSliderAlwaysShowBar,this.maxLeft=0,this.precision=0,this.step=0,this.tracking="",this.minValue=0,this.maxValue=0,this.hideLimitLabels=!!c.rzSliderHideLimitLabels,this.valueRange=0,this.initHasRun=!1,this.customTrFn=this.scope.rzSliderTranslate()||function(a){return""+a},this.unbinders=[],this.fullBar=null,this.selBar=null,this.minH=null,this.maxH=null,this.flrLab=null,this.ceilLab=null,this.minLab=null,this.maxLab=null,this.cmbLab=null,this.init()};return e.prototype={init:function(){var e=this;this.initElemHandles(),this.calcViewDimensions(),this.setMinAndMax(),this.precision=void 0===this.scope.rzSliderPrecision?0:+this.scope.rzSliderPrecision,this.step=void 0===this.scope.rzSliderStep?1:+this.scope.rzSliderStep,a(function(){e.updateCeilLab(),e.updateFloorLab(),e.initHandles(),e.bindEvents()}),this.scope.$on("reCalcViewDimensions",angular.bind(this,this.calcViewDimensions)),angular.element(c).on("resize",angular.bind(this,this.calcViewDimensions)),this.initHasRun=!0;var f=d(function(){e.setMinAndMax(),e.updateLowHandle(e.valueToOffset(e.scope.rzSliderModel)),e.updateSelectionBar(),e.range&&e.updateCmbLabel()},350,{leading:!1}),g=d(function(){e.setMinAndMax(),e.updateHighHandle(e.valueToOffset(e.scope.rzSliderHigh)),e.updateSelectionBar(),e.updateCmbLabel()},350,{leading:!1});this.scope.$on("rzSliderForceRender",function(){e.resetLabelsValue(),f(),e.range&&g(),e.resetSlider()}),this.unbinders.push(this.scope.$watch("rzSliderModel",function(a,b){a!==b&&f()})),this.unbinders.push(this.scope.$watch("rzSliderHigh",function(a,b){a!==b&&g()})),this.unbinders.push(this.scope.$watch("rzSliderFloor",function(a,b){a!==b&&e.resetSlider()})),this.unbinders.push(this.scope.$watch("rzSliderCeil",function(a,b){a!==b&&e.resetSlider()})),b.on("$destroy",function(){e.minH.off(".rzslider"),e.maxH.off(".rzslider"),b.off(".rzslider"),angular.element(c).off(".rzslider")}),this.scope.$on("$destroy",function(){e.unbinders.map(function(a){a()})})},resetSlider:function(){this.setMinAndMax(),this.calcViewDimensions(),this.updateCeilLab(),this.updateFloorLab()},resetLabelsValue:function(){this.minLab.rzsv=void 0,this.maxLab.rzsv=void 0},initHandles:function(){this.updateLowHandle(this.valueToOffset(this.scope.rzSliderModel)),this.range&&(this.updateHighHandle(this.valueToOffset(this.scope.rzSliderHigh)),this.updateCmbLabel()),this.updateSelectionBar()},translateFn:function(a,b,c){c=void 0===c?!0:c;var d=c?""+this.customTrFn(a):""+a,e=!1;(void 0===b.rzsv||b.rzsv.length!==d.length||b.rzsv.length>0&&0===b.rzsw)&&(e=!0,b.rzsv=d),b.text(d),e&&this.getWidth(b)},setMinAndMax:function(){this.scope.rzSliderFloor?this.minValue=+this.scope.rzSliderFloor:this.minValue=this.scope.rzSliderFloor=0,this.scope.rzSliderCeil?this.maxValue=+this.scope.rzSliderCeil:this.scope.rzSliderCeil=this.maxValue=this.range?this.scope.rzSliderHigh:this.scope.rzSliderModel,this.scope.rzSliderStep&&(this.step=+this.scope.rzSliderStep),this.valueRange=this.maxValue-this.minValue},initElemHandles:function(){angular.forEach(this.sliderElem.children(),function(a,b){var c=angular.element(a);switch(b){case 0:this.fullBar=c;break;case 1:this.selBar=c;break;case 2:this.minH=c;break;case 3:this.maxH=c;break;case 4:this.flrLab=c;break;case 5:this.ceilLab=c;break;case 6:this.minLab=c;break;case 7:this.maxLab=c;break;case 8:this.cmbLab=c}},this),this.fullBar.rzsl=0,this.selBar.rzsl=0,this.minH.rzsl=0,this.maxH.rzsl=0,this.flrLab.rzsl=0,this.ceilLab.rzsl=0,this.minLab.rzsl=0,this.maxLab.rzsl=0,this.cmbLab.rzsl=0,this.hideLimitLabels&&(this.flrLab.rzAlwaysHide=!0,this.ceilLab.rzAlwaysHide=!0,this.hideEl(this.flrLab),this.hideEl(this.ceilLab)),this.range===!1&&(this.cmbLab.remove(),this.maxLab.remove(),this.maxH.rzAlwaysHide=!0,this.maxH[0].style.zIndex="-1000",this.hideEl(this.maxH)),this.range===!1&&this.alwaysShowBar===!1&&(this.maxH.remove(),this.selBar.remove())},calcViewDimensions:function(){var a=this.getWidth(this.minH);this.handleHalfWidth=a/2,this.barWidth=this.getWidth(this.fullBar),this.maxLeft=this.barWidth-a,this.getWidth(this.sliderElem),this.sliderElem.rzsl=this.sliderElem[0].getBoundingClientRect().left,this.initHasRun&&(this.updateCeilLab(),this.initHandles())},updateCeilLab:function(){this.translateFn(this.scope.rzSliderCeil,this.ceilLab),this.setLeft(this.ceilLab,this.barWidth-this.ceilLab.rzsw),this.getWidth(this.ceilLab)},updateFloorLab:function(){this.translateFn(this.scope.rzSliderFloor,this.flrLab),this.getWidth(this.flrLab)},updateHandles:function(a,b){return"rzSliderModel"===a?(this.updateLowHandle(b),this.updateSelectionBar(),void(this.range&&this.updateCmbLabel())):"rzSliderHigh"===a?(this.updateHighHandle(b),this.updateSelectionBar(),void(this.range&&this.updateCmbLabel())):(this.updateLowHandle(b),this.updateHighHandle(b),this.updateSelectionBar(),void this.updateCmbLabel())},updateLowHandle:function(a){var b=Math.abs(this.minH.rzsl-a);0!==b&&1!==b&&(this.setLeft(this.minH,a),this.translateFn(this.scope.rzSliderModel,this.minLab),this.setLeft(this.minLab,a-this.minLab.rzsw/2+this.handleHalfWidth),this.shFloorCeil())},updateHighHandle:function(a){this.setLeft(this.maxH,a),this.translateFn(this.scope.rzSliderHigh,this.maxLab),this.setLeft(this.maxLab,a-this.maxLab.rzsw/2+this.handleHalfWidth),this.shFloorCeil()},shFloorCeil:function(){var a=!1,b=!1;this.minLab.rzsl<=this.flrLab.rzsl+this.flrLab.rzsw+5?(a=!0,this.hideEl(this.flrLab)):(a=!1,this.showEl(this.flrLab)),this.minLab.rzsl+this.minLab.rzsw>=this.ceilLab.rzsl-this.handleHalfWidth-10?(b=!0,this.hideEl(this.ceilLab)):(b=!1,this.showEl(this.ceilLab)),this.range&&(this.maxLab.rzsl+this.maxLab.rzsw>=this.ceilLab.rzsl-10?this.hideEl(this.ceilLab):b||this.showEl(this.ceilLab),this.maxLab.rzsl<=this.flrLab.rzsl+this.flrLab.rzsw+this.handleHalfWidth?this.hideEl(this.flrLab):a||this.showEl(this.flrLab))},updateSelectionBar:function(){this.setWidth(this.selBar,Math.abs(this.maxH.rzsl-this.minH.rzsl)),this.setLeft(this.selBar,this.range?this.minH.rzsl+this.handleHalfWidth:0)},updateCmbLabel:function(){var a,b;this.minLab.rzsl+this.minLab.rzsw+10>=this.maxLab.rzsl?(this.customTrFn?(a=this.customTrFn(this.scope.rzSliderModel),b=this.customTrFn(this.scope.rzSliderHigh)):(a=this.scope.rzSliderModel,b=this.scope.rzSliderHigh),this.translateFn(a+" - "+b,this.cmbLab,!1),this.setLeft(this.cmbLab,this.selBar.rzsl+this.selBar.rzsw/2-this.cmbLab.rzsw/2),this.hideEl(this.minLab),this.hideEl(this.maxLab),this.showEl(this.cmbLab)):(this.showEl(this.maxLab),this.showEl(this.minLab),this.hideEl(this.cmbLab))},roundStep:function(a){var b=this.step/Math.pow(10,this.precision),c=(a-this.minValue)%b,d=c>b/2?a+b-c:a-c;return+d.toFixed(this.precision)},hideEl:function(a){return a.css({opacity:0})},showEl:function(a){return a.rzAlwaysHide?a:a.css({opacity:1})},setLeft:function(a,b){return a.rzsl=b,a.css({left:b+"px"}),b},getWidth:function(a){var b=a[0].getBoundingClientRect();return a.rzsw=b.right-b.left,a.rzsw},setWidth:function(a,b){return a.rzsw=b,a.css({width:b+"px"}),b},valueToOffset:function(a){return Math.round((Math.ceil(a)-this.minValue)*this.maxLeft/this.valueRange)},offsetToValue:function(a){return Math.ceil(a/this.maxLeft*this.valueRange+this.minValue)},bindEvents:function(){this.minH.on("mousedown",angular.bind(this,this.onStart,this.minH,"rzSliderModel")),this.range&&this.maxH.on("mousedown",angular.bind(this,this.onStart,this.maxH,"rzSliderHigh")),this.minH.on("touchstart",angular.bind(this,this.onStart,this.minH,"rzSliderModel")),this.range&&this.maxH.on("touchstart",angular.bind(this,this.onStart,this.maxH,"rzSliderHigh"))},onStart:function(a,c,d){d.stopPropagation(),d.preventDefault(),""===this.tracking&&(this.calcViewDimensions(),this.tracking=c,a.addClass("rz-active"),d.touches||void 0!==d.originalEvent&&d.originalEvent.touches?(b.on("touchmove",angular.bind(this,this.onMove,a)),b.one("touchend",angular.bind(this,this.onEnd))):(b.on("mousemove",angular.bind(this,this.onMove,a)),b.one("mouseup",angular.bind(this,this.onEnd))))},onMove:function(a,b){var c,d,e,f;return c="clientX"in b?b.clientX:void 0===b.originalEvent?b.touches[0].clientX:b.originalEvent.touches[0].clientX,d=this.sliderElem.rzsl,e=c-d-this.handleHalfWidth,0>=e?void(0!==a.rzsl&&(this.scope[this.tracking]=this.minValue,this.updateHandles(this.tracking,0),this.scope.$apply())):e>=this.maxLeft?void(a.rzsl!==this.maxLeft&&(this.scope[this.tracking]=this.maxValue,this.updateHandles(this.tracking,this.maxLeft),this.scope.$apply())):(f=this.offsetToValue(e),f=this.roundStep(f),this.range&&("rzSliderModel"===this.tracking&&f>=this.scope.rzSliderHigh?(this.scope[this.tracking]=this.scope.rzSliderHigh,this.updateHandles(this.tracking,this.maxH.rzsl),this.tracking="rzSliderHigh",this.minH.removeClass("rz-active"),this.maxH.addClass("rz-active")):"rzSliderHigh"===this.tracking&&f<=this.scope.rzSliderModel&&(this.scope[this.tracking]=this.scope.rzSliderModel,this.updateHandles(this.tracking,this.minH.rzsl),this.tracking="rzSliderModel",this.maxH.removeClass("rz-active"),this.minH.addClass("rz-active"))),void(this.scope[this.tracking]!==f&&(this.scope[this.tracking]=f,this.updateHandles(this.tracking,e),this.scope.$apply())))},onEnd:function(a){this.minH.removeClass("rz-active"),this.maxH.removeClass("rz-active"),a.touches||void 0!==a.originalEvent&&a.originalEvent.touches?b.off("touchmove"):b.off("mousemove"),this.scope.$emit("slideEnded"),this.tracking=""}},e}]).directive("rzslider",["RzSlider",function(a){"use strict";return{restrict:"E",scope:{rzSliderFloor:"=?",rzSliderCeil:"=?",rzSliderStep:"@",rzSliderPrecision:"@",rzSliderModel:"=?",rzSliderHigh:"=?",rzSliderTranslate:"&",rzSliderHideLimitLabels:"=?",rzSliderAlwaysShowBar:"=?"},templateUrl:function(a,b){return b.rzSliderTplUrl||"rzSliderTpl.html"},link:function(b,c,d){return new a(b,c,d)}}}]);
\ No newline at end of file \ No newline at end of file
...@@ -9,11 +9,12 @@ ...@@ -9,11 +9,12 @@
* Licensed under the MIT license * Licensed under the MIT license
*/ */
/* global angular: false */ /*global angular: false */
angular.module('rzModule', []) angular.module('rzModule', [])
.run(['$templateCache', function($templateCache) { .run(['$templateCache', function($templateCache) {
'use strict';
var template = '<span class="rz-bar"></span>' + // 0 The slider bar var template = '<span class="rz-bar"></span>' + // 0 The slider bar
'<span class="rz-bar rz-selection"></span>' + // 1 Highlight between two handles '<span class="rz-bar rz-selection"></span>' + // 1 Highlight between two handles
'<span class="rz-pointer"></span>' + // 2 Left slider handle '<span class="rz-pointer"></span>' + // 2 Left slider handle
...@@ -38,6 +39,7 @@ angular.module('rzModule', []) ...@@ -38,6 +39,7 @@ angular.module('rzModule', [])
* @returns {Function} * @returns {Function}
*/ */
function throttle(func, wait, options) { function throttle(func, wait, options) {
'use strict';
var getTime = (Date.now || function() { var getTime = (Date.now || function() {
return new Date().getTime(); return new Date().getTime();
}); });
...@@ -53,7 +55,7 @@ function throttle(func, wait, options) { ...@@ -53,7 +55,7 @@ function throttle(func, wait, options) {
}; };
return function() { return function() {
var now = getTime(); var now = getTime();
if (!previous && options.leading === false) previous = now; if (!previous && options.leading === false) { previous = now; }
var remaining = wait - (now - previous); var remaining = wait - (now - previous);
context = this; context = this;
args = arguments; args = arguments;
...@@ -67,11 +69,13 @@ function throttle(func, wait, options) { ...@@ -67,11 +69,13 @@ function throttle(func, wait, options) {
timeout = setTimeout(later, remaining); timeout = setTimeout(later, remaining);
} }
return result; return result;
} };
}) })
.factory('RzSlider', ['$timeout', '$document', '$window', 'throttle', function($timeout, $document, $window, throttle) .factory('RzSlider', ['$timeout', '$document', '$window', 'throttle', function($timeout, $document, $window, throttle)
{ {
'use strict';
/** /**
* Slider * Slider
* *
...@@ -273,7 +277,7 @@ function throttle(func, wait, options) { ...@@ -273,7 +277,7 @@ function throttle(func, wait, options) {
{ {
self.resetLabelsValue(); self.resetLabelsValue();
thrLow(); thrLow();
if(this.range) thrHigh(); if(self.range) { thrHigh(); }
self.resetSlider(); self.resetSlider();
}); });
...@@ -281,25 +285,25 @@ function throttle(func, wait, options) { ...@@ -281,25 +285,25 @@ function throttle(func, wait, options) {
this.unbinders.push(this.scope.$watch('rzSliderModel', function(newValue, oldValue) this.unbinders.push(this.scope.$watch('rzSliderModel', function(newValue, oldValue)
{ {
if(newValue === oldValue) return; if(newValue === oldValue) { return; }
thrLow(); thrLow();
})); }));
this.unbinders.push(this.scope.$watch('rzSliderHigh', function(newValue, oldValue) this.unbinders.push(this.scope.$watch('rzSliderHigh', function(newValue, oldValue)
{ {
if(newValue === oldValue) return; if(newValue === oldValue) { return; }
thrHigh(); thrHigh();
})); }));
this.unbinders.push(this.scope.$watch('rzSliderFloor', function(newValue, oldValue) this.unbinders.push(this.scope.$watch('rzSliderFloor', function(newValue, oldValue)
{ {
if(newValue === oldValue) return; if(newValue === oldValue) { return; }
self.resetSlider(); self.resetSlider();
})); }));
this.unbinders.push(this.scope.$watch('rzSliderCeil', function(newValue, oldValue) this.unbinders.push(this.scope.$watch('rzSliderCeil', function(newValue, oldValue)
{ {
if(newValue === oldValue) return; if(newValue === oldValue) { return; }
self.resetSlider(); self.resetSlider();
})); }));
...@@ -379,7 +383,7 @@ function throttle(func, wait, options) { ...@@ -379,7 +383,7 @@ function throttle(func, wait, options) {
var valStr = useCustomTr ? '' + this.customTrFn(value) : '' + value, var valStr = useCustomTr ? '' + this.customTrFn(value) : '' + value,
getWidth = false; getWidth = false;
if(label.rzsv === undefined || label.rzsv.length != valStr.length || (label.rzsv.length > 0 && label.rzsw == 0)) if(label.rzsv === undefined || label.rzsv.length !== valStr.length || (label.rzsv.length > 0 && label.rzsw === 0))
{ {
getWidth = true; getWidth = true;
label.rzsv = valStr; label.rzsv = valStr;
...@@ -436,19 +440,19 @@ function throttle(func, wait, options) { ...@@ -436,19 +440,19 @@ function throttle(func, wait, options) {
// Assign all slider elements to object properties for easy access // Assign all slider elements to object properties for easy access
angular.forEach(this.sliderElem.children(), function(elem, index) angular.forEach(this.sliderElem.children(), function(elem, index)
{ {
var _elem = angular.element(elem); var jElem = angular.element(elem);
switch(index) switch(index)
{ {
case 0: this.fullBar = _elem; break; case 0: this.fullBar = jElem; break;
case 1: this.selBar = _elem; break; case 1: this.selBar = jElem; break;
case 2: this.minH = _elem; break; case 2: this.minH = jElem; break;
case 3: this.maxH = _elem; break; case 3: this.maxH = jElem; break;
case 4: this.flrLab = _elem; break; case 4: this.flrLab = jElem; break;
case 5: this.ceilLab = _elem; break; case 5: this.ceilLab = jElem; break;
case 6: this.minLab = _elem; break; case 6: this.minLab = jElem; break;
case 7: this.maxLab = _elem; break; case 7: this.maxLab = jElem; break;
case 8: this.cmbLab = _elem; break; case 8: this.cmbLab = jElem; break;
} }
}, this); }, this);
...@@ -590,7 +594,7 @@ function throttle(func, wait, options) { ...@@ -590,7 +594,7 @@ function throttle(func, wait, options) {
updateLowHandle: function(newOffset) updateLowHandle: function(newOffset)
{ {
var delta = Math.abs(this.minH.rzsl - newOffset); var delta = Math.abs(this.minH.rzsl - newOffset);
if(delta === 0 || delta === 1) return; if(delta === 0 || delta === 1) { return; }
this.setLeft(this.minH, newOffset); this.setLeft(this.minH, newOffset);
this.translateFn(this.scope.rzSliderModel, this.minLab); this.translateFn(this.scope.rzSliderModel, this.minLab);
...@@ -749,7 +753,7 @@ function throttle(func, wait, options) { ...@@ -749,7 +753,7 @@ function throttle(func, wait, options) {
*/ */
showEl: function (element) showEl: function (element)
{ {
if(!!element.rzAlwaysHide) return element; if(!!element.rzAlwaysHide) { return element; }
return element.css({opacity: 1}); return element.css({opacity: 1});
}, },
...@@ -827,10 +831,10 @@ function throttle(func, wait, options) { ...@@ -827,10 +831,10 @@ function throttle(func, wait, options) {
bindEvents: function() bindEvents: function()
{ {
this.minH.on('mousedown', angular.bind(this, this.onStart, this.minH, 'rzSliderModel')); this.minH.on('mousedown', angular.bind(this, this.onStart, this.minH, 'rzSliderModel'));
if(this.range) { this.maxH.on('mousedown', angular.bind(this, this.onStart, this.maxH, 'rzSliderHigh')) } if(this.range) { this.maxH.on('mousedown', angular.bind(this, this.onStart, this.maxH, 'rzSliderHigh')); }
this.minH.on('touchstart', angular.bind(this, this.onStart, this.minH, 'rzSliderModel')); this.minH.on('touchstart', angular.bind(this, this.onStart, this.minH, 'rzSliderModel'));
if(this.range) { this.maxH.on('touchstart', angular.bind(this, this.onStart, this.maxH, 'rzSliderHigh')) } if(this.range) { this.maxH.on('touchstart', angular.bind(this, this.onStart, this.maxH, 'rzSliderHigh')); }
}, },
/** /**
...@@ -846,7 +850,7 @@ function throttle(func, wait, options) { ...@@ -846,7 +850,7 @@ function throttle(func, wait, options) {
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
if(this.tracking !== '') { return } if(this.tracking !== '') { return; }
// We have to do this in case the HTML where the sliders are on // We have to do this in case the HTML where the sliders are on
// have been animated into view. // have been animated into view.
...@@ -855,7 +859,7 @@ function throttle(func, wait, options) { ...@@ -855,7 +859,7 @@ function throttle(func, wait, options) {
pointer.addClass('rz-active'); pointer.addClass('rz-active');
if(event.touches || (typeof(event.originalEvent) != 'undefined' && event.originalEvent.touches)) if(event.touches || (event.originalEvent !== undefined && event.originalEvent.touches))
{ {
$document.on('touchmove', angular.bind(this, this.onMove, pointer)); $document.on('touchmove', angular.bind(this, this.onMove, pointer));
$document.one('touchend', angular.bind(this, this.onEnd)); $document.one('touchend', angular.bind(this, this.onEnd));
...@@ -884,7 +888,9 @@ function throttle(func, wait, options) { ...@@ -884,7 +888,9 @@ function throttle(func, wait, options) {
} }
else else
{ {
eventX = typeof event.originalEvent !== 'undefined' ? event.originalEvent.touches[0].clientX : event.touches[0].clientX; eventX = event.originalEvent === undefined ?
event.touches[0].clientX
: event.originalEvent.touches[0].clientX;
} }
sliderLO = this.sliderElem.rzsl; sliderLO = this.sliderElem.rzsl;
...@@ -956,7 +962,7 @@ function throttle(func, wait, options) { ...@@ -956,7 +962,7 @@ function throttle(func, wait, options) {
this.minH.removeClass('rz-active'); this.minH.removeClass('rz-active');
this.maxH.removeClass('rz-active'); this.maxH.removeClass('rz-active');
if(event.touches || (typeof(event.originalEvent) != 'undefined' && event.originalEvent.touches)) if(event.touches || (event.originalEvent !== undefined && event.originalEvent.touches))
{ {
$document.off('touchmove'); $document.off('touchmove');
} }
...@@ -976,6 +982,8 @@ function throttle(func, wait, options) { ...@@ -976,6 +982,8 @@ function throttle(func, wait, options) {
.directive('rzslider', ['RzSlider', function(Slider) .directive('rzslider', ['RzSlider', function(Slider)
{ {
'use strict';
return { return {
restrict: 'E', restrict: 'E',
scope: { scope: {
...@@ -990,8 +998,16 @@ function throttle(func, wait, options) { ...@@ -990,8 +998,16 @@ function throttle(func, wait, options) {
rzSliderAlwaysShowBar: '=?' rzSliderAlwaysShowBar: '=?'
}, },
/**
* Return template URL
*
* @param {*} elem
* @param {*} attrs
* @return {string}
*/
templateUrl: function(elem, attrs) { templateUrl: function(elem, attrs) {
return attrs.rzSliderTplUrl || 'rzSliderTpl.html' //noinspection JSUnresolvedVariable
return attrs.rzSliderTplUrl || 'rzSliderTpl.html';
}, },
link: function(scope, elem, attr) link: function(scope, elem, attr)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment