foundation-rails 6.1.2.0 → 6.2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +7 -6
  3. data/README.md +1 -1
  4. data/Rakefile +5 -1
  5. data/bower.json +3 -3
  6. data/foundation-rails.gemspec +1 -0
  7. data/lib/foundation-rails.rb +1 -0
  8. data/lib/foundation/rails/version.rb +1 -1
  9. data/lib/generators/foundation/templates/foundation_and_overrides.scss +2 -2
  10. data/vendor/assets/js/foundation.abide.js.es6 +462 -0
  11. data/vendor/assets/js/{foundation.accordion.js → foundation.accordion.js.es6} +55 -47
  12. data/vendor/assets/js/{foundation.accordionMenu.js → foundation.accordionMenu.js.es6} +46 -35
  13. data/vendor/assets/js/{foundation.core.js → foundation.core.js.es6} +10 -8
  14. data/vendor/assets/js/{foundation.drilldown.js → foundation.drilldown.js.es6} +75 -49
  15. data/vendor/assets/js/{foundation.dropdown.js → foundation.dropdown.js.es6} +100 -88
  16. data/vendor/assets/js/{foundation.dropdownMenu.js → foundation.dropdownMenu.js.es6} +134 -128
  17. data/vendor/assets/js/{foundation.equalizer.js → foundation.equalizer.js.es6} +72 -61
  18. data/vendor/assets/js/{foundation.interchange.js → foundation.interchange.js.es6} +44 -45
  19. data/vendor/assets/js/{foundation.js → foundation.js.es6} +0 -0
  20. data/vendor/assets/js/{foundation.magellan.js → foundation.magellan.js.es6} +80 -83
  21. data/vendor/assets/js/foundation.offcanvas.js.es6 +395 -0
  22. data/vendor/assets/js/foundation.orbit.js.es6 +445 -0
  23. data/vendor/assets/js/{foundation.responsiveMenu.js → foundation.responsiveMenu.js.es6} +37 -31
  24. data/vendor/assets/js/foundation.responsiveToggle.js.es6 +112 -0
  25. data/vendor/assets/js/foundation.reveal.js.es6 +544 -0
  26. data/vendor/assets/js/{foundation.slider.js → foundation.slider.js.es6} +235 -184
  27. data/vendor/assets/js/{foundation.sticky.js → foundation.sticky.js.es6} +177 -166
  28. data/vendor/assets/js/{foundation.tabs.js → foundation.tabs.js.es6} +138 -118
  29. data/vendor/assets/js/{foundation.toggler.js → foundation.toggler.js.es6} +34 -37
  30. data/vendor/assets/js/{foundation.tooltip.js → foundation.tooltip.js.es6} +162 -153
  31. data/vendor/assets/js/foundation.util.box.js.es6 +183 -0
  32. data/vendor/assets/js/{foundation.util.keyboard.js → foundation.util.keyboard.js.es6} +54 -54
  33. data/vendor/assets/js/{foundation.util.mediaQuery.js → foundation.util.mediaQuery.js.es6} +46 -46
  34. data/vendor/assets/js/{foundation.util.motion.js → foundation.util.motion.js.es6} +58 -48
  35. data/vendor/assets/js/foundation.util.nest.js.es6 +76 -0
  36. data/vendor/assets/js/foundation.util.timerAndImageLoader.js.es6 +86 -0
  37. data/vendor/assets/js/{foundation.util.touch.js → foundation.util.touch.js.es6} +2 -2
  38. data/vendor/assets/js/foundation.util.triggers.js.es6 +239 -0
  39. data/vendor/assets/scss/_global.scss +28 -27
  40. data/vendor/assets/scss/components/_badge.scss +1 -1
  41. data/vendor/assets/scss/components/_button-group.scss +77 -26
  42. data/vendor/assets/scss/components/_button.scss +8 -8
  43. data/vendor/assets/scss/components/_callout.scss +2 -2
  44. data/vendor/assets/scss/components/_drilldown.scss +4 -0
  45. data/vendor/assets/scss/components/_dropdown-menu.scss +104 -54
  46. data/vendor/assets/scss/components/_flex.scss +28 -0
  47. data/vendor/assets/scss/components/_label.scss +1 -1
  48. data/vendor/assets/scss/components/_media-object.scss +37 -7
  49. data/vendor/assets/scss/components/_menu-icon.scss +9 -0
  50. data/vendor/assets/scss/components/_menu.scss +127 -29
  51. data/vendor/assets/scss/components/_off-canvas.scss +1 -0
  52. data/vendor/assets/scss/components/_pagination.scss +3 -3
  53. data/vendor/assets/scss/components/_progress-bar.scss +1 -25
  54. data/vendor/assets/scss/components/_reveal.scss +12 -6
  55. data/vendor/assets/scss/components/_slider.scss +3 -35
  56. data/vendor/assets/scss/components/_table.scss +8 -0
  57. data/vendor/assets/scss/components/_tabs.scss +5 -10
  58. data/vendor/assets/scss/components/_title-bar.scss +27 -10
  59. data/vendor/assets/scss/components/_tooltip.scss +0 -4
  60. data/vendor/assets/scss/components/_top-bar.scss +93 -21
  61. data/vendor/assets/scss/components/_visibility.scss +1 -1
  62. data/vendor/assets/scss/forms/_checkbox.scss +1 -1
  63. data/vendor/assets/scss/forms/_error.scss +7 -5
  64. data/vendor/assets/scss/forms/_forms.scss +3 -0
  65. data/vendor/assets/scss/forms/_help-text.scss +1 -1
  66. data/vendor/assets/scss/forms/_input-group.scss +44 -9
  67. data/vendor/assets/scss/forms/_meter.scss +109 -0
  68. data/vendor/assets/scss/forms/_progress.scss +85 -0
  69. data/vendor/assets/scss/forms/_range.scss +144 -0
  70. data/vendor/assets/scss/forms/_select.scss +1 -1
  71. data/vendor/assets/scss/forms/_text.scss +10 -1
  72. data/vendor/assets/scss/foundation.scss +16 -5
  73. data/vendor/assets/scss/grid/_classes.scss +5 -18
  74. data/vendor/assets/scss/grid/_column.scss +13 -11
  75. data/vendor/assets/scss/grid/_flex-grid.scss +54 -80
  76. data/vendor/assets/scss/grid/_grid.scss +22 -10
  77. data/vendor/assets/scss/grid/_layout.scss +18 -0
  78. data/vendor/assets/scss/grid/_row.scss +11 -15
  79. data/vendor/assets/scss/motion-ui/_classes.scss +10 -3
  80. data/vendor/assets/scss/motion-ui/effects/_fade.scss +4 -1
  81. data/vendor/assets/scss/motion-ui/effects/_zoom.scss +1 -1
  82. data/vendor/assets/scss/motion-ui/transitions/_slide.scss +1 -1
  83. data/vendor/assets/scss/motion-ui/util/_transition.scss +1 -1
  84. data/vendor/assets/scss/settings/_settings.scss +64 -47
  85. data/vendor/assets/scss/typography/_base.scss +4 -0
  86. data/vendor/assets/scss/typography/_print.scss +9 -5
  87. data/vendor/assets/scss/util/_breakpoint.scss +31 -25
  88. data/vendor/assets/scss/util/_color.scss +19 -0
  89. data/vendor/assets/scss/util/_flex.scss +68 -0
  90. data/vendor/assets/scss/util/_mixins.scss +13 -7
  91. data/vendor/assets/scss/util/_util.scss +1 -5
  92. data/vendor/assets/scss/util/_value.scss +9 -28
  93. metadata +51 -31
  94. data/vendor/assets/js/foundation.abide.js +0 -418
  95. data/vendor/assets/js/foundation.offcanvas.js +0 -376
  96. data/vendor/assets/js/foundation.orbit.js +0 -421
  97. data/vendor/assets/js/foundation.responsiveToggle.js +0 -106
  98. data/vendor/assets/js/foundation.reveal.js +0 -514
  99. data/vendor/assets/js/foundation.util.box.js +0 -169
  100. data/vendor/assets/js/foundation.util.nest.js +0 -63
  101. data/vendor/assets/js/foundation.util.timerAndImageLoader.js +0 -82
  102. data/vendor/assets/js/foundation.util.triggers.js +0 -224
@@ -1,3 +1,7 @@
1
+ 'use strict';
2
+
3
+ !function($) {
4
+
1
5
  /**
2
6
  * Slider module.
3
7
  * @module foundation.slider
@@ -6,16 +10,15 @@
6
10
  * @requires foundation.util.keyboard
7
11
  * @requires foundation.util.touch
8
12
  */
9
- !function($, Foundation){
10
- 'use strict';
11
13
 
14
+ class Slider {
12
15
  /**
13
16
  * Creates a new instance of a drilldown menu.
14
17
  * @class
15
18
  * @param {jQuery} element - jQuery object to make into an accordion menu.
16
19
  * @param {Object} options - Overrides to the default plugin settings.
17
20
  */
18
- function Slider(element, options){
21
+ constructor(element, options) {
19
22
  this.$element = element;
20
23
  this.options = $.extend({}, Slider.defaults, this.$element.data(), options);
21
24
 
@@ -42,137 +45,43 @@
42
45
  });
43
46
  }
44
47
 
45
- Slider.defaults = {
46
- /**
47
- * Minimum value for the slider scale.
48
- * @option
49
- * @example 0
50
- */
51
- start: 0,
52
- /**
53
- * Maximum value for the slider scale.
54
- * @option
55
- * @example 100
56
- */
57
- end: 100,
58
- /**
59
- * Minimum value change per change event. Not Currently Implemented!
60
-
61
- */
62
- step: 1,
63
- /**
64
- * Value at which the handle/input *(left handle/first input)* should be set to on initialization.
65
- * @option
66
- * @example 0
67
- */
68
- initialStart: 0,
69
- /**
70
- * Value at which the right handle/second input should be set to on initialization.
71
- * @option
72
- * @example 100
73
- */
74
- initialEnd: 100,
75
- /**
76
- * Allows the input to be located outside the container and visible. Set to by the JS
77
- * @option
78
- * @example false
79
- */
80
- binding: false,
81
- /**
82
- * Allows the user to click/tap on the slider bar to select a value.
83
- * @option
84
- * @example true
85
- */
86
- clickSelect: true,
87
- /**
88
- * Set to true and use the `vertical` class to change alignment to vertical.
89
- * @option
90
- * @example false
91
- */
92
- vertical: false,
93
- /**
94
- * Allows the user to drag the slider handle(s) to select a value.
95
- * @option
96
- * @example true
97
- */
98
- draggable: true,
99
- /**
100
- * Disables the slider and prevents event listeners from being applied. Double checked by JS with `disabledClass`.
101
- * @option
102
- * @example false
103
- */
104
- disabled: false,
105
- /**
106
- * Allows the use of two handles. Double checked by the JS. Changes some logic handling.
107
- * @option
108
- * @example false
109
- */
110
- doubleSided: false,
111
- /**
112
- * Potential future feature.
113
- */
114
- // steps: 100,
115
- /**
116
- * Number of decimal places the plugin should go to for floating point precision.
117
- * @option
118
- * @example 2
119
- */
120
- decimal: 2,
121
- /**
122
- * Time delay for dragged elements.
123
- */
124
- // dragDelay: 0,
125
- /**
126
- * Time, in ms, to animate the movement of a slider handle if user clicks/taps on the bar. Needs to be manually set if updating the transition time in the Sass settings.
127
- * @option
128
- * @example 200
129
- */
130
- moveTime: 200,//update this if changing the transition time in the sass
131
- /**
132
- * Class applied to disabled sliders.
133
- * @option
134
- * @example 'disabled'
135
- */
136
- disabledClass: 'disabled',
137
- invertVertical: false
138
- };
139
48
  /**
140
49
  * Initilizes the plugin by reading/setting attributes, creating collections and setting the initial position of the handle(s).
141
50
  * @function
142
51
  * @private
143
52
  */
144
- Slider.prototype._init = function(){
53
+ _init() {
145
54
  this.inputs = this.$element.find('input');
146
55
  this.handles = this.$element.find('[data-slider-handle]');
147
56
 
148
57
  this.$handle = this.handles.eq(0);
149
- this.$input = this.inputs.length ? this.inputs.eq(0) : $('#' + this.$handle.attr('aria-controls'));
58
+ this.$input = this.inputs.length ? this.inputs.eq(0) : $(`#${this.$handle.attr('aria-controls')}`);
150
59
  this.$fill = this.$element.find('[data-slider-fill]').css(this.options.vertical ? 'height' : 'width', 0);
151
60
 
152
61
  var isDbl = false,
153
62
  _this = this;
154
- if(this.options.disabled || this.$element.hasClass(this.options.disabledClass)){
63
+ if (this.options.disabled || this.$element.hasClass(this.options.disabledClass)) {
155
64
  this.options.disabled = true;
156
65
  this.$element.addClass(this.options.disabledClass);
157
66
  }
158
- if(!this.inputs.length){
67
+ if (!this.inputs.length) {
159
68
  this.inputs = $().add(this.$input);
160
69
  this.options.binding = true;
161
70
  }
162
71
  this._setInitAttr(0);
163
72
  this._events(this.$handle);
164
73
 
165
- if(this.handles[1]){
74
+ if (this.handles[1]) {
166
75
  this.options.doubleSided = true;
167
76
  this.$handle2 = this.handles.eq(1);
168
- this.$input2 = this.inputs.length > 1 ? this.inputs.eq(1) : $('#' + this.$handle2.attr('aria-controls'));
77
+ this.$input2 = this.inputs.length > 1 ? this.inputs.eq(1) : $(`#${this.$handle2.attr('aria-controls')}`);
169
78
 
170
- if(!this.inputs[1]){
79
+ if (!this.inputs[1]) {
171
80
  this.inputs = this.inputs.add(this.$input2);
172
81
  }
173
82
  isDbl = true;
174
83
 
175
- this._setHandlePos(this.$handle, this.options.initialStart, true, function(){
84
+ this._setHandlePos(this.$handle, this.options.initialStart, true, function() {
176
85
 
177
86
  _this._setHandlePos(_this.$handle2, _this.options.initialEnd, true);
178
87
  });
@@ -181,10 +90,11 @@
181
90
  this._events(this.$handle2);
182
91
  }
183
92
 
184
- if(!isDbl){
93
+ if (!isDbl) {
185
94
  this._setHandlePos(this.$handle, this.options.initialStart, true);
186
95
  }
187
- };
96
+ }
97
+
188
98
  /**
189
99
  * Sets the position of the selected handle and fill bar.
190
100
  * @function
@@ -194,21 +104,21 @@
194
104
  * @param {Function} cb - callback function to fire on completion.
195
105
  * @fires Slider#moved
196
106
  */
197
- Slider.prototype._setHandlePos = function($hndl, location, noInvert, cb){
107
+ _setHandlePos($hndl, location, noInvert, cb) {
198
108
  //might need to alter that slightly for bars that will have odd number selections.
199
109
  location = parseFloat(location);//on input change events, convert string to number...grumble.
200
110
 
201
111
  // prevent slider from running out of bounds, if value exceeds the limits set through options, override the value to min/max
202
- if(location < this.options.start){ location = this.options.start; }
203
- else if(location > this.options.end){ location = this.options.end; }
112
+ if (location < this.options.start) { location = this.options.start; }
113
+ else if (location > this.options.end) { location = this.options.end; }
204
114
 
205
115
  var isDbl = this.options.doubleSided;
206
116
 
207
- if(isDbl){ //this block is to prevent 2 handles from crossing eachother. Could/should be improved.
208
- if(this.handles.index($hndl) === 0){
117
+ if (isDbl) { //this block is to prevent 2 handles from crossing eachother. Could/should be improved.
118
+ if (this.handles.index($hndl) === 0) {
209
119
  var h2Val = parseFloat(this.$handle2.attr('aria-valuenow'));
210
120
  location = location >= h2Val ? h2Val - this.options.step : location;
211
- }else{
121
+ } else {
212
122
  var h1Val = parseFloat(this.$handle.attr('aria-valuenow'));
213
123
  location = location <= h1Val ? h1Val + this.options.step : location;
214
124
  }
@@ -216,7 +126,7 @@
216
126
 
217
127
  //this is for single-handled vertical sliders, it adjusts the value to account for the slider being "upside-down"
218
128
  //for click and drag events, it's weird due to the scale(-1, 1) css property
219
- if(this.options.vertical && !noInvert){
129
+ if (this.options.vertical && !noInvert) {
220
130
  location = this.options.end - location;
221
131
  }
222
132
 
@@ -231,42 +141,42 @@
231
141
  //number of actual pixels to shift the handle, based on the percentage obtained above
232
142
  pxToMove = (elemDim - handleDim) * pctOfBar,
233
143
  //percentage of bar to shift the handle
234
- movement = (percent(pxToMove, elemDim) * 100).toFixed(this.options.decimal),
144
+ movement = (percent(pxToMove, elemDim) * 100).toFixed(this.options.decimal);
235
145
  //fixing the decimal value for the location number, is passed to other methods as a fixed floating-point value
236
- location = parseFloat(location.toFixed(this.options.decimal)),
146
+ location = parseFloat(location.toFixed(this.options.decimal));
237
147
  // declare empty object for css adjustments, only used with 2 handled-sliders
238
- css = {};
148
+ var css = {};
239
149
 
240
150
  this._setValues($hndl, location);
241
151
 
242
152
  // TODO update to calculate based on values set to respective inputs??
243
- if(isDbl){
153
+ if (isDbl) {
244
154
  var isLeftHndl = this.handles.index($hndl) === 0,
245
155
  //empty variable, will be used for min-height/width for fill bar
246
156
  dim,
247
157
  //percentage w/h of the handle compared to the slider bar
248
158
  handlePct = ~~(percent(handleDim, elemDim) * 100);
249
159
  //if left handle, the math is slightly different than if it's the right handle, and the left/top property needs to be changed for the fill bar
250
- if(isLeftHndl){
160
+ if (isLeftHndl) {
251
161
  //left or top percentage value to apply to the fill bar.
252
- css[lOrT] = movement + '%';
162
+ css[lOrT] = `${movement}%`;
253
163
  //calculate the new min-height/width for the fill bar.
254
164
  dim = parseFloat(this.$handle2[0].style[lOrT]) - movement + handlePct;
255
165
  //this callback is necessary to prevent errors and allow the proper placement and initialization of a 2-handled slider
256
166
  //plus, it means we don't care if 'dim' isNaN on init, it won't be in the future.
257
- if(cb && typeof cb === 'function'){ cb(); }//this is only needed for the initialization of 2 handled sliders
258
- }else{
167
+ if (cb && typeof cb === 'function') { cb(); }//this is only needed for the initialization of 2 handled sliders
168
+ } else {
259
169
  //just caching the value of the left/bottom handle's left/top property
260
170
  var handlePos = parseFloat(this.$handle[0].style[lOrT]);
261
171
  //calculate the new min-height/width for the fill bar. Use isNaN to prevent false positives for numbers <= 0
262
172
  //based on the percentage of movement of the handle being manipulated, less the opposing handle's left/top position, plus the percentage w/h of the handle itself
263
- dim = movement - (isNaN(handlePos) ? this.options.initialStart : handlePos) + handlePct;
173
+ dim = movement - (isNaN(handlePos) ? this.options.initialStart/((this.options.end-this.options.start)/100) : handlePos) + handlePct;
264
174
  }
265
175
  // assign the min-height/width to our css object
266
- css['min-' + hOrW] = dim + '%';
176
+ css[`min-${hOrW}`] = `${dim}%`;
267
177
  }
268
178
 
269
- this.$element.one('finished.zf.animate', function(){
179
+ this.$element.one('finished.zf.animate', function() {
270
180
  /**
271
181
  * Fires when the handle is done moving.
272
182
  * @event Slider#moved
@@ -277,33 +187,33 @@
277
187
  //because we don't know exactly how the handle will be moved, check the amount of time it should take to move.
278
188
  var moveTime = this.$element.data('dragging') ? 1000/60 : this.options.moveTime;
279
189
 
280
- Foundation.Move(moveTime, $hndl, function(){
190
+ Foundation.Move(moveTime, $hndl, function() {
281
191
  //adjusting the left/top property of the handle, based on the percentage calculated above
282
- $hndl.css(lOrT, movement + '%');
192
+ $hndl.css(lOrT, `${movement}%`);
283
193
 
284
- if(!_this.options.doubleSided){
194
+ if (!_this.options.doubleSided) {
285
195
  //if single-handled, a simple method to expand the fill bar
286
- _this.$fill.css(hOrW, pctOfBar * 100 + '%');
287
- }else{
196
+ _this.$fill.css(hOrW, `${pctOfBar * 100}%`);
197
+ } else {
288
198
  //otherwise, use the css object we created above
289
199
  _this.$fill.css(css);
290
200
  }
291
201
  });
202
+ }
292
203
 
293
- };
294
204
  /**
295
205
  * Sets the initial attribute for the slider element.
296
206
  * @function
297
207
  * @private
298
208
  * @param {Number} idx - index of the current handle/input to use.
299
209
  */
300
- Slider.prototype._setInitAttr = function(idx){
210
+ _setInitAttr(idx) {
301
211
  var id = this.inputs.eq(idx).attr('id') || Foundation.GetYoDigits(6, 'slider');
302
212
  this.inputs.eq(idx).attr({
303
213
  'id': id,
304
214
  'max': this.options.end,
305
- 'min': this.options.start
306
-
215
+ 'min': this.options.start,
216
+ 'step': this.options.step
307
217
  });
308
218
  this.handles.eq(idx).attr({
309
219
  'role': 'slider',
@@ -314,7 +224,8 @@
314
224
  'aria-orientation': this.options.vertical ? 'vertical' : 'horizontal',
315
225
  'tabindex': 0
316
226
  });
317
- };
227
+ }
228
+
318
229
  /**
319
230
  * Sets the input and `aria-valuenow` values for the slider element.
320
231
  * @function
@@ -322,11 +233,12 @@
322
233
  * @param {jQuery} $handle - the currently selected handle.
323
234
  * @param {Number} val - floating point of the new value.
324
235
  */
325
- Slider.prototype._setValues = function($handle, val){
236
+ _setValues($handle, val) {
326
237
  var idx = this.options.doubleSided ? this.handles.index($handle) : 0;
327
238
  this.inputs.eq(idx).val(val);
328
239
  $handle.attr('aria-valuenow', val);
329
- };
240
+ }
241
+
330
242
  /**
331
243
  * Handles events on the slider element.
332
244
  * Calculates the new location of the current handle.
@@ -338,9 +250,9 @@
338
250
  * @param {Number} val - floating point number for the new value of the slider.
339
251
  * TODO clean this up, there's a lot of repeated code between this and the _setHandlePos fn.
340
252
  */
341
- Slider.prototype._handleEvent = function(e, $handle, val){
253
+ _handleEvent(e, $handle, val) {
342
254
  var value, hasVal;
343
- if(!val){//click or drag events
255
+ if (!val) {//click or drag events
344
256
  e.preventDefault();
345
257
  var _this = this,
346
258
  vertical = this.options.vertical,
@@ -354,73 +266,107 @@
354
266
  barXY = barOffset > 0 ? -halfOfHandle : (barOffset - halfOfHandle) < -barDim ? barDim : Math.abs(barOffset),
355
267
  offsetPct = percent(barXY, barDim);
356
268
  value = (this.options.end - this.options.start) * offsetPct;
269
+
357
270
  // turn everything around for RTL, yay math!
358
271
  if (Foundation.rtl() && !this.options.vertical) {value = this.options.end - value;}
272
+
273
+ value = _this._adjustValue(null, value);
359
274
  //boolean flag for the setHandlePos fn, specifically for vertical sliders
360
275
  hasVal = false;
361
276
 
362
- if(!$handle){//figure out which handle it is, pass it to the next function.
277
+ if (!$handle) {//figure out which handle it is, pass it to the next function.
363
278
  var firstHndlPos = absPosition(this.$handle, direction, barXY, param),
364
279
  secndHndlPos = absPosition(this.$handle2, direction, barXY, param);
365
280
  $handle = firstHndlPos <= secndHndlPos ? this.$handle : this.$handle2;
366
281
  }
367
282
 
368
- }else{//change event on input
369
- value = val;
283
+ } else {//change event on input
284
+ value = this._adjustValue(null, val);
370
285
  hasVal = true;
371
286
  }
372
287
 
373
288
  this._setHandlePos($handle, value, hasVal);
374
- };
289
+ }
290
+
291
+ /**
292
+ * Adjustes value for handle in regard to step value. returns adjusted value
293
+ * @function
294
+ * @private
295
+ * @param {jQuery} $handle - the selected handle.
296
+ * @param {Number} value - value to adjust. used if $handle is falsy
297
+ */
298
+ _adjustValue($handle, value) {
299
+ var val,
300
+ step = this.options.step,
301
+ div = parseFloat(step/2),
302
+ left, prev_val, next_val;
303
+ if (!!$handle) {
304
+ val = parseFloat($handle.attr('aria-valuenow'));
305
+ }
306
+ else {
307
+ val = value;
308
+ }
309
+ left = val % step;
310
+ prev_val = val - left;
311
+ next_val = prev_val + step;
312
+ if (left === 0) {
313
+ return val;
314
+ }
315
+ val = val >= prev_val + div ? next_val : prev_val;
316
+ return val;
317
+ }
318
+
375
319
  /**
376
320
  * Adds event listeners to the slider elements.
377
321
  * @function
378
322
  * @private
379
323
  * @param {jQuery} $handle - the current handle to apply listeners to.
380
324
  */
381
- Slider.prototype._events = function($handle){
382
- if(this.options.disabled){ return false; }
325
+ _events($handle) {
326
+ if (this.options.disabled) { return false; }
383
327
 
384
328
  var _this = this,
385
329
  curHandle,
386
330
  timer;
387
331
 
388
- this.inputs.off('change.zf.slider').on('change.zf.slider', function(e){
332
+ this.inputs.off('change.zf.slider').on('change.zf.slider', function(e) {
389
333
  var idx = _this.inputs.index($(this));
390
334
  _this._handleEvent(e, _this.handles.eq(idx), $(this).val());
391
335
  });
392
336
 
393
- if(this.options.clickSelect){
394
- this.$element.off('click.zf.slider').on('click.zf.slider', function(e){
395
- if(_this.$element.data('dragging')){ return false; }
396
-
397
- if(_this.options.doubleSided){
398
- _this._handleEvent(e);
399
- }else{
400
- _this._handleEvent(e, _this.$handle);
401
- }
402
- });
403
- }
337
+ if (this.options.clickSelect) {
338
+ this.$element.off('click.zf.slider').on('click.zf.slider', function(e) {
339
+ if (_this.$element.data('dragging')) { return false; }
340
+
341
+ if (!$(e.target).is('[data-slider-handle]')) {
342
+ if (_this.options.doubleSided) {
343
+ _this._handleEvent(e);
344
+ } else {
345
+ _this._handleEvent(e, _this.$handle);
346
+ }
347
+ }
348
+ });
349
+ }
404
350
 
405
- if(this.options.draggable){
351
+ if (this.options.draggable) {
406
352
  this.handles.addTouch();
407
353
 
408
354
  var $body = $('body');
409
355
  $handle
410
356
  .off('mousedown.zf.slider')
411
- .on('mousedown.zf.slider', function(e){
357
+ .on('mousedown.zf.slider', function(e) {
412
358
  $handle.addClass('is-dragging');
413
359
  _this.$fill.addClass('is-dragging');//
414
360
  _this.$element.data('dragging', true);
415
361
 
416
362
  curHandle = $(e.currentTarget);
417
363
 
418
- $body.on('mousemove.zf.slider', function(e){
364
+ $body.on('mousemove.zf.slider', function(e) {
419
365
  e.preventDefault();
420
366
 
421
367
  _this._handleEvent(e, curHandle);
422
368
 
423
- }).on('mouseup.zf.slider', function(e){
369
+ }).on('mouseup.zf.slider', function(e) {
424
370
  _this._handleEvent(e, curHandle);
425
371
 
426
372
  $handle.removeClass('is-dragging');
@@ -431,13 +377,13 @@
431
377
  });
432
378
  });
433
379
  }
434
- $handle.off('keydown.zf.slider').on('keydown.zf.slider', function(e){
380
+
381
+ $handle.off('keydown.zf.slider').on('keydown.zf.slider', function(e) {
435
382
  var _$handle = $(this),
436
383
  idx = _this.options.doubleSided ? _this.handles.index(_$handle) : 0,
437
384
  oldValue = parseFloat(_this.inputs.eq(idx).val()),
438
385
  newValue;
439
386
 
440
-
441
387
  // handle keyboard event with keyboard util
442
388
  Foundation.Keyboard.handleKey(e, 'Slider', {
443
389
  decrease: function() {
@@ -462,46 +408,151 @@
462
408
  _this._setHandlePos(_$handle, newValue);
463
409
  }*/
464
410
  });
465
- };
411
+ }
412
+
466
413
  /**
467
414
  * Destroys the slider plugin.
468
415
  */
469
- Slider.prototype.destroy = function(){
470
- this.handles.off('.zf.slider');
471
- this.inputs.off('.zf.slider');
472
- this.$element.off('.zf.slider');
416
+ destroy() {
417
+ this.handles.off('.zf.slider');
418
+ this.inputs.off('.zf.slider');
419
+ this.$element.off('.zf.slider');
473
420
 
474
- Foundation.unregisterPlugin(this);
475
- };
421
+ Foundation.unregisterPlugin(this);
422
+ }
423
+ }
476
424
 
477
- Foundation.plugin(Slider, 'Slider');
425
+ Slider.defaults = {
426
+ /**
427
+ * Minimum value for the slider scale.
428
+ * @option
429
+ * @example 0
430
+ */
431
+ start: 0,
432
+ /**
433
+ * Maximum value for the slider scale.
434
+ * @option
435
+ * @example 100
436
+ */
437
+ end: 100,
438
+ /**
439
+ * Minimum value change per change event.
440
+ * @option
441
+ * @example 1
442
+ */
443
+ step: 1,
444
+ /**
445
+ * Value at which the handle/input *(left handle/first input)* should be set to on initialization.
446
+ * @option
447
+ * @example 0
448
+ */
449
+ initialStart: 0,
450
+ /**
451
+ * Value at which the right handle/second input should be set to on initialization.
452
+ * @option
453
+ * @example 100
454
+ */
455
+ initialEnd: 100,
456
+ /**
457
+ * Allows the input to be located outside the container and visible. Set to by the JS
458
+ * @option
459
+ * @example false
460
+ */
461
+ binding: false,
462
+ /**
463
+ * Allows the user to click/tap on the slider bar to select a value.
464
+ * @option
465
+ * @example true
466
+ */
467
+ clickSelect: true,
468
+ /**
469
+ * Set to true and use the `vertical` class to change alignment to vertical.
470
+ * @option
471
+ * @example false
472
+ */
473
+ vertical: false,
474
+ /**
475
+ * Allows the user to drag the slider handle(s) to select a value.
476
+ * @option
477
+ * @example true
478
+ */
479
+ draggable: true,
480
+ /**
481
+ * Disables the slider and prevents event listeners from being applied. Double checked by JS with `disabledClass`.
482
+ * @option
483
+ * @example false
484
+ */
485
+ disabled: false,
486
+ /**
487
+ * Allows the use of two handles. Double checked by the JS. Changes some logic handling.
488
+ * @option
489
+ * @example false
490
+ */
491
+ doubleSided: false,
492
+ /**
493
+ * Potential future feature.
494
+ */
495
+ // steps: 100,
496
+ /**
497
+ * Number of decimal places the plugin should go to for floating point precision.
498
+ * @option
499
+ * @example 2
500
+ */
501
+ decimal: 2,
502
+ /**
503
+ * Time delay for dragged elements.
504
+ */
505
+ // dragDelay: 0,
506
+ /**
507
+ * Time, in ms, to animate the movement of a slider handle if user clicks/taps on the bar. Needs to be manually set if updating the transition time in the Sass settings.
508
+ * @option
509
+ * @example 200
510
+ */
511
+ moveTime: 200,//update this if changing the transition time in the sass
512
+ /**
513
+ * Class applied to disabled sliders.
514
+ * @option
515
+ * @example 'disabled'
516
+ */
517
+ disabledClass: 'disabled',
518
+ /**
519
+ * Will invert the default layout for a vertical<span data-tooltip title="who would do this???"> </span>slider.
520
+ * @option
521
+ * @example false
522
+ */
523
+ invertVertical: false
524
+ };
478
525
 
479
- function percent(frac, num){
480
- return (frac / num);
481
- }
482
- function absPosition($handle, dir, clickPos, param){
483
- return Math.abs(($handle.position()[dir] + ($handle[param]() / 2)) - clickPos);
484
- }
485
- }(jQuery, window.Foundation);
526
+ function percent(frac, num) {
527
+ return (frac / num);
528
+ }
529
+ function absPosition($handle, dir, clickPos, param) {
530
+ return Math.abs(($handle.position()[dir] + ($handle[param]() / 2)) - clickPos);
531
+ }
532
+
533
+ // Window exports
534
+ Foundation.plugin(Slider, 'Slider');
535
+
536
+ }(jQuery);
486
537
 
487
538
  //*********this is in case we go to static, absolute positions instead of dynamic positioning********
488
- // this.setSteps(function(){
539
+ // this.setSteps(function() {
489
540
  // _this._events();
490
541
  // var initStart = _this.options.positions[_this.options.initialStart - 1] || null;
491
542
  // var initEnd = _this.options.initialEnd ? _this.options.position[_this.options.initialEnd - 1] : null;
492
- // if(initStart || initEnd){
543
+ // if (initStart || initEnd) {
493
544
  // _this._handleEvent(initStart, initEnd);
494
545
  // }
495
546
  // });
496
547
 
497
548
  //***********the other part of absolute positions*************
498
- // Slider.prototype.setSteps = function(cb){
549
+ // Slider.prototype.setSteps = function(cb) {
499
550
  // var posChange = this.$element.outerWidth() / this.options.steps;
500
551
  // var counter = 0
501
- // while(counter < this.options.steps){
502
- // if(counter){
552
+ // while(counter < this.options.steps) {
553
+ // if (counter) {
503
554
  // this.options.positions.push(this.options.positions[counter - 1] + posChange);
504
- // }else{
555
+ // } else {
505
556
  // this.options.positions.push(posChange);
506
557
  // }
507
558
  // counter++;