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.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/Rakefile +5 -6
- data/lib/foundation/rails/version.rb +1 -1
- data/vendor/assets/js/foundation.abide.js +781 -0
- data/vendor/assets/js/foundation.accordion.js +511 -0
- data/vendor/assets/js/foundation.accordionMenu.js +527 -0
- data/vendor/assets/js/foundation.core.js +860 -0
- data/vendor/assets/js/foundation.drilldown.js +759 -0
- data/vendor/assets/js/foundation.dropdown.js +1131 -0
- data/vendor/assets/js/foundation.dropdownMenu.js +678 -0
- data/vendor/assets/js/foundation.equalizer.js +542 -0
- data/vendor/assets/js/foundation.interchange.js +399 -0
- data/vendor/assets/js/{foundation.js.es6 → foundation.js} +11 -12
- data/vendor/assets/js/foundation.magellan.js +449 -0
- data/vendor/assets/js/foundation.offcanvas.js +1052 -0
- data/vendor/assets/js/foundation.orbit.js +767 -0
- data/vendor/assets/js/foundation.responsiveAccordionTabs.js +440 -0
- data/vendor/assets/js/foundation.responsiveMenu.js +362 -0
- data/vendor/assets/js/foundation.responsiveToggle.js +336 -0
- data/vendor/assets/js/foundation.reveal.js +1066 -0
- data/vendor/assets/js/foundation.slider.js +1236 -0
- data/vendor/assets/js/foundation.smoothScroll.js +303 -0
- data/vendor/assets/js/foundation.sticky.js +1001 -0
- data/vendor/assets/js/foundation.tabs.js +678 -0
- data/vendor/assets/js/foundation.toggler.js +602 -0
- data/vendor/assets/js/foundation.tooltip.js +1195 -0
- data/vendor/assets/js/{foundation.util.box.js.es6 → foundation.util.box.js} +154 -41
- data/vendor/assets/js/foundation.util.imageLoader.js +163 -0
- data/vendor/assets/js/foundation.util.keyboard.js +298 -0
- data/vendor/assets/js/foundation.util.mediaQuery.js +353 -0
- data/vendor/assets/js/foundation.util.motion.js +231 -0
- data/vendor/assets/js/foundation.util.nest.js +181 -0
- data/vendor/assets/js/foundation.util.timer.js +170 -0
- data/vendor/assets/js/foundation.util.timerAndImageLoader.js +90 -0
- data/vendor/assets/js/foundation.util.touch.js +275 -0
- data/vendor/assets/js/foundation.util.triggers.js +399 -0
- data/vendor/assets/js/foundation.zf.responsiveAccordionTabs.js +262 -0
- metadata +37 -71
- data/vendor/assets/js/entries/foundation-plugins.js +0 -25
- data/vendor/assets/js/entries/foundation.js +0 -101
- data/vendor/assets/js/entries/plugins/foundation.abide.js +0 -4
- data/vendor/assets/js/entries/plugins/foundation.accordion.js +0 -4
- data/vendor/assets/js/entries/plugins/foundation.accordionMenu.js +0 -5
- data/vendor/assets/js/entries/plugins/foundation.core.js +0 -21
- data/vendor/assets/js/entries/plugins/foundation.drilldown.js +0 -4
- data/vendor/assets/js/entries/plugins/foundation.dropdown.js +0 -5
- data/vendor/assets/js/entries/plugins/foundation.dropdownMenu.js +0 -4
- data/vendor/assets/js/entries/plugins/foundation.equalizer.js +0 -4
- data/vendor/assets/js/entries/plugins/foundation.interchange.js +0 -4
- data/vendor/assets/js/entries/plugins/foundation.magellan.js +0 -4
- data/vendor/assets/js/entries/plugins/foundation.offcanvas.js +0 -4
- data/vendor/assets/js/entries/plugins/foundation.orbit.js +0 -5
- data/vendor/assets/js/entries/plugins/foundation.responsiveAccordionTabs.js +0 -5
- data/vendor/assets/js/entries/plugins/foundation.responsiveMenu.js +0 -5
- data/vendor/assets/js/entries/plugins/foundation.responsiveToggle.js +0 -5
- data/vendor/assets/js/entries/plugins/foundation.reveal.js +0 -4
- data/vendor/assets/js/entries/plugins/foundation.slider.js +0 -5
- data/vendor/assets/js/entries/plugins/foundation.smoothScroll.js +0 -5
- data/vendor/assets/js/entries/plugins/foundation.sticky.js +0 -5
- data/vendor/assets/js/entries/plugins/foundation.tabs.js +0 -5
- data/vendor/assets/js/entries/plugins/foundation.toggler.js +0 -5
- data/vendor/assets/js/entries/plugins/foundation.tooltip.js +0 -4
- data/vendor/assets/js/entries/plugins/foundation.util.box.js +0 -4
- data/vendor/assets/js/entries/plugins/foundation.util.imageLoader.js +0 -5
- data/vendor/assets/js/entries/plugins/foundation.util.keyboard.js +0 -4
- data/vendor/assets/js/entries/plugins/foundation.util.mediaQuery.js +0 -4
- data/vendor/assets/js/entries/plugins/foundation.util.motion.js +0 -5
- data/vendor/assets/js/entries/plugins/foundation.util.nest.js +0 -5
- data/vendor/assets/js/entries/plugins/foundation.util.timer.js +0 -5
- data/vendor/assets/js/entries/plugins/foundation.util.touch.js +0 -7
- data/vendor/assets/js/entries/plugins/foundation.util.triggers.js +0 -5
- data/vendor/assets/js/foundation.abide.js.es6 +0 -587
- data/vendor/assets/js/foundation.accordion.js.es6 +0 -329
- data/vendor/assets/js/foundation.accordionMenu.js.es6 +0 -328
- data/vendor/assets/js/foundation.core.js.es6 +0 -337
- data/vendor/assets/js/foundation.drilldown.js.es6 +0 -536
- data/vendor/assets/js/foundation.dropdown.js.es6 +0 -394
- data/vendor/assets/js/foundation.dropdownMenu.js.es6 +0 -458
- data/vendor/assets/js/foundation.equalizer.js.es6 +0 -318
- data/vendor/assets/js/foundation.interchange.js.es6 +0 -210
- data/vendor/assets/js/foundation.magellan.js.es6 +0 -257
- data/vendor/assets/js/foundation.offcanvas.js.es6 +0 -546
- data/vendor/assets/js/foundation.orbit.js.es6 +0 -531
- data/vendor/assets/js/foundation.plugin.js.es6 +0 -54
- data/vendor/assets/js/foundation.positionable.js.es6 +0 -206
- data/vendor/assets/js/foundation.responsiveAccordionTabs.js.es6 +0 -243
- data/vendor/assets/js/foundation.responsiveMenu.js.es6 +0 -155
- data/vendor/assets/js/foundation.responsiveToggle.js.es6 +0 -156
- data/vendor/assets/js/foundation.reveal.js.es6 +0 -585
- data/vendor/assets/js/foundation.slider.js.es6 +0 -712
- data/vendor/assets/js/foundation.smoothScroll.js.es6 +0 -135
- data/vendor/assets/js/foundation.sticky.js.es6 +0 -507
- data/vendor/assets/js/foundation.tabs.js.es6 +0 -498
- data/vendor/assets/js/foundation.toggler.js.es6 +0 -150
- data/vendor/assets/js/foundation.tooltip.js.es6 +0 -462
- data/vendor/assets/js/foundation.util.core.js.es6 +0 -52
- data/vendor/assets/js/foundation.util.imageLoader.js.es6 +0 -45
- data/vendor/assets/js/foundation.util.keyboard.js.es6 +0 -162
- data/vendor/assets/js/foundation.util.mediaQuery.js.es6 +0 -234
- data/vendor/assets/js/foundation.util.motion.js.es6 +0 -104
- data/vendor/assets/js/foundation.util.nest.js.es6 +0 -67
- data/vendor/assets/js/foundation.util.timer.js.es6 +0 -48
- data/vendor/assets/js/foundation.util.touch.js.es6 +0 -149
- data/vendor/assets/js/foundation.util.triggers.js.es6 +0 -268
@@ -1,54 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
import $ from 'jquery';
|
4
|
-
import { GetYoDigits } from './foundation.util.core';
|
5
|
-
|
6
|
-
// Abstract class for providing lifecycle hooks. Expect plugins to define AT LEAST
|
7
|
-
// {function} _setup (replaces previous constructor),
|
8
|
-
// {function} _destroy (replaces previous destroy)
|
9
|
-
class Plugin {
|
10
|
-
|
11
|
-
constructor(element, options) {
|
12
|
-
this._setup(element, options);
|
13
|
-
var pluginName = getPluginName(this);
|
14
|
-
this.uuid = GetYoDigits(6, pluginName);
|
15
|
-
|
16
|
-
if(!this.$element.attr(`data-${pluginName}`)){ this.$element.attr(`data-${pluginName}`, this.uuid); }
|
17
|
-
if(!this.$element.data('zfPlugin')){ this.$element.data('zfPlugin', this); }
|
18
|
-
/**
|
19
|
-
* Fires when the plugin has initialized.
|
20
|
-
* @event Plugin#init
|
21
|
-
*/
|
22
|
-
this.$element.trigger(`init.zf.${pluginName}`);
|
23
|
-
}
|
24
|
-
|
25
|
-
destroy() {
|
26
|
-
this._destroy();
|
27
|
-
var pluginName = getPluginName(this);
|
28
|
-
this.$element.removeAttr(`data-${pluginName}`).removeData('zfPlugin')
|
29
|
-
/**
|
30
|
-
* Fires when the plugin has been destroyed.
|
31
|
-
* @event Plugin#destroyed
|
32
|
-
*/
|
33
|
-
.trigger(`destroyed.zf.${pluginName}`);
|
34
|
-
for(var prop in this){
|
35
|
-
this[prop] = null;//clean up script to prep for garbage collection.
|
36
|
-
}
|
37
|
-
}
|
38
|
-
}
|
39
|
-
|
40
|
-
// Convert PascalCase to kebab-case
|
41
|
-
// Thank you: http://stackoverflow.com/a/8955580
|
42
|
-
function hyphenate(str) {
|
43
|
-
return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
44
|
-
}
|
45
|
-
|
46
|
-
function getPluginName(obj) {
|
47
|
-
if(typeof(obj.constructor.name) !== 'undefined') {
|
48
|
-
return hyphenate(obj.constructor.name);
|
49
|
-
} else {
|
50
|
-
return hyphenate(obj.className);
|
51
|
-
}
|
52
|
-
}
|
53
|
-
|
54
|
-
export {Plugin};
|
@@ -1,206 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
import { Box } from './foundation.util.box';
|
4
|
-
import { Plugin } from './foundation.plugin';
|
5
|
-
import { rtl as Rtl } from './foundation.util.core';
|
6
|
-
|
7
|
-
const POSITIONS = ['left', 'right', 'top', 'bottom'];
|
8
|
-
const VERTICAL_ALIGNMENTS = ['top', 'bottom', 'center'];
|
9
|
-
const HORIZONTAL_ALIGNMENTS = ['left', 'right', 'center'];
|
10
|
-
|
11
|
-
const ALIGNMENTS = {
|
12
|
-
'left': VERTICAL_ALIGNMENTS,
|
13
|
-
'right': VERTICAL_ALIGNMENTS,
|
14
|
-
'top': HORIZONTAL_ALIGNMENTS,
|
15
|
-
'bottom': HORIZONTAL_ALIGNMENTS
|
16
|
-
}
|
17
|
-
|
18
|
-
function nextItem(item, array) {
|
19
|
-
var currentIdx = array.indexOf(item);
|
20
|
-
if(currentIdx === array.length - 1) {
|
21
|
-
return array[0];
|
22
|
-
} else {
|
23
|
-
return array[currentIdx + 1];
|
24
|
-
}
|
25
|
-
}
|
26
|
-
|
27
|
-
|
28
|
-
class Positionable extends Plugin {
|
29
|
-
/**
|
30
|
-
* Abstract class encapsulating the tether-like explicit positioning logic
|
31
|
-
* including repositioning based on overlap.
|
32
|
-
* Expects classes to define defaults for vOffset, hOffset, position,
|
33
|
-
* alignment, allowOverlap, and allowBottomOverlap. They can do this by
|
34
|
-
* extending the defaults, or (for now recommended due to the way docs are
|
35
|
-
* generated) by explicitly declaring them.
|
36
|
-
*
|
37
|
-
**/
|
38
|
-
|
39
|
-
_init() {
|
40
|
-
this.triedPositions = {};
|
41
|
-
this.position = this.options.position === 'auto' ? this._getDefaultPosition() : this.options.position;
|
42
|
-
this.alignment = this.options.alignment === 'auto' ? this._getDefaultAlignment() : this.options.alignment;
|
43
|
-
}
|
44
|
-
|
45
|
-
_getDefaultPosition () {
|
46
|
-
return 'bottom';
|
47
|
-
}
|
48
|
-
|
49
|
-
_getDefaultAlignment() {
|
50
|
-
switch(this.position) {
|
51
|
-
case 'bottom':
|
52
|
-
case 'top':
|
53
|
-
return Rtl() ? 'right' : 'left';
|
54
|
-
case 'left':
|
55
|
-
case 'right':
|
56
|
-
return 'bottom';
|
57
|
-
}
|
58
|
-
}
|
59
|
-
|
60
|
-
/**
|
61
|
-
* Adjusts the positionable possible positions by iterating through alignments
|
62
|
-
* and positions.
|
63
|
-
* @function
|
64
|
-
* @private
|
65
|
-
*/
|
66
|
-
_reposition() {
|
67
|
-
if(this._alignmentsExhausted(this.position)) {
|
68
|
-
this.position = nextItem(this.position, POSITIONS);
|
69
|
-
this.alignment = ALIGNMENTS[this.position][0];
|
70
|
-
} else {
|
71
|
-
this._realign();
|
72
|
-
}
|
73
|
-
}
|
74
|
-
|
75
|
-
/**
|
76
|
-
* Adjusts the dropdown pane possible positions by iterating through alignments
|
77
|
-
* on the current position.
|
78
|
-
* @function
|
79
|
-
* @private
|
80
|
-
*/
|
81
|
-
_realign() {
|
82
|
-
this._addTriedPosition(this.position, this.alignment)
|
83
|
-
this.alignment = nextItem(this.alignment, ALIGNMENTS[this.position])
|
84
|
-
}
|
85
|
-
|
86
|
-
_addTriedPosition(position, alignment) {
|
87
|
-
this.triedPositions[position] = this.triedPositions[position] || []
|
88
|
-
this.triedPositions[position].push(alignment);
|
89
|
-
}
|
90
|
-
|
91
|
-
_positionsExhausted() {
|
92
|
-
var isExhausted = true;
|
93
|
-
for(var i = 0; i < POSITIONS.length; i++) {
|
94
|
-
isExhausted = isExhausted && this._alignmentsExhausted(POSITIONS[i]);
|
95
|
-
}
|
96
|
-
return isExhausted;
|
97
|
-
}
|
98
|
-
|
99
|
-
_alignmentsExhausted(position) {
|
100
|
-
return this.triedPositions[position] && this.triedPositions[position].length == ALIGNMENTS[position].length;
|
101
|
-
}
|
102
|
-
|
103
|
-
|
104
|
-
// When we're trying to center, we don't want to apply offset that's going to
|
105
|
-
// take us just off center, so wrap around to return 0 for the appropriate
|
106
|
-
// offset in those alignments. TODO: Figure out if we want to make this
|
107
|
-
// configurable behavior... it feels more intuitive, especially for tooltips, but
|
108
|
-
// it's possible someone might actually want to start from center and then nudge
|
109
|
-
// slightly off.
|
110
|
-
_getVOffset() {
|
111
|
-
return this.options.vOffset;
|
112
|
-
}
|
113
|
-
|
114
|
-
_getHOffset() {
|
115
|
-
return this.options.hOffset;
|
116
|
-
}
|
117
|
-
|
118
|
-
|
119
|
-
_setPosition($anchor, $element, $parent) {
|
120
|
-
if($anchor.attr('aria-expanded') === 'false'){ return false; }
|
121
|
-
var $eleDims = Box.GetDimensions($element),
|
122
|
-
$anchorDims = Box.GetDimensions($anchor);
|
123
|
-
|
124
|
-
|
125
|
-
$element.offset(Box.GetExplicitOffsets($element, $anchor, this.position, this.alignment, this._getVOffset(), this._getHOffset()));
|
126
|
-
|
127
|
-
if(!this.options.allowOverlap) {
|
128
|
-
var overlaps = {};
|
129
|
-
var minOverlap = 100000000;
|
130
|
-
// default coordinates to how we start, in case we can't figure out better
|
131
|
-
var minCoordinates = {position: this.position, alignment: this.alignment};
|
132
|
-
while(!this._positionsExhausted()) {
|
133
|
-
let overlap = Box.OverlapArea($element, $parent, false, false, this.options.allowBottomOverlap);
|
134
|
-
if(overlap === 0) {
|
135
|
-
return;
|
136
|
-
}
|
137
|
-
|
138
|
-
if(overlap < minOverlap) {
|
139
|
-
minOverlap = overlap;
|
140
|
-
minCoordinates = {position: this.position, alignment: this.alignment};
|
141
|
-
}
|
142
|
-
|
143
|
-
this._reposition();
|
144
|
-
|
145
|
-
$element.offset(Box.GetExplicitOffsets($element, $anchor, this.position, this.alignment, this._getVOffset(), this._getHOffset()));
|
146
|
-
}
|
147
|
-
// If we get through the entire loop, there was no non-overlapping
|
148
|
-
// position available. Pick the version with least overlap.
|
149
|
-
this.position = minCoordinates.position;
|
150
|
-
this.alignment = minCoordinates.alignment;
|
151
|
-
$element.offset(Box.GetExplicitOffsets($element, $anchor, this.position, this.alignment, this._getVOffset(), this._getHOffset()));
|
152
|
-
}
|
153
|
-
}
|
154
|
-
|
155
|
-
}
|
156
|
-
|
157
|
-
Positionable.defaults = {
|
158
|
-
/**
|
159
|
-
* Position of positionable relative to anchor. Can be left, right, bottom, top, or auto.
|
160
|
-
* @option
|
161
|
-
* @type {string}
|
162
|
-
* @default 'auto'
|
163
|
-
*/
|
164
|
-
position: 'auto',
|
165
|
-
/**
|
166
|
-
* Alignment of positionable relative to anchor. Can be left, right, bottom, top, center, or auto.
|
167
|
-
* @option
|
168
|
-
* @type {string}
|
169
|
-
* @default 'auto'
|
170
|
-
*/
|
171
|
-
alignment: 'auto',
|
172
|
-
/**
|
173
|
-
* Allow overlap of container/window. If false, dropdown positionable first
|
174
|
-
* try to position as defined by data-position and data-alignment, but
|
175
|
-
* reposition if it would cause an overflow.
|
176
|
-
* @option
|
177
|
-
* @type {boolean}
|
178
|
-
* @default false
|
179
|
-
*/
|
180
|
-
allowOverlap: false,
|
181
|
-
/**
|
182
|
-
* Allow overlap of only the bottom of the container. This is the most common
|
183
|
-
* behavior for dropdowns, allowing the dropdown to extend the bottom of the
|
184
|
-
* screen but not otherwise influence or break out of the container.
|
185
|
-
* @option
|
186
|
-
* @type {boolean}
|
187
|
-
* @default true
|
188
|
-
*/
|
189
|
-
allowBottomOverlap: true,
|
190
|
-
/**
|
191
|
-
* Number of pixels the positionable should be separated vertically from anchor
|
192
|
-
* @option
|
193
|
-
* @type {number}
|
194
|
-
* @default 0
|
195
|
-
*/
|
196
|
-
vOffset: 0,
|
197
|
-
/**
|
198
|
-
* Number of pixels the positionable should be separated horizontally from anchor
|
199
|
-
* @option
|
200
|
-
* @type {number}
|
201
|
-
* @default 0
|
202
|
-
*/
|
203
|
-
hOffset: 0,
|
204
|
-
}
|
205
|
-
|
206
|
-
export {Positionable};
|
@@ -1,243 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
import $ from 'jquery';
|
4
|
-
import { MediaQuery } from './foundation.util.mediaQuery';
|
5
|
-
import { GetYoDigits } from './foundation.util.core';
|
6
|
-
import { Plugin }from './foundation.plugin';
|
7
|
-
|
8
|
-
import { Accordion } from './foundation.accordion';
|
9
|
-
import { Tabs } from './foundation.tabs';
|
10
|
-
|
11
|
-
// The plugin matches the plugin classes with these plugin instances.
|
12
|
-
var MenuPlugins = {
|
13
|
-
tabs: {
|
14
|
-
cssClass: 'tabs',
|
15
|
-
plugin: Tabs
|
16
|
-
},
|
17
|
-
accordion: {
|
18
|
-
cssClass: 'accordion',
|
19
|
-
plugin: Accordion
|
20
|
-
}
|
21
|
-
};
|
22
|
-
|
23
|
-
|
24
|
-
/**
|
25
|
-
* ResponsiveAccordionTabs module.
|
26
|
-
* @module foundation.responsiveAccordionTabs
|
27
|
-
* @requires foundation.util.motion
|
28
|
-
* @requires foundation.accordion
|
29
|
-
* @requires foundation.tabs
|
30
|
-
*/
|
31
|
-
|
32
|
-
class ResponsiveAccordionTabs extends Plugin{
|
33
|
-
/**
|
34
|
-
* Creates a new instance of a responsive accordion tabs.
|
35
|
-
* @class
|
36
|
-
* @name ResponsiveAccordionTabs
|
37
|
-
* @fires ResponsiveAccordionTabs#init
|
38
|
-
* @param {jQuery} element - jQuery object to make into Responsive Accordion Tabs.
|
39
|
-
* @param {Object} options - Overrides to the default plugin settings.
|
40
|
-
*/
|
41
|
-
_setup(element, options) {
|
42
|
-
this.$element = $(element);
|
43
|
-
this.options = $.extend({}, this.$element.data(), options);
|
44
|
-
this.rules = this.$element.data('responsive-accordion-tabs');
|
45
|
-
this.currentMq = null;
|
46
|
-
this.currentPlugin = null;
|
47
|
-
this.className = 'ResponsiveAccordionTabs'; // ie9 back compat
|
48
|
-
if (!this.$element.attr('id')) {
|
49
|
-
this.$element.attr('id',GetYoDigits(6, 'responsiveaccordiontabs'));
|
50
|
-
};
|
51
|
-
|
52
|
-
this._init();
|
53
|
-
this._events();
|
54
|
-
}
|
55
|
-
|
56
|
-
/**
|
57
|
-
* Initializes the Menu by parsing the classes from the 'data-responsive-accordion-tabs' attribute on the element.
|
58
|
-
* @function
|
59
|
-
* @private
|
60
|
-
*/
|
61
|
-
_init() {
|
62
|
-
MediaQuery._init();
|
63
|
-
|
64
|
-
// The first time an Interchange plugin is initialized, this.rules is converted from a string of "classes" to an object of rules
|
65
|
-
if (typeof this.rules === 'string') {
|
66
|
-
let rulesTree = {};
|
67
|
-
|
68
|
-
// Parse rules from "classes" pulled from data attribute
|
69
|
-
let rules = this.rules.split(' ');
|
70
|
-
|
71
|
-
// Iterate through every rule found
|
72
|
-
for (let i = 0; i < rules.length; i++) {
|
73
|
-
let rule = rules[i].split('-');
|
74
|
-
let ruleSize = rule.length > 1 ? rule[0] : 'small';
|
75
|
-
let rulePlugin = rule.length > 1 ? rule[1] : rule[0];
|
76
|
-
|
77
|
-
if (MenuPlugins[rulePlugin] !== null) {
|
78
|
-
rulesTree[ruleSize] = MenuPlugins[rulePlugin];
|
79
|
-
}
|
80
|
-
}
|
81
|
-
|
82
|
-
this.rules = rulesTree;
|
83
|
-
}
|
84
|
-
|
85
|
-
this._getAllOptions();
|
86
|
-
|
87
|
-
if (!$.isEmptyObject(this.rules)) {
|
88
|
-
this._checkMediaQueries();
|
89
|
-
}
|
90
|
-
}
|
91
|
-
|
92
|
-
_getAllOptions() {
|
93
|
-
//get all defaults and options
|
94
|
-
var _this = this;
|
95
|
-
_this.allOptions = {};
|
96
|
-
for (var key in MenuPlugins) {
|
97
|
-
if (MenuPlugins.hasOwnProperty(key)) {
|
98
|
-
var obj = MenuPlugins[key];
|
99
|
-
try {
|
100
|
-
var dummyPlugin = $('<ul></ul>');
|
101
|
-
var tmpPlugin = new obj.plugin(dummyPlugin,_this.options);
|
102
|
-
for (var keyKey in tmpPlugin.options) {
|
103
|
-
if (tmpPlugin.options.hasOwnProperty(keyKey) && keyKey !== 'zfPlugin') {
|
104
|
-
var objObj = tmpPlugin.options[keyKey];
|
105
|
-
_this.allOptions[keyKey] = objObj;
|
106
|
-
}
|
107
|
-
}
|
108
|
-
tmpPlugin.destroy();
|
109
|
-
}
|
110
|
-
catch(e) {
|
111
|
-
}
|
112
|
-
}
|
113
|
-
}
|
114
|
-
}
|
115
|
-
|
116
|
-
/**
|
117
|
-
* Initializes events for the Menu.
|
118
|
-
* @function
|
119
|
-
* @private
|
120
|
-
*/
|
121
|
-
_events() {
|
122
|
-
var _this = this;
|
123
|
-
|
124
|
-
$(window).on('changed.zf.mediaquery', function() {
|
125
|
-
_this._checkMediaQueries();
|
126
|
-
});
|
127
|
-
}
|
128
|
-
|
129
|
-
/**
|
130
|
-
* 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.
|
131
|
-
* @function
|
132
|
-
* @private
|
133
|
-
*/
|
134
|
-
_checkMediaQueries() {
|
135
|
-
var matchedMq, _this = this;
|
136
|
-
// Iterate through each rule and find the last matching rule
|
137
|
-
$.each(this.rules, function(key) {
|
138
|
-
if (MediaQuery.atLeast(key)) {
|
139
|
-
matchedMq = key;
|
140
|
-
}
|
141
|
-
});
|
142
|
-
|
143
|
-
// No match? No dice
|
144
|
-
if (!matchedMq) return;
|
145
|
-
|
146
|
-
// Plugin already initialized? We good
|
147
|
-
if (this.currentPlugin instanceof this.rules[matchedMq].plugin) return;
|
148
|
-
|
149
|
-
// Remove existing plugin-specific CSS classes
|
150
|
-
$.each(MenuPlugins, function(key, value) {
|
151
|
-
_this.$element.removeClass(value.cssClass);
|
152
|
-
});
|
153
|
-
|
154
|
-
// Add the CSS class for the new plugin
|
155
|
-
this.$element.addClass(this.rules[matchedMq].cssClass);
|
156
|
-
|
157
|
-
// Create an instance of the new plugin
|
158
|
-
if (this.currentPlugin) {
|
159
|
-
//don't know why but on nested elements data zfPlugin get's lost
|
160
|
-
if (!this.currentPlugin.$element.data('zfPlugin') && this.storezfData) this.currentPlugin.$element.data('zfPlugin',this.storezfData);
|
161
|
-
this.currentPlugin.destroy();
|
162
|
-
}
|
163
|
-
this._handleMarkup(this.rules[matchedMq].cssClass);
|
164
|
-
this.currentPlugin = new this.rules[matchedMq].plugin(this.$element, {});
|
165
|
-
this.storezfData = this.currentPlugin.$element.data('zfPlugin');
|
166
|
-
|
167
|
-
}
|
168
|
-
|
169
|
-
_handleMarkup(toSet){
|
170
|
-
var _this = this, fromString = 'accordion';
|
171
|
-
var $panels = $('[data-tabs-content='+this.$element.attr('id')+']');
|
172
|
-
if ($panels.length) fromString = 'tabs';
|
173
|
-
if (fromString === toSet) {
|
174
|
-
return;
|
175
|
-
};
|
176
|
-
|
177
|
-
var tabsTitle = _this.allOptions.linkClass?_this.allOptions.linkClass:'tabs-title';
|
178
|
-
var tabsPanel = _this.allOptions.panelClass?_this.allOptions.panelClass:'tabs-panel';
|
179
|
-
|
180
|
-
this.$element.removeAttr('role');
|
181
|
-
var $liHeads = this.$element.children('.'+tabsTitle+',[data-accordion-item]').removeClass(tabsTitle).removeClass('accordion-item').removeAttr('data-accordion-item');
|
182
|
-
var $liHeadsA = $liHeads.children('a').removeClass('accordion-title');
|
183
|
-
|
184
|
-
if (fromString === 'tabs') {
|
185
|
-
$panels = $panels.children('.'+tabsPanel).removeClass(tabsPanel).removeAttr('role').removeAttr('aria-hidden').removeAttr('aria-labelledby');
|
186
|
-
$panels.children('a').removeAttr('role').removeAttr('aria-controls').removeAttr('aria-selected');
|
187
|
-
}else{
|
188
|
-
$panels = $liHeads.children('[data-tab-content]').removeClass('accordion-content');
|
189
|
-
};
|
190
|
-
|
191
|
-
$panels.css({display:'',visibility:''});
|
192
|
-
$liHeads.css({display:'',visibility:''});
|
193
|
-
if (toSet === 'accordion') {
|
194
|
-
$panels.each(function(key,value){
|
195
|
-
$(value).appendTo($liHeads.get(key)).addClass('accordion-content').attr('data-tab-content','').removeClass('is-active').css({height:''});
|
196
|
-
$('[data-tabs-content='+_this.$element.attr('id')+']').after('<div id="tabs-placeholder-'+_this.$element.attr('id')+'"></div>').detach();
|
197
|
-
$liHeads.addClass('accordion-item').attr('data-accordion-item','');
|
198
|
-
$liHeadsA.addClass('accordion-title');
|
199
|
-
});
|
200
|
-
}else if (toSet === 'tabs'){
|
201
|
-
var $tabsContent = $('[data-tabs-content='+_this.$element.attr('id')+']');
|
202
|
-
var $placeholder = $('#tabs-placeholder-'+_this.$element.attr('id'));
|
203
|
-
if ($placeholder.length) {
|
204
|
-
$tabsContent = $('<div class="tabs-content"></div>').insertAfter($placeholder).attr('data-tabs-content',_this.$element.attr('id'));
|
205
|
-
$placeholder.remove();
|
206
|
-
}else{
|
207
|
-
$tabsContent = $('<div class="tabs-content"></div>').insertAfter(_this.$element).attr('data-tabs-content',_this.$element.attr('id'));
|
208
|
-
};
|
209
|
-
$panels.each(function(key,value){
|
210
|
-
var tempValue = $(value).appendTo($tabsContent).addClass(tabsPanel);
|
211
|
-
var hash = $liHeadsA.get(key).hash.slice(1);
|
212
|
-
var id = $(value).attr('id') || GetYoDigits(6, 'accordion');
|
213
|
-
if (hash !== id) {
|
214
|
-
if (hash !== '') {
|
215
|
-
$(value).attr('id',hash);
|
216
|
-
}else{
|
217
|
-
hash = id;
|
218
|
-
$(value).attr('id',hash);
|
219
|
-
$($liHeadsA.get(key)).attr('href',$($liHeadsA.get(key)).attr('href').replace('#','')+'#'+hash);
|
220
|
-
};
|
221
|
-
};
|
222
|
-
var isActive = $($liHeads.get(key)).hasClass('is-active');
|
223
|
-
if (isActive) {
|
224
|
-
tempValue.addClass('is-active');
|
225
|
-
};
|
226
|
-
});
|
227
|
-
$liHeads.addClass(tabsTitle);
|
228
|
-
};
|
229
|
-
}
|
230
|
-
|
231
|
-
/**
|
232
|
-
* Destroys the instance of the current plugin on this element, as well as the window resize handler that switches the plugins out.
|
233
|
-
* @function
|
234
|
-
*/
|
235
|
-
_destroy() {
|
236
|
-
if (this.currentPlugin) this.currentPlugin.destroy();
|
237
|
-
$(window).off('.zf.ResponsiveAccordionTabs');
|
238
|
-
}
|
239
|
-
}
|
240
|
-
|
241
|
-
ResponsiveAccordionTabs.defaults = {};
|
242
|
-
|
243
|
-
export {ResponsiveAccordionTabs};
|