forked from SC5/nouislider-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnouislider.min.js
1 lines (1 loc) · 1.75 KB
/
nouislider.min.js
1
angular.module("ya.nouislider",[]).value("noUiSliderConfig",{}).directive("noUiSlider",["noUiSliderConfig",function(a){function b(a){return angular.isUndefined(a)?0:angular.isArray(a)&&2==a.length?2:1}return a=a||{},{restrict:"A",require:"ngModel",scope:{ngDisabled:"=",noUiSlider:"=",noUiSliderLib:"=",noUiSliderEvents:"=",noUiSliderTrigger:"@"},link:function(c,d,e,f){function g(){var b=f.$viewValue,d=angular.extend({},a,c.noUiSlider,{start:b}),e=c.noUiSliderLib?c.noUiSliderLib:window.noUiSlider;angular.isDefined(d.start)&&angular.isDefined(d.range)&&(i=angular.copy(b),h||(e.create(j,d),angular.forEach(c.noUiSliderEvents,function(a,b){j.noUiSlider.on(a,b)}),j.noUiSlider.on(c.noUiSliderTrigger||"update",function(a){a=j.noUiSlider.get();var b=angular.isArray(a);b&&(a=a[0]),a=parseFloat(a)||0,a=Math.min(Math.max(a,c.noUiSlider.range.min),c.noUiSlider.range.max),newValue=b?[a]:a,f.$setViewValue(newValue)}),j.removeAttribute("disabled"),c.ngDisabled&&j.setAttribute("disabled",!0)),h=!0)}var h=!1,i=void 0,j=d[0];c.$on("$destroy",function(){j.noUiSlider.off("slide set change update")}),f.$render=function(){if(h){var a=f.$viewValue,d=void 0;if(2==b(a)){a[0]=Math.max(a[0],c.noUiSlider.range.min),a[1]=Math.min(a[1],c.noUiSlider.range.max);var e=a[0]==i[0],g=a[1]==i[1];i=angular.copy(a),a[0]>a[1]&&(e&&(a[1]=a[0]),g&&(a[0]=a[1]),a[0]>a[1]&&(a[1]=a[0])),d=[e?null:a[0],g?null:a[1]]}else{var k=angular.isArray(a);k&&(a=a[0]),a=parseFloat(a)||0,a=Math.min(Math.max(a,c.noUiSlider.range.min),c.noUiSlider.range.max),d=k?[a]:a,f.$setViewValue(d)}j.noUiSlider.set(d)}},c.$watch(function(){return c.noUiSlider},function(){g()},!0),c.$watch(function(){return f.$viewValue},function(){f.$render()},!0),c.$watch(function(){return b(f.$viewValue)},function(a){angular.isDefined(a)&&g()},!0)}}}]);