foundation-rails 6.2.4.0 → 6.3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/Rakefile +2 -0
- data/bower.json +2 -2
- data/lib/foundation/rails/version.rb +1 -1
- data/lib/generators/foundation/templates/_settings.scss +117 -70
- data/lib/generators/foundation/templates/foundation_and_overrides.scss +2 -1
- data/vendor/assets/_vendor/normalize-scss/sass/_normalize.scss +3 -0
- data/vendor/assets/_vendor/normalize-scss/sass/normalize/_import-now.scss +11 -0
- data/vendor/assets/_vendor/normalize-scss/sass/normalize/_normalize-mixin.scss +676 -0
- data/vendor/assets/_vendor/normalize-scss/sass/normalize/_variables.scss +36 -0
- data/vendor/assets/_vendor/normalize-scss/sass/normalize/_vertical-rhythm.scss +61 -0
- data/vendor/assets/_vendor/sassy-lists/stylesheets/functions/_purge.scss +38 -0
- data/vendor/assets/_vendor/sassy-lists/stylesheets/functions/_remove.scss +31 -0
- data/vendor/assets/_vendor/sassy-lists/stylesheets/functions/_replace.scss +46 -0
- data/vendor/assets/_vendor/sassy-lists/stylesheets/functions/_to-list.scss +27 -0
- data/vendor/assets/_vendor/sassy-lists/stylesheets/helpers/_missing-dependencies.scss +25 -0
- data/vendor/assets/_vendor/sassy-lists/stylesheets/helpers/_true.scss +13 -0
- data/vendor/assets/js/foundation.abide.js.es6 +28 -0
- data/vendor/assets/js/foundation.accordion.js.es6 +1 -1
- data/vendor/assets/js/foundation.accordionMenu.js.es6 +9 -1
- data/vendor/assets/js/foundation.core.js.es6 +4 -4
- data/vendor/assets/js/foundation.drilldown.js.es6 +128 -14
- data/vendor/assets/js/foundation.dropdown.js.es6 +48 -42
- data/vendor/assets/js/foundation.dropdownMenu.js.es6 +20 -18
- data/vendor/assets/js/foundation.equalizer.js.es6 +12 -6
- data/vendor/assets/js/foundation.interchange.js.es6 +3 -2
- data/vendor/assets/js/foundation.js.es6 +2 -1
- data/vendor/assets/js/foundation.magellan.js.es6 +28 -9
- data/vendor/assets/js/foundation.offcanvas.js.es6 +90 -123
- data/vendor/assets/js/foundation.orbit.js.es6 +61 -10
- data/vendor/assets/js/foundation.responsiveMenu.js.es6 +2 -0
- data/vendor/assets/js/foundation.responsiveToggle.js.es6 +52 -12
- data/vendor/assets/js/foundation.reveal.js.es6 +48 -48
- data/vendor/assets/js/foundation.slider.js.es6 +124 -42
- data/vendor/assets/js/foundation.sticky.js.es6 +11 -9
- data/vendor/assets/js/foundation.tabs.js.es6 +164 -35
- data/vendor/assets/js/foundation.toggler.js.es6 +3 -0
- data/vendor/assets/js/foundation.tooltip.js.es6 +20 -10
- data/vendor/assets/js/foundation.util.box.js.es6 +2 -2
- data/vendor/assets/js/foundation.util.keyboard.js.es6 +37 -0
- data/vendor/assets/js/foundation.util.mediaQuery.js.es6 +16 -0
- data/vendor/assets/js/foundation.util.motion.js.es6 +7 -1
- data/vendor/assets/js/foundation.util.nest.js.es6 +10 -5
- data/vendor/assets/js/foundation.util.timerAndImageLoader.js.es6 +6 -4
- data/vendor/assets/js/foundation.util.triggers.js.es6 +54 -36
- data/vendor/assets/js/foundation.zf.responsiveAccordionTabs.js.es6 +240 -0
- data/vendor/assets/scss/_global.scss +25 -450
- data/vendor/assets/scss/components/_accordion-menu.scss +8 -4
- data/vendor/assets/scss/components/_accordion.scss +43 -22
- data/vendor/assets/scss/components/_badge.scss +17 -9
- data/vendor/assets/scss/components/_breadcrumbs.scss +7 -5
- data/vendor/assets/scss/components/_button-group.scss +54 -6
- data/vendor/assets/scss/components/_button.scss +27 -16
- data/vendor/assets/scss/components/_callout.scss +3 -2
- data/vendor/assets/scss/components/_card.scss +121 -0
- data/vendor/assets/scss/components/_close-button.scss +54 -13
- data/vendor/assets/scss/components/_drilldown.scss +19 -5
- data/vendor/assets/scss/components/_dropdown-menu.scss +23 -18
- data/vendor/assets/scss/components/_dropdown.scss +14 -7
- data/vendor/assets/scss/components/_flex-video.scss +1 -63
- data/vendor/assets/scss/components/_float.scss +1 -1
- data/vendor/assets/scss/components/_label.scss +16 -8
- data/vendor/assets/scss/components/_media-object.scss +2 -3
- data/vendor/assets/scss/components/_menu.scss +68 -33
- data/vendor/assets/scss/components/_off-canvas.scss +231 -80
- data/vendor/assets/scss/components/_orbit.scss +8 -6
- data/vendor/assets/scss/components/_pagination.scss +42 -22
- data/vendor/assets/scss/components/_progress-bar.scss +1 -1
- data/vendor/assets/scss/components/_responsive-embed.scss +66 -0
- data/vendor/assets/scss/components/_reveal.scss +17 -11
- data/vendor/assets/scss/components/_slider.scss +6 -1
- data/vendor/assets/scss/components/_sticky.scss +3 -3
- data/vendor/assets/scss/components/_switch.scss +47 -36
- data/vendor/assets/scss/components/_table.scss +83 -23
- data/vendor/assets/scss/components/_tabs.scss +54 -23
- data/vendor/assets/scss/components/_thumbnail.scss +17 -4
- data/vendor/assets/scss/components/_title-bar.scss +5 -6
- data/vendor/assets/scss/components/_tooltip.scss +15 -12
- data/vendor/assets/scss/components/_top-bar.scss +11 -8
- data/vendor/assets/scss/forms/_checkbox.scss +2 -1
- data/vendor/assets/scss/forms/_error.scss +10 -6
- data/vendor/assets/scss/forms/_fieldset.scss +7 -7
- data/vendor/assets/scss/forms/_input-group.scss +17 -11
- data/vendor/assets/scss/forms/_label.scss +2 -0
- data/vendor/assets/scss/forms/_meter.scss +9 -10
- data/vendor/assets/scss/forms/_progress.scss +9 -9
- data/vendor/assets/scss/forms/_range.scss +20 -15
- data/vendor/assets/scss/forms/_select.scss +26 -8
- data/vendor/assets/scss/forms/_text.scss +19 -16
- data/vendor/assets/scss/foundation.scss +19 -3
- data/vendor/assets/scss/grid/_classes.scss +31 -14
- data/vendor/assets/scss/grid/_column.scss +10 -24
- data/vendor/assets/scss/grid/_flex-grid.scss +84 -76
- data/vendor/assets/scss/grid/_grid.scss +0 -16
- data/vendor/assets/scss/grid/_gutter.scss +53 -5
- data/vendor/assets/scss/grid/_layout.scss +3 -3
- data/vendor/assets/scss/grid/_position.scss +3 -3
- data/vendor/assets/scss/grid/_row.scss +24 -19
- data/vendor/assets/scss/settings/_settings.scss +117 -70
- data/vendor/assets/scss/typography/_base.scss +110 -44
- data/vendor/assets/scss/typography/_helpers.scss +1 -0
- data/vendor/assets/scss/typography/_print.scss +7 -3
- data/vendor/assets/scss/typography/_typography.scss +0 -2
- data/vendor/assets/scss/util/_breakpoint.scss +28 -19
- data/vendor/assets/scss/util/_color.scss +69 -16
- data/vendor/assets/scss/util/_flex.scss +20 -3
- data/vendor/assets/scss/util/_math.scss +72 -0
- data/vendor/assets/scss/util/_mixins.scss +63 -26
- data/vendor/assets/scss/util/_selector.scss +3 -2
- data/vendor/assets/scss/util/_unit.scss +61 -4
- data/vendor/assets/scss/util/_util.scss +1 -0
- data/vendor/assets/scss/util/_value.scss +33 -0
- metadata +17 -2
@@ -34,9 +34,17 @@ var Keyboard = {
|
|
34
34
|
*/
|
35
35
|
parseKey(event) {
|
36
36
|
var key = keyCodes[event.which || event.keyCode] || String.fromCharCode(event.which).toUpperCase();
|
37
|
+
|
38
|
+
// Remove un-printable characters, e.g. for `fromCharCode` calls for CTRL only events
|
39
|
+
key = key.replace(/\W+/, '');
|
40
|
+
|
37
41
|
if (event.shiftKey) key = `SHIFT_${key}`;
|
38
42
|
if (event.ctrlKey) key = `CTRL_${key}`;
|
39
43
|
if (event.altKey) key = `ALT_${key}`;
|
44
|
+
|
45
|
+
// Remove trailing underscore, in case only modifiers were used (e.g. only `CTRL_ALT`)
|
46
|
+
key = key.replace(/_$/, '');
|
47
|
+
|
40
48
|
return key;
|
41
49
|
},
|
42
50
|
|
@@ -83,6 +91,7 @@ var Keyboard = {
|
|
83
91
|
* @return {jQuery} $focusable - all focusable elements within `$element`
|
84
92
|
*/
|
85
93
|
findFocusable($element) {
|
94
|
+
if(!$element) {return false; }
|
86
95
|
return $element.find('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, *[tabindex], *[contenteditable]').filter(function() {
|
87
96
|
if (!$(this).is(':visible') || $(this).attr('tabindex') < 0) { return false; } //only have visible elements and those that have a tabindex greater or equal 0
|
88
97
|
return true;
|
@@ -97,6 +106,34 @@ var Keyboard = {
|
|
97
106
|
|
98
107
|
register(componentName, cmds) {
|
99
108
|
commands[componentName] = cmds;
|
109
|
+
},
|
110
|
+
|
111
|
+
/**
|
112
|
+
* Traps the focus in the given element.
|
113
|
+
* @param {jQuery} $element jQuery object to trap the foucs into.
|
114
|
+
*/
|
115
|
+
trapFocus($element) {
|
116
|
+
var $focusable = Foundation.Keyboard.findFocusable($element),
|
117
|
+
$firstFocusable = $focusable.eq(0),
|
118
|
+
$lastFocusable = $focusable.eq(-1);
|
119
|
+
|
120
|
+
$element.on('keydown.zf.trapfocus', function(event) {
|
121
|
+
if (event.target === $lastFocusable[0] && Foundation.Keyboard.parseKey(event) === 'TAB') {
|
122
|
+
event.preventDefault();
|
123
|
+
$firstFocusable.focus();
|
124
|
+
}
|
125
|
+
else if (event.target === $firstFocusable[0] && Foundation.Keyboard.parseKey(event) === 'SHIFT_TAB') {
|
126
|
+
event.preventDefault();
|
127
|
+
$lastFocusable.focus();
|
128
|
+
}
|
129
|
+
});
|
130
|
+
},
|
131
|
+
/**
|
132
|
+
* Releases the trapped focus from the given element.
|
133
|
+
* @param {jQuery} $element jQuery object to release the focus for.
|
134
|
+
*/
|
135
|
+
releaseFocus($element) {
|
136
|
+
$element.off('keydown.zf.trapfocus');
|
100
137
|
}
|
101
138
|
}
|
102
139
|
|
@@ -62,6 +62,22 @@ var MediaQuery = {
|
|
62
62
|
return false;
|
63
63
|
},
|
64
64
|
|
65
|
+
/**
|
66
|
+
* Checks if the screen matches to a breakpoint.
|
67
|
+
* @function
|
68
|
+
* @param {String} size - Name of the breakpoint to check, either 'small only' or 'small'. Omitting 'only' falls back to using atLeast() method.
|
69
|
+
* @returns {Boolean} `true` if the breakpoint matches, `false` if it does not.
|
70
|
+
*/
|
71
|
+
is(size) {
|
72
|
+
size = size.trim().split(' ');
|
73
|
+
if(size.length > 1 && size[1] === 'only') {
|
74
|
+
if(size[0] === this._getCurrentSize()) return true;
|
75
|
+
} else {
|
76
|
+
return this.atLeast(size[0]);
|
77
|
+
}
|
78
|
+
return false;
|
79
|
+
},
|
80
|
+
|
65
81
|
/**
|
66
82
|
* Gets the media query of a breakpoint.
|
67
83
|
* @function
|
@@ -24,8 +24,14 @@ function Move(duration, elem, fn){
|
|
24
24
|
var anim, prog, start = null;
|
25
25
|
// console.log('called');
|
26
26
|
|
27
|
+
if (duration === 0) {
|
28
|
+
fn.apply(elem);
|
29
|
+
elem.trigger('finished.zf.animate', [elem]).triggerHandler('finished.zf.animate', [elem]);
|
30
|
+
return;
|
31
|
+
}
|
32
|
+
|
27
33
|
function move(ts){
|
28
|
-
if(!start) start =
|
34
|
+
if(!start) start = ts;
|
29
35
|
// console.log(start, ts);
|
30
36
|
prog = ts - start;
|
31
37
|
fn.apply(elem);
|
@@ -11,8 +11,6 @@ const Nest = {
|
|
11
11
|
subItemClass = `${subMenuClass}-item`,
|
12
12
|
hasSubClass = `is-${type}-submenu-parent`;
|
13
13
|
|
14
|
-
menu.find('a:first').attr('tabindex', 0);
|
15
|
-
|
16
14
|
items.each(function() {
|
17
15
|
var $item = $(this),
|
18
16
|
$sub = $item.children('ul');
|
@@ -22,17 +20,24 @@ const Nest = {
|
|
22
20
|
.addClass(hasSubClass)
|
23
21
|
.attr({
|
24
22
|
'aria-haspopup': true,
|
25
|
-
'aria-expanded': false,
|
26
23
|
'aria-label': $item.children('a:first').text()
|
27
24
|
});
|
25
|
+
// Note: Drilldowns behave differently in how they hide, and so need
|
26
|
+
// additional attributes. We should look if this possibly over-generalized
|
27
|
+
// utility (Nest) is appropriate when we rework menus in 6.4
|
28
|
+
if(type === 'drilldown') {
|
29
|
+
$item.attr({'aria-expanded': false});
|
30
|
+
}
|
28
31
|
|
29
32
|
$sub
|
30
33
|
.addClass(`submenu ${subMenuClass}`)
|
31
34
|
.attr({
|
32
35
|
'data-submenu': '',
|
33
|
-
'aria-hidden': true,
|
34
36
|
'role': 'menu'
|
35
37
|
});
|
38
|
+
if(type === 'drilldown') {
|
39
|
+
$sub.attr({'aria-hidden': true});
|
40
|
+
}
|
36
41
|
}
|
37
42
|
|
38
43
|
if ($item.parent('[data-submenu]').length) {
|
@@ -44,7 +49,7 @@ const Nest = {
|
|
44
49
|
},
|
45
50
|
|
46
51
|
Burn(menu, type) {
|
47
|
-
var items = menu.find('li')
|
52
|
+
var //items = menu.find('li'),
|
48
53
|
subMenuClass = `is-${type}-submenu`,
|
49
54
|
subItemClass = `${subMenuClass}-item`,
|
50
55
|
hasSubClass = `is-${type}-submenu-parent`;
|
@@ -59,13 +59,15 @@ function onImagesLoaded(images, callback){
|
|
59
59
|
}
|
60
60
|
|
61
61
|
images.each(function() {
|
62
|
-
if
|
63
|
-
|
64
|
-
}
|
65
|
-
else if (typeof this.naturalWidth !== 'undefined' && this.naturalWidth > 0) {
|
62
|
+
// Check if image is loaded
|
63
|
+
if (this.complete || (this.readyState === 4) || (this.readyState === 'complete')) {
|
66
64
|
singleImageLoaded();
|
67
65
|
}
|
66
|
+
// Force load the image
|
68
67
|
else {
|
68
|
+
// fix for IE. See https://css-tricks.com/snippets/jquery/fixing-load-in-ie-for-cached-images/
|
69
|
+
var src = $(this).attr('src');
|
70
|
+
$(this).attr('src', src + '?' + (new Date().getTime()));
|
69
71
|
$(this).one('load', function() {
|
70
72
|
singleImageLoaded();
|
71
73
|
});
|
@@ -36,7 +36,12 @@ $(document).on('click.zf.trigger', '[data-close]', function() {
|
|
36
36
|
|
37
37
|
// Elements with [data-toggle] will toggle a plugin that supports it when clicked.
|
38
38
|
$(document).on('click.zf.trigger', '[data-toggle]', function() {
|
39
|
-
|
39
|
+
let id = $(this).data('toggle');
|
40
|
+
if (id) {
|
41
|
+
triggers($(this), 'toggle');
|
42
|
+
} else {
|
43
|
+
$(this).trigger('toggle.zf.trigger');
|
44
|
+
}
|
40
45
|
});
|
41
46
|
|
42
47
|
// Elements with [data-closable] will respond to close.zf.trigger events.
|
@@ -71,6 +76,7 @@ function checkListeners() {
|
|
71
76
|
eventsListener();
|
72
77
|
resizeListener();
|
73
78
|
scrollListener();
|
79
|
+
mutateListener();
|
74
80
|
closemeListener();
|
75
81
|
}
|
76
82
|
|
@@ -150,49 +156,61 @@ function scrollListener(debounce){
|
|
150
156
|
}
|
151
157
|
}
|
152
158
|
|
159
|
+
function mutateListener(debounce) {
|
160
|
+
let $nodes = $('[data-mutate]');
|
161
|
+
if ($nodes.length && MutationObserver){
|
162
|
+
//trigger all listening elements and signal a mutate event
|
163
|
+
//no IE 9 or 10
|
164
|
+
$nodes.each(function () {
|
165
|
+
$(this).triggerHandler('mutateme.zf.trigger');
|
166
|
+
});
|
167
|
+
}
|
168
|
+
}
|
169
|
+
|
153
170
|
function eventsListener() {
|
154
171
|
if(!MutationObserver){ return false; }
|
155
172
|
let nodes = document.querySelectorAll('[data-resize], [data-scroll], [data-mutate]');
|
156
173
|
|
157
174
|
//element callback
|
158
|
-
var listeningElementsMutation = function(mutationRecordsList) {
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
175
|
+
var listeningElementsMutation = function (mutationRecordsList) {
|
176
|
+
var $target = $(mutationRecordsList[0].target);
|
177
|
+
|
178
|
+
//trigger the event handler for the element depending on type
|
179
|
+
switch (mutationRecordsList[0].type) {
|
180
|
+
|
181
|
+
case "attributes":
|
182
|
+
if ($target.attr("data-events") === "scroll" && mutationRecordsList[0].attributeName === "data-events") {
|
183
|
+
$target.triggerHandler('scrollme.zf.trigger', [$target, window.pageYOffset]);
|
184
|
+
}
|
185
|
+
if ($target.attr("data-events") === "resize" && mutationRecordsList[0].attributeName === "data-events") {
|
186
|
+
$target.triggerHandler('resizeme.zf.trigger', [$target]);
|
187
|
+
}
|
188
|
+
if (mutationRecordsList[0].attributeName === "style") {
|
189
|
+
$target.closest("[data-mutate]").attr("data-events","mutate");
|
190
|
+
$target.closest("[data-mutate]").triggerHandler('mutateme.zf.trigger', [$target.closest("[data-mutate]")]);
|
191
|
+
}
|
192
|
+
break;
|
193
|
+
|
194
|
+
case "childList":
|
195
|
+
$target.closest("[data-mutate]").attr("data-events","mutate");
|
196
|
+
$target.closest("[data-mutate]").triggerHandler('mutateme.zf.trigger', [$target.closest("[data-mutate]")]);
|
197
|
+
break;
|
198
|
+
|
199
|
+
default:
|
200
|
+
return false;
|
201
|
+
//nothing
|
202
|
+
}
|
203
|
+
};
|
204
|
+
|
205
|
+
if (nodes.length) {
|
206
|
+
//for each element that needs to listen for resizing, scrolling, or mutation add a single observer
|
207
|
+
for (var i = 0; i <= nodes.length - 1; i++) {
|
208
|
+
var elementObserver = new MutationObserver(listeningElementsMutation);
|
209
|
+
elementObserver.observe(nodes[i], { attributes: true, childList: true, characterData: false, subtree: true, attributeFilter: ["data-events", "style"] });
|
210
|
+
}
|
184
211
|
}
|
185
212
|
}
|
186
213
|
|
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
214
|
// ------------------------------------
|
197
215
|
|
198
216
|
// [PH]
|
@@ -0,0 +1,240 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
!function($) {
|
4
|
+
|
5
|
+
/**
|
6
|
+
* ResponsiveAccordionTabs module.
|
7
|
+
* @module foundation.responsiveAccordionTabs
|
8
|
+
* @requires foundation.util.keyboard
|
9
|
+
* @requires foundation.util.timerAndImageLoader
|
10
|
+
* @requires foundation.util.motion
|
11
|
+
* @requires foundation.accordion
|
12
|
+
* @requires foundation.tabs
|
13
|
+
*/
|
14
|
+
|
15
|
+
class ResponsiveAccordionTabs {
|
16
|
+
/**
|
17
|
+
* Creates a new instance of a responsive accordion tabs.
|
18
|
+
* @class
|
19
|
+
* @fires ResponsiveAccordionTabs#init
|
20
|
+
* @param {jQuery} element - jQuery object to make into a dropdown menu.
|
21
|
+
* @param {Object} options - Overrides to the default plugin settings.
|
22
|
+
*/
|
23
|
+
constructor(element, options) {
|
24
|
+
this.$element = $(element);
|
25
|
+
this.options = $.extend({}, this.$element.data(), options);
|
26
|
+
this.rules = this.$element.data('responsive-accordion-tabs');
|
27
|
+
this.currentMq = null;
|
28
|
+
this.currentPlugin = null;
|
29
|
+
if (!this.$element.attr('id')) {
|
30
|
+
this.$element.attr('id',Foundation.GetYoDigits(6, 'responsiveaccordiontabs'));
|
31
|
+
};
|
32
|
+
|
33
|
+
this._init();
|
34
|
+
this._events();
|
35
|
+
|
36
|
+
Foundation.registerPlugin(this, 'ResponsiveAccordionTabs');
|
37
|
+
}
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Initializes the Menu by parsing the classes from the 'data-responsive-accordion-tabs' attribute on the element.
|
41
|
+
* @function
|
42
|
+
* @private
|
43
|
+
*/
|
44
|
+
_init() {
|
45
|
+
// The first time an Interchange plugin is initialized, this.rules is converted from a string of "classes" to an object of rules
|
46
|
+
if (typeof this.rules === 'string') {
|
47
|
+
let rulesTree = {};
|
48
|
+
|
49
|
+
// Parse rules from "classes" pulled from data attribute
|
50
|
+
let rules = this.rules.split(' ');
|
51
|
+
|
52
|
+
// Iterate through every rule found
|
53
|
+
for (let i = 0; i < rules.length; i++) {
|
54
|
+
let rule = rules[i].split('-');
|
55
|
+
let ruleSize = rule.length > 1 ? rule[0] : 'small';
|
56
|
+
let rulePlugin = rule.length > 1 ? rule[1] : rule[0];
|
57
|
+
|
58
|
+
if (MenuPlugins[rulePlugin] !== null) {
|
59
|
+
rulesTree[ruleSize] = MenuPlugins[rulePlugin];
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
this.rules = rulesTree;
|
64
|
+
}
|
65
|
+
|
66
|
+
this._getAllOptions();
|
67
|
+
|
68
|
+
if (!$.isEmptyObject(this.rules)) {
|
69
|
+
this._checkMediaQueries();
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
_getAllOptions() {
|
74
|
+
//get all defaults and options
|
75
|
+
var _this = this;
|
76
|
+
_this.allOptions = {};
|
77
|
+
for (var key in MenuPlugins) {
|
78
|
+
if (MenuPlugins.hasOwnProperty(key)) {
|
79
|
+
var obj = MenuPlugins[key];
|
80
|
+
try {
|
81
|
+
var dummyPlugin = $('<ul></ul>');
|
82
|
+
var tmpPlugin = new obj.plugin(dummyPlugin,_this.options);
|
83
|
+
for (var keyKey in tmpPlugin.options) {
|
84
|
+
if (tmpPlugin.options.hasOwnProperty(keyKey) && keyKey !== 'zfPlugin') {
|
85
|
+
var objObj = tmpPlugin.options[keyKey];
|
86
|
+
_this.allOptions[keyKey] = objObj;
|
87
|
+
}
|
88
|
+
}
|
89
|
+
tmpPlugin.destroy();
|
90
|
+
}
|
91
|
+
catch(e) {
|
92
|
+
}
|
93
|
+
}
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
/**
|
98
|
+
* Initializes events for the Menu.
|
99
|
+
* @function
|
100
|
+
* @private
|
101
|
+
*/
|
102
|
+
_events() {
|
103
|
+
var _this = this;
|
104
|
+
|
105
|
+
$(window).on('changed.zf.mediaquery', function() {
|
106
|
+
_this._checkMediaQueries();
|
107
|
+
});
|
108
|
+
}
|
109
|
+
|
110
|
+
/**
|
111
|
+
* Checks the current screen width against available media queries. If the media query has changed, and the plugin needed has changed, the plugins will swap out.
|
112
|
+
* @function
|
113
|
+
* @private
|
114
|
+
*/
|
115
|
+
_checkMediaQueries() {
|
116
|
+
var matchedMq, _this = this;
|
117
|
+
// Iterate through each rule and find the last matching rule
|
118
|
+
$.each(this.rules, function(key) {
|
119
|
+
if (Foundation.MediaQuery.atLeast(key)) {
|
120
|
+
matchedMq = key;
|
121
|
+
}
|
122
|
+
});
|
123
|
+
|
124
|
+
// No match? No dice
|
125
|
+
if (!matchedMq) return;
|
126
|
+
|
127
|
+
// Plugin already initialized? We good
|
128
|
+
if (this.currentPlugin instanceof this.rules[matchedMq].plugin) return;
|
129
|
+
|
130
|
+
// Remove existing plugin-specific CSS classes
|
131
|
+
$.each(MenuPlugins, function(key, value) {
|
132
|
+
_this.$element.removeClass(value.cssClass);
|
133
|
+
});
|
134
|
+
|
135
|
+
// Add the CSS class for the new plugin
|
136
|
+
this.$element.addClass(this.rules[matchedMq].cssClass);
|
137
|
+
|
138
|
+
// Create an instance of the new plugin
|
139
|
+
if (this.currentPlugin) {
|
140
|
+
//don't know why but on nested elements data zfPlugin get's lost
|
141
|
+
if (!this.currentPlugin.$element.data('zfPlugin') && this.storezfData) this.currentPlugin.$element.data('zfPlugin',this.storezfData);
|
142
|
+
this.currentPlugin.destroy();
|
143
|
+
}
|
144
|
+
this._handleMarkup(this.rules[matchedMq].cssClass);
|
145
|
+
this.currentPlugin = new this.rules[matchedMq].plugin(this.$element, {});
|
146
|
+
this.storezfData = this.currentPlugin.$element.data('zfPlugin');
|
147
|
+
|
148
|
+
}
|
149
|
+
|
150
|
+
_handleMarkup(toSet){
|
151
|
+
var _this = this, fromString = 'accordion';
|
152
|
+
var $panels = $('[data-tabs-content='+this.$element.attr('id')+']');
|
153
|
+
if ($panels.length) fromString = 'tabs';
|
154
|
+
if (fromString === toSet) {
|
155
|
+
return;
|
156
|
+
};
|
157
|
+
|
158
|
+
var tabsTitle = _this.allOptions.linkClass?_this.allOptions.linkClass:'tabs-title';
|
159
|
+
var tabsPanel = _this.allOptions.panelClass?_this.allOptions.panelClass:'tabs-panel';
|
160
|
+
|
161
|
+
this.$element.removeAttr('role');
|
162
|
+
var $liHeads = this.$element.children('.'+tabsTitle+',[data-accordion-item]').removeClass(tabsTitle).removeClass('accordion-item').removeAttr('data-accordion-item');
|
163
|
+
var $liHeadsA = $liHeads.children('a').removeClass('accordion-title');
|
164
|
+
|
165
|
+
if (fromString === 'tabs') {
|
166
|
+
$panels = $panels.children('.'+tabsPanel).removeClass(tabsPanel).removeAttr('role').removeAttr('aria-hidden').removeAttr('aria-labelledby');
|
167
|
+
$panels.children('a').removeAttr('role').removeAttr('aria-controls').removeAttr('aria-selected');
|
168
|
+
}else{
|
169
|
+
$panels = $liHeads.children('[data-tab-content]').removeClass('accordion-content');
|
170
|
+
};
|
171
|
+
|
172
|
+
$panels.css({display:'',visibility:''});
|
173
|
+
$liHeads.css({display:'',visibility:''});
|
174
|
+
if (toSet === 'accordion') {
|
175
|
+
$panels.each(function(key,value){
|
176
|
+
$(value).appendTo($liHeads.get(key)).addClass('accordion-content').attr('data-tab-content','').removeClass('is-active').css({height:''});
|
177
|
+
$('[data-tabs-content='+_this.$element.attr('id')+']').after('<div id="tabs-placeholder-'+_this.$element.attr('id')+'"></div>').remove();
|
178
|
+
$liHeads.addClass('accordion-item').attr('data-accordion-item','');
|
179
|
+
$liHeadsA.addClass('accordion-title');
|
180
|
+
});
|
181
|
+
}else if (toSet === 'tabs'){
|
182
|
+
var $tabsContent = $('[data-tabs-content='+_this.$element.attr('id')+']');
|
183
|
+
var $placeholder = $('#tabs-placeholder-'+_this.$element.attr('id'));
|
184
|
+
if ($placeholder.length) {
|
185
|
+
$tabsContent = $('<div class="tabs-content"></div>').insertAfter($placeholder).attr('data-tabs-content',_this.$element.attr('id'));
|
186
|
+
$placeholder.remove();
|
187
|
+
}else{
|
188
|
+
$tabsContent = $('<div class="tabs-content"></div>').insertAfter(_this.$element).attr('data-tabs-content',_this.$element.attr('id'));
|
189
|
+
};
|
190
|
+
$panels.each(function(key,value){
|
191
|
+
var tempValue = $(value).appendTo($tabsContent).addClass(tabsPanel);
|
192
|
+
var hash = $liHeadsA.get(key).hash.slice(1);
|
193
|
+
var id = $(value).attr('id') || Foundation.GetYoDigits(6, 'accordion');
|
194
|
+
if (hash !== id) {
|
195
|
+
if (hash !== '') {
|
196
|
+
$(value).attr('id',hash);
|
197
|
+
}else{
|
198
|
+
hash = id;
|
199
|
+
$(value).attr('id',hash);
|
200
|
+
$($liHeadsA.get(key)).attr('href',$($liHeadsA.get(key)).attr('href').replace('#','')+'#'+hash);
|
201
|
+
};
|
202
|
+
};
|
203
|
+
var isActive = $($liHeads.get(key)).hasClass('is-active');
|
204
|
+
if (isActive) {
|
205
|
+
tempValue.addClass('is-active');
|
206
|
+
};
|
207
|
+
});
|
208
|
+
$liHeads.addClass(tabsTitle);
|
209
|
+
};
|
210
|
+
}
|
211
|
+
|
212
|
+
/**
|
213
|
+
* Destroys the instance of the current plugin on this element, as well as the window resize handler that switches the plugins out.
|
214
|
+
* @function
|
215
|
+
*/
|
216
|
+
destroy() {
|
217
|
+
if (this.currentPlugin) this.currentPlugin.destroy();
|
218
|
+
$(window).off('.zf.ResponsiveAccordionTabs');
|
219
|
+
Foundation.unregisterPlugin(this);
|
220
|
+
}
|
221
|
+
}
|
222
|
+
|
223
|
+
ResponsiveAccordionTabs.defaults = {};
|
224
|
+
|
225
|
+
// The plugin matches the plugin classes with these plugin instances.
|
226
|
+
var MenuPlugins = {
|
227
|
+
tabs: {
|
228
|
+
cssClass: 'tabs',
|
229
|
+
plugin: Foundation._plugins.tabs || null
|
230
|
+
},
|
231
|
+
accordion: {
|
232
|
+
cssClass: 'accordion',
|
233
|
+
plugin: Foundation._plugins.accordion || null
|
234
|
+
}
|
235
|
+
};
|
236
|
+
|
237
|
+
// Window exports
|
238
|
+
Foundation.plugin(ResponsiveAccordionTabs, 'ResponsiveAccordionTabs');
|
239
|
+
|
240
|
+
}(jQuery);
|