nouislider-rails 7.0.1 → 7.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -245,10 +245,10 @@
245
245
  if ( optionValue === undefined ) {
246
246
 
247
247
  // Only default if negativeBefore isn't set.
248
- if ( optionName === 'negative' && !filteredOptions['negativeBefore'] ) {
248
+ if ( optionName === 'negative' && !filteredOptions.negativeBefore ) {
249
249
  filteredOptions[optionName] = '-';
250
250
  // Don't set a default for mark when 'thousand' is set.
251
- } else if ( optionName === 'mark' && filteredOptions['thousand'] !== '.' ) {
251
+ } else if ( optionName === 'mark' && filteredOptions.thousand !== '.' ) {
252
252
  filteredOptions[optionName] = '.';
253
253
  } else {
254
254
  filteredOptions[optionName] = false;
@@ -319,17 +319,17 @@
319
319
  options = validate(options);
320
320
 
321
321
  // Call 'formatTo' with proper arguments.
322
- this['to'] = function ( input ) {
322
+ this.to = function ( input ) {
323
323
  return passAll(options, formatTo, input);
324
324
  };
325
325
 
326
326
  // Call 'formatFrom' with proper arguments.
327
- this['from'] = function ( input ) {
327
+ this.from = function ( input ) {
328
328
  return passAll(options, formatFrom, input);
329
329
  };
330
330
  }
331
331
 
332
332
  /** @export */
333
- window['wNumb'] = wNumb;
333
+ window.wNumb = wNumb;
334
334
 
335
- }());
335
+ }());
@@ -1,4 +1,3 @@
1
1
  /*
2
2
  *= require nouislider/jquery.nouislider
3
- *= require nouislider/jquery.nouislider.pips
4
3
  */
@@ -1,3 +1,5 @@
1
+ /*! noUiSlider - 7.0.2 - 2014-09-09 10:05:55 */
2
+
1
3
 
2
4
  /* Functional styling;
3
5
  * These styles are required for noUiSlider to function.
@@ -5,161 +7,259 @@
5
7
  */
6
8
  .noUi-target,
7
9
  .noUi-target * {
8
- -webkit-touch-callout: none;
9
- -webkit-user-select: none;
10
- -ms-touch-action: none;
11
- -ms-user-select: none;
12
- -moz-user-select: none;
13
- -moz-box-sizing: border-box;
14
- box-sizing: border-box;
10
+ -webkit-touch-callout: none;
11
+ -webkit-user-select: none;
12
+ -ms-touch-action: none;
13
+ -ms-user-select: none;
14
+ -moz-user-select: none;
15
+ -moz-box-sizing: border-box;
16
+ box-sizing: border-box;
15
17
  }
16
18
  .noUi-target {
17
- position: relative;
19
+ position: relative;
18
20
  }
19
21
  .noUi-base {
20
- width: 100%;
21
- height: 100%;
22
- position: relative;
22
+ width: 100%;
23
+ height: 100%;
24
+ position: relative;
23
25
  }
24
26
  .noUi-origin {
25
- position: absolute;
26
- right: 0;
27
- top: 0;
28
- left: 0;
29
- bottom: 0;
27
+ position: absolute;
28
+ right: 0;
29
+ top: 0;
30
+ left: 0;
31
+ bottom: 0;
30
32
  }
31
33
  .noUi-handle {
32
- position: relative;
33
- z-index: 1;
34
+ position: relative;
35
+ z-index: 1;
34
36
  }
35
37
  .noUi-stacking .noUi-handle {
36
- /* This class is applied to the lower origin when
37
- its values is > 50%. */
38
- z-index: 10;
38
+ /* This class is applied to the lower origin when
39
+ its values is > 50%. */
40
+ z-index: 10;
39
41
  }
40
42
  .noUi-stacking + .noUi-origin {
41
- /* Fix stacking order in IE7, which incorrectly
42
- creates a new context for the origins. */
43
- *z-index: -1;
43
+ /* Fix stacking order in IE7, which incorrectly
44
+ creates a new context for the origins. */
45
+ *z-index: -1;
44
46
  }
45
47
  .noUi-state-tap .noUi-origin {
46
- -webkit-transition: left 0.3s, top 0.3s;
47
- transition: left 0.3s, top 0.3s;
48
+ -webkit-transition: left 0.3s, top 0.3s;
49
+ transition: left 0.3s, top 0.3s;
48
50
  }
49
51
  .noUi-state-drag * {
50
- cursor: inherit !important;
52
+ cursor: inherit !important;
51
53
  }
52
54
 
53
55
  /* Painting and performance;
54
56
  * Browsers can paint handles in their own layer.
55
57
  */
56
- .noUi-origin,
57
- .noUi-handle {
58
- -webkit-transform: translate3d(0,0,0);
59
- transform: translate3d(0,0,0);
58
+ .noUi-base {
59
+ -webkit-transform: translate3d(0,0,0);
60
+ transform: translate3d(0,0,0);
60
61
  }
61
62
 
62
63
  /* Slider size and handle placement;
63
64
  */
64
65
  .noUi-horizontal {
65
- height: 18px;
66
+ height: 18px;
66
67
  }
67
68
  .noUi-horizontal .noUi-handle {
68
- width: 34px;
69
- height: 28px;
70
- left: -17px;
71
- top: -6px;
69
+ width: 34px;
70
+ height: 28px;
71
+ left: -17px;
72
+ top: -6px;
72
73
  }
73
74
  .noUi-vertical {
74
- width: 18px;
75
+ width: 18px;
75
76
  }
76
77
  .noUi-vertical .noUi-handle {
77
- width: 28px;
78
- height: 34px;
79
- left: -6px;
80
- top: -17px;
78
+ width: 28px;
79
+ height: 34px;
80
+ left: -6px;
81
+ top: -17px;
81
82
  }
82
83
 
83
84
  /* Styling;
84
85
  */
85
86
  .noUi-background {
86
- background: #FAFAFA;
87
- box-shadow: inset 0 1px 1px #f0f0f0;
87
+ background: #FAFAFA;
88
+ box-shadow: inset 0 1px 1px #f0f0f0;
88
89
  }
89
90
  .noUi-connect {
90
- background: #3FB8AF;
91
- box-shadow: inset 0 0 3px rgba(51,51,51,0.45);
92
- -webkit-transition: background 450ms;
93
- transition: background 450ms;
91
+ background: #3FB8AF;
92
+ box-shadow: inset 0 0 3px rgba(51,51,51,0.45);
93
+ -webkit-transition: background 450ms;
94
+ transition: background 450ms;
94
95
  }
95
96
  .noUi-origin {
96
- border-radius: 2px;
97
+ border-radius: 2px;
97
98
  }
98
99
  .noUi-target {
99
- border-radius: 4px;
100
- border: 1px solid #D3D3D3;
101
- box-shadow: inset 0 1px 1px #F0F0F0, 0 3px 6px -5px #BBB;
100
+ border-radius: 4px;
101
+ border: 1px solid #D3D3D3;
102
+ box-shadow: inset 0 1px 1px #F0F0F0, 0 3px 6px -5px #BBB;
102
103
  }
103
104
  .noUi-target.noUi-connect {
104
- box-shadow: inset 0 0 3px rgba(51,51,51,0.45), 0 3px 6px -5px #BBB;
105
+ box-shadow: inset 0 0 3px rgba(51,51,51,0.45), 0 3px 6px -5px #BBB;
105
106
  }
106
107
 
107
108
  /* Handles and cursors;
108
109
  */
109
110
  .noUi-dragable {
110
- cursor: w-resize;
111
+ cursor: w-resize;
111
112
  }
112
113
  .noUi-vertical .noUi-dragable {
113
- cursor: n-resize;
114
+ cursor: n-resize;
114
115
  }
115
116
  .noUi-handle {
116
- border: 1px solid #D9D9D9;
117
- border-radius: 3px;
118
- background: #FFF;
119
- cursor: default;
120
- box-shadow: inset 0 0 1px #FFF,
121
- inset 0 1px 7px #EBEBEB,
122
- 0 3px 6px -3px #BBB;
117
+ border: 1px solid #D9D9D9;
118
+ border-radius: 3px;
119
+ background: #FFF;
120
+ cursor: default;
121
+ box-shadow: inset 0 0 1px #FFF,
122
+ inset 0 1px 7px #EBEBEB,
123
+ 0 3px 6px -3px #BBB;
123
124
  }
124
125
  .noUi-active {
125
- box-shadow: inset 0 0 1px #FFF,
126
- inset 0 1px 7px #DDD,
127
- 0 3px 6px -3px #BBB;
126
+ box-shadow: inset 0 0 1px #FFF,
127
+ inset 0 1px 7px #DDD,
128
+ 0 3px 6px -3px #BBB;
128
129
  }
129
130
 
130
131
  /* Handle stripes;
131
132
  */
132
133
  .noUi-handle:before,
133
134
  .noUi-handle:after {
134
- content: "";
135
- display: block;
136
- position: absolute;
137
- height: 14px;
138
- width: 1px;
139
- background: #E8E7E6;
140
- left: 14px;
141
- top: 6px;
135
+ content: "";
136
+ display: block;
137
+ position: absolute;
138
+ height: 14px;
139
+ width: 1px;
140
+ background: #E8E7E6;
141
+ left: 14px;
142
+ top: 6px;
142
143
  }
143
144
  .noUi-handle:after {
144
- left: 17px;
145
+ left: 17px;
145
146
  }
146
147
  .noUi-vertical .noUi-handle:before,
147
148
  .noUi-vertical .noUi-handle:after {
148
- width: 14px;
149
- height: 1px;
150
- left: 6px;
151
- top: 14px;
149
+ width: 14px;
150
+ height: 1px;
151
+ left: 6px;
152
+ top: 14px;
152
153
  }
153
154
  .noUi-vertical .noUi-handle:after {
154
- top: 17px;
155
+ top: 17px;
155
156
  }
156
157
 
157
158
  /* Disabled state;
158
159
  */
159
160
  [disabled].noUi-connect,
160
161
  [disabled] .noUi-connect {
161
- background: #B8B8B8;
162
+ background: #B8B8B8;
162
163
  }
163
164
  [disabled] .noUi-handle {
164
- cursor: not-allowed;
165
+ cursor: not-allowed;
166
+ }
167
+
168
+
169
+ /* Base;
170
+ *
171
+ */
172
+ .noUi-pips,
173
+ .noUi-pips * {
174
+ -moz-box-sizing: border-box;
175
+ box-sizing: border-box;
176
+ }
177
+ .noUi-pips {
178
+ position: absolute;
179
+ font: 400 12px Arial;
180
+ color: #999;
181
+ }
182
+
183
+ /* Values;
184
+ *
185
+ */
186
+ .noUi-value {
187
+ width: 40px;
188
+ position: absolute;
189
+ text-align: center;
190
+ }
191
+ .noUi-value-sub {
192
+ color: #ccc;
193
+ font-size: 10px;
194
+ }
195
+
196
+ /* Markings;
197
+ *
198
+ */
199
+ .noUi-marker {
200
+ position: absolute;
201
+ background: #CCC;
202
+ }
203
+ .noUi-marker-sub {
204
+ background: #AAA;
205
+ }
206
+ .noUi-marker-large {
207
+ background: #AAA;
208
+ }
209
+
210
+ /* Horizontal layout;
211
+ *
212
+ */
213
+ .noUi-pips-horizontal {
214
+ padding: 10px 0;
215
+ height: 50px;
216
+ top: 100%;
217
+ left: 0;
218
+ width: 100%;
219
+ }
220
+ .noUi-value-horizontal {
221
+ margin-left: -20px;
222
+ padding-top: 20px;
223
+ }
224
+ .noUi-value-horizontal.noUi-value-sub {
225
+ padding-top: 15px;
226
+ }
227
+
228
+ .noUi-marker-horizontal.noUi-marker {
229
+ margin-left: -1px;
230
+ width: 2px;
231
+ height: 5px;
232
+ }
233
+ .noUi-marker-horizontal.noUi-marker-sub {
234
+ height: 10px;
235
+ }
236
+ .noUi-marker-horizontal.noUi-marker-large {
237
+ height: 15px;
238
+ }
239
+
240
+ /* Vertical layout;
241
+ *
242
+ */
243
+ .noUi-pips-vertical {
244
+ padding: 0 10px;
245
+ height: 100%;
246
+ top: 0;
247
+ left: 100%;
248
+ }
249
+ .noUi-value-vertical {
250
+ width: 15px;
251
+ margin-left: 20px;
252
+ margin-top: -5px;
253
+ }
254
+
255
+ .noUi-marker-vertical.noUi-marker {
256
+ width: 5px;
257
+ height: 2px;
258
+ margin-top: -1px;
259
+ }
260
+ .noUi-marker-vertical.noUi-marker-sub {
261
+ width: 10px;
262
+ }
263
+ .noUi-marker-vertical.noUi-marker-large {
264
+ width: 15px;
165
265
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nouislider-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.1
4
+ version: 7.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-02 00:00:00.000000000 Z
11
+ date: 2014-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description: 'Currently tracking 7.0.1 of jquery-noUiSlider: https://github.com/leongersen/noUiSlider).
55
+ description: 'Currently tracking 7.0.2 of jquery-noUiSlider: https://github.com/leongersen/noUiSlider).
56
56
  All credit and thanks to @leongersen for the awesome library.'
57
57
  email:
58
58
  - chug2k@gmail.com
@@ -71,14 +71,10 @@ files:
71
71
  - screenshot.png
72
72
  - vendor/assets/javascripts/jquery.nouislider.js
73
73
  - vendor/assets/javascripts/libLink/jquery.liblink.js
74
- - vendor/assets/javascripts/nouislider/module.base.js
75
- - vendor/assets/javascripts/nouislider/module.options.js
76
- - vendor/assets/javascripts/nouislider/module.range.js
77
- - vendor/assets/javascripts/nouislider/optional.pips.js
74
+ - vendor/assets/javascripts/nouislider/jquery.nouislider.js
78
75
  - vendor/assets/javascripts/wnumb/wNumb.js
79
76
  - vendor/assets/stylesheets/jquery.nouislider.css
80
77
  - vendor/assets/stylesheets/nouislider/jquery.nouislider.css
81
- - vendor/assets/stylesheets/nouislider/jquery.nouislider.pips.css
82
78
  homepage: https://github.com/chug2k/nouislider-rails
83
79
  licenses:
84
80
  - MIT
@@ -1,872 +0,0 @@
1
- /*jslint browser: true */
2
- /*jslint white: true */
3
-
4
- (function( $ ){
5
-
6
- 'use strict';
7
-
8
- var
9
- // Cache the document selector;
10
- /** @const */
11
- doc = $(document),
12
- // Make a backup of the original jQuery/Zepto .val() method.
13
- /** @const */
14
- $val = $.fn.val,
15
- // Namespace for binding and unbinding slider events;
16
- /** @const */
17
- namespace = '.nui',
18
- // Determine the events to bind. IE11 implements pointerEvents without
19
- // a prefix, which breaks compatibility with the IE10 implementation.
20
- /** @const */
21
- actions = window.navigator.pointerEnabled ? {
22
- start: 'pointerdown',
23
- move: 'pointermove',
24
- end: 'pointerup'
25
- } : window.navigator.msPointerEnabled ? {
26
- start: 'MSPointerDown',
27
- move: 'MSPointerMove',
28
- end: 'MSPointerUp'
29
- } : {
30
- start: 'mousedown touchstart',
31
- move: 'mousemove touchmove',
32
- end: 'mouseup touchend'
33
- },
34
- // Re-usable list of classes;
35
- /** @const */
36
- Classes = [
37
- /* 0 */ 'noUi-target'
38
- /* 1 */ ,'noUi-base'
39
- /* 2 */ ,'noUi-origin'
40
- /* 3 */ ,'noUi-handle'
41
- /* 4 */ ,'noUi-horizontal'
42
- /* 5 */ ,'noUi-vertical'
43
- /* 6 */ ,'noUi-background'
44
- /* 7 */ ,'noUi-connect'
45
- /* 8 */ ,'noUi-ltr'
46
- /* 9 */ ,'noUi-rtl'
47
- /* 10 */ ,'noUi-dragable'
48
- /* 11 */ ,''
49
- /* 12 */ ,'noUi-state-drag'
50
- /* 13 */ ,''
51
- /* 14 */ ,'noUi-state-tap'
52
- /* 15 */ ,'noUi-active'
53
- /* 16 */ ,''
54
- /* 17 */ ,'noUi-stacking'
55
- ];
56
-
57
-
58
- // General helpers
59
-
60
- // Limits a value to 0 - 100
61
- function limit ( a ) {
62
- return Math.max(Math.min(a, 100), 0);
63
- }
64
-
65
- // Wraps a variable as an array, if it isn't one yet.
66
- function asArray ( a ) {
67
- return $.isArray(a) ? a : [a];
68
- }
69
-
70
-
71
- // Class handling
72
-
73
- // Sets a class and removes it after [duration] ms.
74
- function addClassFor ( element, className, duration ) {
75
- element.addClass(className);
76
- setTimeout(function(){
77
- element.removeClass(className);
78
- }, duration);
79
- }
80
-
81
- // Delimit proposed values for handle positions.
82
- function getPositions ( a, b, delimit ) {
83
-
84
- // Add movement to current position.
85
- var c = a + b[0], d = a + b[1];
86
-
87
- // Only alter the other position on drag,
88
- // not on standard sliding.
89
- if ( delimit ) {
90
- if ( c < 0 ) {
91
- d += Math.abs(c);
92
- }
93
- if ( d > 100 ) {
94
- c -= ( d - 100 );
95
- }
96
-
97
- // Limit values to 0 and 100.
98
- return [limit(c), limit(d)];
99
- }
100
-
101
- return [c,d];
102
- }
103
-
104
-
105
-
106
- // Event handling
107
-
108
- // Provide a clean event with standardized offset values.
109
- function fixEvent ( e ) {
110
-
111
- // Prevent scrolling and panning on touch events, while
112
- // attempting to slide. The tap event also depends on this.
113
- e.preventDefault();
114
-
115
- // Filter the event to register the type, which can be
116
- // touch, mouse or pointer. Offset changes need to be
117
- // made on an event specific basis.
118
- var touch = e.type.indexOf('touch') === 0
119
- ,mouse = e.type.indexOf('mouse') === 0
120
- ,pointer = e.type.indexOf('pointer') === 0
121
- ,x,y, event = e;
122
-
123
- // IE10 implemented pointer events with a prefix;
124
- if ( e.type.indexOf('MSPointer') === 0 ) {
125
- pointer = true;
126
- }
127
-
128
- // Get the originalEvent, if the event has been wrapped
129
- // by jQuery. Zepto doesn't wrap the event.
130
- if ( e.originalEvent ) {
131
- e = e.originalEvent;
132
- }
133
-
134
- if ( touch ) {
135
- // noUiSlider supports one movement at a time,
136
- // so we can select the first 'changedTouch'.
137
- x = e.changedTouches[0].pageX;
138
- y = e.changedTouches[0].pageY;
139
- }
140
-
141
- if ( mouse || pointer ) {
142
-
143
- // Polyfill the pageXOffset and pageYOffset
144
- // variables for IE7 and IE8;
145
- if( !pointer && window.pageXOffset === undefined ){
146
- window.pageXOffset = document.documentElement.scrollLeft;
147
- window.pageYOffset = document.documentElement.scrollTop;
148
- }
149
-
150
- x = e.clientX + window.pageXOffset;
151
- y = e.clientY + window.pageYOffset;
152
- }
153
-
154
- event.points = [x, y];
155
- event.cursor = mouse;
156
-
157
- return event;
158
- }
159
-
160
-
161
- // DOM additions
162
-
163
- // Append a handle to the base.
164
- function addHandle ( direction, index ) {
165
-
166
- var handle = $('<div><div/></div>').addClass( Classes[2] ),
167
- additions = [ '-lower', '-upper' ];
168
-
169
- if ( direction ) {
170
- additions.reverse();
171
- }
172
-
173
- handle.children().addClass(
174
- Classes[3] + " " + Classes[3]+additions[index]
175
- );
176
-
177
- return handle;
178
- }
179
-
180
- // Add the proper connection classes.
181
- function addConnection ( connect, target, handles ) {
182
-
183
- // Apply the required connection classes to the elements
184
- // that need them. Some classes are made up for several
185
- // segments listed in the class list, to allow easy
186
- // renaming and provide a minor compression benefit.
187
- switch ( connect ) {
188
- case 1: target.addClass( Classes[7] );
189
- handles[0].addClass( Classes[6] );
190
- break;
191
- case 3: handles[1].addClass( Classes[6] );
192
- /* falls through */
193
- case 2: handles[0].addClass( Classes[7] );
194
- /* falls through */
195
- case 0: target.addClass(Classes[6]);
196
- break;
197
- }
198
- }
199
-
200
- // Add handles to the slider base.
201
- function addHandles ( nrHandles, direction, base ) {
202
-
203
- var index, handles = [];
204
-
205
- // Append handles.
206
- for ( index = 0; index < nrHandles; index += 1 ) {
207
-
208
- // Keep a list of all added handles.
209
- handles.push( addHandle( direction, index ).appendTo(base) );
210
- }
211
-
212
- return handles;
213
- }
214
-
215
- // Initialize a single slider.
216
- function addSlider ( direction, orientation, target ) {
217
-
218
- // Apply classes and data to the target.
219
- target.addClass([
220
- Classes[0],
221
- Classes[8 + direction],
222
- Classes[4 + orientation]
223
- ].join(' '));
224
-
225
- return $('<div/>').appendTo(target).addClass( Classes[1] );
226
- }
227
-
228
-
229
- // Slider scope
230
-
231
- function closure ( target, options, originalOptions ){
232
-
233
- // Internal variables
234
-
235
- // All variables local to 'closure' are marked $.
236
- var $Target = $(target),
237
- $Locations = [-1, -1],
238
- $Base,
239
- $Handles,
240
- $Spectrum = options.spectrum,
241
- $Values = [],
242
- // libLink. For rtl sliders, 'lower' and 'upper' should not be inverted
243
- // for one-handle sliders, so trim 'upper' it that case.
244
- triggerPos = ['lower', 'upper'].slice(0, options.handles);
245
-
246
- // Invert the libLink connection for rtl sliders.
247
- if ( options.dir ) {
248
- triggerPos.reverse();
249
- }
250
-
251
-
252
- // Helpers
253
-
254
- // Shorthand for base dimensions.
255
- function baseSize ( ) {
256
- return $Base[['width', 'height'][options.ort]]();
257
- }
258
-
259
- // External event handling
260
- function fireEvents ( events ) {
261
-
262
- // Use the external api to get the values.
263
- // Wrap the values in an array, as .trigger takes
264
- // only one additional argument.
265
- var index, values = [ $Target.val() ];
266
-
267
- for ( index = 0; index < events.length; index += 1 ){
268
- $Target.trigger(events[index], values);
269
- }
270
- }
271
-
272
- // Returns the input array, respecting the slider direction configuration.
273
- function inSliderOrder ( values ) {
274
-
275
- // If only one handle is used, return a single value.
276
- if ( values.length === 1 ){
277
- return values[0];
278
- }
279
-
280
- if ( options.dir ) {
281
- return values.reverse();
282
- }
283
-
284
- return values;
285
- }
286
-
287
-
288
- // libLink integration
289
-
290
- // Create a new function which calls .val on input change.
291
- function createChangeHandler ( trigger ) {
292
- return function ( ignore, value ){
293
- // Determine which array position to 'null' based on 'trigger'.
294
- $Target.val( [ trigger ? null : value, trigger ? value : null ], true );
295
- };
296
- }
297
-
298
- // Called by libLink when it wants a set of links updated.
299
- function linkUpdate ( flag ) {
300
-
301
- var trigger = $.inArray(flag, triggerPos);
302
-
303
- // The API might not have been set yet.
304
- if ( $Target[0].linkAPI && $Target[0].linkAPI[flag] ) {
305
- $Target[0].linkAPI[flag].change(
306
- $Values[trigger],
307
- $Handles[trigger].children(),
308
- $Target
309
- );
310
- }
311
- }
312
-
313
- // Called by libLink to append an element to the slider.
314
- function linkConfirm ( flag, element ) {
315
-
316
- // Find the trigger for the passed flag.
317
- var trigger = $.inArray(flag, triggerPos);
318
-
319
- // If set, append the element to the handle it belongs to.
320
- if ( element ) {
321
- element.appendTo( $Handles[trigger].children() );
322
- }
323
-
324
- // The public API is reversed for rtl sliders, so the changeHandler
325
- // should not be aware of the inverted trigger positions.
326
- if ( options.dir ) {
327
- trigger = trigger === 1 ? 0 : 1;
328
- }
329
-
330
- return createChangeHandler( trigger );
331
- }
332
-
333
- // Place elements back on the slider.
334
- function reAppendLink ( ) {
335
-
336
- var i, flag;
337
-
338
- // The API keeps a list of elements: we can re-append them on rebuild.
339
- for ( i = 0; i < triggerPos.length; i += 1 ) {
340
- if ( this.linkAPI && this.linkAPI[(flag = triggerPos[i])] ) {
341
- this.linkAPI[flag].reconfirm(flag);
342
- }
343
- }
344
- }
345
-
346
- target.LinkUpdate = linkUpdate;
347
- target.LinkConfirm = linkConfirm;
348
- target.LinkDefaultFormatter = options.format;
349
- target.LinkDefaultFlag = 'lower';
350
-
351
- target.reappend = reAppendLink;
352
-
353
-
354
- // Test suggested values and apply margin, step.
355
- function setHandle ( handle, to, noLimitOption ) {
356
-
357
- var trigger = handle[0] !== $Handles[0][0] ? 1 : 0,
358
- lowerMargin = $Locations[0] + options.margin,
359
- upperMargin = $Locations[1] - options.margin,
360
- lowerLimit = $Locations[0] + options.limit,
361
- upperLimit = $Locations[1] - options.limit;
362
-
363
- // For sliders with multiple handles,
364
- // limit movement to the other handle.
365
- // Apply the margin option by adding it to the handle positions.
366
- if ( $Handles.length > 1 ) {
367
- to = trigger ? Math.max( to, lowerMargin ) : Math.min( to, upperMargin );
368
- }
369
-
370
- // The limit option has the opposite effect, limiting handles to a
371
- // maximum distance from another. Limit must be > 0, as otherwise
372
- // handles would be unmoveable. 'noLimitOption' is set to 'false'
373
- // for the .val() method, except for pass 4/4.
374
- if ( noLimitOption !== false && options.limit && $Handles.length > 1 ) {
375
- to = trigger ? Math.min ( to, lowerLimit ) : Math.max( to, upperLimit );
376
- }
377
-
378
- // Handle the step option.
379
- to = $Spectrum.getStep( to );
380
-
381
- // Limit to 0/100 for .val input, trim anything beyond 7 digits, as
382
- // JavaScript has some issues in its floating point implementation.
383
- to = limit(parseFloat(to.toFixed(7)));
384
-
385
- // Return false if handle can't move.
386
- if ( to === $Locations[trigger] ) {
387
- return false;
388
- }
389
-
390
- // Set the handle to the new position.
391
- handle.css( options.style, to + '%' );
392
-
393
- // Force proper handle stacking
394
- if ( handle.is(':first-child') ) {
395
- handle.toggleClass(Classes[17], to > 50 );
396
- }
397
-
398
- // Update locations.
399
- $Locations[trigger] = to;
400
-
401
- // Convert the value to the slider stepping/range.
402
- $Values[trigger] = $Spectrum.fromStepping( to );
403
-
404
- linkUpdate(triggerPos[trigger]);
405
-
406
- return true;
407
- }
408
-
409
- // Loop values from value method and apply them.
410
- function setValues ( count, values ) {
411
-
412
- var i, trigger, to;
413
-
414
- // With the limit option, we'll need another limiting pass.
415
- if ( options.limit ) {
416
- count += 1;
417
- }
418
-
419
- // If there are multiple handles to be set run the setting
420
- // mechanism twice for the first handle, to make sure it
421
- // can be bounced of the second one properly.
422
- for ( i = 0; i < count; i += 1 ) {
423
-
424
- trigger = i%2;
425
-
426
- // Get the current argument from the array.
427
- to = values[trigger];
428
-
429
- // Setting with null indicates an 'ignore'.
430
- // Inputting 'false' is invalid.
431
- if ( to !== null && to !== false ) {
432
-
433
- // If a formatted number was passed, attemt to decode it.
434
- if ( typeof to === 'number' ) {
435
- to = String(to);
436
- }
437
-
438
- to = options.format.from( to );
439
-
440
- // Request an update for all links if the value was invalid.
441
- // Do so too if setting the handle fails.
442
- if ( to === false || isNaN(to) || setHandle( $Handles[trigger], $Spectrum.toStepping( to ), i === (3 - options.dir) ) === false ) {
443
-
444
- linkUpdate(triggerPos[trigger]);
445
- }
446
- }
447
- }
448
- }
449
-
450
-
451
-
452
- // Handler for attaching events trough a proxy.
453
- function attach ( events, element, callback, data ) {
454
-
455
- // This function can be used to 'filter' events to the slider.
456
-
457
- // Add the noUiSlider namespace to all events.
458
- events = events.replace( /\s/g, namespace + ' ' ) + namespace;
459
-
460
- // Bind a closure on the target.
461
- return element.on( events, function( e ){
462
-
463
- // jQuery and Zepto (1) handle unset attributes differently,
464
- // but always falsy; #208
465
- if ( !!$Target.attr('disabled') ) {
466
- return false;
467
- }
468
-
469
- // Stop if an active 'tap' transition is taking place.
470
- if ( $Target.hasClass( Classes[14] ) ) {
471
- return false;
472
- }
473
-
474
- e = fixEvent(e);
475
- e.calcPoint = e.points[ options.ort ];
476
-
477
- // Call the event handler with the event [ and additional data ].
478
- callback ( e, data );
479
- });
480
- }
481
-
482
- // Handle movement on document for handle and range drag.
483
- function move ( event, data ) {
484
-
485
- var handles = data.handles || $Handles, positions, state = false,
486
- proposal = ((event.calcPoint - data.start) * 100) / baseSize(),
487
- h = handles[0][0] !== $Handles[0][0] ? 1 : 0;
488
-
489
- // Calculate relative positions for the handles.
490
- positions = getPositions( proposal, data.positions, handles.length > 1);
491
-
492
- state = setHandle ( handles[0], positions[h], handles.length === 1 );
493
-
494
- if ( handles.length > 1 ) {
495
- state = setHandle ( handles[1], positions[h?0:1], false ) || state;
496
- }
497
-
498
- // Fire the 'slide' event if any handle moved.
499
- if ( state ) {
500
- fireEvents(['slide']);
501
- }
502
- }
503
-
504
- // Unbind move events on document, call callbacks.
505
- function end ( event ) {
506
-
507
- // The handle is no longer active, so remove the class.
508
- $('.' + Classes[15]).removeClass(Classes[15]);
509
-
510
- // Remove cursor styles and text-selection events bound to the body.
511
- if ( event.cursor ) {
512
- $('body').css('cursor', '').off( namespace );
513
- }
514
-
515
- // Unbind the move and end events, which are added on 'start'.
516
- doc.off( namespace );
517
-
518
- // Remove dragging class.
519
- $Target.removeClass(Classes[12]);
520
-
521
- // Fire the change and set events.
522
- fireEvents(['set', 'change']);
523
- }
524
-
525
- // Bind move events on document.
526
- function start ( event, data ) {
527
-
528
- // Mark the handle as 'active' so it can be styled.
529
- if( data.handles.length === 1 ) {
530
- data.handles[0].children().addClass(Classes[15]);
531
- }
532
-
533
- // A drag should never propagate up to the 'tap' event.
534
- event.stopPropagation();
535
-
536
- // Attach the move event.
537
- attach ( actions.move, doc, move, {
538
- start: event.calcPoint,
539
- handles: data.handles,
540
- positions: [
541
- $Locations[0],
542
- $Locations[$Handles.length - 1]
543
- ]
544
- });
545
-
546
- // Unbind all movement when the drag ends.
547
- attach ( actions.end, doc, end, null );
548
-
549
- // Text selection isn't an issue on touch devices,
550
- // so adding cursor styles can be skipped.
551
- if ( event.cursor ) {
552
-
553
- // Prevent the 'I' cursor and extend the range-drag cursor.
554
- $('body').css('cursor', $(event.target).css('cursor'));
555
-
556
- // Mark the target with a dragging state.
557
- if ( $Handles.length > 1 ) {
558
- $Target.addClass(Classes[12]);
559
- }
560
-
561
- // Prevent text selection when dragging the handles.
562
- $('body').on('selectstart' + namespace, false);
563
- }
564
- }
565
-
566
- // Move closest handle to tapped location.
567
- function tap ( event ) {
568
-
569
- var location = event.calcPoint, total = 0, to;
570
-
571
- // The tap event shouldn't propagate up and cause 'edge' to run.
572
- event.stopPropagation();
573
-
574
- // Add up the handle offsets.
575
- $.each( $Handles, function(){
576
- total += this.offset()[ options.style ];
577
- });
578
-
579
- // Find the handle closest to the tapped position.
580
- total = ( location < total/2 || $Handles.length === 1 ) ? 0 : 1;
581
-
582
- location -= $Base.offset()[ options.style ];
583
-
584
- // Calculate the new position.
585
- to = ( location * 100 ) / baseSize();
586
-
587
- if ( !options.events.snap ) {
588
- // Flag the slider as it is now in a transitional state.
589
- // Transition takes 300 ms, so re-enable the slider afterwards.
590
- addClassFor( $Target, Classes[14], 300 );
591
- }
592
-
593
- // Find the closest handle and calculate the tapped point.
594
- // The set handle to the new position.
595
- setHandle( $Handles[total], to );
596
-
597
- fireEvents(['slide', 'set', 'change']);
598
-
599
- if ( options.events.snap ) {
600
- start(event, { handles: [$Handles[total]] });
601
- }
602
- }
603
-
604
- // Attach events to several slider parts.
605
- function events ( behaviour ) {
606
-
607
- var i, drag;
608
-
609
- // Attach the standard drag event to the handles.
610
- if ( !behaviour.fixed ) {
611
-
612
- for ( i = 0; i < $Handles.length; i += 1 ) {
613
-
614
- // These events are only bound to the visual handle
615
- // element, not the 'real' origin element.
616
- attach ( actions.start, $Handles[i].children(), start, {
617
- handles: [ $Handles[i] ]
618
- });
619
- }
620
- }
621
-
622
- // Attach the tap event to the slider base.
623
- if ( behaviour.tap ) {
624
-
625
- attach ( actions.start, $Base, tap, {
626
- handles: $Handles
627
- });
628
- }
629
-
630
- // Make the range dragable.
631
- if ( behaviour.drag ){
632
-
633
- drag = $Base.find( '.' + Classes[7] ).addClass( Classes[10] );
634
-
635
- // When the range is fixed, the entire range can
636
- // be dragged by the handles. The handle in the first
637
- // origin will propagate the start event upward,
638
- // but it needs to be bound manually on the other.
639
- if ( behaviour.fixed ) {
640
- drag = drag.add($Base.children().not( drag ).children());
641
- }
642
-
643
- attach ( actions.start, drag, start, {
644
- handles: $Handles
645
- });
646
- }
647
- }
648
-
649
-
650
-
651
- // Set the slider value.
652
- function valueSet ( input ) {
653
-
654
- // LibLink: don't accept new values when currently emitting changes.
655
- if ( $Target[0].LinkIsEmitting ) {
656
- return this;
657
- }
658
-
659
- var count, values = asArray( input );
660
-
661
- // The RTL settings is implemented by reversing the front-end,
662
- // internal mechanisms are the same.
663
- if ( options.dir && options.handles > 1 ) {
664
- values.reverse();
665
- }
666
-
667
- // Animation is optional.
668
- // Make sure the initial values where set before using animated
669
- // placement. (no report, unit testing);
670
- if ( options.animate && $Locations[0] !== -1 ) {
671
- addClassFor( $Target, Classes[14], 300 );
672
- }
673
-
674
- // Determine how often to set the handles.
675
- count = $Handles.length > 1 ? 3 : 1;
676
-
677
- if ( values.length === 1 ) {
678
- count = 1;
679
- }
680
-
681
- setValues ( count, values );
682
-
683
- // Fire the 'set' event. As of noUiSlider 7,
684
- // this is no longer optional.
685
- fireEvents(['set']);
686
-
687
- return this;
688
- }
689
-
690
- // Get the slider value.
691
- function valueGet ( ) {
692
-
693
- var i, retour = [];
694
-
695
- // Get the value from all handles.
696
- for ( i = 0; i < options.handles; i += 1 ){
697
- retour[i] = options.format.to( $Values[i] );
698
- }
699
-
700
- return inSliderOrder( retour );
701
- }
702
-
703
-
704
-
705
- // Destroy the slider and unbind all events.
706
- function destroyTarget ( ) {
707
-
708
- // Unbind events on the slider, remove all classes and child elements.
709
- $(this).off(namespace)
710
- .removeClass(Classes.join(' '))
711
- .empty();
712
-
713
- delete this.LinkUpdate;
714
- delete this.LinkConfirm;
715
- delete this.LinkDefaultFormatter;
716
- delete this.LinkDefaultFlag;
717
- delete this.reappend;
718
- delete this.vGet;
719
- delete this.vSet;
720
- delete this.getCurrentStep;
721
- delete this.getInfo;
722
- delete this.destroy;
723
-
724
- // Return the original options from the closure.
725
- return originalOptions;
726
- }
727
-
728
- // Get the current step size for the slider.
729
- function getCurrentStep ( ) {
730
-
731
- // Check all locations, map them to their stepping point.
732
- // Get the step point, then find it in the input list.
733
- var retour = $.map($Locations, function( location, index ){
734
-
735
- var step = $Spectrum.getApplicableStep( location ),
736
- value = $Values[index],
737
- increment = step[2],
738
- decrement = (value - step[2]) >= step[1] ? step[2] : step[0];
739
-
740
- return [[decrement, increment]];
741
- });
742
-
743
- // Return values in the proper order.
744
- return inSliderOrder( retour );
745
- }
746
-
747
-
748
-
749
- // Initialize slider
750
-
751
- // Throw an error if the slider was already initialized.
752
- if ( $Target.hasClass(Classes[0]) ) {
753
- throw new Error('Slider was already initialized.');
754
- }
755
-
756
- // Create the base element, initialise HTML and set classes.
757
- // Add handles and links.
758
- $Base = addSlider( options.dir, options.ort, $Target );
759
- $Handles = addHandles( options.handles, options.dir, $Base );
760
-
761
- // Set the connect classes.
762
- addConnection ( options.connect, $Target, $Handles );
763
-
764
- // Attach user events.
765
- events( options.events );
766
-
767
- // Methods
768
-
769
- target.vSet = valueSet;
770
- target.vGet = valueGet;
771
- target.destroy = destroyTarget;
772
- target.getCurrentStep = getCurrentStep;
773
- target.getInfo = function(){
774
- return [
775
- $Spectrum,
776
- options.style,
777
- options.ort
778
- ];
779
- };
780
-
781
- // Use the public value method to set the start values.
782
- $Target.val( options.start );
783
- }
784
-
785
-
786
- // Access points
787
-
788
- // Run the standard initializer
789
- function initialize ( originalOptions ) {
790
-
791
- // Throw error if group is empty.
792
- if ( !this.length ){
793
- throw new Error("noUiSlider: Can't initialize slider on empty selection.");
794
- }
795
-
796
- // Test the options once, not for every slider.
797
- var options = $.noUiSlider.testOptions( originalOptions, this );
798
-
799
- // Loop all items, and provide a new closed-scope environment.
800
- return this.each(function(){
801
- closure(this, options, originalOptions);
802
- });
803
- }
804
-
805
- // Destroy the slider, then re-enter initialization.
806
- function rebuild ( options ) {
807
-
808
- return this.each(function(){
809
-
810
- // The rebuild flag can be used if the slider wasn't initialized yet.
811
- if ( !this.destroy ) {
812
- $(this).noUiSlider( options );
813
- return;
814
- }
815
-
816
- // Get the current values from the slider,
817
- // including the initialization options.
818
- var values = $(this).val(), originalOptions = this.destroy(),
819
-
820
- // Extend the previous options with the newly provided ones.
821
- newOptions = $.extend( {}, originalOptions, options );
822
-
823
- // Run the standard initializer.
824
- $(this).noUiSlider( newOptions );
825
-
826
- // Place Link elements back.
827
- this.reappend();
828
-
829
- // If the start option hasn't changed,
830
- // reset the previous values.
831
- if ( originalOptions.start === newOptions.start ) {
832
- $(this).val(values);
833
- }
834
- });
835
- }
836
-
837
- // Access the internal getting and setting methods based on argument count.
838
- function value ( ) {
839
- return this[0][ !arguments.length ? 'vGet' : 'vSet' ].apply(this[0], arguments);
840
- }
841
-
842
- // Override the .val() method. Test every element. Is it a slider? Go to
843
- // the slider value handling. No? Use the standard method.
844
- // Note how $.fn.val expects 'this' to be an instance of $. For convenience,
845
- // the above 'value' function does too.
846
- $.fn.val = function ( ) {
847
-
848
- // this === instanceof $
849
-
850
- function valMethod( a ){
851
- return a.hasClass(Classes[0]) ? value : $val;
852
- }
853
-
854
- var args = arguments,
855
- first = $(this[0]);
856
-
857
- if ( !arguments.length ) {
858
- return valMethod(first).call(first);
859
- }
860
-
861
- // Return the set so it remains chainable
862
- return this.each(function(){
863
- valMethod($(this)).apply($(this), args);
864
- });
865
- };
866
-
867
- // Extend jQuery/Zepto with the noUiSlider method.
868
- $.fn.noUiSlider = function ( options, rebuildFlag ) {
869
- return ( rebuildFlag ? rebuild : initialize ).call(this, options);
870
- };
871
-
872
- }( window.jQuery || window.Zepto ));