glider-rails 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/app/assets/javascripts/glider.coffee +88 -94
- data/app/assets/javascripts/glider.js +106 -129
- data/app/assets/javascripts/glider.map +1 -1
- data/app/assets/javascripts/glider.min.js +1 -1
- data/glider-rails.gemspec +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
###
|
2
|
-
glider 0.1.
|
2
|
+
glider 0.1.4 - AngularJS slider
|
3
3
|
https://github.com/evrone/glider
|
4
4
|
Copyright (c) 2013 Valentin Vasilyev, Dmitry Karpunin
|
5
5
|
Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
|
@@ -18,24 +18,18 @@
|
|
18
18
|
slider with increments (incompatible with step option)
|
19
19
|
<slider min="0" max="100" increments="10,50,60,90"></slider>
|
20
20
|
###
|
21
|
-
'use strict'
|
21
|
+
'use strict'
|
22
|
+
|
22
23
|
gliderModule = angular.module('glider', [])
|
23
24
|
|
24
25
|
gliderModule.directive 'slider', ['$document', ($document) ->
|
25
26
|
|
26
|
-
getSubElement = (sliderElement, className) ->
|
27
|
-
sliderElement[0].getElementsByClassName(className)[0]
|
28
|
-
|
29
|
-
moveHandle = (elem, posX) ->
|
30
|
-
angular.element(getSubElement(elem, 'handle')).css('left', "#{posX}%")
|
31
|
-
angular.element(getSubElement(elem, 'range')).css('width', "#{posX}%")
|
32
|
-
|
33
27
|
template: """
|
34
28
|
<span class="g-slider horizontal">
|
35
|
-
<span class="slider">
|
36
|
-
<span class="range"></span>
|
37
|
-
<span class="handle" ng-mousedown="
|
38
|
-
<span class="value" ng-show="showValueInHandle">{{
|
29
|
+
<span class="slider" ng-click="sliderClick($event)">
|
30
|
+
<span class="range" style="width: {{xPosition}}%;"></span>
|
31
|
+
<span class="handle" style="left: {{xPosition}}%;" ng-mousedown="handleMouseDown($event)">
|
32
|
+
<span class="value" ng-show="showValueInHandle">{{handleValue | intersperse}}</span>
|
39
33
|
</span>
|
40
34
|
</span>
|
41
35
|
<span class="side dec">
|
@@ -62,58 +56,65 @@ gliderModule.directive 'slider', ['$document', ($document) ->
|
|
62
56
|
max: "&"
|
63
57
|
|
64
58
|
link: (scope, element, attrs) ->
|
59
|
+
|
65
60
|
parseIncrements = ->
|
66
|
-
|
67
|
-
offset = (min, max, value) ->
|
68
|
-
value = parseInt(value) - min
|
69
|
-
value / Math.abs(max - min) * 100
|
70
|
-
if attrs.increments
|
61
|
+
if attrs.increments?
|
71
62
|
min = scope.min()
|
72
63
|
max = scope.max()
|
73
|
-
|
74
|
-
increments =
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
64
|
+
offsetK = 100 / Math.abs(max - min)
|
65
|
+
scope.increments = []
|
66
|
+
scope.snapValues = [min, max]
|
67
|
+
for i in attrs.increments.split(',')
|
68
|
+
i = parseInt(i)
|
69
|
+
if min < i < max
|
70
|
+
scope.increments.push value: i, offset: (i - min) * offsetK
|
71
|
+
scope.snapValues.push i
|
72
|
+
scope.snapValues.sort((a, b) -> a - b)
|
73
|
+
undefined
|
74
|
+
|
75
|
+
sliderElement = element[0].getElementsByClassName('slider')[0]
|
84
76
|
dragging = false
|
85
|
-
xPosition = 0
|
86
|
-
step =
|
87
|
-
deferUpdate =
|
77
|
+
scope.xPosition = 0
|
78
|
+
step = attrs.step or 1
|
79
|
+
deferUpdate = attrs.deferUpdate?
|
88
80
|
scope.showValueInHandle = attrs.showValueInHandle?
|
89
81
|
|
90
82
|
scope.value = scope.min() unless scope.value?
|
91
83
|
|
92
|
-
scope.increments = parseIncrements(attrs.increments)
|
93
|
-
scope.snapValues = createSnapValues(scope.increments)
|
94
|
-
|
95
84
|
refreshHandle = ->
|
96
85
|
range = scope.max() - scope.min()
|
97
86
|
if range is 0
|
98
|
-
xPosition = 0
|
87
|
+
scope.xPosition = 0
|
99
88
|
else
|
100
|
-
xPosition = (scope.value - scope.min()) / range * 100
|
101
|
-
xPosition = Math.min(Math.max(0, xPosition), 100)
|
102
|
-
|
89
|
+
scope.xPosition = (scope.value - scope.min()) / range * 100
|
90
|
+
scope.xPosition = Math.min(Math.max(0, scope.xPosition), 100)
|
91
|
+
scope.handleValue = scope.value if scope.showValueInHandle
|
92
|
+
|
93
|
+
snap = ->
|
94
|
+
if scope.increments
|
95
|
+
minDiff = Infinity
|
96
|
+
for snapValue in scope.snapValues
|
97
|
+
diff = Math.abs(snapValue - scope.value)
|
98
|
+
if diff < minDiff
|
99
|
+
minDiff = diff
|
100
|
+
closestValue = snapValue
|
101
|
+
scope.value = closestValue
|
102
|
+
refreshHandle()
|
103
|
+
|
104
|
+
valueFromPosition = ->
|
105
|
+
Math.round((((scope.max() - scope.min()) * (scope.xPosition / 100)) + scope.min()) / step) * step
|
103
106
|
|
104
107
|
scope.$watch 'min()', (minValue) ->
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
refreshHandle()
|
108
|
+
parseIncrements()
|
109
|
+
scope.value = minValue if scope.value < minValue
|
110
|
+
snap()
|
109
111
|
|
110
112
|
scope.$watch 'max()', (maxValue) ->
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
refreshHandle()
|
113
|
+
parseIncrements()
|
114
|
+
scope.value = maxValue if scope.value > maxValue
|
115
|
+
snap()
|
115
116
|
|
116
|
-
scope.$watch 'value', (newVal, oldVal)->
|
117
|
+
scope.$watch 'value', (newVal, oldVal) ->
|
117
118
|
return if dragging
|
118
119
|
if scope.min() <= newVal <= scope.max()
|
119
120
|
refreshHandle()
|
@@ -130,64 +131,57 @@ gliderModule.directive 'slider', ['$document', ($document) ->
|
|
130
131
|
newVal = if steps > 0
|
131
132
|
(sv for sv in scope.snapValues when sv > scope.value)[0]
|
132
133
|
else
|
133
|
-
(sv for sv in scope.snapValues when sv < scope.value).
|
134
|
+
(sv for sv in scope.snapValues when sv < scope.value).reverse()[0]
|
134
135
|
scope.value = newVal if newVal?
|
135
136
|
|
136
137
|
if attrs.increments?
|
137
|
-
doIncrement
|
138
|
+
doIncrement steps
|
138
139
|
else
|
139
|
-
doStep
|
140
|
+
doStep steps
|
141
|
+
|
142
|
+
scope.sliderClick = ($event) ->
|
143
|
+
return if angular.element($event.target).hasClass('handle')
|
144
|
+
scope.xPosition = $event.layerX / sliderElement.offsetWidth * 100
|
145
|
+
scope.value = valueFromPosition()
|
146
|
+
snap()
|
140
147
|
|
148
|
+
startPointX = null
|
141
149
|
|
142
|
-
scope.
|
150
|
+
scope.handleMouseDown = ($event) ->
|
143
151
|
return unless angular.element($event.target).hasClass('handle')
|
144
|
-
dragging = true
|
145
152
|
startPointX = $event.pageX
|
153
|
+
dragging = true
|
146
154
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
moveDelta = $event.pageX - startPointX
|
168
|
-
xPosition += moveDelta / sliderElement.offsetWidth * 100
|
169
|
-
if xPosition < 0
|
170
|
-
xPosition = 0
|
171
|
-
else if xPosition > 100
|
172
|
-
xPosition = 100
|
173
|
-
else
|
174
|
-
startPointX = $event.pageX
|
175
|
-
updateValue() unless deferUpdate
|
176
|
-
moveHandle element, xPosition
|
177
|
-
|
178
|
-
$document.on 'mouseup', ->
|
179
|
-
dragging = false
|
180
|
-
updateValue() if deferUpdate
|
181
|
-
snap() if scope.increments
|
182
|
-
$document.off 'mousemove'
|
155
|
+
$document.on 'mousemove', ($event) ->
|
156
|
+
return unless dragging
|
157
|
+
moveDelta = $event.pageX - startPointX
|
158
|
+
scope.xPosition += moveDelta / sliderElement.offsetWidth * 100
|
159
|
+
if scope.xPosition < 0
|
160
|
+
scope.xPosition = 0
|
161
|
+
else if scope.xPosition > 100
|
162
|
+
scope.xPosition = 100
|
163
|
+
else
|
164
|
+
startPointX = $event.pageX
|
165
|
+
scope.value = valueFromPosition() unless deferUpdate
|
166
|
+
scope.handleValue = valueFromPosition() if scope.showValueInHandle
|
167
|
+
scope.$apply()
|
168
|
+
|
169
|
+
$document.on 'mouseup', ->
|
170
|
+
return unless dragging
|
171
|
+
scope.value = valueFromPosition() if deferUpdate
|
172
|
+
snap()
|
173
|
+
scope.$apply()
|
174
|
+
dragging = false
|
183
175
|
]
|
176
|
+
|
177
|
+
|
178
|
+
|
184
179
|
gliderModule.filter 'intersperse', ->
|
185
180
|
(input) ->
|
186
181
|
return unless input?
|
187
182
|
input = input.toString()
|
188
|
-
|
189
|
-
reversed =
|
190
|
-
|
191
|
-
sliced =
|
183
|
+
reverseString = (input) -> input.split('').reverse().join('')
|
184
|
+
reversed = reverseString(input)
|
185
|
+
reversed = reversed.replace(/(.{3})/g, '$1 ')
|
186
|
+
sliced = reverseString(reversed)
|
192
187
|
sliced.trim()
|
193
|
-
|
@@ -1,6 +1,6 @@
|
|
1
1
|
// Generated by CoffeeScript 1.6.3
|
2
2
|
/*
|
3
|
-
glider 0.1.
|
3
|
+
glider 0.1.4 - AngularJS slider
|
4
4
|
https://github.com/evrone/glider
|
5
5
|
Copyright (c) 2013 Valentin Vasilyev, Dmitry Karpunin
|
6
6
|
Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
|
@@ -29,16 +29,8 @@
|
|
29
29
|
|
30
30
|
gliderModule.directive('slider', [
|
31
31
|
'$document', function($document) {
|
32
|
-
var getSubElement, moveHandle;
|
33
|
-
getSubElement = function(sliderElement, className) {
|
34
|
-
return sliderElement[0].getElementsByClassName(className)[0];
|
35
|
-
};
|
36
|
-
moveHandle = function(elem, posX) {
|
37
|
-
angular.element(getSubElement(elem, 'handle')).css('left', "" + posX + "%");
|
38
|
-
return angular.element(getSubElement(elem, 'range')).css('width', "" + posX + "%");
|
39
|
-
};
|
40
32
|
return {
|
41
|
-
template: "<span class=\"g-slider horizontal\">\n <span class=\"slider\">\n <span class=\"range\"></span>\n <span class=\"handle\" ng-mousedown=\"
|
33
|
+
template: "<span class=\"g-slider horizontal\">\n <span class=\"slider\" ng-click=\"sliderClick($event)\">\n <span class=\"range\" style=\"width: {{xPosition}}%;\"></span>\n <span class=\"handle\" style=\"left: {{xPosition}}%;\" ng-mousedown=\"handleMouseDown($event)\">\n <span class=\"value\" ng-show=\"showValueInHandle\">{{handleValue | intersperse}}</span>\n </span>\n </span>\n <span class=\"side dec\">\n <span class=\"button\" ng-click=\"step(-1)\">-</span>\n <span class=\"bound-value\">{{min() | intersperse}}</span>\n </span>\n <span class=\"side inc\">\n <span class=\"button\" ng-click=\"step(+1)\">+</span>\n <span class=\"bound-value\">{{max() | intersperse}}</span>\n </span>\n <span class=\"increments\">\n <span ng-repeat=\"i in increments\" class=\"i\" style=\"left: {{i.offset}}%\">\n {{ i.value | intersperse }}\n </span>\n </span>\n</span>",
|
42
34
|
replace: true,
|
43
35
|
restrict: "E",
|
44
36
|
scope: {
|
@@ -47,91 +39,88 @@
|
|
47
39
|
max: "&"
|
48
40
|
},
|
49
41
|
link: function(scope, element, attrs) {
|
50
|
-
var
|
42
|
+
var deferUpdate, dragging, parseIncrements, refreshHandle, sliderElement, snap, startPointX, step, valueFromPosition;
|
51
43
|
parseIncrements = function() {
|
52
|
-
var i,
|
53
|
-
|
54
|
-
if (input) {
|
55
|
-
return input.replace(/^\s+|\s+$/g, '');
|
56
|
-
} else {
|
57
|
-
return input;
|
58
|
-
}
|
59
|
-
};
|
60
|
-
offset = function(min, max, value) {
|
61
|
-
value = parseInt(value) - min;
|
62
|
-
return value / Math.abs(max - min) * 100;
|
63
|
-
};
|
64
|
-
if (attrs.increments) {
|
44
|
+
var i, max, min, offsetK, _i, _len, _ref;
|
45
|
+
if (attrs.increments != null) {
|
65
46
|
min = scope.min();
|
66
47
|
max = scope.max();
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
}
|
79
|
-
|
80
|
-
return _results;
|
81
|
-
})();
|
82
|
-
}
|
83
|
-
};
|
84
|
-
createSnapValues = function(increments) {
|
85
|
-
var i;
|
86
|
-
if (attrs.increments != null) {
|
87
|
-
return ([scope.min(), scope.max()].concat((function() {
|
88
|
-
var _i, _len, _results;
|
89
|
-
_results = [];
|
90
|
-
for (_i = 0, _len = increments.length; _i < _len; _i++) {
|
91
|
-
i = increments[_i];
|
92
|
-
_results.push(i.value);
|
48
|
+
offsetK = 100 / Math.abs(max - min);
|
49
|
+
scope.increments = [];
|
50
|
+
scope.snapValues = [min, max];
|
51
|
+
_ref = attrs.increments.split(',');
|
52
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
53
|
+
i = _ref[_i];
|
54
|
+
i = parseInt(i);
|
55
|
+
if ((min < i && i < max)) {
|
56
|
+
scope.increments.push({
|
57
|
+
value: i,
|
58
|
+
offset: (i - min) * offsetK
|
59
|
+
});
|
60
|
+
scope.snapValues.push(i);
|
93
61
|
}
|
94
|
-
|
95
|
-
|
62
|
+
}
|
63
|
+
scope.snapValues.sort(function(a, b) {
|
96
64
|
return a - b;
|
97
65
|
});
|
98
66
|
}
|
67
|
+
return void 0;
|
99
68
|
};
|
100
|
-
sliderElement =
|
69
|
+
sliderElement = element[0].getElementsByClassName('slider')[0];
|
101
70
|
dragging = false;
|
102
|
-
xPosition = 0;
|
103
|
-
step = attrs.step
|
71
|
+
scope.xPosition = 0;
|
72
|
+
step = attrs.step || 1;
|
104
73
|
deferUpdate = attrs.deferUpdate != null;
|
105
74
|
scope.showValueInHandle = attrs.showValueInHandle != null;
|
106
75
|
if (scope.value == null) {
|
107
76
|
scope.value = scope.min();
|
108
77
|
}
|
109
|
-
scope.increments = parseIncrements(attrs.increments);
|
110
|
-
scope.snapValues = createSnapValues(scope.increments);
|
111
78
|
refreshHandle = function() {
|
112
79
|
var range;
|
113
80
|
range = scope.max() - scope.min();
|
114
81
|
if (range === 0) {
|
115
|
-
xPosition = 0;
|
82
|
+
scope.xPosition = 0;
|
116
83
|
} else {
|
117
|
-
xPosition = (scope.value - scope.min()) / range * 100;
|
118
|
-
xPosition = Math.min(Math.max(0, xPosition), 100);
|
84
|
+
scope.xPosition = (scope.value - scope.min()) / range * 100;
|
85
|
+
scope.xPosition = Math.min(Math.max(0, scope.xPosition), 100);
|
86
|
+
}
|
87
|
+
if (scope.showValueInHandle) {
|
88
|
+
return scope.handleValue = scope.value;
|
119
89
|
}
|
120
|
-
|
90
|
+
};
|
91
|
+
snap = function() {
|
92
|
+
var closestValue, diff, minDiff, snapValue, _i, _len, _ref;
|
93
|
+
if (scope.increments) {
|
94
|
+
minDiff = Infinity;
|
95
|
+
_ref = scope.snapValues;
|
96
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
97
|
+
snapValue = _ref[_i];
|
98
|
+
diff = Math.abs(snapValue - scope.value);
|
99
|
+
if (diff < minDiff) {
|
100
|
+
minDiff = diff;
|
101
|
+
closestValue = snapValue;
|
102
|
+
}
|
103
|
+
}
|
104
|
+
scope.value = closestValue;
|
105
|
+
}
|
106
|
+
return refreshHandle();
|
107
|
+
};
|
108
|
+
valueFromPosition = function() {
|
109
|
+
return Math.round((((scope.max() - scope.min()) * (scope.xPosition / 100)) + scope.min()) / step) * step;
|
121
110
|
};
|
122
111
|
scope.$watch('min()', function(minValue) {
|
112
|
+
parseIncrements();
|
123
113
|
if (scope.value < minValue) {
|
124
|
-
|
125
|
-
} else {
|
126
|
-
return refreshHandle();
|
114
|
+
scope.value = minValue;
|
127
115
|
}
|
116
|
+
return snap();
|
128
117
|
});
|
129
118
|
scope.$watch('max()', function(maxValue) {
|
119
|
+
parseIncrements();
|
130
120
|
if (scope.value > maxValue) {
|
131
|
-
|
132
|
-
} else {
|
133
|
-
return refreshHandle();
|
121
|
+
scope.value = maxValue;
|
134
122
|
}
|
123
|
+
return snap();
|
135
124
|
});
|
136
125
|
scope.$watch('value', function(newVal, oldVal) {
|
137
126
|
if (dragging) {
|
@@ -176,9 +165,7 @@
|
|
176
165
|
}
|
177
166
|
}
|
178
167
|
return _results;
|
179
|
-
})()).
|
180
|
-
return b - a;
|
181
|
-
})[0];
|
168
|
+
})()).reverse()[0];
|
182
169
|
if (newVal != null) {
|
183
170
|
return scope.value = newVal;
|
184
171
|
}
|
@@ -189,65 +176,55 @@
|
|
189
176
|
return doStep(steps);
|
190
177
|
}
|
191
178
|
};
|
192
|
-
|
193
|
-
|
179
|
+
scope.sliderClick = function($event) {
|
180
|
+
if (angular.element($event.target).hasClass('handle')) {
|
181
|
+
return;
|
182
|
+
}
|
183
|
+
scope.xPosition = $event.layerX / sliderElement.offsetWidth * 100;
|
184
|
+
scope.value = valueFromPosition();
|
185
|
+
return snap();
|
186
|
+
};
|
187
|
+
startPointX = null;
|
188
|
+
scope.handleMouseDown = function($event) {
|
194
189
|
if (!angular.element($event.target).hasClass('handle')) {
|
195
190
|
return;
|
196
191
|
}
|
197
|
-
dragging = true;
|
198
192
|
startPointX = $event.pageX;
|
199
|
-
|
200
|
-
scope.value = Math.round((((scope.max() - scope.min()) * (xPosition / 100)) + scope.min()) / step) * step;
|
201
|
-
return scope.$apply();
|
202
|
-
};
|
203
|
-
snap = function() {
|
204
|
-
var closest, diff, i, l, min;
|
205
|
-
i = 0;
|
206
|
-
l = scope.snapValues.length;
|
207
|
-
while (i < l) {
|
208
|
-
diff = Math.abs(scope.snapValues[i] - scope.value);
|
209
|
-
if (typeof min === "undefined" || min === null) {
|
210
|
-
min = diff;
|
211
|
-
}
|
212
|
-
if (diff <= min) {
|
213
|
-
closest = scope.snapValues[i];
|
214
|
-
min = diff;
|
215
|
-
}
|
216
|
-
i++;
|
217
|
-
}
|
218
|
-
scope.value = closest;
|
219
|
-
return scope.$apply();
|
220
|
-
};
|
221
|
-
$document.on('mousemove', function($event) {
|
222
|
-
var moveDelta;
|
223
|
-
if (!dragging) {
|
224
|
-
return;
|
225
|
-
}
|
226
|
-
moveDelta = $event.pageX - startPointX;
|
227
|
-
xPosition += moveDelta / sliderElement.offsetWidth * 100;
|
228
|
-
if (xPosition < 0) {
|
229
|
-
xPosition = 0;
|
230
|
-
} else if (xPosition > 100) {
|
231
|
-
xPosition = 100;
|
232
|
-
} else {
|
233
|
-
startPointX = $event.pageX;
|
234
|
-
}
|
235
|
-
if (!deferUpdate) {
|
236
|
-
updateValue();
|
237
|
-
}
|
238
|
-
return moveHandle(element, xPosition);
|
239
|
-
});
|
240
|
-
return $document.on('mouseup', function() {
|
241
|
-
dragging = false;
|
242
|
-
if (deferUpdate) {
|
243
|
-
updateValue();
|
244
|
-
}
|
245
|
-
if (scope.increments) {
|
246
|
-
snap();
|
247
|
-
}
|
248
|
-
return $document.off('mousemove');
|
249
|
-
});
|
193
|
+
return dragging = true;
|
250
194
|
};
|
195
|
+
$document.on('mousemove', function($event) {
|
196
|
+
var moveDelta;
|
197
|
+
if (!dragging) {
|
198
|
+
return;
|
199
|
+
}
|
200
|
+
moveDelta = $event.pageX - startPointX;
|
201
|
+
scope.xPosition += moveDelta / sliderElement.offsetWidth * 100;
|
202
|
+
if (scope.xPosition < 0) {
|
203
|
+
scope.xPosition = 0;
|
204
|
+
} else if (scope.xPosition > 100) {
|
205
|
+
scope.xPosition = 100;
|
206
|
+
} else {
|
207
|
+
startPointX = $event.pageX;
|
208
|
+
}
|
209
|
+
if (!deferUpdate) {
|
210
|
+
scope.value = valueFromPosition();
|
211
|
+
}
|
212
|
+
if (scope.showValueInHandle) {
|
213
|
+
scope.handleValue = valueFromPosition();
|
214
|
+
}
|
215
|
+
return scope.$apply();
|
216
|
+
});
|
217
|
+
return $document.on('mouseup', function() {
|
218
|
+
if (!dragging) {
|
219
|
+
return;
|
220
|
+
}
|
221
|
+
if (deferUpdate) {
|
222
|
+
scope.value = valueFromPosition();
|
223
|
+
}
|
224
|
+
snap();
|
225
|
+
scope.$apply();
|
226
|
+
return dragging = false;
|
227
|
+
});
|
251
228
|
}
|
252
229
|
};
|
253
230
|
}
|
@@ -255,17 +232,17 @@
|
|
255
232
|
|
256
233
|
gliderModule.filter('intersperse', function() {
|
257
234
|
return function(input) {
|
258
|
-
var
|
235
|
+
var reverseString, reversed, sliced;
|
259
236
|
if (input == null) {
|
260
237
|
return;
|
261
238
|
}
|
262
239
|
input = input.toString();
|
263
|
-
|
240
|
+
reverseString = function(input) {
|
264
241
|
return input.split('').reverse().join('');
|
265
242
|
};
|
266
|
-
reversed =
|
267
|
-
|
268
|
-
sliced =
|
243
|
+
reversed = reverseString(input);
|
244
|
+
reversed = reversed.replace(/(.{3})/g, '$1 ');
|
245
|
+
sliced = reverseString(reversed);
|
269
246
|
return sliced.trim();
|
270
247
|
};
|
271
248
|
});
|
@@ -6,5 +6,5 @@
|
|
6
6
|
"src/glider.coffee"
|
7
7
|
],
|
8
8
|
"names": [],
|
9
|
-
"mappings": ";AAAA;;;;;;;;;;;;;;;;;;;;CAAA;CAAA;CAAA;CAAA,CAoBA,UApBA;CAAA,KAAA,MAAA;;CAAA,
|
9
|
+
"mappings": ";AAAA;;;;;;;;;;;;;;;;;;;;CAAA;CAAA;CAAA;CAAA,CAoBA,UApBA;CAAA,KAAA,MAAA;;CAAA,CAsBA,CAAe,GAAA,CAAO,CAAP,IAAf;;CAtBA,CAwBA,MAAA,CAAA,GAAY;EAAmC,CAAA,EAAb,IAAc,EAAf;aAE/B;CAAA,CAAU,MAAV,y3BAAA;CAAA,CAwBS,EAxBT,GAwBA,CAAA;CAxBA,CAyBU,CAzBV,KAyBA;CAzBA,CA2BE,GADF,GAAA;CACE,CAAO,CAAP,EAAA,KAAA;CAAA,CACK,CAAL,OAAA;CADA,CAEK,CAAL,OAAA;UA7BF;CAAA,CA+BM,CAAA,CAAN,CAAM,EAAA,CAAN,CAAO;CAEL,aAAA,kGAAA;CAAA,EAAkB,MAAA,CAAlB,KAAA;CACE,eAAA,oBAAA;CAAA,GAAG,QAAH,YAAA;CACE,EAAA,EAAW,SAAX;CAA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KAAA;CAAA,EAAoB,EAAf,MAAL,GAAA,GAAoB;cAVpB;CAWM,IAAD,CAAL,aAAA;CAZF,UAA0B;CAchB,CAAV,CAAwB,MAAf,QAAT;AACiB,CAAf,GAAA,IAAA,IAAA;CAAA,mBAAA;cAAA;CACA,GAAqC,OAArC,CAAA;CAAA,EAAc,EAAT,SAAL,GAAc;cADd;CAAA,GAEA,QAAA;CAFA,IAGK,CAAL,MAAA;CAJsB,EAKX,KAAX,WAAA;CALF,UAAwB;CA9I1B,QA+BM;CAjCuC;CAAd,IAAc;CAxB/C,GAwBA;;CAxBA,CAkLA,CAAmC,GAAnC,GAAmC,GAAvB,CAAZ;GACE,EAAA,IAAC,EAAD;CACE,SAAA,qBAAA;CAAA,GAAc,EAAd,OAAA;CAAA,aAAA;QAAA;CAAA,EACQ,EAAR,CAAA,EAAQ;CADR,EAEgB,EAAA,CAAhB,GAAiB,IAAjB;CAAiC,CAAN,EAAA,CAAK,EAAL,QAAA;CAF3B,MAEgB;CAFhB,EAGW,EAAA,CAAX,EAAA,KAAW;CAHX,CAIuC,CAA5B,EAAA,CAAX,CAAW,CAAX,CAAW;CAJX,EAKS,GAAT,EAAS,KAAA;CACF,GAAP,EAAM,OAAN;CAR+B,IACjC;CADF,EAAmC;CAlLnC"
|
10
10
|
}
|
@@ -1 +1 @@
|
|
1
|
-
(function(){"use strict";var n;n=angular.module("glider",[]),n.directive("slider",["$document",function(n){
|
1
|
+
(function(){"use strict";var n;n=angular.module("glider",[]),n.directive("slider",["$document",function(n){return{template:'<span class="g-slider horizontal">\n <span class="slider" ng-click="sliderClick($event)">\n <span class="range" style="width: {{xPosition}}%;"></span>\n <span class="handle" style="left: {{xPosition}}%;" ng-mousedown="handleMouseDown($event)">\n <span class="value" ng-show="showValueInHandle">{{handleValue | intersperse}}</span>\n </span>\n </span>\n <span class="side dec">\n <span class="button" ng-click="step(-1)">-</span>\n <span class="bound-value">{{min() | intersperse}}</span>\n </span>\n <span class="side inc">\n <span class="button" ng-click="step(+1)">+</span>\n <span class="bound-value">{{max() | intersperse}}</span>\n </span>\n <span class="increments">\n <span ng-repeat="i in increments" class="i" style="left: {{i.offset}}%">\n {{ i.value | intersperse }}\n </span>\n </span>\n</span>',replace:!0,restrict:"E",scope:{value:"=",min:"&",max:"&"},link:function(e,a,s){var t,l,i,u,r,o,c,p,v;return i=function(){var n,a,t,l,i,u,r;if(null!=s.increments){for(t=e.min(),a=e.max(),l=100/Math.abs(a-t),e.increments=[],e.snapValues=[t,a],r=s.increments.split(","),i=0,u=r.length;u>i;i++)n=r[i],n=parseInt(n),n>t&&a>n&&(e.increments.push({value:n,offset:(n-t)*l}),e.snapValues.push(n));e.snapValues.sort(function(n,e){return n-e})}return void 0},r=a[0].getElementsByClassName("slider")[0],l=!1,e.xPosition=0,p=s.step||1,t=null!=s.deferUpdate,e.showValueInHandle=null!=s.showValueInHandle,null==e.value&&(e.value=e.min()),u=function(){var n;return n=e.max()-e.min(),0===n?e.xPosition=0:(e.xPosition=100*((e.value-e.min())/n),e.xPosition=Math.min(Math.max(0,e.xPosition),100)),e.showValueInHandle?e.handleValue=e.value:void 0},o=function(){var n,a,s,t,l,i,r;if(e.increments){for(s=1/0,r=e.snapValues,l=0,i=r.length;i>l;l++)t=r[l],a=Math.abs(t-e.value),s>a&&(s=a,n=t);e.value=n}return u()},v=function(){return Math.round(((e.max()-e.min())*(e.xPosition/100)+e.min())/p)*p},e.$watch("min()",function(n){return i(),e.value<n&&(e.value=n),o()}),e.$watch("max()",function(n){return i(),e.value>n&&(e.value=n),o()}),e.$watch("value",function(n,a){return l?void 0:e.min()<=n&&n<=e.max()?u():n=a}),e.step=function(n){var a,t;return t=function(n){var a;return a=e.value+n*p,e.min()<=a&&a<=e.max()?e.value=a:void 0},a=function(n){var a,s;return a=n>0?function(){var n,a,t,l;for(t=e.snapValues,l=[],n=0,a=t.length;a>n;n++)s=t[n],s>e.value&&l.push(s);return l}()[0]:function(){var n,a,t,l;for(t=e.snapValues,l=[],n=0,a=t.length;a>n;n++)s=t[n],s<e.value&&l.push(s);return l}().reverse()[0],null!=a?e.value=a:void 0},null!=s.increments?a(n):t(n)},e.sliderClick=function(n){return angular.element(n.target).hasClass("handle")?void 0:(e.xPosition=100*(n.layerX/r.offsetWidth),e.value=v(),o())},c=null,e.handleMouseDown=function(n){return angular.element(n.target).hasClass("handle")?(c=n.pageX,l=!0):void 0},n.on("mousemove",function(n){var a;if(l)return a=n.pageX-c,e.xPosition+=100*(a/r.offsetWidth),e.xPosition<0?e.xPosition=0:e.xPosition>100?e.xPosition=100:c=n.pageX,t||(e.value=v()),e.showValueInHandle&&(e.handleValue=v()),e.$apply()}),n.on("mouseup",function(){return l?(t&&(e.value=v()),o(),e.$apply(),l=!1):void 0})}}}]),n.filter("intersperse",function(){return function(n){var e,a,s;if(null!=n)return n=n.toString(),e=function(n){return n.split("").reverse().join("")},a=e(n),a=a.replace(/(.{3})/g,"$1 "),s=e(a),s.trim()}})}).call(this);
|
data/glider-rails.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
6
|
gem.name = "glider-rails"
|
7
|
-
gem.version = "0.1.
|
7
|
+
gem.version = "0.1.4"
|
8
8
|
gem.authors = ["Valentin Valve Vasilyev", "Dmitry KODer Karpunin"]
|
9
9
|
gem.email = ["iamvalentin@gmail.com", "koderfunk@gmail.com"]
|
10
10
|
gem.description = "Glider, AngularJS UI slider for rails asset pipeline"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glider-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-11-14 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: Glider, AngularJS UI slider for rails asset pipeline
|
16
16
|
email:
|