-
Notifications
You must be signed in to change notification settings - Fork 20
/
nouislider.min.js
1 lines (1 loc) · 2.29 KB
/
nouislider.min.js
1
"use strict";angular.module("ya.nouislider",[]).value("yaNoUiSliderConfig",{}).directive("yaNoUiSlider",["$timeout","$log","yaNoUiSliderConfig",function(i,e,n){function a(i){return angular.isArray(i)?i:[i]}function r(i){return a(i).slice()}function t(i,e){return i=a(i),e=a(e),i[0]===e[0]&&i[1]===e[1]}function o(i,e){for(var n=Object.keys(i),a=-1,r=n.length,t={};++a<r;){var o=n[a];o!==e&&(t[o]=i[o])}return t}return{restrict:"A",require:"yaNoUiSlider",scope:{yaNoUiSlider:"=",yaNoUiSliderDisabled:"=",yaNoUiSliderHandle1Disabled:"=",yaNoUiSliderHandle2Disabled:"=",yaNoUiSliderSlideDebounce:"@"},controller:["$scope","$element","$attrs",function(a,l,d){function s(i,e,n){e?i.setAttribute("disabled",!0):i.removeAttribute("disabled")}function c(){U.$destroy(),f.off("slide change update slide"),f.destroy(),i.cancel(N)}function u(){function o(i){var e=r(i);t(e,d)||(d=e,a.$applyAsync(function(){angular.isArray(i)?angular.isArray(a.yaNoUiSlider.start)?(a.yaNoUiSlider.start[0]=i[0],a.yaNoUiSlider.start[1]=i[1]):a.yaNoUiSlider.start=i[0]:a.yaNoUiSlider.start=i}))}U=a.$new();var l=angular.extend({},n,a.yaNoUiSlider),d=r(l.start);l.start=r(l.start),noUiSlider.create($,l),S=$.getElementsByClassName("noUi-origin"),f=$.noUiSlider,U.$watch(function(){var i=a.yaNoUiSlider.start;return t(i,d)||(d=r(i),f.set(r(i))),d}),angular.forEach(v,function(e){f.on(e+".internal",function(n,a,r){"slide"===e&&h?(i.cancel(N),N=i(function(){o(r)},h)):o(r)})}),angular.forEach(b,function(i,e){f.on(e+".noUiSlider",function(){var e=Array.prototype.slice.call(arguments),n=this;a.$applyAsync(function(){i.apply(n,e)})})}),U.$watch("yaNoUiSliderDisabled",s.bind(void 0,$)),U.$watch("yaNoUiSliderHandle1Disabled",s.bind(void 0,S[0])),U.$watch("yaNoUiSliderHandle2Disabled",function(i,n){if(i&&!S[1])return e.warn("Warning: attempt to toggle disabled state of second handle using ya-no-ui-slider-handle2-disabled attribute in one-handle slider, nouislider-angular is ignoring such call.");S[1]&&s(S[1],i,n)})}function y(){a.$watch(function(){return o(a.yaNoUiSlider,"start")},function(){f&&c(),u()},!0),a.$on("$destroy",c)}var f,S,U,N,g=this,$=l[0],b=a.$parent.$eval(d.yaNoUiSliderEvents),h=a.yaNoUiSliderSlideDebounce||0,v=h&&"Infinity"===h?["change"]:["change","slide"];g.getNoUiSlider=function(){return f};var p=a.$watch("yaNoUiSlider",function(i){i&&(p(),y())})}]}}]);