foundation-rails 6.4.1.0 → 6.4.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/Rakefile +5 -6
  4. data/lib/foundation/rails/version.rb +1 -1
  5. data/vendor/assets/js/foundation.abide.js +781 -0
  6. data/vendor/assets/js/foundation.accordion.js +511 -0
  7. data/vendor/assets/js/foundation.accordionMenu.js +527 -0
  8. data/vendor/assets/js/foundation.core.js +860 -0
  9. data/vendor/assets/js/foundation.drilldown.js +759 -0
  10. data/vendor/assets/js/foundation.dropdown.js +1131 -0
  11. data/vendor/assets/js/foundation.dropdownMenu.js +678 -0
  12. data/vendor/assets/js/foundation.equalizer.js +542 -0
  13. data/vendor/assets/js/foundation.interchange.js +399 -0
  14. data/vendor/assets/js/{foundation.js.es6 → foundation.js} +11 -12
  15. data/vendor/assets/js/foundation.magellan.js +449 -0
  16. data/vendor/assets/js/foundation.offcanvas.js +1052 -0
  17. data/vendor/assets/js/foundation.orbit.js +767 -0
  18. data/vendor/assets/js/foundation.responsiveAccordionTabs.js +440 -0
  19. data/vendor/assets/js/foundation.responsiveMenu.js +362 -0
  20. data/vendor/assets/js/foundation.responsiveToggle.js +336 -0
  21. data/vendor/assets/js/foundation.reveal.js +1066 -0
  22. data/vendor/assets/js/foundation.slider.js +1236 -0
  23. data/vendor/assets/js/foundation.smoothScroll.js +303 -0
  24. data/vendor/assets/js/foundation.sticky.js +1001 -0
  25. data/vendor/assets/js/foundation.tabs.js +678 -0
  26. data/vendor/assets/js/foundation.toggler.js +602 -0
  27. data/vendor/assets/js/foundation.tooltip.js +1195 -0
  28. data/vendor/assets/js/{foundation.util.box.js.es6 → foundation.util.box.js} +154 -41
  29. data/vendor/assets/js/foundation.util.imageLoader.js +163 -0
  30. data/vendor/assets/js/foundation.util.keyboard.js +298 -0
  31. data/vendor/assets/js/foundation.util.mediaQuery.js +353 -0
  32. data/vendor/assets/js/foundation.util.motion.js +231 -0
  33. data/vendor/assets/js/foundation.util.nest.js +181 -0
  34. data/vendor/assets/js/foundation.util.timer.js +170 -0
  35. data/vendor/assets/js/foundation.util.timerAndImageLoader.js +90 -0
  36. data/vendor/assets/js/foundation.util.touch.js +275 -0
  37. data/vendor/assets/js/foundation.util.triggers.js +399 -0
  38. data/vendor/assets/js/foundation.zf.responsiveAccordionTabs.js +262 -0
  39. metadata +37 -71
  40. data/vendor/assets/js/entries/foundation-plugins.js +0 -25
  41. data/vendor/assets/js/entries/foundation.js +0 -101
  42. data/vendor/assets/js/entries/plugins/foundation.abide.js +0 -4
  43. data/vendor/assets/js/entries/plugins/foundation.accordion.js +0 -4
  44. data/vendor/assets/js/entries/plugins/foundation.accordionMenu.js +0 -5
  45. data/vendor/assets/js/entries/plugins/foundation.core.js +0 -21
  46. data/vendor/assets/js/entries/plugins/foundation.drilldown.js +0 -4
  47. data/vendor/assets/js/entries/plugins/foundation.dropdown.js +0 -5
  48. data/vendor/assets/js/entries/plugins/foundation.dropdownMenu.js +0 -4
  49. data/vendor/assets/js/entries/plugins/foundation.equalizer.js +0 -4
  50. data/vendor/assets/js/entries/plugins/foundation.interchange.js +0 -4
  51. data/vendor/assets/js/entries/plugins/foundation.magellan.js +0 -4
  52. data/vendor/assets/js/entries/plugins/foundation.offcanvas.js +0 -4
  53. data/vendor/assets/js/entries/plugins/foundation.orbit.js +0 -5
  54. data/vendor/assets/js/entries/plugins/foundation.responsiveAccordionTabs.js +0 -5
  55. data/vendor/assets/js/entries/plugins/foundation.responsiveMenu.js +0 -5
  56. data/vendor/assets/js/entries/plugins/foundation.responsiveToggle.js +0 -5
  57. data/vendor/assets/js/entries/plugins/foundation.reveal.js +0 -4
  58. data/vendor/assets/js/entries/plugins/foundation.slider.js +0 -5
  59. data/vendor/assets/js/entries/plugins/foundation.smoothScroll.js +0 -5
  60. data/vendor/assets/js/entries/plugins/foundation.sticky.js +0 -5
  61. data/vendor/assets/js/entries/plugins/foundation.tabs.js +0 -5
  62. data/vendor/assets/js/entries/plugins/foundation.toggler.js +0 -5
  63. data/vendor/assets/js/entries/plugins/foundation.tooltip.js +0 -4
  64. data/vendor/assets/js/entries/plugins/foundation.util.box.js +0 -4
  65. data/vendor/assets/js/entries/plugins/foundation.util.imageLoader.js +0 -5
  66. data/vendor/assets/js/entries/plugins/foundation.util.keyboard.js +0 -4
  67. data/vendor/assets/js/entries/plugins/foundation.util.mediaQuery.js +0 -4
  68. data/vendor/assets/js/entries/plugins/foundation.util.motion.js +0 -5
  69. data/vendor/assets/js/entries/plugins/foundation.util.nest.js +0 -5
  70. data/vendor/assets/js/entries/plugins/foundation.util.timer.js +0 -5
  71. data/vendor/assets/js/entries/plugins/foundation.util.touch.js +0 -7
  72. data/vendor/assets/js/entries/plugins/foundation.util.triggers.js +0 -5
  73. data/vendor/assets/js/foundation.abide.js.es6 +0 -587
  74. data/vendor/assets/js/foundation.accordion.js.es6 +0 -329
  75. data/vendor/assets/js/foundation.accordionMenu.js.es6 +0 -328
  76. data/vendor/assets/js/foundation.core.js.es6 +0 -337
  77. data/vendor/assets/js/foundation.drilldown.js.es6 +0 -536
  78. data/vendor/assets/js/foundation.dropdown.js.es6 +0 -394
  79. data/vendor/assets/js/foundation.dropdownMenu.js.es6 +0 -458
  80. data/vendor/assets/js/foundation.equalizer.js.es6 +0 -318
  81. data/vendor/assets/js/foundation.interchange.js.es6 +0 -210
  82. data/vendor/assets/js/foundation.magellan.js.es6 +0 -257
  83. data/vendor/assets/js/foundation.offcanvas.js.es6 +0 -546
  84. data/vendor/assets/js/foundation.orbit.js.es6 +0 -531
  85. data/vendor/assets/js/foundation.plugin.js.es6 +0 -54
  86. data/vendor/assets/js/foundation.positionable.js.es6 +0 -206
  87. data/vendor/assets/js/foundation.responsiveAccordionTabs.js.es6 +0 -243
  88. data/vendor/assets/js/foundation.responsiveMenu.js.es6 +0 -155
  89. data/vendor/assets/js/foundation.responsiveToggle.js.es6 +0 -156
  90. data/vendor/assets/js/foundation.reveal.js.es6 +0 -585
  91. data/vendor/assets/js/foundation.slider.js.es6 +0 -712
  92. data/vendor/assets/js/foundation.smoothScroll.js.es6 +0 -135
  93. data/vendor/assets/js/foundation.sticky.js.es6 +0 -507
  94. data/vendor/assets/js/foundation.tabs.js.es6 +0 -498
  95. data/vendor/assets/js/foundation.toggler.js.es6 +0 -150
  96. data/vendor/assets/js/foundation.tooltip.js.es6 +0 -462
  97. data/vendor/assets/js/foundation.util.core.js.es6 +0 -52
  98. data/vendor/assets/js/foundation.util.imageLoader.js.es6 +0 -45
  99. data/vendor/assets/js/foundation.util.keyboard.js.es6 +0 -162
  100. data/vendor/assets/js/foundation.util.mediaQuery.js.es6 +0 -234
  101. data/vendor/assets/js/foundation.util.motion.js.es6 +0 -104
  102. data/vendor/assets/js/foundation.util.nest.js.es6 +0 -67
  103. data/vendor/assets/js/foundation.util.timer.js.es6 +0 -48
  104. data/vendor/assets/js/foundation.util.touch.js.es6 +0 -149
  105. data/vendor/assets/js/foundation.util.triggers.js.es6 +0 -268
@@ -1,104 +0,0 @@
1
- 'use strict';
2
-
3
- import $ from 'jquery';
4
- import { transitionend } from './foundation.util.core';
5
-
6
- /**
7
- * Motion module.
8
- * @module foundation.motion
9
- */
10
-
11
- const initClasses = ['mui-enter', 'mui-leave'];
12
- const activeClasses = ['mui-enter-active', 'mui-leave-active'];
13
-
14
- const Motion = {
15
- animateIn: function(element, animation, cb) {
16
- animate(true, element, animation, cb);
17
- },
18
-
19
- animateOut: function(element, animation, cb) {
20
- animate(false, element, animation, cb);
21
- }
22
- }
23
-
24
- function Move(duration, elem, fn){
25
- var anim, prog, start = null;
26
- // console.log('called');
27
-
28
- if (duration === 0) {
29
- fn.apply(elem);
30
- elem.trigger('finished.zf.animate', [elem]).triggerHandler('finished.zf.animate', [elem]);
31
- return;
32
- }
33
-
34
- function move(ts){
35
- if(!start) start = ts;
36
- // console.log(start, ts);
37
- prog = ts - start;
38
- fn.apply(elem);
39
-
40
- if(prog < duration){ anim = window.requestAnimationFrame(move, elem); }
41
- else{
42
- window.cancelAnimationFrame(anim);
43
- elem.trigger('finished.zf.animate', [elem]).triggerHandler('finished.zf.animate', [elem]);
44
- }
45
- }
46
- anim = window.requestAnimationFrame(move);
47
- }
48
-
49
- /**
50
- * Animates an element in or out using a CSS transition class.
51
- * @function
52
- * @private
53
- * @param {Boolean} isIn - Defines if the animation is in or out.
54
- * @param {Object} element - jQuery or HTML object to animate.
55
- * @param {String} animation - CSS class to use.
56
- * @param {Function} cb - Callback to run when animation is finished.
57
- */
58
- function animate(isIn, element, animation, cb) {
59
- element = $(element).eq(0);
60
-
61
- if (!element.length) return;
62
-
63
- var initClass = isIn ? initClasses[0] : initClasses[1];
64
- var activeClass = isIn ? activeClasses[0] : activeClasses[1];
65
-
66
- // Set up the animation
67
- reset();
68
-
69
- element
70
- .addClass(animation)
71
- .css('transition', 'none');
72
-
73
- requestAnimationFrame(() => {
74
- element.addClass(initClass);
75
- if (isIn) element.show();
76
- });
77
-
78
- // Start the animation
79
- requestAnimationFrame(() => {
80
- element[0].offsetWidth;
81
- element
82
- .css('transition', '')
83
- .addClass(activeClass);
84
- });
85
-
86
- // Clean up the animation when it finishes
87
- element.one(transitionend(element), finish);
88
-
89
- // Hides the element (for out animations), resets the element, and runs a callback
90
- function finish() {
91
- if (!isIn) element.hide();
92
- reset();
93
- if (cb) cb.apply(element);
94
- }
95
-
96
- // Resets transitions and removes motion-specific classes
97
- function reset() {
98
- element[0].style.transitionDuration = 0;
99
- element.removeClass(`${initClass} ${activeClass} ${animation}`);
100
- }
101
- }
102
-
103
- export {Move, Motion};
104
-
@@ -1,67 +0,0 @@
1
- 'use strict';
2
-
3
- import $ from 'jquery';
4
-
5
- const Nest = {
6
- Feather(menu, type = 'zf') {
7
- menu.attr('role', 'menubar');
8
-
9
- var items = menu.find('li').attr({'role': 'menuitem'}),
10
- subMenuClass = `is-${type}-submenu`,
11
- subItemClass = `${subMenuClass}-item`,
12
- hasSubClass = `is-${type}-submenu-parent`,
13
- applyAria = (type !== 'accordion'); // Accordions handle their own ARIA attriutes.
14
-
15
- items.each(function() {
16
- var $item = $(this),
17
- $sub = $item.children('ul');
18
-
19
- if ($sub.length) {
20
- $item.addClass(hasSubClass);
21
- $sub.addClass(`submenu ${subMenuClass}`).attr({'data-submenu': ''});
22
- if(applyAria) {
23
- $item.attr({
24
- 'aria-haspopup': true,
25
- 'aria-label': $item.children('a:first').text()
26
- });
27
- // Note: Drilldowns behave differently in how they hide, and so need
28
- // additional attributes. We should look if this possibly over-generalized
29
- // utility (Nest) is appropriate when we rework menus in 6.4
30
- if(type === 'drilldown') {
31
- $item.attr({'aria-expanded': false});
32
- }
33
- }
34
- $sub
35
- .addClass(`submenu ${subMenuClass}`)
36
- .attr({
37
- 'data-submenu': '',
38
- 'role': 'menu'
39
- });
40
- if(type === 'drilldown') {
41
- $sub.attr({'aria-hidden': true});
42
- }
43
- }
44
-
45
- if ($item.parent('[data-submenu]').length) {
46
- $item.addClass(`is-submenu-item ${subItemClass}`);
47
- }
48
- });
49
-
50
- return;
51
- },
52
-
53
- Burn(menu, type) {
54
- var //items = menu.find('li'),
55
- subMenuClass = `is-${type}-submenu`,
56
- subItemClass = `${subMenuClass}-item`,
57
- hasSubClass = `is-${type}-submenu-parent`;
58
-
59
- menu
60
- .find('>li, .menu, .menu > li')
61
- .removeClass(`${subMenuClass} ${subItemClass} ${hasSubClass} is-submenu-item submenu is-active`)
62
- .removeAttr('data-submenu').css('display', '');
63
-
64
- }
65
- }
66
-
67
- export {Nest};
@@ -1,48 +0,0 @@
1
- 'use strict';
2
-
3
- import $ from 'jquery';
4
-
5
- function Timer(elem, options, cb) {
6
- var _this = this,
7
- duration = options.duration,//options is an object for easily adding features later.
8
- nameSpace = Object.keys(elem.data())[0] || 'timer',
9
- remain = -1,
10
- start,
11
- timer;
12
-
13
- this.isPaused = false;
14
-
15
- this.restart = function() {
16
- remain = -1;
17
- clearTimeout(timer);
18
- this.start();
19
- }
20
-
21
- this.start = function() {
22
- this.isPaused = false;
23
- // if(!elem.data('paused')){ return false; }//maybe implement this sanity check if used for other things.
24
- clearTimeout(timer);
25
- remain = remain <= 0 ? duration : remain;
26
- elem.data('paused', false);
27
- start = Date.now();
28
- timer = setTimeout(function(){
29
- if(options.infinite){
30
- _this.restart();//rerun the timer.
31
- }
32
- if (cb && typeof cb === 'function') { cb(); }
33
- }, remain);
34
- elem.trigger(`timerstart.zf.${nameSpace}`);
35
- }
36
-
37
- this.pause = function() {
38
- this.isPaused = true;
39
- //if(elem.data('paused')){ return false; }//maybe implement this sanity check if used for other things.
40
- clearTimeout(timer);
41
- elem.data('paused', true);
42
- var end = Date.now();
43
- remain = remain - (end - start);
44
- elem.trigger(`timerpaused.zf.${nameSpace}`);
45
- }
46
- }
47
-
48
- export {Timer};
@@ -1,149 +0,0 @@
1
- //**************************************************
2
- //**Work inspired by multiple jquery swipe plugins**
3
- //**Done by Yohai Ararat ***************************
4
- //**************************************************
5
-
6
- import $ from 'jquery';
7
-
8
- var Touch = {};
9
-
10
- var startPosX,
11
- startPosY,
12
- startTime,
13
- elapsedTime,
14
- isMoving = false;
15
-
16
- function onTouchEnd() {
17
- // alert(this);
18
- this.removeEventListener('touchmove', onTouchMove);
19
- this.removeEventListener('touchend', onTouchEnd);
20
- isMoving = false;
21
- }
22
-
23
- function onTouchMove(e) {
24
- if ($.spotSwipe.preventDefault) { e.preventDefault(); }
25
- if(isMoving) {
26
- var x = e.touches[0].pageX;
27
- var y = e.touches[0].pageY;
28
- var dx = startPosX - x;
29
- var dy = startPosY - y;
30
- var dir;
31
- elapsedTime = new Date().getTime() - startTime;
32
- if(Math.abs(dx) >= $.spotSwipe.moveThreshold && elapsedTime <= $.spotSwipe.timeThreshold) {
33
- dir = dx > 0 ? 'left' : 'right';
34
- }
35
- // else if(Math.abs(dy) >= $.spotSwipe.moveThreshold && elapsedTime <= $.spotSwipe.timeThreshold) {
36
- // dir = dy > 0 ? 'down' : 'up';
37
- // }
38
- if(dir) {
39
- e.preventDefault();
40
- onTouchEnd.call(this);
41
- $(this).trigger('swipe', dir).trigger(`swipe${dir}`);
42
- }
43
- }
44
- }
45
-
46
- function onTouchStart(e) {
47
- if (e.touches.length == 1) {
48
- startPosX = e.touches[0].pageX;
49
- startPosY = e.touches[0].pageY;
50
- isMoving = true;
51
- startTime = new Date().getTime();
52
- this.addEventListener('touchmove', onTouchMove, false);
53
- this.addEventListener('touchend', onTouchEnd, false);
54
- }
55
- }
56
-
57
- function init() {
58
- this.addEventListener && this.addEventListener('touchstart', onTouchStart, false);
59
- }
60
-
61
- function teardown() {
62
- this.removeEventListener('touchstart', onTouchStart);
63
- }
64
-
65
- class SpotSwipe {
66
- constructor($) {
67
- this.version = '1.0.0';
68
- this.enabled = 'ontouchstart' in document.documentElement;
69
- this.preventDefault = false;
70
- this.moveThreshold = 75;
71
- this.timeThreshold = 200;
72
- this.$ = $;
73
- this._init();
74
- }
75
-
76
- _init() {
77
- var $ = this.$;
78
- $.event.special.swipe = { setup: init };
79
-
80
- $.each(['left', 'up', 'down', 'right'], function () {
81
- $.event.special[`swipe${this}`] = { setup: function(){
82
- $(this).on('swipe', $.noop);
83
- } };
84
- });
85
- }
86
- }
87
-
88
- /****************************************************
89
- * As far as I can tell, both setupSpotSwipe and *
90
- * setupTouchHandler should be idempotent, *
91
- * because they directly replace functions & *
92
- * values, and do not add event handlers directly. *
93
- ****************************************************/
94
-
95
- Touch.setupSpotSwipe = function($) {
96
- $.spotSwipe = new SpotSwipe($);
97
- };
98
-
99
- /****************************************************
100
- * Method for adding pseudo drag events to elements *
101
- ***************************************************/
102
- Touch.setupTouchHandler = function($) {
103
- $.fn.addTouch = function(){
104
- this.each(function(i,el){
105
- $(el).bind('touchstart touchmove touchend touchcancel',function(){
106
- //we pass the original event object because the jQuery event
107
- //object is normalized to w3c specs and does not provide the TouchList
108
- handleTouch(event);
109
- });
110
- });
111
-
112
- var handleTouch = function(event){
113
- var touches = event.changedTouches,
114
- first = touches[0],
115
- eventTypes = {
116
- touchstart: 'mousedown',
117
- touchmove: 'mousemove',
118
- touchend: 'mouseup'
119
- },
120
- type = eventTypes[event.type],
121
- simulatedEvent
122
- ;
123
-
124
- if('MouseEvent' in window && typeof window.MouseEvent === 'function') {
125
- simulatedEvent = new window.MouseEvent(type, {
126
- 'bubbles': true,
127
- 'cancelable': true,
128
- 'screenX': first.screenX,
129
- 'screenY': first.screenY,
130
- 'clientX': first.clientX,
131
- 'clientY': first.clientY
132
- });
133
- } else {
134
- simulatedEvent = document.createEvent('MouseEvent');
135
- simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY, false, false, false, false, 0/*left*/, null);
136
- }
137
- first.target.dispatchEvent(simulatedEvent);
138
- };
139
- };
140
- };
141
-
142
- Touch.init = function($) {
143
- if(typeof($.spotSwipe) === 'undefined') {
144
- Touch.setupSpotSwipe($);
145
- Touch.setupTouchHandler($);
146
- }
147
- };
148
-
149
- export {Touch};
@@ -1,268 +0,0 @@
1
- 'use strict';
2
-
3
- import $ from 'jquery';
4
- import { Motion } from './foundation.util.motion';
5
-
6
- const MutationObserver = (function () {
7
- var prefixes = ['WebKit', 'Moz', 'O', 'Ms', ''];
8
- for (var i=0; i < prefixes.length; i++) {
9
- if (`${prefixes[i]}MutationObserver` in window) {
10
- return window[`${prefixes[i]}MutationObserver`];
11
- }
12
- }
13
- return false;
14
- }());
15
-
16
- const triggers = (el, type) => {
17
- el.data(type).split(' ').forEach(id => {
18
- $(`#${id}`)[ type === 'close' ? 'trigger' : 'triggerHandler'](`${type}.zf.trigger`, [el]);
19
- });
20
- };
21
-
22
- var Triggers = {
23
- Listeners: {
24
- Basic: {},
25
- Global: {}
26
- },
27
- Initializers: {}
28
- }
29
-
30
- Triggers.Listeners.Basic = {
31
- openListener: function() {
32
- triggers($(this), 'open');
33
- },
34
- closeListener: function() {
35
- let id = $(this).data('close');
36
- if (id) {
37
- triggers($(this), 'close');
38
- }
39
- else {
40
- $(this).trigger('close.zf.trigger');
41
- }
42
- },
43
- toggleListener: function() {
44
- let id = $(this).data('toggle');
45
- if (id) {
46
- triggers($(this), 'toggle');
47
- } else {
48
- $(this).trigger('toggle.zf.trigger');
49
- }
50
- },
51
- closeableListener: function(e) {
52
- e.stopPropagation();
53
- let animation = $(this).data('closable');
54
-
55
- if(animation !== ''){
56
- Motion.animateOut($(this), animation, function() {
57
- $(this).trigger('closed.zf');
58
- });
59
- }else{
60
- $(this).fadeOut().trigger('closed.zf');
61
- }
62
- },
63
- toggleFocusListener: function() {
64
- let id = $(this).data('toggle-focus');
65
- $(`#${id}`).triggerHandler('toggle.zf.trigger', [$(this)]);
66
- }
67
- };
68
-
69
- // Elements with [data-open] will reveal a plugin that supports it when clicked.
70
- Triggers.Initializers.addOpenListener = ($elem) => {
71
- $elem.off('click.zf.trigger', Triggers.Listeners.Basic.openListener);
72
- $elem.on('click.zf.trigger', '[data-open]', Triggers.Listeners.Basic.openListener);
73
- }
74
-
75
- // Elements with [data-close] will close a plugin that supports it when clicked.
76
- // If used without a value on [data-close], the event will bubble, allowing it to close a parent component.
77
- Triggers.Initializers.addCloseListener = ($elem) => {
78
- $elem.off('click.zf.trigger', Triggers.Listeners.Basic.closeListener);
79
- $elem.on('click.zf.trigger', '[data-close]', Triggers.Listeners.Basic.closeListener);
80
- }
81
-
82
- // Elements with [data-toggle] will toggle a plugin that supports it when clicked.
83
- Triggers.Initializers.addToggleListener = ($elem) => {
84
- $elem.off('click.zf.trigger', Triggers.Listeners.Basic.toggleListener);
85
- $elem.on('click.zf.trigger', '[data-toggle]', Triggers.Listeners.Basic.toggleListener);
86
- }
87
-
88
- // Elements with [data-closable] will respond to close.zf.trigger events.
89
- Triggers.Initializers.addCloseableListener = ($elem) => {
90
- $elem.off('close.zf.trigger', Triggers.Listeners.Basic.closeableListener);
91
- $elem.on('close.zf.trigger', '[data-closeable], [data-closable]', Triggers.Listeners.Basic.closeableListener);
92
- }
93
-
94
- // Elements with [data-toggle-focus] will respond to coming in and out of focus
95
- Triggers.Initializers.addToggleFocusListener = ($elem) => {
96
- $elem.off('focus.zf.trigger blur.zf.trigger', Triggers.Listeners.Basic.toggleFocusListener);
97
- $elem.on('focus.zf.trigger blur.zf.trigger', '[data-toggle-focus]', Triggers.Listeners.Basic.toggleFocusListener);
98
- }
99
-
100
-
101
-
102
- // More Global/complex listeners and triggers
103
- Triggers.Listeners.Global = {
104
- resizeListener: function($nodes) {
105
- if(!MutationObserver){//fallback for IE 9
106
- $nodes.each(function(){
107
- $(this).triggerHandler('resizeme.zf.trigger');
108
- });
109
- }
110
- //trigger all listening elements and signal a resize event
111
- $nodes.attr('data-events', "resize");
112
- },
113
- scrollListener: function($nodes) {
114
- if(!MutationObserver){//fallback for IE 9
115
- $nodes.each(function(){
116
- $(this).triggerHandler('scrollme.zf.trigger');
117
- });
118
- }
119
- //trigger all listening elements and signal a scroll event
120
- $nodes.attr('data-events', "scroll");
121
- },
122
- closeMeListener: function(e, pluginId){
123
- let plugin = e.namespace.split('.')[0];
124
- let plugins = $(`[data-${plugin}]`).not(`[data-yeti-box="${pluginId}"]`);
125
-
126
- plugins.each(function(){
127
- let _this = $(this);
128
- _this.triggerHandler('close.zf.trigger', [_this]);
129
- });
130
- }
131
- }
132
-
133
- // Global, parses whole document.
134
- Triggers.Initializers.addClosemeListener = function(pluginName) {
135
- var yetiBoxes = $('[data-yeti-box]'),
136
- plugNames = ['dropdown', 'tooltip', 'reveal'];
137
-
138
- if(pluginName){
139
- if(typeof pluginName === 'string'){
140
- plugNames.push(pluginName);
141
- }else if(typeof pluginName === 'object' && typeof pluginName[0] === 'string'){
142
- plugNames.concat(pluginName);
143
- }else{
144
- console.error('Plugin names must be strings');
145
- }
146
- }
147
- if(yetiBoxes.length){
148
- let listeners = plugNames.map((name) => {
149
- return `closeme.zf.${name}`;
150
- }).join(' ');
151
-
152
- $(window).off(listeners).on(listeners, Triggers.Listeners.Global.closeMeListener);
153
- }
154
- }
155
-
156
- function debounceGlobalListener(debounce, trigger, listener) {
157
- let timer, args = Array.prototype.slice.call(arguments, 3);
158
- $(window).off(trigger).on(trigger, function(e) {
159
- if (timer) { clearTimeout(timer); }
160
- timer = setTimeout(function(){
161
- listener.apply(null, args);
162
- }, debounce || 10);//default time to emit scroll event
163
- });
164
- }
165
-
166
- Triggers.Initializers.addResizeListener = function(debounce){
167
- let $nodes = $('[data-resize]');
168
- if($nodes.length){
169
- debounceGlobalListener(debounce, 'resize.zf.trigger', Triggers.Listeners.Global.resizeListener, $nodes);
170
- }
171
- }
172
-
173
- Triggers.Initializers.addScrollListener = function(debounce){
174
- let $nodes = $('[data-scroll]');
175
- if($nodes.length){
176
- debounceGlobalListener(debounce, 'scroll.zf.trigger', Triggers.Listeners.Global.scrollListener, $nodes);
177
- }
178
- }
179
-
180
- Triggers.Initializers.addMutationEventsListener = function($elem) {
181
- if(!MutationObserver){ return false; }
182
- let $nodes = $elem.find('[data-resize], [data-scroll], [data-mutate]');
183
-
184
- //element callback
185
- var listeningElementsMutation = function (mutationRecordsList) {
186
- var $target = $(mutationRecordsList[0].target);
187
-
188
- //trigger the event handler for the element depending on type
189
- switch (mutationRecordsList[0].type) {
190
- case "attributes":
191
- if ($target.attr("data-events") === "scroll" && mutationRecordsList[0].attributeName === "data-events") {
192
- $target.triggerHandler('scrollme.zf.trigger', [$target, window.pageYOffset]);
193
- }
194
- if ($target.attr("data-events") === "resize" && mutationRecordsList[0].attributeName === "data-events") {
195
- $target.triggerHandler('resizeme.zf.trigger', [$target]);
196
- }
197
- if (mutationRecordsList[0].attributeName === "style") {
198
- $target.closest("[data-mutate]").attr("data-events","mutate");
199
- $target.closest("[data-mutate]").triggerHandler('mutateme.zf.trigger', [$target.closest("[data-mutate]")]);
200
- }
201
- break;
202
-
203
- case "childList":
204
- $target.closest("[data-mutate]").attr("data-events","mutate");
205
- $target.closest("[data-mutate]").triggerHandler('mutateme.zf.trigger', [$target.closest("[data-mutate]")]);
206
- break;
207
-
208
- default:
209
- return false;
210
- //nothing
211
- }
212
- };
213
-
214
- if ($nodes.length) {
215
- //for each element that needs to listen for resizing, scrolling, or mutation add a single observer
216
- for (var i = 0; i <= $nodes.length - 1; i++) {
217
- var elementObserver = new MutationObserver(listeningElementsMutation);
218
- elementObserver.observe($nodes[i], { attributes: true, childList: true, characterData: false, subtree: true, attributeFilter: ["data-events", "style"] });
219
- }
220
- }
221
- }
222
-
223
- Triggers.Initializers.addSimpleListeners = function() {
224
- let $document = $(document);
225
-
226
- Triggers.Initializers.addOpenListener($document);
227
- Triggers.Initializers.addCloseListener($document);
228
- Triggers.Initializers.addToggleListener($document);
229
- Triggers.Initializers.addCloseableListener($document);
230
- Triggers.Initializers.addToggleFocusListener($document);
231
-
232
- }
233
-
234
- Triggers.Initializers.addGlobalListeners = function() {
235
- let $document = $(document);
236
- Triggers.Initializers.addMutationEventsListener($document);
237
- Triggers.Initializers.addResizeListener();
238
- Triggers.Initializers.addScrollListener();
239
- Triggers.Initializers.addClosemeListener();
240
- }
241
-
242
-
243
- Triggers.init = function($, Foundation) {
244
- if (typeof($.triggersInitialized) === 'undefined') {
245
- let $document = $(document);
246
-
247
- if(document.readyState === "complete") {
248
- Triggers.Initializers.addSimpleListeners();
249
- Triggers.Initializers.addGlobalListeners();
250
- } else {
251
- $(window).on('load', () => {
252
- Triggers.Initializers.addSimpleListeners();
253
- Triggers.Initializers.addGlobalListeners();
254
- });
255
- }
256
-
257
-
258
- $.triggersInitialized = true;
259
- }
260
-
261
- if(Foundation) {
262
- Foundation.Triggers = Triggers;
263
- // Legacy included to be backwards compatible for now.
264
- Foundation.IHearYou = Triggers.Initializers.addGlobalListeners
265
- }
266
- }
267
-
268
- export {Triggers};