Skip to content

Commit 39ef89e

Browse files
Valentin HervieuValentin Hervieu
authored andcommitted
Refactor the slider architecture. Add a rzSliderOptions that handle all the options except model, high and rzSliderTplUrl
1 parent d26c0ea commit 39ef89e

File tree

7 files changed

+2938
-3093
lines changed

7 files changed

+2938
-3093
lines changed

demo/demo.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
body { font-family: 'Open Sans', sans-serif; color: #1f2636; font-size: 14px; }
33
header { background: #0db9f0; color: #fff; margin: -40px; margin-bottom: 40px; text-align: center; padding: 40px 0; }
44
h1 { font-weight: 300; }
5+
h2 {margin-bottom:10px;}
56
.wrapper { background: #fff; padding: 40px; }
67
article { margin-bottom: 40px; }
78

demo/demo.js

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
var app = angular.module('rzSliderDemo', ['rzModule']);
2+
3+
app.controller('MainCtrl', function($scope, $timeout) {
4+
//Minimal slider config
5+
$scope.minSlider = {
6+
value: 10
7+
};
8+
9+
//Slider with selection bar
10+
$scope.slider_visible_bar = {
11+
value: 10,
12+
options: {
13+
showSelectionBar: true
14+
}
15+
};
16+
17+
//Range slider config
18+
$scope.minRangeSlider = {
19+
minValue: 10,
20+
maxValue: 90,
21+
options: {
22+
floor: 0,
23+
ceil: 100,
24+
step: 1
25+
}
26+
};
27+
28+
//Slider config with floor, ceil and step
29+
$scope.slider_floor_ceil = {
30+
value: 12,
31+
options: {
32+
floor: 10,
33+
ceil: 100,
34+
step: 5
35+
}
36+
};
37+
38+
//Slider config with callbacks
39+
$scope.slider_callbacks = {
40+
value: 100,
41+
options: {
42+
onStart: function() {
43+
$scope.otherData.start = $scope.slider_callbacks.value * 10;
44+
},
45+
onChange: function() {
46+
$scope.otherData.change = $scope.slider_callbacks.value * 10;
47+
},
48+
onEnd: function() {
49+
$scope.otherData.end = $scope.slider_callbacks.value * 10;
50+
}
51+
}
52+
};
53+
$scope.otherData = {start: 0, change: 0, end: 0};
54+
55+
//Slider config with custom display function
56+
$scope.slider_translate = {
57+
minValue: 100,
58+
maxValue: 400,
59+
options: {
60+
ceil: 500,
61+
floor: 0,
62+
translate: function(value) {
63+
return '$' + value;
64+
}
65+
}
66+
};
67+
68+
//Slider config with custom display function displaying letters
69+
var alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
70+
$scope.slider_alphabet = {
71+
value: 0,
72+
options: {
73+
ceil: alphabet.length - 1,
74+
floor: 0,
75+
translate: function(value) {
76+
if (value >= 0 && value < alphabet.length)
77+
return alphabet[value];
78+
return '';
79+
}
80+
}
81+
};
82+
83+
//Slider with ticks
84+
$scope.slider_ticks = {
85+
value: 5,
86+
options: {
87+
ceil: 10,
88+
floor: 0,
89+
showTicks: true
90+
}
91+
};
92+
93+
//Slider with ticks and values
94+
$scope.slider_ticks_values = {
95+
value: 5,
96+
options: {
97+
ceil: 10,
98+
floor: 0,
99+
showTicksValues: true
100+
}
101+
};
102+
103+
//Range slider with ticks and values
104+
$scope.range_slider_ticks_values = {
105+
minValue: 1,
106+
maxValue: 8,
107+
options: {
108+
ceil: 10,
109+
floor: 0,
110+
showTicksValues: true
111+
}
112+
};
113+
114+
//Slider with draggable range
115+
$scope.slider_draggable_range = {
116+
minValue: 1,
117+
maxValue: 8,
118+
options: {
119+
ceil: 10,
120+
floor: 0,
121+
draggableRange: true
122+
}
123+
};
124+
125+
//Read-only slider
126+
$scope.read_only_slider = {
127+
value: 50,
128+
options: {
129+
ceil: 100,
130+
floor: 0,
131+
readOnly: true
132+
}
133+
};
134+
135+
//Disabled slider
136+
$scope.disabled_slider = {
137+
value: 50,
138+
options: {
139+
ceil: 100,
140+
floor: 0,
141+
disabled: true
142+
}
143+
};
144+
145+
$scope.visible = false;
146+
147+
$scope.toggle = function() {
148+
$scope.visible = !$scope.visible;
149+
$timeout(function() {
150+
$scope.$broadcast('rzSliderForceRender');
151+
});
152+
};
153+
154+
$scope.slider_toggle = {
155+
value: 5,
156+
options: {
157+
ceil: 10,
158+
floor: 0
159+
}
160+
};
161+
});

0 commit comments

Comments
 (0)