|
1 | 1 | /*! angularjs-slider - v2.3.0 -
|
2 | 2 | (c) Rafal Zajac <[email protected]>, Valentin Hervieu <[email protected]>, Jussi Saarivirta <[email protected]>, Angelin Sirbu <[email protected]> -
|
3 | 3 | https://github.com/angular-slider/angularjs-slider -
|
4 |
| - 2015-12-22 */ |
| 4 | + 2015-12-23 */ |
5 | 5 | /*jslint unparam: true */
|
6 | 6 | /*global angular: false, console: false, define, module */
|
7 | 7 | (function(root, factory) {
|
|
74 | 74 | return factory;
|
75 | 75 | })
|
76 | 76 |
|
77 |
| - .value('rzThrottle', |
| 77 | + .factory('rzThrottle', ['$timeout', function($timeout) { |
78 | 78 | /**
|
79 | 79 | * rzThrottle
|
80 | 80 | *
|
|
85 | 85 | * @param {ThrottleOptions} options
|
86 | 86 | * @returns {Function}
|
87 | 87 | */
|
88 |
| - function throttle(func, wait, options) { |
| 88 | + return function(func, wait, options) { |
89 | 89 | 'use strict';
|
90 | 90 | var getTime = (Date.now || function() {
|
91 | 91 | return new Date().getTime();
|
|
109 | 109 | context = this;
|
110 | 110 | args = arguments;
|
111 | 111 | if (remaining <= 0) {
|
112 |
| - clearTimeout(timeout); |
| 112 | + $timeout.cancel(timeout); |
113 | 113 | timeout = null;
|
114 | 114 | previous = now;
|
115 | 115 | result = func.apply(context, args);
|
116 | 116 | context = args = null;
|
117 | 117 | } else if (!timeout && options.trailing !== false) {
|
118 |
| - timeout = setTimeout(later, remaining); |
| 118 | + timeout = $timeout(later, remaining); |
119 | 119 | }
|
120 | 120 | return result;
|
121 | 121 | };
|
122 |
| - }) |
| 122 | + } |
| 123 | + }]) |
123 | 124 |
|
124 | 125 | .factory('RzSlider', ['$timeout', '$document', '$window', '$compile', 'RzSliderOptions', 'rzThrottle', function($timeout, $document, $window, $compile, RzSliderOptions, rzThrottle) {
|
125 | 126 | 'use strict';
|
|
344 | 345 | }, true);
|
345 | 346 |
|
346 | 347 | this.scope.$watch('rzSliderModel', function(newValue, oldValue) {
|
347 |
| - if(self.internalChange) |
| 348 | + if (self.internalChange) |
348 | 349 | return;
|
349 | 350 | if (newValue === oldValue)
|
350 | 351 | return;
|
351 | 352 | thrLow();
|
352 | 353 | });
|
353 | 354 |
|
354 | 355 | this.scope.$watch('rzSliderHigh', function(newValue, oldValue) {
|
355 |
| - if(self.internalChange) |
| 356 | + if (self.internalChange) |
356 | 357 | return;
|
357 | 358 | if (newValue === oldValue)
|
358 | 359 | return;
|
|
492 | 493 | if (!this.range)
|
493 | 494 | this.maxH.css('display', 'none');
|
494 | 495 | else
|
495 |
| - this.maxH.css('display', null); |
| 496 | + this.maxH.css('display', ''); |
496 | 497 |
|
497 | 498 | this.alwaysHide(this.flrLab, this.options.showTicksValues || this.options.hideLimitLabels);
|
498 | 499 | this.alwaysHide(this.ceilLab, this.options.showTicksValues || this.options.hideLimitLabels);
|
|
1345 | 1346 | HOME: this.minValue,
|
1346 | 1347 | END: this.maxValue
|
1347 | 1348 | },
|
1348 |
| - key = keys[keyCode], |
| 1349 | + key = keys[keyCode], |
1349 | 1350 | action = actions[key];
|
1350 | 1351 | if (action == null || this.tracking === '') return;
|
1351 | 1352 | event.preventDefault();
|
|
1570 | 1571 | },
|
1571 | 1572 |
|
1572 | 1573 | link: function(scope, elem) {
|
1573 |
| - return new RzSlider(scope, elem); |
| 1574 | + scope.slider = new RzSlider(scope, elem); //attach on scope so we can test it |
1574 | 1575 | }
|
1575 | 1576 | };
|
1576 | 1577 | }]);
|
|
0 commit comments