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,19 +1,22 @@
1
+ 'use strict';
2
+
3
+ !function($) {
4
+
1
5
  /**
2
6
  * Sticky module.
3
7
  * @module foundation.sticky
4
8
  * @requires foundation.util.triggers
5
9
  * @requires foundation.util.mediaQuery
6
10
  */
7
- !function($, Foundation){
8
- 'use strict';
9
11
 
12
+ class Sticky {
10
13
  /**
11
14
  * Creates a new instance of a sticky thing.
12
15
  * @class
13
16
  * @param {jQuery} element - jQuery object to make sticky.
14
17
  * @param {Object} options - options object passed when creating the element programmatically.
15
18
  */
16
- function Sticky(element, options){
19
+ constructor(element, options) {
17
20
  this.$element = element;
18
21
  this.options = $.extend({}, Sticky.defaults, this.$element.data(), options);
19
22
 
@@ -21,163 +24,96 @@
21
24
 
22
25
  Foundation.registerPlugin(this, 'Sticky');
23
26
  }
24
- Sticky.defaults = {
25
- /**
26
- * Customizable container template. Add your own classes for styling and sizing.
27
- * @option
28
- * @example '<div data-sticky-container class="small-6 columns"></div>'
29
- */
30
- container: '<div data-sticky-container></div>',
31
- /**
32
- * Location in the view the element sticks to.
33
- * @option
34
- * @example 'top'
35
- */
36
- stickTo: 'top',
37
- /**
38
- * If anchored to a single element, the id of that element.
39
- * @option
40
- * @example 'exampleId'
41
- */
42
- anchor: '',
43
- /**
44
- * If using more than one element as anchor points, the id of the top anchor.
45
- * @option
46
- * @example 'exampleId:top'
47
- */
48
- topAnchor: '',
49
- /**
50
- * If using more than one element as anchor points, the id of the bottom anchor.
51
- * @option
52
- * @example 'exampleId:bottom'
53
- */
54
- btmAnchor: '',
55
- /**
56
- * Margin, in `em`'s to apply to the top of the element when it becomes sticky.
57
- * @option
58
- * @example 1
59
- */
60
- marginTop: 1,
61
- /**
62
- * Margin, in `em`'s to apply to the bottom of the element when it becomes sticky.
63
- * @option
64
- * @example 1
65
- */
66
- marginBottom: 1,
67
- /**
68
- * Breakpoint string that is the minimum screen size an element should become sticky.
69
- * @option
70
- * @example 'medium'
71
- */
72
- stickyOn: 'medium',
73
- /**
74
- * Class applied to sticky element, and removed on destruction. Foundation defaults to `sticky`.
75
- * @option
76
- * @example 'sticky'
77
- */
78
- stickyClass: 'sticky',
79
- /**
80
- * Class applied to sticky container. Foundation defaults to `sticky-container`.
81
- * @option
82
- * @example 'sticky-container'
83
- */
84
- containerClass: 'sticky-container',
85
- /**
86
- * Number of scroll events between the plugin's recalculating sticky points. Setting it to `0` will cause it to recalc every scroll event, setting it to `-1` will prevent recalc on scroll.
87
- * @option
88
- * @example 50
89
- */
90
- checkEvery: -1
91
- };
92
27
 
93
28
  /**
94
29
  * Initializes the sticky element by adding classes, getting/setting dimensions, breakpoints and attributes
95
30
  * @function
96
31
  * @private
97
32
  */
98
- Sticky.prototype._init = function(){
33
+ _init() {
99
34
  var $parent = this.$element.parent('[data-sticky-container]'),
100
35
  id = this.$element[0].id || Foundation.GetYoDigits(6, 'sticky'),
101
36
  _this = this;
102
37
 
103
- if(!$parent.length){
38
+ if (!$parent.length) {
104
39
  this.wasWrapped = true;
105
40
  }
106
41
  this.$container = $parent.length ? $parent : $(this.options.container).wrapInner(this.$element);
107
42
  this.$container.addClass(this.options.containerClass);
108
43
 
109
-
110
44
  this.$element.addClass(this.options.stickyClass)
111
45
  .attr({'data-resize': id});
112
46
 
113
47
  this.scrollCount = this.options.checkEvery;
114
48
  this.isStuck = false;
49
+ $(window).one('load.zf.sticky', function(){
50
+ if(_this.options.anchor !== ''){
51
+ _this.$anchor = $('#' + _this.options.anchor);
52
+ }else{
53
+ _this._parsePoints();
54
+ }
115
55
 
116
- if(this.options.anchor !== ''){
117
- this.$anchor = $('#' + this.options.anchor);
118
- }else{
119
- this._parsePoints();
120
- }
121
-
122
- this._setSizes(function(){
123
- _this._calc(false);
56
+ _this._setSizes(function(){
57
+ _this._calc(false);
58
+ });
59
+ _this._events(id.split('-').reverse().join('-'));
124
60
  });
125
- this._events(id.split('-').reverse().join('-'));
126
- };
61
+ }
62
+
127
63
  /**
128
64
  * If using multiple elements as anchors, calculates the top and bottom pixel values the sticky thing should stick and unstick on.
129
65
  * @function
130
66
  * @private
131
67
  */
132
- Sticky.prototype._parsePoints = function(){
68
+ _parsePoints() {
133
69
  var top = this.options.topAnchor,
134
70
  btm = this.options.btmAnchor,
135
71
  pts = [top, btm],
136
72
  breaks = {};
137
- if(top && btm){
73
+ if (top && btm) {
138
74
 
139
- for(var i = 0, len = pts.length; i < len && pts[i]; i++){
75
+ for (var i = 0, len = pts.length; i < len && pts[i]; i++) {
140
76
  var pt;
141
- if(typeof pts[i] === 'number'){
77
+ if (typeof pts[i] === 'number') {
142
78
  pt = pts[i];
143
- }else{
79
+ } else {
144
80
  var place = pts[i].split(':'),
145
- anchor = $('#' + place[0]);
81
+ anchor = $(`#${place[0]}`);
146
82
 
147
83
  pt = anchor.offset().top;
148
- if(place[1] && place[1].toLowerCase() === 'bottom'){
84
+ if (place[1] && place[1].toLowerCase() === 'bottom') {
149
85
  pt += anchor[0].getBoundingClientRect().height;
150
86
  }
151
87
  }
152
88
  breaks[i] = pt;
153
89
  }
154
- }else{
90
+ } else {
155
91
  breaks = {0: 1, 1: document.documentElement.scrollHeight};
156
92
  }
157
93
 
158
94
  this.points = breaks;
159
95
  return;
160
- };
96
+ }
161
97
 
162
98
  /**
163
99
  * Adds event handlers for the scrolling element.
164
100
  * @private
165
101
  * @param {String} id - psuedo-random id for unique scroll event listener.
166
102
  */
167
- Sticky.prototype._events = function(id){
103
+ _events(id) {
168
104
  var _this = this,
169
- scrollListener = this.scrollListener = 'scroll.zf.' + id;
170
- if(this.isOn){ return; }
171
- if(this.canStick){
105
+ scrollListener = this.scrollListener = `scroll.zf.${id}`;
106
+ if (this.isOn) { return; }
107
+ if (this.canStick) {
172
108
  this.isOn = true;
173
109
  $(window).off(scrollListener)
174
- .on(scrollListener, function(e){
175
- if(_this.scrollCount === 0){
110
+ .on(scrollListener, function(e) {
111
+ if (_this.scrollCount === 0) {
176
112
  _this.scrollCount = _this.options.checkEvery;
177
- _this._setSizes(function(){
113
+ _this._setSizes(function() {
178
114
  _this._calc(false, window.pageYOffset);
179
115
  });
180
- }else{
116
+ } else {
181
117
  _this.scrollCount--;
182
118
  _this._calc(false, window.pageYOffset);
183
119
  }
@@ -185,26 +121,26 @@
185
121
  }
186
122
 
187
123
  this.$element.off('resizeme.zf.trigger')
188
- .on('resizeme.zf.trigger', function(e, el){
189
- _this._setSizes(function(){
124
+ .on('resizeme.zf.trigger', function(e, el) {
125
+ _this._setSizes(function() {
190
126
  _this._calc(false);
191
- if(_this.canStick){
192
- if(!_this.isOn){
127
+ if (_this.canStick) {
128
+ if (!_this.isOn) {
193
129
  _this._events(id);
194
130
  }
195
- }else if(_this.isOn){
131
+ } else if (_this.isOn) {
196
132
  _this._pauseListeners(scrollListener);
197
133
  }
198
134
  });
199
135
  });
200
- };
136
+ }
201
137
 
202
138
  /**
203
139
  * Removes event handlers for scroll and change events on anchor.
204
140
  * @fires Sticky#pause
205
141
  * @param {String} scrollListener - unique, namespaced scroll listener attached to `window`
206
142
  */
207
- Sticky.prototype._pauseListeners = function(scrollListener){
143
+ _pauseListeners(scrollListener) {
208
144
  this.isOn = false;
209
145
  $(window).off(scrollListener);
210
146
 
@@ -214,7 +150,7 @@
214
150
  * @private
215
151
  */
216
152
  this.$element.trigger('pause.zf.sticky');
217
- };
153
+ }
218
154
 
219
155
  /**
220
156
  * Called on every `scroll` event and on `_init`
@@ -222,34 +158,35 @@
222
158
  * @param {Boolean} checkSizes - true if plugin should recalculate sizes and breakpoints.
223
159
  * @param {Number} scroll - current scroll position passed from scroll event cb function. If not passed, defaults to `window.pageYOffset`.
224
160
  */
225
- Sticky.prototype._calc = function(checkSizes, scroll){
226
- if(checkSizes){ this._setSizes(); }
161
+ _calc(checkSizes, scroll) {
162
+ if (checkSizes) { this._setSizes(); }
227
163
 
228
- if(!this.canStick){
229
- if(this.isStuck){
164
+ if (!this.canStick) {
165
+ if (this.isStuck) {
230
166
  this._removeSticky(true);
231
167
  }
232
168
  return false;
233
169
  }
234
170
 
235
- if(!scroll){ scroll = window.pageYOffset; }
171
+ if (!scroll) { scroll = window.pageYOffset; }
236
172
 
237
- if(scroll >= this.topPoint){
238
- if(scroll <= this.bottomPoint){
239
- if(!this.isStuck){
173
+ if (scroll >= this.topPoint) {
174
+ if (scroll <= this.bottomPoint) {
175
+ if (!this.isStuck) {
240
176
  this._setSticky();
241
177
  }
242
- }else{
243
- if(this.isStuck){
178
+ } else {
179
+ if (this.isStuck) {
244
180
  this._removeSticky(false);
245
181
  }
246
182
  }
247
- }else{
248
- if(this.isStuck){
183
+ } else {
184
+ if (this.isStuck) {
249
185
  this._removeSticky(true);
250
186
  }
251
187
  }
252
- };
188
+ }
189
+
253
190
  /**
254
191
  * Causes the $element to become stuck.
255
192
  * Adds `position: fixed;`, and helper classes.
@@ -257,27 +194,27 @@
257
194
  * @function
258
195
  * @private
259
196
  */
260
- Sticky.prototype._setSticky = function(){
197
+ _setSticky() {
261
198
  var stickTo = this.options.stickTo,
262
199
  mrgn = stickTo === 'top' ? 'marginTop' : 'marginBottom',
263
200
  notStuckTo = stickTo === 'top' ? 'bottom' : 'top',
264
201
  css = {};
265
202
 
266
- css[mrgn] = this.options[mrgn] + 'em';
203
+ css[mrgn] = `${this.options[mrgn]}em`;
267
204
  css[stickTo] = 0;
268
205
  css[notStuckTo] = 'auto';
269
206
  css['left'] = this.$container.offset().left + parseInt(window.getComputedStyle(this.$container[0])["padding-left"], 10);
270
207
  this.isStuck = true;
271
- this.$element.removeClass('is-anchored is-at-' + notStuckTo)
272
- .addClass('is-stuck is-at-' + stickTo)
208
+ this.$element.removeClass(`is-anchored is-at-${notStuckTo}`)
209
+ .addClass(`is-stuck is-at-${stickTo}`)
273
210
  .css(css)
274
211
  /**
275
212
  * Fires when the $element has become `position: fixed;`
276
- * Namespaced to `top` or `bottom`.
213
+ * Namespaced to `top` or `bottom`, e.g. `sticky.zf.stuckto:top`
277
214
  * @event Sticky#stuckto
278
215
  */
279
- .trigger('sticky.zf.stuckto:' + stickTo);
280
- };
216
+ .trigger(`sticky.zf.stuckto:${stickTo}`);
217
+ }
281
218
 
282
219
  /**
283
220
  * Causes the $element to become unstuck.
@@ -287,7 +224,7 @@
287
224
  * @fires Sticky#unstuckfrom
288
225
  * @private
289
226
  */
290
- Sticky.prototype._removeSticky = function(isTop){
227
+ _removeSticky(isTop) {
291
228
  var stickTo = this.options.stickTo,
292
229
  stickToTop = stickTo === 'top',
293
230
  css = {},
@@ -298,26 +235,26 @@
298
235
 
299
236
  css[mrgn] = 0;
300
237
 
301
- if((isTop && !stickToTop) || (stickToTop && !isTop)){
238
+ if ((isTop && !stickToTop) || (stickToTop && !isTop)) {
302
239
  css[stickTo] = anchorPt;
303
240
  css[notStuckTo] = 0;
304
- }else{
241
+ } else {
305
242
  css[stickTo] = 0;
306
243
  css[notStuckTo] = anchorPt;
307
244
  }
308
245
 
309
246
  css['left'] = '';
310
247
  this.isStuck = false;
311
- this.$element.removeClass('is-stuck is-at-' + stickTo)
312
- .addClass('is-anchored is-at-' + topOrBottom)
248
+ this.$element.removeClass(`is-stuck is-at-${stickTo}`)
249
+ .addClass(`is-anchored is-at-${topOrBottom}`)
313
250
  .css(css)
314
251
  /**
315
252
  * Fires when the $element has become anchored.
316
- * Namespaced to `top` or `bottom`.
253
+ * Namespaced to `top` or `bottom`, e.g. `sticky.zf.unstuckfrom:bottom`
317
254
  * @event Sticky#unstuckfrom
318
255
  */
319
- .trigger('sticky.zf.unstuckfrom:' + topOrBottom);
320
- };
256
+ .trigger(`sticky.zf.unstuckfrom:${topOrBottom}`);
257
+ }
321
258
 
322
259
  /**
323
260
  * Sets the $element and $container sizes for plugin.
@@ -325,22 +262,22 @@
325
262
  * @param {Function} cb - optional callback function to fire on completion of `_setBreakPoints`.
326
263
  * @private
327
264
  */
328
- Sticky.prototype._setSizes = function(cb){
265
+ _setSizes(cb) {
329
266
  this.canStick = Foundation.MediaQuery.atLeast(this.options.stickyOn);
330
- if(!this.canStick){ cb(); }
267
+ if (!this.canStick) { cb(); }
331
268
  var _this = this,
332
269
  newElemWidth = this.$container[0].getBoundingClientRect().width,
333
270
  comp = window.getComputedStyle(this.$container[0]),
334
271
  pdng = parseInt(comp['padding-right'], 10);
335
272
 
336
- if(this.$anchor && this.$anchor.length){
273
+ if (this.$anchor && this.$anchor.length) {
337
274
  this.anchorHeight = this.$anchor[0].getBoundingClientRect().height;
338
- }else{
275
+ } else {
339
276
  this._parsePoints();
340
277
  }
341
278
 
342
279
  this.$element.css({
343
- 'max-width': newElemWidth - pdng + 'px'
280
+ 'max-width': `${newElemWidth - pdng}px`
344
281
  });
345
282
 
346
283
  var newContainerHeight = this.$element[0].getBoundingClientRect().height || this.containerHeight;
@@ -354,21 +291,21 @@
354
291
  this.$element.css({"left":this.$container.offset().left + parseInt(comp['padding-left'], 10)});
355
292
  }
356
293
 
357
- this._setBreakPoints(newContainerHeight, function(){
358
- if(cb){ cb(); }
294
+ this._setBreakPoints(newContainerHeight, function() {
295
+ if (cb) { cb(); }
359
296
  });
297
+ }
360
298
 
361
- };
362
299
  /**
363
300
  * Sets the upper and lower breakpoints for the element to become sticky/unsticky.
364
301
  * @param {Number} elemHeight - px value for sticky.$element height, calculated by `_setSizes`.
365
302
  * @param {Function} cb - optional callback function to be called on completion.
366
303
  * @private
367
304
  */
368
- Sticky.prototype._setBreakPoints = function(elemHeight, cb){
369
- if(!this.canStick){
370
- if(cb){ cb(); }
371
- else{ return false; }
305
+ _setBreakPoints(elemHeight, cb) {
306
+ if (!this.canStick) {
307
+ if (cb) { cb(); }
308
+ else { return false; }
372
309
  }
373
310
  var mTop = emCalc(this.options.marginTop),
374
311
  mBtm = emCalc(this.options.marginBottom),
@@ -378,21 +315,21 @@
378
315
  // bottomPoint = topPoint + this.anchorHeight || this.points[1],
379
316
  winHeight = window.innerHeight;
380
317
 
381
- if(this.options.stickTo === 'top'){
318
+ if (this.options.stickTo === 'top') {
382
319
  topPoint -= mTop;
383
320
  bottomPoint -= (elemHeight + mTop);
384
- }else if(this.options.stickTo === 'bottom'){
321
+ } else if (this.options.stickTo === 'bottom') {
385
322
  topPoint -= (winHeight - (elemHeight + mBtm));
386
323
  bottomPoint -= (winHeight - mBtm);
387
- }else{
324
+ } else {
388
325
  //this would be the stickTo: both option... tricky
389
326
  }
390
327
 
391
328
  this.topPoint = topPoint;
392
329
  this.bottomPoint = bottomPoint;
393
330
 
394
- if(cb){ cb(); }
395
- };
331
+ if (cb) { cb(); }
332
+ }
396
333
 
397
334
  /**
398
335
  * Destroys the current sticky element.
@@ -400,10 +337,10 @@
400
337
  * Removes event listeners, JS-added css properties and classes, and unwraps the $element if the JS added the $container.
401
338
  * @function
402
339
  */
403
- Sticky.prototype.destroy = function(){
340
+ destroy() {
404
341
  this._removeSticky(true);
405
342
 
406
- this.$element.removeClass(this.options.stickyClass + ' is-anchored is-at-top')
343
+ this.$element.removeClass(`${this.options.stickyClass} is-anchored is-at-top`)
407
344
  .css({
408
345
  height: '',
409
346
  top: '',
@@ -415,22 +352,96 @@
415
352
  this.$anchor.off('change.zf.sticky');
416
353
  $(window).off(this.scrollListener);
417
354
 
418
- if(this.wasWrapped){
355
+ if (this.wasWrapped) {
419
356
  this.$element.unwrap();
420
- }else{
357
+ } else {
421
358
  this.$container.removeClass(this.options.containerClass)
422
359
  .css({
423
360
  height: ''
424
361
  });
425
362
  }
426
363
  Foundation.unregisterPlugin(this);
427
- };
364
+ }
365
+ }
366
+
367
+ Sticky.defaults = {
428
368
  /**
429
- * Helper function to calculate em values
430
- * @param Number {em} - number of em's to calculate into pixels
369
+ * Customizable container template. Add your own classes for styling and sizing.
370
+ * @option
371
+ * @example '&lt;div data-sticky-container class="small-6 columns"&gt;&lt;/div&gt;'
431
372
  */
432
- function emCalc(em){
433
- return parseInt(window.getComputedStyle(document.body, null).fontSize, 10) * em;
434
- }
435
- Foundation.plugin(Sticky, 'Sticky');
436
- }(jQuery, window.Foundation);
373
+ container: '<div data-sticky-container></div>',
374
+ /**
375
+ * Location in the view the element sticks to.
376
+ * @option
377
+ * @example 'top'
378
+ */
379
+ stickTo: 'top',
380
+ /**
381
+ * If anchored to a single element, the id of that element.
382
+ * @option
383
+ * @example 'exampleId'
384
+ */
385
+ anchor: '',
386
+ /**
387
+ * If using more than one element as anchor points, the id of the top anchor.
388
+ * @option
389
+ * @example 'exampleId:top'
390
+ */
391
+ topAnchor: '',
392
+ /**
393
+ * If using more than one element as anchor points, the id of the bottom anchor.
394
+ * @option
395
+ * @example 'exampleId:bottom'
396
+ */
397
+ btmAnchor: '',
398
+ /**
399
+ * Margin, in `em`'s to apply to the top of the element when it becomes sticky.
400
+ * @option
401
+ * @example 1
402
+ */
403
+ marginTop: 1,
404
+ /**
405
+ * Margin, in `em`'s to apply to the bottom of the element when it becomes sticky.
406
+ * @option
407
+ * @example 1
408
+ */
409
+ marginBottom: 1,
410
+ /**
411
+ * Breakpoint string that is the minimum screen size an element should become sticky.
412
+ * @option
413
+ * @example 'medium'
414
+ */
415
+ stickyOn: 'medium',
416
+ /**
417
+ * Class applied to sticky element, and removed on destruction. Foundation defaults to `sticky`.
418
+ * @option
419
+ * @example 'sticky'
420
+ */
421
+ stickyClass: 'sticky',
422
+ /**
423
+ * Class applied to sticky container. Foundation defaults to `sticky-container`.
424
+ * @option
425
+ * @example 'sticky-container'
426
+ */
427
+ containerClass: 'sticky-container',
428
+ /**
429
+ * Number of scroll events between the plugin's recalculating sticky points. Setting it to `0` will cause it to recalc every scroll event, setting it to `-1` will prevent recalc on scroll.
430
+ * @option
431
+ * @example 50
432
+ */
433
+ checkEvery: -1
434
+ };
435
+
436
+ /**
437
+ * Helper function to calculate em values
438
+ * @param Number {em} - number of em's to calculate into pixels
439
+ */
440
+ function emCalc(em) {
441
+ return parseInt(window.getComputedStyle(document.body, null).fontSize, 10) * em;
442
+ }
443
+
444
+ // Window exports
445
+ Foundation.plugin(Sticky, 'Sticky');
446
+
447
+ }(jQuery);