nouislider-rails 7.0.1 → 7.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,234 +0,0 @@
1
- /*jslint browser: true */
2
- /*jslint white: true */
3
-
4
- (function( $ ){
5
-
6
- 'use strict';
7
-
8
- // Removes duplicates from an array.
9
- function unique(array) {
10
- return $.grep(array, function(el, index) {
11
- return index === $.inArray(el, array);
12
- });
13
- }
14
-
15
- // Pips
16
-
17
- function getGroup ( $Spectrum, mode, values, stepped ) {
18
-
19
- // Use the range.
20
- if ( mode === 'range' || mode === 'steps' ) {
21
- return $Spectrum.xVal;
22
- }
23
-
24
- if ( mode === 'count' ) {
25
-
26
- // Divide 0 - 100 in 'count' parts.
27
- var spread = ( 100 / (values-1) ), v, i = 0;
28
- values = [];
29
-
30
- // List these parts and have them handled as 'positions'.
31
- while ((v=i++*spread) <= 100 ) {
32
- values.push(v);
33
- }
34
-
35
- mode = 'positions';
36
- }
37
-
38
- if ( mode === 'positions' ) {
39
-
40
- // Map all percentages to on-range values.
41
- return $.map(values, function( value ){
42
- return $Spectrum.fromStepping( stepped ? $Spectrum.getStep( value ) : value );
43
- });
44
- }
45
-
46
- if ( mode === 'values' ) {
47
-
48
- // If the value must be stepped, it needs to be converted to a percentage first.
49
- if ( stepped ) {
50
-
51
- return $.map(values, function( value ){
52
-
53
- // Convert to percentage, apply step, return to value.
54
- return $Spectrum.fromStepping( $Spectrum.getStep( $Spectrum.toStepping( value ) ) );
55
- });
56
-
57
- }
58
-
59
- // Otherwise, we can simply use the values.
60
- return values;
61
- }
62
- }
63
-
64
- function generateSpread ( $Spectrum, density, mode, group ) {
65
-
66
- var originalSpectrumDirection = $Spectrum.direction,
67
- indexes = {},
68
- firstInRange = $Spectrum.xVal[0],
69
- lastInRange = $Spectrum.xVal[$Spectrum.xVal.length-1],
70
- ignoreFirst = false,
71
- ignoreLast = false,
72
- prevPct = 0;
73
-
74
- // This function loops the spectrum in an ltr linear fashion,
75
- // while the toStepping method is direction aware. Trick it into
76
- // believing it is ltr.
77
- $Spectrum.direction = 0;
78
-
79
- // Create a copy of the group, sort it and filter away all duplicates.
80
- group = unique(group.slice().sort(function(a, b){ return a - b; }));
81
-
82
- // Make sure the range starts with the first element.
83
- if ( group[0] !== firstInRange ) {
84
- group.unshift(firstInRange);
85
- ignoreFirst = true;
86
- }
87
-
88
- // Likewise for the last one.
89
- if ( group[group.length - 1] !== lastInRange ) {
90
- group.push(lastInRange);
91
- ignoreLast = true;
92
- }
93
-
94
- $.each(group, function ( index ) {
95
-
96
- // Get the current step and the lower + upper positions.
97
- var step, i, q,
98
- low = group[index],
99
- high = group[index+1],
100
- newPct, pctDifference, pctPos, type,
101
- steps, realSteps, stepsize;
102
-
103
- // When using 'steps' mode, use the provided steps.
104
- // Otherwise, we'll step on to the next subrange.
105
- if ( mode === 'steps' ) {
106
- step = $Spectrum.xNumSteps[ index ];
107
- }
108
-
109
- // Default to a 'full' step.
110
- if ( !step ) {
111
- step = high-low;
112
- }
113
-
114
- // Low can be 0, so test for false. If high is undefined,
115
- // we are at the last subrange. Index 0 is already handled.
116
- if ( low === false || high === undefined ) {
117
- return;
118
- }
119
-
120
- // Find all steps in the subrange.
121
- for ( i = low; i <= high; i += step ) {
122
-
123
- // Get the percentage value for the current step,
124
- // calculate the size for the subrange.
125
- newPct = $Spectrum.toStepping( i );
126
- pctDifference = newPct - prevPct;
127
-
128
- steps = pctDifference / density;
129
- realSteps = Math.round(steps);
130
-
131
- // This ratio represents the ammount of percentage-space a point indicates.
132
- // For a density 1 the points/percentage = 1. For density 2, that percentage needs to be re-devided.
133
- // Round the percentage offset to an even number, then divide by two
134
- // to spread the offset on both sides of the range.
135
- stepsize = pctDifference/realSteps;
136
-
137
- // Divide all points evenly, adding the correct number to this subrange.
138
- // Run up to <= so that 100% gets a point, event if ignoreLast is set.
139
- for ( q = 1; q <= realSteps; q += 1 ) {
140
-
141
- // The ratio between the rounded value and the actual size might be ~1% off.
142
- // Correct the percentage offset by the number of points
143
- // per subrange. density = 1 will result in 100 points on the
144
- // full range, 2 for 50, 4 for 25, etc.
145
- pctPos = prevPct + ( q * stepsize );
146
- indexes[pctPos.toFixed(5)] = ['x', 0];
147
- }
148
-
149
- // Determine the point type.
150
- type = ($.inArray(i, group) > -1) ? 1 : ( mode === 'steps' ? 2 : 0 );
151
-
152
- // Enforce the 'ignoreFirst' option by overwriting the type for 0.
153
- if ( !index && ignoreFirst && !low ) {
154
- type = 0;
155
- }
156
-
157
- if ( !(i === high && ignoreLast)) {
158
- // Mark the 'type' of this point. 0 = plain, 1 = real value, 2 = step value.
159
- indexes[newPct.toFixed(5)] = [i, type];
160
- }
161
-
162
- // Update the percentage count.
163
- prevPct = newPct;
164
- }
165
- });
166
-
167
- // Reset the spectrum.
168
- $Spectrum.direction = originalSpectrumDirection;
169
-
170
- return indexes;
171
- }
172
-
173
- function addMarking ( CSSstyle, orientation, direction, spread, filterFunc ) {
174
-
175
- var style = ['horizontal', 'vertical'][orientation],
176
- element = $('<div/>');
177
-
178
- element.addClass('noUi-pips noUi-pips-'+style);
179
-
180
- function getSize( type, value ){
181
- return [ '-normal', '-large', '-sub' ][(type&&filterFunc) ? filterFunc(value, type) : type];
182
- }
183
- function getTags( offset, source, values ) {
184
- return 'class="' + source + ' ' +
185
- source + '-' + style + ' ' +
186
- source + getSize(values[1], values[0]) +
187
- '" style="' + CSSstyle + ': ' + offset + '%"';
188
- }
189
- function addSpread ( offset, values ){
190
-
191
- if ( direction ) {
192
- offset = 100 - offset;
193
- }
194
-
195
- // Add a marker for every point
196
- element.append('<div '+getTags(offset, 'noUi-marker', values)+'></div>');
197
-
198
- // Values are only appended for points marked '1' or '2'.
199
- if ( values[1] ) {
200
- element.append('<div '+getTags(offset, 'noUi-value', values)+'>' + Math.round(values[0]) + '</div>');
201
- }
202
- }
203
-
204
- // Append all points.
205
- $.each(spread, addSpread);
206
-
207
- return element;
208
- }
209
-
210
- $.fn.noUiSlider_pips = function ( grid ) {
211
-
212
- var mode = grid.mode,
213
- density = grid.density || 1,
214
- filter = grid.filter || false,
215
- values = grid.values || false,
216
- stepped = grid.stepped || false;
217
-
218
- return this.each(function(){
219
-
220
- var info = this.getInfo(),
221
- group = getGroup( info[0], mode, values, stepped ),
222
- spread = generateSpread( info[0], density, mode, group );
223
-
224
- return $(this).append(addMarking(
225
- info[1],
226
- info[2],
227
- info[0].direction,
228
- spread,
229
- filter
230
- ));
231
- });
232
- };
233
-
234
- }( window.jQuery || window.Zepto ));
@@ -1,98 +0,0 @@
1
-
2
- /* Base;
3
- *
4
- */
5
- .noUi-pips,
6
- .noUi-pips * {
7
- -moz-box-sizing: border-box;
8
- box-sizing: border-box;
9
- }
10
- .noUi-pips {
11
- position: absolute;
12
- font: 400 12px Arial;
13
- color: #999;
14
- }
15
-
16
- /* Values;
17
- *
18
- */
19
- .noUi-value {
20
- width: 40px;
21
- position: absolute;
22
- text-align: center;
23
- }
24
- .noUi-value-sub {
25
- color: #ccc;
26
- font-size: 10px;
27
- }
28
-
29
- /* Markings;
30
- *
31
- */
32
- .noUi-marker {
33
- position: absolute;
34
- background: #CCC;
35
- }
36
- .noUi-marker-sub {
37
- background: #AAA;
38
- }
39
- .noUi-marker-large {
40
- background: #AAA;
41
- }
42
-
43
- /* Horizontal layout;
44
- *
45
- */
46
- .noUi-pips-horizontal {
47
- padding: 10px 0;
48
- height: 50px;
49
- top: 100%;
50
- left: 0;
51
- width: 100%;
52
- }
53
- .noUi-value-horizontal {
54
- margin-left: -20px;
55
- padding-top: 20px;
56
- }
57
- .noUi-value-horizontal.noUi-value-sub {
58
- padding-top: 15px;
59
- }
60
-
61
- .noUi-marker-horizontal.noUi-marker {
62
- margin-left: -1px;
63
- width: 2px;
64
- height: 5px;
65
- }
66
- .noUi-marker-horizontal.noUi-marker-sub {
67
- height: 10px;
68
- }
69
- .noUi-marker-horizontal.noUi-marker-large {
70
- height: 15px;
71
- }
72
-
73
- /* Vertical layout;
74
- *
75
- */
76
- .noUi-pips-vertical {
77
- padding: 0 10px;
78
- height: 100%;
79
- top: 0;
80
- left: 100%;
81
- }
82
- .noUi-value-vertical {
83
- width: 15px;
84
- margin-left: 20px;
85
- margin-top: -5px;
86
- }
87
-
88
- .noUi-marker-vertical.noUi-marker {
89
- width: 5px;
90
- height: 2px;
91
- margin-top: -1px;
92
- }
93
- .noUi-marker-vertical.noUi-marker-sub {
94
- width: 10px;
95
- }
96
- .noUi-marker-vertical.noUi-marker-large {
97
- width: 15px;
98
- }