forked from AbdullahNasir/ionRangeSlider-Angular-Directive
-
Notifications
You must be signed in to change notification settings - Fork 11
/
slider.js
72 lines (68 loc) · 2.32 KB
/
slider.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* Created by Abdullah on 9/19/14.
*
* Modified and enhanced by Juergen Wahlmann on 3/5/15
*/
var app = angular.module('ionSlider',['ngRoute']);
app.directive('ionslider',function($timeout){
return{
restrict:'EC',
scope:{min:'=',
max:'=',
type:'@',
prefix:'@',
maxPostfix:'@',
prettify:'@',
grid:'@',
gridMargin:'@',
postfix:'@',
step:'@',
hideMinMax:'@',
hideFromTo:'@',
from:'=',
disable:'=',
onChange:'=',
onFinish:'=',
onStart:'=',
onUpdate:'='
},
template:'<input>',
replace:true,
link:function($scope,$element,attrs){
(function init(){
$element.ionRangeSlider({
min: $scope.min,
max: $scope.max,
type: $scope.type,
prefix: $scope.prefix,
maxPostfix: $scope.maxPostfix,
prettify: $scope.prettify,
grid: $scope.grid,
gridMargin: $scope.gridMargin,
postfix:$scope.postfix,
step:$scope.step,
hideMinMax:$scope.hideMinMax,
hideFromTo:$scope.hideFromTo,
from:$scope.from,
disable:$scope.disable,
onChange:$scope.onChange,
onFinish:$scope.onFinish,
onStart:$scope.onStart,
onUpdate:$scope.onUpdate
});
})();
$scope.$watch('min', function(value) {
$timeout(function(){ $element.data("ionRangeSlider").update({min: value}); });
},true);
$scope.$watch('max', function(value) {
$timeout(function(){ $element.data("ionRangeSlider").update({max: value}); });
});
$scope.$watch('from', function(value) {
$timeout(function(){ $element.data("ionRangeSlider").update({from: value}); });
});
$scope.$watch('disable', function(value) {
$timeout(function(){ $element.data("ionRangeSlider").update({disable: value}); });
});
}
}
});