foundation-rails 6.3.1.0 → 6.4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/bower.json +3 -3
  3. data/lib/foundation/rails/version.rb +1 -1
  4. data/lib/generators/foundation/install_generator.rb +1 -1
  5. data/lib/generators/foundation/templates/_settings.scss +291 -48
  6. data/vendor/assets/js/entries/foundation-plugins.js +25 -0
  7. data/vendor/assets/js/entries/foundation.js +101 -0
  8. data/vendor/assets/js/entries/plugins/foundation.abide.js +4 -0
  9. data/vendor/assets/js/entries/plugins/foundation.accordion.js +4 -0
  10. data/vendor/assets/js/entries/plugins/foundation.accordionMenu.js +5 -0
  11. data/vendor/assets/js/entries/plugins/foundation.core.js +21 -0
  12. data/vendor/assets/js/entries/plugins/foundation.drilldown.js +4 -0
  13. data/vendor/assets/js/entries/plugins/foundation.dropdown.js +5 -0
  14. data/vendor/assets/js/entries/plugins/foundation.dropdownMenu.js +4 -0
  15. data/vendor/assets/js/entries/plugins/foundation.equalizer.js +4 -0
  16. data/vendor/assets/js/entries/plugins/foundation.interchange.js +4 -0
  17. data/vendor/assets/js/entries/plugins/foundation.magellan.js +4 -0
  18. data/vendor/assets/js/entries/plugins/foundation.offcanvas.js +4 -0
  19. data/vendor/assets/js/entries/plugins/foundation.orbit.js +5 -0
  20. data/vendor/assets/js/entries/plugins/foundation.responsiveAccordionTabs.js +5 -0
  21. data/vendor/assets/js/entries/plugins/foundation.responsiveMenu.js +5 -0
  22. data/vendor/assets/js/entries/plugins/foundation.responsiveToggle.js +5 -0
  23. data/vendor/assets/js/entries/plugins/foundation.reveal.js +4 -0
  24. data/vendor/assets/js/entries/plugins/foundation.slider.js +5 -0
  25. data/vendor/assets/js/entries/plugins/foundation.smoothScroll.js +5 -0
  26. data/vendor/assets/js/entries/plugins/foundation.sticky.js +5 -0
  27. data/vendor/assets/js/entries/plugins/foundation.tabs.js +5 -0
  28. data/vendor/assets/js/entries/plugins/foundation.toggler.js +5 -0
  29. data/vendor/assets/js/entries/plugins/foundation.tooltip.js +4 -0
  30. data/vendor/assets/js/entries/plugins/foundation.util.box.js +4 -0
  31. data/vendor/assets/js/entries/plugins/foundation.util.imageLoader.js +5 -0
  32. data/vendor/assets/js/entries/plugins/foundation.util.keyboard.js +4 -0
  33. data/vendor/assets/js/entries/plugins/foundation.util.mediaQuery.js +4 -0
  34. data/vendor/assets/js/entries/plugins/foundation.util.motion.js +5 -0
  35. data/vendor/assets/js/entries/plugins/foundation.util.nest.js +5 -0
  36. data/vendor/assets/js/entries/plugins/foundation.util.timer.js +5 -0
  37. data/vendor/assets/js/entries/plugins/foundation.util.touch.js +7 -0
  38. data/vendor/assets/js/entries/plugins/foundation.util.triggers.js +5 -0
  39. data/vendor/assets/js/foundation.abide.js.es6 +18 -15
  40. data/vendor/assets/js/foundation.accordion.js.es6 +37 -23
  41. data/vendor/assets/js/foundation.accordionMenu.js.es6 +96 -51
  42. data/vendor/assets/js/foundation.core.js.es6 +46 -87
  43. data/vendor/assets/js/foundation.drilldown.js.es6 +47 -29
  44. data/vendor/assets/js/foundation.dropdown.js.es6 +84 -122
  45. data/vendor/assets/js/foundation.dropdownMenu.js.es6 +44 -28
  46. data/vendor/assets/js/foundation.equalizer.js.es6 +18 -17
  47. data/vendor/assets/js/foundation.interchange.js.es6 +26 -19
  48. data/vendor/assets/js/foundation.js.es6 +8 -3
  49. data/vendor/assets/js/foundation.magellan.js.es6 +36 -30
  50. data/vendor/assets/js/foundation.offcanvas.js.es6 +148 -36
  51. data/vendor/assets/js/foundation.orbit.js.es6 +26 -18
  52. data/vendor/assets/js/foundation.plugin.js.es6 +54 -0
  53. data/vendor/assets/js/foundation.positionable.js.es6 +206 -0
  54. data/vendor/assets/js/{foundation.zf.responsiveAccordionTabs.js.es6 → foundation.responsiveAccordionTabs.js.es6} +33 -30
  55. data/vendor/assets/js/foundation.responsiveMenu.js.es6 +37 -29
  56. data/vendor/assets/js/foundation.responsiveToggle.js.es6 +17 -16
  57. data/vendor/assets/js/foundation.reveal.js.es6 +61 -79
  58. data/vendor/assets/js/foundation.slider.js.es6 +33 -18
  59. data/vendor/assets/js/foundation.smoothScroll.js.es6 +135 -0
  60. data/vendor/assets/js/foundation.sticky.js.es6 +25 -17
  61. data/vendor/assets/js/foundation.tabs.js.es6 +35 -27
  62. data/vendor/assets/js/foundation.toggler.js.es6 +15 -13
  63. data/vendor/assets/js/foundation.tooltip.js.es6 +100 -108
  64. data/vendor/assets/js/foundation.util.box.js.es6 +114 -78
  65. data/vendor/assets/js/foundation.util.core.js.es6 +52 -0
  66. data/vendor/assets/js/foundation.util.imageLoader.js.es6 +45 -0
  67. data/vendor/assets/js/foundation.util.keyboard.js.es6 +41 -31
  68. data/vendor/assets/js/foundation.util.mediaQuery.js.es6 +59 -55
  69. data/vendor/assets/js/foundation.util.motion.js.es6 +4 -5
  70. data/vendor/assets/js/foundation.util.nest.js.es6 +9 -23
  71. data/vendor/assets/js/{foundation.util.timerAndImageLoader.js.es6 → foundation.util.timer.js.es6} +2 -42
  72. data/vendor/assets/js/foundation.util.touch.js.es6 +91 -294
  73. data/vendor/assets/js/foundation.util.triggers.js.es6 +199 -141
  74. data/vendor/assets/scss/_global.scss +29 -1
  75. data/vendor/assets/scss/components/_accordion-menu.scss +148 -13
  76. data/vendor/assets/scss/components/_accordion.scss +5 -0
  77. data/vendor/assets/scss/components/_breadcrumbs.scss +26 -9
  78. data/vendor/assets/scss/components/_button-group.scss +4 -4
  79. data/vendor/assets/scss/components/_button.scss +59 -12
  80. data/vendor/assets/scss/components/_card.scss +10 -2
  81. data/vendor/assets/scss/components/_drilldown.scss +90 -41
  82. data/vendor/assets/scss/components/_dropdown-menu.scss +52 -6
  83. data/vendor/assets/scss/components/_dropdown.scss +8 -1
  84. data/vendor/assets/scss/components/_flex.scss +85 -2
  85. data/vendor/assets/scss/components/_menu.scss +267 -162
  86. data/vendor/assets/scss/components/_off-canvas.scss +159 -45
  87. data/vendor/assets/scss/components/_pagination.scss +1 -1
  88. data/vendor/assets/scss/components/_reveal.scss +13 -11
  89. data/vendor/assets/scss/components/_slider.scss +0 -1
  90. data/vendor/assets/scss/components/_sticky.scss +1 -0
  91. data/vendor/assets/scss/components/_table.scss +7 -6
  92. data/vendor/assets/scss/components/_tabs.scss +1 -1
  93. data/vendor/assets/scss/components/_title-bar.scss +1 -1
  94. data/vendor/assets/scss/components/_tooltip.scss +74 -21
  95. data/vendor/assets/scss/components/_top-bar.scss +2 -0
  96. data/vendor/assets/scss/forms/_fieldset.scss +0 -1
  97. data/vendor/assets/scss/forms/_meter.scss +7 -1
  98. data/vendor/assets/scss/forms/_select.scss +4 -3
  99. data/vendor/assets/scss/forms/_text.scss +11 -2
  100. data/vendor/assets/scss/foundation.scss +17 -3
  101. data/vendor/assets/scss/grid/_flex-grid.scss +3 -52
  102. data/vendor/assets/scss/prototype/_arrow.scss +36 -0
  103. data/vendor/assets/scss/prototype/_border-box.scss +35 -0
  104. data/vendor/assets/scss/prototype/_border-none.scss +35 -0
  105. data/vendor/assets/scss/prototype/_bordered.scss +54 -0
  106. data/vendor/assets/scss/prototype/_box.scss +23 -0
  107. data/vendor/assets/scss/prototype/_display.scss +50 -0
  108. data/vendor/assets/scss/prototype/_font-styling.scss +95 -0
  109. data/vendor/assets/scss/prototype/_list-style-type.scss +95 -0
  110. data/vendor/assets/scss/prototype/_overflow.scss +72 -0
  111. data/vendor/assets/scss/prototype/_position.scss +114 -0
  112. data/vendor/assets/scss/prototype/_prototype.scss +91 -0
  113. data/vendor/assets/scss/prototype/_relation.scss +157 -0
  114. data/vendor/assets/scss/prototype/_rotate.scss +31 -0
  115. data/vendor/assets/scss/prototype/_rounded.scss +54 -0
  116. data/vendor/assets/scss/prototype/_separator.scss +96 -0
  117. data/vendor/assets/scss/prototype/_shadow.scss +43 -0
  118. data/vendor/assets/scss/prototype/_sizing.scss +73 -0
  119. data/vendor/assets/scss/prototype/_spacing.scss +204 -0
  120. data/vendor/assets/scss/prototype/_text-decoration.scss +48 -0
  121. data/vendor/assets/scss/prototype/_text-transformation.scss +48 -0
  122. data/vendor/assets/scss/prototype/_text-utilities.scss +88 -0
  123. data/vendor/assets/scss/prototype/_typescale.scss +20 -0
  124. data/vendor/assets/scss/settings/_settings.scss +291 -48
  125. data/vendor/assets/scss/typography/_base.scss +2 -2
  126. data/vendor/assets/scss/typography/_helpers.scss +6 -4
  127. data/vendor/assets/scss/util/_breakpoint.scss +60 -1
  128. data/vendor/assets/scss/util/_color.scss +8 -5
  129. data/vendor/assets/scss/util/_mixins.scss +45 -5
  130. data/vendor/assets/scss/xy-grid/_cell.scss +179 -0
  131. data/vendor/assets/scss/xy-grid/_classes.scss +455 -0
  132. data/vendor/assets/scss/xy-grid/_collapse.scss +54 -0
  133. data/vendor/assets/scss/xy-grid/_frame.scss +54 -0
  134. data/vendor/assets/scss/xy-grid/_grid.scss +56 -0
  135. data/vendor/assets/scss/xy-grid/_gutters.scss +45 -0
  136. data/vendor/assets/scss/xy-grid/_layout.scss +33 -0
  137. data/vendor/assets/scss/xy-grid/_position.scss +28 -0
  138. data/vendor/assets/scss/xy-grid/_xy-grid.scss +52 -0
  139. metadata +73 -4
@@ -1,6 +1,9 @@
1
1
  'use strict';
2
2
 
3
- !function($) {
3
+ import $ from 'jquery';
4
+ import { Motion } from './foundation.util.motion';
5
+ import { Plugin } from './foundation.plugin';
6
+ import { Triggers } from './foundation.util.triggers';
4
7
 
5
8
  /**
6
9
  * Toggler module.
@@ -9,23 +12,26 @@
9
12
  * @requires foundation.util.triggers
10
13
  */
11
14
 
12
- class Toggler {
15
+ class Toggler extends Plugin {
13
16
  /**
14
17
  * Creates a new instance of Toggler.
15
18
  * @class
19
+ * @name Toggler
16
20
  * @fires Toggler#init
17
21
  * @param {Object} element - jQuery object to add the trigger to.
18
22
  * @param {Object} options - Overrides to the default plugin settings.
19
23
  */
20
- constructor(element, options) {
24
+ _setup(element, options) {
21
25
  this.$element = element;
22
26
  this.options = $.extend({}, Toggler.defaults, element.data(), options);
23
27
  this.className = '';
28
+ this.className = 'Toggler'; // ie9 back compat
29
+
30
+ // Triggers init is idempotent, just need to make sure it is initialized
31
+ Triggers.init($);
24
32
 
25
33
  this._init();
26
34
  this._events();
27
-
28
- Foundation.registerPlugin(this, 'Toggler');
29
35
  }
30
36
 
31
37
  /**
@@ -103,14 +109,14 @@ class Toggler {
103
109
  var _this = this;
104
110
 
105
111
  if (this.$element.is(':hidden')) {
106
- Foundation.Motion.animateIn(this.$element, this.animationIn, function() {
112
+ Motion.animateIn(this.$element, this.animationIn, function() {
107
113
  _this._updateARIA(true);
108
114
  this.trigger('on.zf.toggler');
109
115
  this.find('[data-mutate]').trigger('mutateme.zf.trigger');
110
116
  });
111
117
  }
112
118
  else {
113
- Foundation.Motion.animateOut(this.$element, this.animationOut, function() {
119
+ Motion.animateOut(this.$element, this.animationOut, function() {
114
120
  _this._updateARIA(false);
115
121
  this.trigger('off.zf.toggler');
116
122
  this.find('[data-mutate]').trigger('mutateme.zf.trigger');
@@ -126,9 +132,8 @@ class Toggler {
126
132
  * Destroys the instance of Toggler on the element.
127
133
  * @function
128
134
  */
129
- destroy() {
135
+ _destroy() {
130
136
  this.$element.off('.zf.toggler');
131
- Foundation.unregisterPlugin(this);
132
137
  }
133
138
  }
134
139
 
@@ -142,7 +147,4 @@ Toggler.defaults = {
142
147
  animate: false
143
148
  };
144
149
 
145
- // Window exports
146
- Foundation.plugin(Toggler, 'Toggler');
147
-
148
- }(jQuery);
150
+ export {Toggler};
@@ -1,6 +1,11 @@
1
1
  'use strict';
2
2
 
3
- !function($) {
3
+ import $ from 'jquery';
4
+
5
+ import { GetYoDigits } from './foundation.util.core';
6
+ import { MediaQuery } from './foundation.util.mediaQuery';
7
+ import { Triggers } from './foundation.util.triggers';
8
+ import { Positionable } from './foundation.positionable';
4
9
 
5
10
  /**
6
11
  * Tooltip module.
@@ -10,23 +15,27 @@
10
15
  * @requires foundation.util.triggers
11
16
  */
12
17
 
13
- class Tooltip {
18
+ class Tooltip extends Positionable {
14
19
  /**
15
20
  * Creates a new instance of a Tooltip.
16
21
  * @class
22
+ * @name Tooltip
17
23
  * @fires Tooltip#init
18
24
  * @param {jQuery} element - jQuery object to attach a tooltip to.
19
25
  * @param {Object} options - object to extend the default configuration.
20
26
  */
21
- constructor(element, options) {
27
+ _setup(element, options) {
22
28
  this.$element = element;
23
29
  this.options = $.extend({}, Tooltip.defaults, this.$element.data(), options);
30
+ this.className = 'Tooltip'; // ie9 back compat
24
31
 
25
32
  this.isActive = false;
26
33
  this.isClick = false;
27
- this._init();
28
34
 
29
- Foundation.registerPlugin(this, 'Tooltip');
35
+ // Triggers init is idempotent, just need to make sure it is initialized
36
+ Triggers.init($);
37
+
38
+ this._init();
30
39
  }
31
40
 
32
41
  /**
@@ -34,9 +43,9 @@ class Tooltip {
34
43
  * @private
35
44
  */
36
45
  _init() {
37
- var elemId = this.$element.attr('aria-describedby') || Foundation.GetYoDigits(6, 'tooltip');
46
+ MediaQuery._init();
47
+ var elemId = this.$element.attr('aria-describedby') || GetYoDigits(6, 'tooltip');
38
48
 
39
- this.options.positionClass = this.options.positionClass || this._getPositionClass(this.$element);
40
49
  this.options.tipText = this.options.tipText || this.$element.attr('title');
41
50
  this.template = this.options.template ? $(this.options.template) : this._buildTemplate(elemId);
42
51
 
@@ -58,25 +67,36 @@ class Tooltip {
58
67
  'data-resize': elemId
59
68
  }).addClass(this.options.triggerClass);
60
69
 
61
- //helper variables to track movement on collisions
62
- this.usedPositions = [];
63
- this.counter = 4;
64
- this.classChanged = false;
65
-
70
+ super._init();
66
71
  this._events();
67
72
  }
68
73
 
69
- /**
70
- * Grabs the current positioning class, if present, and returns the value or an empty string.
71
- * @private
72
- */
73
- _getPositionClass(element) {
74
- if (!element) { return ''; }
75
- // var position = element.attr('class').match(/top|left|right/g);
76
- var position = element[0].className.match(/\b(top|left|right)\b/g);
77
- position = position ? position[0] : '';
78
- return position;
79
- };
74
+ _getDefaultPosition() {
75
+ // handle legacy classnames
76
+ var position = this.$element[0].className.match(/\b(top|left|right|bottom)\b/g);
77
+ return position ? position[0] : 'top';
78
+ }
79
+
80
+ _getDefaultAlignment() {
81
+ return 'center';
82
+ }
83
+
84
+ _getHOffset() {
85
+ if(this.position === 'left' || this.position === 'right') {
86
+ return this.options.hOffset + this.options.tooltipWidth;
87
+ } else {
88
+ return this.options.hOffset
89
+ }
90
+ }
91
+
92
+ _getVOffset() {
93
+ if(this.position === 'top' || this.position === 'bottom') {
94
+ return this.options.vOffset + this.options.tooltipHeight;
95
+ } else {
96
+ return this.options.vOffset
97
+ }
98
+ }
99
+
80
100
  /**
81
101
  * builds the tooltip element, adds attributes, and returns the template.
82
102
  * @private
@@ -93,75 +113,13 @@ class Tooltip {
93
113
  return $template;
94
114
  }
95
115
 
96
- /**
97
- * Function that gets called if a collision event is detected.
98
- * @param {String} position - positioning class to try
99
- * @private
100
- */
101
- _reposition(position) {
102
- this.usedPositions.push(position ? position : 'bottom');
103
-
104
- //default, try switching to opposite side
105
- if (!position && (this.usedPositions.indexOf('top') < 0)) {
106
- this.template.addClass('top');
107
- } else if (position === 'top' && (this.usedPositions.indexOf('bottom') < 0)) {
108
- this.template.removeClass(position);
109
- } else if (position === 'left' && (this.usedPositions.indexOf('right') < 0)) {
110
- this.template.removeClass(position)
111
- .addClass('right');
112
- } else if (position === 'right' && (this.usedPositions.indexOf('left') < 0)) {
113
- this.template.removeClass(position)
114
- .addClass('left');
115
- }
116
-
117
- //if default change didn't work, try bottom or left first
118
- else if (!position && (this.usedPositions.indexOf('top') > -1) && (this.usedPositions.indexOf('left') < 0)) {
119
- this.template.addClass('left');
120
- } else if (position === 'top' && (this.usedPositions.indexOf('bottom') > -1) && (this.usedPositions.indexOf('left') < 0)) {
121
- this.template.removeClass(position)
122
- .addClass('left');
123
- } else if (position === 'left' && (this.usedPositions.indexOf('right') > -1) && (this.usedPositions.indexOf('bottom') < 0)) {
124
- this.template.removeClass(position);
125
- } else if (position === 'right' && (this.usedPositions.indexOf('left') > -1) && (this.usedPositions.indexOf('bottom') < 0)) {
126
- this.template.removeClass(position);
127
- }
128
- //if nothing cleared, set to bottom
129
- else {
130
- this.template.removeClass(position);
131
- }
132
- this.classChanged = true;
133
- this.counter--;
134
- }
135
-
136
116
  /**
137
117
  * sets the position class of an element and recursively calls itself until there are no more possible positions to attempt, or the tooltip element is no longer colliding.
138
118
  * if the tooltip is larger than the screen width, default to full width - any user selected margin
139
119
  * @private
140
120
  */
141
121
  _setPosition() {
142
- var position = this._getPositionClass(this.template),
143
- $tipDims = Foundation.Box.GetDimensions(this.template),
144
- $anchorDims = Foundation.Box.GetDimensions(this.$element),
145
- direction = (position === 'left' ? 'left' : ((position === 'right') ? 'left' : 'top')),
146
- param = (direction === 'top') ? 'height' : 'width',
147
- offset = (param === 'height') ? this.options.vOffset : this.options.hOffset,
148
- _this = this;
149
-
150
- if (($tipDims.width >= $tipDims.windowDims.width) || (!this.counter && !Foundation.Box.ImNotTouchingYou(this.template))) {
151
- this.template.offset(Foundation.Box.GetOffsets(this.template, this.$element, 'center bottom', this.options.vOffset, this.options.hOffset, true)).css({
152
- // this.$element.offset(Foundation.GetOffsets(this.template, this.$element, 'center bottom', this.options.vOffset, this.options.hOffset, true)).css({
153
- 'width': $anchorDims.windowDims.width - (this.options.hOffset * 2),
154
- 'height': 'auto'
155
- });
156
- return false;
157
- }
158
-
159
- this.template.offset(Foundation.Box.GetOffsets(this.template, this.$element,'center ' + (position || 'bottom'), this.options.vOffset, this.options.hOffset));
160
-
161
- while(!Foundation.Box.ImNotTouchingYou(this.template) && this.counter) {
162
- this._reposition(position);
163
- this._setPosition();
164
- }
122
+ super._setPosition(this.$element, this.template);
165
123
  }
166
124
 
167
125
  /**
@@ -171,7 +129,7 @@ class Tooltip {
171
129
  * @function
172
130
  */
173
131
  show() {
174
- if (this.options.showOn !== 'all' && !Foundation.MediaQuery.is(this.options.showOn)) {
132
+ if (this.options.showOn !== 'all' && !MediaQuery.is(this.options.showOn)) {
175
133
  // console.error('The screen is too small to display this tooltip');
176
134
  return false;
177
135
  }
@@ -179,6 +137,8 @@ class Tooltip {
179
137
  var _this = this;
180
138
  this.template.css('visibility', 'hidden').show();
181
139
  this._setPosition();
140
+ this.template.removeClass('top bottom left right').addClass(this.position)
141
+ this.template.removeClass('align-top align-bottom align-left align-right align-center').addClass('align-' + this.alignment);
182
142
 
183
143
  /**
184
144
  * Fires to close all other open tooltips on the page
@@ -217,15 +177,6 @@ class Tooltip {
217
177
  }).fadeOut(this.options.fadeOutDuration, function() {
218
178
  _this.isActive = false;
219
179
  _this.isClick = false;
220
- if (_this.classChanged) {
221
- _this.template
222
- .removeClass(_this._getPositionClass(_this.template))
223
- .addClass(_this.options.positionClass);
224
-
225
- _this.usedPositions = [];
226
- _this.counter = 4;
227
- _this.classChanged = false;
228
- }
229
180
  });
230
181
  /**
231
182
  * fires when the tooltip is hidden
@@ -337,15 +288,13 @@ class Tooltip {
337
288
  * Destroys an instance of tooltip, removes template element from the view.
338
289
  * @function
339
290
  */
340
- destroy() {
291
+ _destroy() {
341
292
  this.$element.attr('title', this.template.text())
342
293
  .off('.zf.trigger .zf.tooltip')
343
294
  .removeClass('has-tip top right left')
344
295
  .removeAttr('aria-describedby aria-haspopup data-disable-hover data-resize data-toggle data-tooltip data-yeti-box');
345
296
 
346
297
  this.template.remove();
347
-
348
- Foundation.unregisterPlugin(this);
349
298
  }
350
299
  }
351
300
 
@@ -430,26 +379,72 @@ Tooltip.defaults = {
430
379
  */
431
380
  clickOpen: true,
432
381
  /**
433
- * Additional positioning classes, set by the JS
382
+ * DEPRECATED Additional positioning classes, set by the JS
434
383
  * @option
435
384
  * @type {string}
436
385
  * @default ''
437
386
  */
438
387
  positionClass: '',
388
+ /**
389
+ * Position of tooltip. Can be left, right, bottom, top, or auto.
390
+ * @option
391
+ * @type {string}
392
+ * @default 'auto'
393
+ */
394
+ position: 'auto',
395
+ /**
396
+ * Alignment of tooltip relative to anchor. Can be left, right, bottom, top, center, or auto.
397
+ * @option
398
+ * @type {string}
399
+ * @default 'auto'
400
+ */
401
+ alignment: 'auto',
402
+ /**
403
+ * Allow overlap of container/window. If false, tooltip will first try to
404
+ * position as defined by data-position and data-alignment, but reposition if
405
+ * it would cause an overflow. @option
406
+ * @type {boolean}
407
+ * @default false
408
+ */
409
+ allowOverlap: false,
410
+ /**
411
+ * Allow overlap of only the bottom of the container. This is the most common
412
+ * behavior for dropdowns, allowing the dropdown to extend the bottom of the
413
+ * screen but not otherwise influence or break out of the container.
414
+ * Less common for tooltips.
415
+ * @option
416
+ * @type {boolean}
417
+ * @default false
418
+ */
419
+ allowBottomOverlap: false,
439
420
  /**
440
421
  * Distance, in pixels, the template should push away from the anchor on the Y axis.
441
422
  * @option
442
423
  * @type {number}
443
- * @default 10
424
+ * @default 0
444
425
  */
445
- vOffset: 10,
426
+ vOffset: 0,
446
427
  /**
447
- * Distance, in pixels, the template should push away from the anchor on the X axis, if aligned to a side.
428
+ * Distance, in pixels, the template should push away from the anchor on the X axis
429
+ * @option
430
+ * @type {number}
431
+ * @default 0
432
+ */
433
+ hOffset: 0,
434
+ /**
435
+ * Distance, in pixels, the template spacing auto-adjust for a vertical tooltip
436
+ * @option
437
+ * @type {number}
438
+ * @default 14
439
+ */
440
+ tooltipHeight: 14,
441
+ /**
442
+ * Distance, in pixels, the template spacing auto-adjust for a horizontal tooltip
448
443
  * @option
449
444
  * @type {number}
450
445
  * @default 12
451
446
  */
452
- hOffset: 12,
447
+ tooltipWidth: 12,
453
448
  /**
454
449
  * Allow HTML in tooltip. Warning: If you are loading user-generated content into tooltips,
455
450
  * allowing HTML may open yourself up to XSS attacks.
@@ -464,7 +459,4 @@ Tooltip.defaults = {
464
459
  * TODO utilize resize event trigger
465
460
  */
466
461
 
467
- // Window exports
468
- Foundation.plugin(Tooltip, 'Tooltip');
469
-
470
- }(jQuery);
462
+ export {Tooltip};
@@ -1,11 +1,14 @@
1
1
  'use strict';
2
2
 
3
- !function($) {
4
3
 
5
- Foundation.Box = {
4
+ import { rtl as Rtl } from "./foundation.util.core";
5
+
6
+ var Box = {
6
7
  ImNotTouchingYou: ImNotTouchingYou,
8
+ OverlapArea: OverlapArea,
7
9
  GetDimensions: GetDimensions,
8
- GetOffsets: GetOffsets
10
+ GetOffsets: GetOffsets,
11
+ GetExplicitOffsets: GetExplicitOffsets
9
12
  }
10
13
 
11
14
  /**
@@ -18,37 +21,43 @@ Foundation.Box = {
18
21
  * @default if no parent object passed, detects collisions with `window`.
19
22
  * @returns {Boolean} - true if collision free, false if a collision in any direction.
20
23
  */
21
- function ImNotTouchingYou(element, parent, lrOnly, tbOnly) {
22
- var eleDims = GetDimensions(element),
23
- top, bottom, left, right;
24
+ function ImNotTouchingYou(element, parent, lrOnly, tbOnly, ignoreBottom) {
25
+ return OverlapArea(element, parent, lrOnly, tbOnly, ignoreBottom) === 0;
26
+ };
24
27
 
28
+ function OverlapArea(element, parent, lrOnly, tbOnly, ignoreBottom) {
29
+ var eleDims = GetDimensions(element),
30
+ topOver, bottomOver, leftOver, rightOver;
25
31
  if (parent) {
26
32
  var parDims = GetDimensions(parent);
27
33
 
28
- bottom = (eleDims.offset.top + eleDims.height <= parDims.height + parDims.offset.top);
29
- top = (eleDims.offset.top >= parDims.offset.top);
30
- left = (eleDims.offset.left >= parDims.offset.left);
31
- right = (eleDims.offset.left + eleDims.width <= parDims.width + parDims.offset.left);
34
+ bottomOver = (parDims.height + parDims.offset.top) - (eleDims.offset.top + eleDims.height);
35
+ topOver = eleDims.offset.top - parDims.offset.top;
36
+ leftOver = eleDims.offset.left - parDims.offset.left;
37
+ rightOver = (parDims.width + parDims.offset.left) - (eleDims.offset.left + eleDims.width);
32
38
  }
33
39
  else {
34
- bottom = (eleDims.offset.top + eleDims.height <= eleDims.windowDims.height + eleDims.windowDims.offset.top);
35
- top = (eleDims.offset.top >= eleDims.windowDims.offset.top);
36
- left = (eleDims.offset.left >= eleDims.windowDims.offset.left);
37
- right = (eleDims.offset.left + eleDims.width <= eleDims.windowDims.width);
40
+ bottomOver = (eleDims.windowDims.height + eleDims.windowDims.offset.top) - (eleDims.offset.top + eleDims.height);
41
+ topOver = eleDims.offset.top - eleDims.windowDims.offset.top;
42
+ leftOver = eleDims.offset.left - eleDims.windowDims.offset.left;
43
+ rightOver = eleDims.windowDims.width - (eleDims.offset.left + eleDims.width);
38
44
  }
39
45
 
40
- var allDirs = [bottom, top, left, right];
46
+ bottomOver = ignoreBottom ? 0 : Math.min(bottomOver, 0);
47
+ topOver = Math.min(topOver, 0);
48
+ leftOver = Math.min(leftOver, 0);
49
+ rightOver = Math.min(rightOver, 0);
41
50
 
42
51
  if (lrOnly) {
43
- return left === right === true;
52
+ return leftOver + rightOver;
44
53
  }
45
-
46
54
  if (tbOnly) {
47
- return top === bottom === true;
55
+ return topOver + bottomOver;
48
56
  }
49
57
 
50
- return allDirs.indexOf(false) === -1;
51
- };
58
+ // use sum of squares b/c we care about overlap area.
59
+ return Math.sqrt((topOver * topOver) + (bottomOver * bottomOver) + (leftOver * leftOver) + (rightOver * rightOver));
60
+ }
52
61
 
53
62
  /**
54
63
  * Uses native methods to return an object of dimension values.
@@ -98,7 +107,9 @@ function GetDimensions(elem, test){
98
107
 
99
108
  /**
100
109
  * Returns an object of top and left integer pixel values for dynamically rendered elements,
101
- * such as: Tooltip, Reveal, and Dropdown
110
+ * such as: Tooltip, Reveal, and Dropdown. Maintained for backwards compatibility, and where
111
+ * you don't know alignment, but generally from
112
+ * 6.4 forward you should use GetExplicitOffsets, as GetOffsets conflates position and alignment.
102
113
  * @function
103
114
  * @param {jQuery} element - jQuery object for the element being positioned.
104
115
  * @param {jQuery} anchor - jQuery object for the element's anchor point.
@@ -109,61 +120,38 @@ function GetDimensions(elem, test){
109
120
  * TODO alter/rewrite to work with `em` values as well/instead of pixels
110
121
  */
111
122
  function GetOffsets(element, anchor, position, vOffset, hOffset, isOverflow) {
112
- var $eleDims = GetDimensions(element),
113
- $anchorDims = anchor ? GetDimensions(anchor) : null;
114
-
123
+ console.log("NOTE: GetOffsets is deprecated in favor of GetExplicitOffsets and will be removed in 6.5");
115
124
  switch (position) {
116
125
  case 'top':
117
- return {
118
- left: (Foundation.rtl() ? $anchorDims.offset.left - $eleDims.width + $anchorDims.width : $anchorDims.offset.left),
119
- top: $anchorDims.offset.top - ($eleDims.height + vOffset)
120
- }
121
- break;
122
- case 'left':
123
- return {
124
- left: $anchorDims.offset.left - ($eleDims.width + hOffset),
125
- top: $anchorDims.offset.top
126
- }
127
- break;
128
- case 'right':
129
- return {
130
- left: $anchorDims.offset.left + $anchorDims.width + hOffset,
131
- top: $anchorDims.offset.top
132
- }
133
- break;
126
+ return Rtl() ?
127
+ GetExplicitOffsets(element, anchor, 'top', 'left', vOffset, hOffset, isOverflow) :
128
+ GetExplicitOffsets(element, anchor, 'top', 'right', vOffset, hOffset, isOverflow);
129
+ case 'bottom':
130
+ return Rtl() ?
131
+ GetExplicitOffsets(element, anchor, 'bottom', 'left', vOffset, hOffset, isOverflow) :
132
+ GetExplicitOffsets(element, anchor, 'bottom', 'right', vOffset, hOffset, isOverflow);
134
133
  case 'center top':
135
- return {
136
- left: ($anchorDims.offset.left + ($anchorDims.width / 2)) - ($eleDims.width / 2),
137
- top: $anchorDims.offset.top - ($eleDims.height + vOffset)
138
- }
139
- break;
134
+ return GetExplicitOffsets(element, anchor, 'top', 'center', vOffset, hOffset, isOverflow);
140
135
  case 'center bottom':
141
- return {
142
- left: isOverflow ? hOffset : (($anchorDims.offset.left + ($anchorDims.width / 2)) - ($eleDims.width / 2)),
143
- top: $anchorDims.offset.top + $anchorDims.height + vOffset
144
- }
145
- break;
136
+ return GetExplicitOffsets(element, anchor, 'bottom', 'center', vOffset, hOffset, isOverflow);
146
137
  case 'center left':
147
- return {
148
- left: $anchorDims.offset.left - ($eleDims.width + hOffset),
149
- top: ($anchorDims.offset.top + ($anchorDims.height / 2)) - ($eleDims.height / 2)
150
- }
151
- break;
138
+ return GetExplicitOffsets(element, anchor, 'left', 'center', vOffset, hOffset, isOverflow);
152
139
  case 'center right':
153
- return {
154
- left: $anchorDims.offset.left + $anchorDims.width + hOffset + 1,
155
- top: ($anchorDims.offset.top + ($anchorDims.height / 2)) - ($eleDims.height / 2)
156
- }
157
- break;
140
+ return GetExplicitOffsets(element, anchor, 'right', 'center', vOffset, hOffset, isOverflow);
141
+ case 'left bottom':
142
+ return GetExplicitOffsets(element, anchor, 'bottom', 'left', vOffset, hOffset, isOverflow);
143
+ case 'right bottom':
144
+ return GetExplicitOffsets(element, anchor, 'bottom', 'right', vOffset, hOffset, isOverflow);
145
+ // Backwards compatibility... this along with the reveal and reveal full
146
+ // classes are the only ones that didn't reference anchor
158
147
  case 'center':
159
148
  return {
160
- left: ($eleDims.windowDims.offset.left + ($eleDims.windowDims.width / 2)) - ($eleDims.width / 2),
161
- top: ($eleDims.windowDims.offset.top + ($eleDims.windowDims.height / 2)) - ($eleDims.height / 2)
149
+ left: ($eleDims.windowDims.offset.left + ($eleDims.windowDims.width / 2)) - ($eleDims.width / 2) + hOffset,
150
+ top: ($eleDims.windowDims.offset.top + ($eleDims.windowDims.height / 2)) - ($eleDims.height / 2 + vOffset)
162
151
  }
163
- break;
164
152
  case 'reveal':
165
153
  return {
166
- left: ($eleDims.windowDims.width - $eleDims.width) / 2,
154
+ left: ($eleDims.windowDims.width - $eleDims.width) / 2 + hOffset,
167
155
  top: $eleDims.windowDims.offset.top + vOffset
168
156
  }
169
157
  case 'reveal full':
@@ -172,24 +160,72 @@ function GetOffsets(element, anchor, position, vOffset, hOffset, isOverflow) {
172
160
  top: $eleDims.windowDims.offset.top
173
161
  }
174
162
  break;
175
- case 'left bottom':
163
+ default:
176
164
  return {
177
- left: $anchorDims.offset.left,
165
+ left: (Rtl() ? $anchorDims.offset.left - $eleDims.width + $anchorDims.width - hOffset: $anchorDims.offset.left + hOffset),
178
166
  top: $anchorDims.offset.top + $anchorDims.height + vOffset
179
- };
167
+ }
168
+
169
+ }
170
+
171
+ }
172
+
173
+ function GetExplicitOffsets(element, anchor, position, alignment, vOffset, hOffset, isOverflow) {
174
+ var $eleDims = GetDimensions(element),
175
+ $anchorDims = anchor ? GetDimensions(anchor) : null;
176
+
177
+ var topVal, leftVal;
178
+
179
+ // set position related attribute
180
+
181
+ switch (position) {
182
+ case 'top':
183
+ topVal = $anchorDims.offset.top - ($eleDims.height + vOffset);
180
184
  break;
181
- case 'right bottom':
182
- return {
183
- left: $anchorDims.offset.left + $anchorDims.width + hOffset - $eleDims.width,
184
- top: $anchorDims.offset.top + $anchorDims.height + vOffset
185
- };
185
+ case 'bottom':
186
+ topVal = $anchorDims.offset.top + $anchorDims.height + vOffset;
186
187
  break;
187
- default:
188
- return {
189
- left: (Foundation.rtl() ? $anchorDims.offset.left - $eleDims.width + $anchorDims.width : $anchorDims.offset.left + hOffset),
190
- top: $anchorDims.offset.top + $anchorDims.height + vOffset
188
+ case 'left':
189
+ leftVal = $anchorDims.offset.left - ($eleDims.width + hOffset);
190
+ break;
191
+ case 'right':
192
+ leftVal = $anchorDims.offset.left + $anchorDims.width + hOffset;
193
+ break;
194
+ }
195
+
196
+
197
+ // set alignment related attribute
198
+ switch (position) {
199
+ case 'top':
200
+ case 'bottom':
201
+ switch (alignment) {
202
+ case 'left':
203
+ leftVal = $anchorDims.offset.left + hOffset;
204
+ break;
205
+ case 'right':
206
+ leftVal = $anchorDims.offset.left - $eleDims.width + $anchorDims.width - hOffset;
207
+ break;
208
+ case 'center':
209
+ leftVal = isOverflow ? hOffset : (($anchorDims.offset.left + ($anchorDims.width / 2)) - ($eleDims.width / 2)) + hOffset;
210
+ break;
191
211
  }
212
+ break;
213
+ case 'right':
214
+ case 'left':
215
+ switch (alignment) {
216
+ case 'bottom':
217
+ topVal = $anchorDims.offset.top - vOffset + $anchorDims.height - $eleDims.height;
218
+ break;
219
+ case 'top':
220
+ topVal = $anchorDims.offset.top + vOffset
221
+ break;
222
+ case 'center':
223
+ topVal = ($anchorDims.offset.top + vOffset + ($anchorDims.height / 2)) - ($eleDims.height / 2)
224
+ break;
225
+ }
226
+ break;
192
227
  }
228
+ return {top: topVal, left: leftVal};
193
229
  }
194
230
 
195
- }(jQuery);
231
+ export {Box};