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.
- checksums.yaml +4 -4
- data/.travis.yml +7 -6
- data/README.md +1 -1
- data/Rakefile +5 -1
- data/bower.json +3 -3
- data/foundation-rails.gemspec +1 -0
- data/lib/foundation-rails.rb +1 -0
- data/lib/foundation/rails/version.rb +1 -1
- data/lib/generators/foundation/templates/foundation_and_overrides.scss +2 -2
- data/vendor/assets/js/foundation.abide.js.es6 +462 -0
- data/vendor/assets/js/{foundation.accordion.js → foundation.accordion.js.es6} +55 -47
- data/vendor/assets/js/{foundation.accordionMenu.js → foundation.accordionMenu.js.es6} +46 -35
- data/vendor/assets/js/{foundation.core.js → foundation.core.js.es6} +10 -8
- data/vendor/assets/js/{foundation.drilldown.js → foundation.drilldown.js.es6} +75 -49
- data/vendor/assets/js/{foundation.dropdown.js → foundation.dropdown.js.es6} +100 -88
- data/vendor/assets/js/{foundation.dropdownMenu.js → foundation.dropdownMenu.js.es6} +134 -128
- data/vendor/assets/js/{foundation.equalizer.js → foundation.equalizer.js.es6} +72 -61
- data/vendor/assets/js/{foundation.interchange.js → foundation.interchange.js.es6} +44 -45
- data/vendor/assets/js/{foundation.js → foundation.js.es6} +0 -0
- data/vendor/assets/js/{foundation.magellan.js → foundation.magellan.js.es6} +80 -83
- data/vendor/assets/js/foundation.offcanvas.js.es6 +395 -0
- data/vendor/assets/js/foundation.orbit.js.es6 +445 -0
- data/vendor/assets/js/{foundation.responsiveMenu.js → foundation.responsiveMenu.js.es6} +37 -31
- data/vendor/assets/js/foundation.responsiveToggle.js.es6 +112 -0
- data/vendor/assets/js/foundation.reveal.js.es6 +544 -0
- data/vendor/assets/js/{foundation.slider.js → foundation.slider.js.es6} +235 -184
- data/vendor/assets/js/{foundation.sticky.js → foundation.sticky.js.es6} +177 -166
- data/vendor/assets/js/{foundation.tabs.js → foundation.tabs.js.es6} +138 -118
- data/vendor/assets/js/{foundation.toggler.js → foundation.toggler.js.es6} +34 -37
- data/vendor/assets/js/{foundation.tooltip.js → foundation.tooltip.js.es6} +162 -153
- data/vendor/assets/js/foundation.util.box.js.es6 +183 -0
- data/vendor/assets/js/{foundation.util.keyboard.js → foundation.util.keyboard.js.es6} +54 -54
- data/vendor/assets/js/{foundation.util.mediaQuery.js → foundation.util.mediaQuery.js.es6} +46 -46
- data/vendor/assets/js/{foundation.util.motion.js → foundation.util.motion.js.es6} +58 -48
- data/vendor/assets/js/foundation.util.nest.js.es6 +76 -0
- data/vendor/assets/js/foundation.util.timerAndImageLoader.js.es6 +86 -0
- data/vendor/assets/js/{foundation.util.touch.js → foundation.util.touch.js.es6} +2 -2
- data/vendor/assets/js/foundation.util.triggers.js.es6 +239 -0
- data/vendor/assets/scss/_global.scss +28 -27
- data/vendor/assets/scss/components/_badge.scss +1 -1
- data/vendor/assets/scss/components/_button-group.scss +77 -26
- data/vendor/assets/scss/components/_button.scss +8 -8
- data/vendor/assets/scss/components/_callout.scss +2 -2
- data/vendor/assets/scss/components/_drilldown.scss +4 -0
- data/vendor/assets/scss/components/_dropdown-menu.scss +104 -54
- data/vendor/assets/scss/components/_flex.scss +28 -0
- data/vendor/assets/scss/components/_label.scss +1 -1
- data/vendor/assets/scss/components/_media-object.scss +37 -7
- data/vendor/assets/scss/components/_menu-icon.scss +9 -0
- data/vendor/assets/scss/components/_menu.scss +127 -29
- data/vendor/assets/scss/components/_off-canvas.scss +1 -0
- data/vendor/assets/scss/components/_pagination.scss +3 -3
- data/vendor/assets/scss/components/_progress-bar.scss +1 -25
- data/vendor/assets/scss/components/_reveal.scss +12 -6
- data/vendor/assets/scss/components/_slider.scss +3 -35
- data/vendor/assets/scss/components/_table.scss +8 -0
- data/vendor/assets/scss/components/_tabs.scss +5 -10
- data/vendor/assets/scss/components/_title-bar.scss +27 -10
- data/vendor/assets/scss/components/_tooltip.scss +0 -4
- data/vendor/assets/scss/components/_top-bar.scss +93 -21
- data/vendor/assets/scss/components/_visibility.scss +1 -1
- data/vendor/assets/scss/forms/_checkbox.scss +1 -1
- data/vendor/assets/scss/forms/_error.scss +7 -5
- data/vendor/assets/scss/forms/_forms.scss +3 -0
- data/vendor/assets/scss/forms/_help-text.scss +1 -1
- data/vendor/assets/scss/forms/_input-group.scss +44 -9
- data/vendor/assets/scss/forms/_meter.scss +109 -0
- data/vendor/assets/scss/forms/_progress.scss +85 -0
- data/vendor/assets/scss/forms/_range.scss +144 -0
- data/vendor/assets/scss/forms/_select.scss +1 -1
- data/vendor/assets/scss/forms/_text.scss +10 -1
- data/vendor/assets/scss/foundation.scss +16 -5
- data/vendor/assets/scss/grid/_classes.scss +5 -18
- data/vendor/assets/scss/grid/_column.scss +13 -11
- data/vendor/assets/scss/grid/_flex-grid.scss +54 -80
- data/vendor/assets/scss/grid/_grid.scss +22 -10
- data/vendor/assets/scss/grid/_layout.scss +18 -0
- data/vendor/assets/scss/grid/_row.scss +11 -15
- data/vendor/assets/scss/motion-ui/_classes.scss +10 -3
- data/vendor/assets/scss/motion-ui/effects/_fade.scss +4 -1
- data/vendor/assets/scss/motion-ui/effects/_zoom.scss +1 -1
- data/vendor/assets/scss/motion-ui/transitions/_slide.scss +1 -1
- data/vendor/assets/scss/motion-ui/util/_transition.scss +1 -1
- data/vendor/assets/scss/settings/_settings.scss +64 -47
- data/vendor/assets/scss/typography/_base.scss +4 -0
- data/vendor/assets/scss/typography/_print.scss +9 -5
- data/vendor/assets/scss/util/_breakpoint.scss +31 -25
- data/vendor/assets/scss/util/_color.scss +19 -0
- data/vendor/assets/scss/util/_flex.scss +68 -0
- data/vendor/assets/scss/util/_mixins.scss +13 -7
- data/vendor/assets/scss/util/_util.scss +1 -5
- data/vendor/assets/scss/util/_value.scss +9 -28
- metadata +51 -31
- data/vendor/assets/js/foundation.abide.js +0 -418
- data/vendor/assets/js/foundation.offcanvas.js +0 -376
- data/vendor/assets/js/foundation.orbit.js +0 -421
- data/vendor/assets/js/foundation.responsiveToggle.js +0 -106
- data/vendor/assets/js/foundation.reveal.js +0 -514
- data/vendor/assets/js/foundation.util.box.js +0 -169
- data/vendor/assets/js/foundation.util.nest.js +0 -63
- data/vendor/assets/js/foundation.util.timerAndImageLoader.js +0 -82
- data/vendor/assets/js/foundation.util.triggers.js +0 -224
@@ -1,12 +1,53 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
!function($) {
|
4
|
+
|
1
5
|
/**
|
2
6
|
* Motion module.
|
3
7
|
* @module foundation.motion
|
4
8
|
*/
|
5
|
-
!function($, Foundation) {
|
6
9
|
|
7
|
-
|
8
|
-
|
10
|
+
const initClasses = ['mui-enter', 'mui-leave'];
|
11
|
+
const activeClasses = ['mui-enter-active', 'mui-leave-active'];
|
12
|
+
|
13
|
+
const Motion = {
|
14
|
+
animateIn: function(element, animation, cb) {
|
15
|
+
animate(true, element, animation, cb);
|
16
|
+
},
|
17
|
+
|
18
|
+
animateOut: function(element, animation, cb) {
|
19
|
+
animate(false, element, animation, cb);
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
function Move(duration, elem, fn){
|
24
|
+
var anim, prog, start = null;
|
25
|
+
// console.log('called');
|
26
|
+
|
27
|
+
function move(ts){
|
28
|
+
if(!start) start = window.performance.now();
|
29
|
+
// console.log(start, ts);
|
30
|
+
prog = ts - start;
|
31
|
+
fn.apply(elem);
|
32
|
+
|
33
|
+
if(prog < duration){ anim = window.requestAnimationFrame(move, elem); }
|
34
|
+
else{
|
35
|
+
window.cancelAnimationFrame(anim);
|
36
|
+
elem.trigger('finished.zf.animate', [elem]).triggerHandler('finished.zf.animate', [elem]);
|
37
|
+
}
|
38
|
+
}
|
39
|
+
anim = window.requestAnimationFrame(move);
|
40
|
+
}
|
9
41
|
|
42
|
+
/**
|
43
|
+
* Animates an element in or out using a CSS transition class.
|
44
|
+
* @function
|
45
|
+
* @private
|
46
|
+
* @param {Boolean} isIn - Defines if the animation is in or out.
|
47
|
+
* @param {Object} element - jQuery or HTML object to animate.
|
48
|
+
* @param {String} animation - CSS class to use.
|
49
|
+
* @param {Function} cb - Callback to run when animation is finished.
|
50
|
+
*/
|
10
51
|
function animate(isIn, element, animation, cb) {
|
11
52
|
element = $(element).eq(0);
|
12
53
|
|
@@ -17,28 +58,26 @@ function animate(isIn, element, animation, cb) {
|
|
17
58
|
|
18
59
|
// Set up the animation
|
19
60
|
reset();
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
61
|
+
|
62
|
+
element
|
63
|
+
.addClass(animation)
|
64
|
+
.css('transition', 'none');
|
65
|
+
|
66
|
+
requestAnimationFrame(() => {
|
25
67
|
element.addClass(initClass);
|
26
68
|
if (isIn) element.show();
|
27
69
|
});
|
70
|
+
|
28
71
|
// Start the animation
|
29
|
-
requestAnimationFrame(
|
72
|
+
requestAnimationFrame(() => {
|
30
73
|
element[0].offsetWidth;
|
31
|
-
element
|
32
|
-
|
74
|
+
element
|
75
|
+
.css('transition', '')
|
76
|
+
.addClass(activeClass);
|
33
77
|
});
|
34
|
-
// Move(500, element, function(){
|
35
|
-
// // element[0].offsetWidth;
|
36
|
-
// element.css('transition', '');
|
37
|
-
// element.addClass(activeClass);
|
38
|
-
// });
|
39
78
|
|
40
79
|
// Clean up the animation when it finishes
|
41
|
-
element.one(Foundation.transitionend(element), finish)
|
80
|
+
element.one(Foundation.transitionend(element), finish);
|
42
81
|
|
43
82
|
// Hides the element (for out animations), resets the element, and runs a callback
|
44
83
|
function finish() {
|
@@ -50,40 +89,11 @@ function animate(isIn, element, animation, cb) {
|
|
50
89
|
// Resets transitions and removes motion-specific classes
|
51
90
|
function reset() {
|
52
91
|
element[0].style.transitionDuration = 0;
|
53
|
-
element.removeClass(initClass
|
92
|
+
element.removeClass(`${initClass} ${activeClass} ${animation}`);
|
54
93
|
}
|
55
94
|
}
|
56
95
|
|
57
|
-
var Motion = {
|
58
|
-
animateIn: function(element, animation, /*duration,*/ cb) {
|
59
|
-
animate(true, element, animation, cb);
|
60
|
-
},
|
61
|
-
|
62
|
-
animateOut: function(element, animation, /*duration,*/ cb) {
|
63
|
-
animate(false, element, animation, cb);
|
64
|
-
}
|
65
|
-
};
|
66
|
-
|
67
|
-
var Move = function(duration, elem, fn){
|
68
|
-
var anim, prog, start = null;
|
69
|
-
// console.log('called');
|
70
|
-
|
71
|
-
function move(ts){
|
72
|
-
if(!start) start = window.performance.now();
|
73
|
-
// console.log(start, ts);
|
74
|
-
prog = ts - start;
|
75
|
-
fn.apply(elem);
|
76
|
-
|
77
|
-
if(prog < duration){ anim = window.requestAnimationFrame(move, elem); }
|
78
|
-
else{
|
79
|
-
window.cancelAnimationFrame(anim);
|
80
|
-
elem.trigger('finished.zf.animate', [elem]).triggerHandler('finished.zf.animate', [elem]);
|
81
|
-
}
|
82
|
-
}
|
83
|
-
anim = window.requestAnimationFrame(move);
|
84
|
-
};
|
85
|
-
|
86
96
|
Foundation.Move = Move;
|
87
97
|
Foundation.Motion = Motion;
|
88
98
|
|
89
|
-
}(jQuery
|
99
|
+
}(jQuery);
|
@@ -0,0 +1,76 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
!function($) {
|
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
|
+
|
14
|
+
menu.find('a:first').attr('tabindex', 0);
|
15
|
+
|
16
|
+
items.each(function() {
|
17
|
+
var $item = $(this),
|
18
|
+
$sub = $item.children('ul');
|
19
|
+
|
20
|
+
if ($sub.length) {
|
21
|
+
$item
|
22
|
+
.addClass(hasSubClass)
|
23
|
+
.attr({
|
24
|
+
'aria-haspopup': true,
|
25
|
+
'aria-expanded': false,
|
26
|
+
'aria-label': $item.children('a:first').text()
|
27
|
+
});
|
28
|
+
|
29
|
+
$sub
|
30
|
+
.addClass(`submenu ${subMenuClass}`)
|
31
|
+
.attr({
|
32
|
+
'data-submenu': '',
|
33
|
+
'aria-hidden': true,
|
34
|
+
'role': 'menu'
|
35
|
+
});
|
36
|
+
}
|
37
|
+
|
38
|
+
if ($item.parent('[data-submenu]').length) {
|
39
|
+
$item.addClass(`is-submenu-item ${subItemClass}`);
|
40
|
+
}
|
41
|
+
});
|
42
|
+
|
43
|
+
return;
|
44
|
+
},
|
45
|
+
|
46
|
+
Burn(menu, type) {
|
47
|
+
var items = menu.find('li').removeAttr('tabindex'),
|
48
|
+
subMenuClass = `is-${type}-submenu`,
|
49
|
+
subItemClass = `${subMenuClass}-item`,
|
50
|
+
hasSubClass = `is-${type}-submenu-parent`;
|
51
|
+
|
52
|
+
menu
|
53
|
+
.find('*')
|
54
|
+
.removeClass(`${subMenuClass} ${subItemClass} ${hasSubClass} is-submenu-item submenu is-active`)
|
55
|
+
.removeAttr('data-submenu').css('display', '');
|
56
|
+
|
57
|
+
// console.log( menu.find('.' + subMenuClass + ', .' + subItemClass + ', .has-submenu, .is-submenu-item, .submenu, [data-submenu]')
|
58
|
+
// .removeClass(subMenuClass + ' ' + subItemClass + ' has-submenu is-submenu-item submenu')
|
59
|
+
// .removeAttr('data-submenu'));
|
60
|
+
// items.each(function(){
|
61
|
+
// var $item = $(this),
|
62
|
+
// $sub = $item.children('ul');
|
63
|
+
// if($item.parent('[data-submenu]').length){
|
64
|
+
// $item.removeClass('is-submenu-item ' + subItemClass);
|
65
|
+
// }
|
66
|
+
// if($sub.length){
|
67
|
+
// $item.removeClass('has-submenu');
|
68
|
+
// $sub.removeClass('submenu ' + subMenuClass).removeAttr('data-submenu');
|
69
|
+
// }
|
70
|
+
// });
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
Foundation.Nest = Nest;
|
75
|
+
|
76
|
+
}(jQuery);
|
@@ -0,0 +1,86 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
!function($) {
|
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
|
+
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
|
+
/**
|
49
|
+
* Runs a callback function when images are fully loaded.
|
50
|
+
* @param {Object} images - Image(s) to check if loaded.
|
51
|
+
* @param {Func} callback - Function to execute when image is fully loaded.
|
52
|
+
*/
|
53
|
+
function onImagesLoaded(images, callback){
|
54
|
+
var self = this,
|
55
|
+
unloaded = images.length;
|
56
|
+
|
57
|
+
if (unloaded === 0) {
|
58
|
+
callback();
|
59
|
+
}
|
60
|
+
|
61
|
+
images.each(function() {
|
62
|
+
if (this.complete) {
|
63
|
+
singleImageLoaded();
|
64
|
+
}
|
65
|
+
else if (typeof this.naturalWidth !== 'undefined' && this.naturalWidth > 0) {
|
66
|
+
singleImageLoaded();
|
67
|
+
}
|
68
|
+
else {
|
69
|
+
$(this).one('load', function() {
|
70
|
+
singleImageLoaded();
|
71
|
+
});
|
72
|
+
}
|
73
|
+
});
|
74
|
+
|
75
|
+
function singleImageLoaded() {
|
76
|
+
unloaded--;
|
77
|
+
if (unloaded === 0) {
|
78
|
+
callback();
|
79
|
+
}
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
83
|
+
Foundation.Timer = Timer;
|
84
|
+
Foundation.onImagesLoaded = onImagesLoaded;
|
85
|
+
|
86
|
+
}(jQuery);
|
@@ -43,7 +43,7 @@
|
|
43
43
|
if(dir) {
|
44
44
|
e.preventDefault();
|
45
45
|
onTouchEnd.call(this);
|
46
|
-
$(this).trigger('swipe', dir).trigger(
|
46
|
+
$(this).trigger('swipe', dir).trigger(`swipe${dir}`);
|
47
47
|
}
|
48
48
|
}
|
49
49
|
}
|
@@ -70,7 +70,7 @@
|
|
70
70
|
$.event.special.swipe = { setup: init };
|
71
71
|
|
72
72
|
$.each(['left', 'up', 'down', 'right'], function () {
|
73
|
-
$.event.special[
|
73
|
+
$.event.special[`swipe${this}`] = { setup: function(){
|
74
74
|
$(this).on('swipe', $.noop);
|
75
75
|
} };
|
76
76
|
});
|
@@ -0,0 +1,239 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
!function($) {
|
4
|
+
|
5
|
+
const MutationObserver = (function () {
|
6
|
+
var prefixes = ['WebKit', 'Moz', 'O', 'Ms', ''];
|
7
|
+
for (var i=0; i < prefixes.length; i++) {
|
8
|
+
if (`${prefixes[i]}MutationObserver` in window) {
|
9
|
+
return window[`${prefixes[i]}MutationObserver`];
|
10
|
+
}
|
11
|
+
}
|
12
|
+
return false;
|
13
|
+
}());
|
14
|
+
|
15
|
+
const triggers = (el, type) => {
|
16
|
+
el.data(type).split(' ').forEach(id => {
|
17
|
+
$(`#${id}`)[ type === 'close' ? 'trigger' : 'triggerHandler'](`${type}.zf.trigger`, [el]);
|
18
|
+
});
|
19
|
+
};
|
20
|
+
// Elements with [data-open] will reveal a plugin that supports it when clicked.
|
21
|
+
$(document).on('click.zf.trigger', '[data-open]', function() {
|
22
|
+
triggers($(this), 'open');
|
23
|
+
});
|
24
|
+
|
25
|
+
// Elements with [data-close] will close a plugin that supports it when clicked.
|
26
|
+
// If used without a value on [data-close], the event will bubble, allowing it to close a parent component.
|
27
|
+
$(document).on('click.zf.trigger', '[data-close]', function() {
|
28
|
+
let id = $(this).data('close');
|
29
|
+
if (id) {
|
30
|
+
triggers($(this), 'close');
|
31
|
+
}
|
32
|
+
else {
|
33
|
+
$(this).trigger('close.zf.trigger');
|
34
|
+
}
|
35
|
+
});
|
36
|
+
|
37
|
+
// Elements with [data-toggle] will toggle a plugin that supports it when clicked.
|
38
|
+
$(document).on('click.zf.trigger', '[data-toggle]', function() {
|
39
|
+
triggers($(this), 'toggle');
|
40
|
+
});
|
41
|
+
|
42
|
+
// Elements with [data-closable] will respond to close.zf.trigger events.
|
43
|
+
$(document).on('close.zf.trigger', '[data-closable]', function(e){
|
44
|
+
e.stopPropagation();
|
45
|
+
let animation = $(this).data('closable');
|
46
|
+
|
47
|
+
if(animation !== ''){
|
48
|
+
Foundation.Motion.animateOut($(this), animation, function() {
|
49
|
+
$(this).trigger('closed.zf');
|
50
|
+
});
|
51
|
+
}else{
|
52
|
+
$(this).fadeOut().trigger('closed.zf');
|
53
|
+
}
|
54
|
+
});
|
55
|
+
|
56
|
+
$(document).on('focus.zf.trigger blur.zf.trigger', '[data-toggle-focus]', function() {
|
57
|
+
let id = $(this).data('toggle-focus');
|
58
|
+
$(`#${id}`).triggerHandler('toggle.zf.trigger', [$(this)]);
|
59
|
+
});
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Fires once after all other scripts have loaded
|
63
|
+
* @function
|
64
|
+
* @private
|
65
|
+
*/
|
66
|
+
$(window).load(() => {
|
67
|
+
checkListeners();
|
68
|
+
});
|
69
|
+
|
70
|
+
function checkListeners() {
|
71
|
+
eventsListener();
|
72
|
+
resizeListener();
|
73
|
+
scrollListener();
|
74
|
+
closemeListener();
|
75
|
+
}
|
76
|
+
|
77
|
+
//******** only fires this function once on load, if there's something to watch ********
|
78
|
+
function closemeListener(pluginName) {
|
79
|
+
var yetiBoxes = $('[data-yeti-box]'),
|
80
|
+
plugNames = ['dropdown', 'tooltip', 'reveal'];
|
81
|
+
|
82
|
+
if(pluginName){
|
83
|
+
if(typeof pluginName === 'string'){
|
84
|
+
plugNames.push(pluginName);
|
85
|
+
}else if(typeof pluginName === 'object' && typeof pluginName[0] === 'string'){
|
86
|
+
plugNames.concat(pluginName);
|
87
|
+
}else{
|
88
|
+
console.error('Plugin names must be strings');
|
89
|
+
}
|
90
|
+
}
|
91
|
+
if(yetiBoxes.length){
|
92
|
+
let listeners = plugNames.map((name) => {
|
93
|
+
return `closeme.zf.${name}`;
|
94
|
+
}).join(' ');
|
95
|
+
|
96
|
+
$(window).off(listeners).on(listeners, function(e, pluginId){
|
97
|
+
let plugin = e.namespace.split('.')[0];
|
98
|
+
let plugins = $(`[data-${plugin}]`).not(`[data-yeti-box="${pluginId}"]`);
|
99
|
+
|
100
|
+
plugins.each(function(){
|
101
|
+
let _this = $(this);
|
102
|
+
|
103
|
+
_this.triggerHandler('close.zf.trigger', [_this]);
|
104
|
+
});
|
105
|
+
});
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
function resizeListener(debounce){
|
110
|
+
let timer,
|
111
|
+
$nodes = $('[data-resize]');
|
112
|
+
if($nodes.length){
|
113
|
+
$(window).off('resize.zf.trigger')
|
114
|
+
.on('resize.zf.trigger', function(e) {
|
115
|
+
if (timer) { clearTimeout(timer); }
|
116
|
+
|
117
|
+
timer = setTimeout(function(){
|
118
|
+
|
119
|
+
if(!MutationObserver){//fallback for IE 9
|
120
|
+
$nodes.each(function(){
|
121
|
+
$(this).triggerHandler('resizeme.zf.trigger');
|
122
|
+
});
|
123
|
+
}
|
124
|
+
//trigger all listening elements and signal a resize event
|
125
|
+
$nodes.attr('data-events', "resize");
|
126
|
+
}, debounce || 10);//default time to emit resize event
|
127
|
+
});
|
128
|
+
}
|
129
|
+
}
|
130
|
+
|
131
|
+
function scrollListener(debounce){
|
132
|
+
let timer,
|
133
|
+
$nodes = $('[data-scroll]');
|
134
|
+
if($nodes.length){
|
135
|
+
$(window).off('scroll.zf.trigger')
|
136
|
+
.on('scroll.zf.trigger', function(e){
|
137
|
+
if(timer){ clearTimeout(timer); }
|
138
|
+
|
139
|
+
timer = setTimeout(function(){
|
140
|
+
|
141
|
+
if(!MutationObserver){//fallback for IE 9
|
142
|
+
$nodes.each(function(){
|
143
|
+
$(this).triggerHandler('scrollme.zf.trigger');
|
144
|
+
});
|
145
|
+
}
|
146
|
+
//trigger all listening elements and signal a scroll event
|
147
|
+
$nodes.attr('data-events', "scroll");
|
148
|
+
}, debounce || 10);//default time to emit scroll event
|
149
|
+
});
|
150
|
+
}
|
151
|
+
}
|
152
|
+
|
153
|
+
function eventsListener() {
|
154
|
+
if(!MutationObserver){ return false; }
|
155
|
+
let nodes = document.querySelectorAll('[data-resize], [data-scroll], [data-mutate]');
|
156
|
+
|
157
|
+
//element callback
|
158
|
+
var listeningElementsMutation = function(mutationRecordsList) {
|
159
|
+
var $target = $(mutationRecordsList[0].target);
|
160
|
+
//trigger the event handler for the element depending on type
|
161
|
+
switch ($target.attr("data-events")) {
|
162
|
+
|
163
|
+
case "resize" :
|
164
|
+
$target.triggerHandler('resizeme.zf.trigger', [$target]);
|
165
|
+
break;
|
166
|
+
|
167
|
+
case "scroll" :
|
168
|
+
$target.triggerHandler('scrollme.zf.trigger', [$target, window.pageYOffset]);
|
169
|
+
break;
|
170
|
+
|
171
|
+
// case "mutate" :
|
172
|
+
// console.log('mutate', $target);
|
173
|
+
// $target.triggerHandler('mutate.zf.trigger');
|
174
|
+
//
|
175
|
+
// //make sure we don't get stuck in an infinite loop from sloppy codeing
|
176
|
+
// if ($target.index('[data-mutate]') == $("[data-mutate]").length-1) {
|
177
|
+
// domMutationObserver();
|
178
|
+
// }
|
179
|
+
// break;
|
180
|
+
|
181
|
+
default :
|
182
|
+
return false;
|
183
|
+
//nothing
|
184
|
+
}
|
185
|
+
}
|
186
|
+
|
187
|
+
if(nodes.length){
|
188
|
+
//for each element that needs to listen for resizing, scrolling, (or coming soon mutation) add a single observer
|
189
|
+
for (var i = 0; i <= nodes.length-1; i++) {
|
190
|
+
let elementObserver = new MutationObserver(listeningElementsMutation);
|
191
|
+
elementObserver.observe(nodes[i], { attributes: true, childList: false, characterData: false, subtree:false, attributeFilter:["data-events"]});
|
192
|
+
}
|
193
|
+
}
|
194
|
+
}
|
195
|
+
|
196
|
+
// ------------------------------------
|
197
|
+
|
198
|
+
// [PH]
|
199
|
+
// Foundation.CheckWatchers = checkWatchers;
|
200
|
+
Foundation.IHearYou = checkListeners;
|
201
|
+
// Foundation.ISeeYou = scrollListener;
|
202
|
+
// Foundation.IFeelYou = closemeListener;
|
203
|
+
|
204
|
+
}(jQuery);
|
205
|
+
|
206
|
+
// function domMutationObserver(debounce) {
|
207
|
+
// // !!! This is coming soon and needs more work; not active !!! //
|
208
|
+
// var timer,
|
209
|
+
// nodes = document.querySelectorAll('[data-mutate]');
|
210
|
+
// //
|
211
|
+
// if (nodes.length) {
|
212
|
+
// // var MutationObserver = (function () {
|
213
|
+
// // var prefixes = ['WebKit', 'Moz', 'O', 'Ms', ''];
|
214
|
+
// // for (var i=0; i < prefixes.length; i++) {
|
215
|
+
// // if (prefixes[i] + 'MutationObserver' in window) {
|
216
|
+
// // return window[prefixes[i] + 'MutationObserver'];
|
217
|
+
// // }
|
218
|
+
// // }
|
219
|
+
// // return false;
|
220
|
+
// // }());
|
221
|
+
//
|
222
|
+
//
|
223
|
+
// //for the body, we need to listen for all changes effecting the style and class attributes
|
224
|
+
// var bodyObserver = new MutationObserver(bodyMutation);
|
225
|
+
// bodyObserver.observe(document.body, { attributes: true, childList: true, characterData: false, subtree:true, attributeFilter:["style", "class"]});
|
226
|
+
//
|
227
|
+
//
|
228
|
+
// //body callback
|
229
|
+
// function bodyMutation(mutate) {
|
230
|
+
// //trigger all listening elements and signal a mutation event
|
231
|
+
// if (timer) { clearTimeout(timer); }
|
232
|
+
//
|
233
|
+
// timer = setTimeout(function() {
|
234
|
+
// bodyObserver.disconnect();
|
235
|
+
// $('[data-mutate]').attr('data-events',"mutate");
|
236
|
+
// }, debounce || 150);
|
237
|
+
// }
|
238
|
+
// }
|
239
|
+
// }
|