volt-foundation 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,326 +0,0 @@
1
- ;(function ($, window, document, undefined) {
2
- 'use strict';
3
-
4
- Foundation.libs.dropdown = {
5
- name : 'dropdown',
6
-
7
- version : '5.4.6',
8
-
9
- settings : {
10
- active_class: 'open',
11
- disabled_class: 'disabled',
12
- mega_class: 'mega',
13
- align: 'bottom',
14
- is_hover: false,
15
- opened: function(){},
16
- closed: function(){}
17
- },
18
-
19
- init : function (scope, method, options) {
20
- Foundation.inherit(this, 'throttle');
21
-
22
- this.bindings(method, options);
23
- },
24
-
25
- events : function (scope) {
26
- var self = this,
27
- S = self.S;
28
-
29
- S(this.scope)
30
- .off('.dropdown')
31
- .on('click.fndtn.dropdown', '[' + this.attr_name() + ']', function (e) {
32
- var settings = S(this).data(self.attr_name(true) + '-init') || self.settings;
33
- if (!settings.is_hover || Modernizr.touch) {
34
- e.preventDefault();
35
- self.toggle($(this));
36
- }
37
- })
38
- .on('mouseenter.fndtn.dropdown', '[' + this.attr_name() + '], [' + this.attr_name() + '-content]', function (e) {
39
- var $this = S(this),
40
- dropdown,
41
- target;
42
-
43
- clearTimeout(self.timeout);
44
-
45
- if ($this.data(self.data_attr())) {
46
- dropdown = S('#' + $this.data(self.data_attr()));
47
- target = $this;
48
- } else {
49
- dropdown = $this;
50
- target = S("[" + self.attr_name() + "='" + dropdown.attr('id') + "']");
51
- }
52
-
53
- var settings = target.data(self.attr_name(true) + '-init') || self.settings;
54
-
55
- if(S(e.target).data(self.data_attr()) && settings.is_hover) {
56
- self.closeall.call(self);
57
- }
58
-
59
- if (settings.is_hover) self.open.apply(self, [dropdown, target]);
60
- })
61
- .on('mouseleave.fndtn.dropdown', '[' + this.attr_name() + '], [' + this.attr_name() + '-content]', function (e) {
62
- var $this = S(this);
63
- self.timeout = setTimeout(function () {
64
- if ($this.data(self.data_attr())) {
65
- var settings = $this.data(self.data_attr(true) + '-init') || self.settings;
66
- if (settings.is_hover) self.close.call(self, S('#' + $this.data(self.data_attr())));
67
- } else {
68
- var target = S('[' + self.attr_name() + '="' + S(this).attr('id') + '"]'),
69
- settings = target.data(self.attr_name(true) + '-init') || self.settings;
70
- if (settings.is_hover) self.close.call(self, $this);
71
- }
72
- }.bind(this), 150);
73
- })
74
- .on('click.fndtn.dropdown', function (e) {
75
- var parent = S(e.target).closest('[' + self.attr_name() + '-content]');
76
-
77
- if (S(e.target).closest('[' + self.attr_name() + ']').length > 0) {
78
- return;
79
- }
80
- if (!(S(e.target).data('revealId')) &&
81
- (parent.length > 0 && (S(e.target).is('[' + self.attr_name() + '-content]') ||
82
- $.contains(parent.first()[0], e.target)))) {
83
- e.stopPropagation();
84
- return;
85
- }
86
-
87
- self.close.call(self, S('[' + self.attr_name() + '-content]'));
88
- })
89
- .on('opened.fndtn.dropdown', '[' + self.attr_name() + '-content]', function () {
90
- self.settings.opened.call(this);
91
- })
92
- .on('closed.fndtn.dropdown', '[' + self.attr_name() + '-content]', function () {
93
- self.settings.closed.call(this);
94
- });
95
-
96
- S(window)
97
- .off('.dropdown')
98
- .on('resize.fndtn.dropdown', self.throttle(function () {
99
- self.resize.call(self);
100
- }, 50));
101
-
102
- this.resize();
103
- },
104
-
105
- close: function (dropdown) {
106
- var self = this;
107
- dropdown.each(function () {
108
- var original_target = $('[' + self.attr_name() + '=' + dropdown[0].id + ']') || $('aria-controls=' + dropdown[0].id+ ']');
109
- original_target.attr('aria-expanded', "false");
110
- if (self.S(this).hasClass(self.settings.active_class)) {
111
- self.S(this)
112
- .css(Foundation.rtl ? 'right':'left', '-99999px')
113
- .attr('aria-hidden', "true")
114
- .removeClass(self.settings.active_class)
115
- .prev('[' + self.attr_name() + ']')
116
- .removeClass(self.settings.active_class)
117
- .removeData('target');
118
-
119
- self.S(this).trigger('closed').trigger('closed.fndtn.dropdown', [dropdown]);
120
- }
121
- });
122
- },
123
-
124
- closeall: function() {
125
- var self = this;
126
- $.each(self.S('[' + this.attr_name() + '-content]'), function() {
127
- self.close.call(self, self.S(this));
128
- });
129
- },
130
-
131
- open: function (dropdown, target) {
132
- this
133
- .css(dropdown
134
- .addClass(this.settings.active_class), target);
135
- dropdown.prev('[' + this.attr_name() + ']').addClass(this.settings.active_class);
136
- dropdown.data('target', target.get(0)).trigger('opened').trigger('opened.fndtn.dropdown', [dropdown, target]);
137
- dropdown.attr('aria-hidden', 'false');
138
- target.attr('aria-expanded', 'true');
139
- dropdown.focus();
140
- },
141
-
142
- data_attr: function () {
143
- if (this.namespace.length > 0) {
144
- return this.namespace + '-' + this.name;
145
- }
146
-
147
- return this.name;
148
- },
149
-
150
- toggle : function (target) {
151
- if (target.hasClass(this.settings.disabled_class)) {
152
- return;
153
- }
154
- var dropdown = this.S('#' + target.data(this.data_attr()));
155
- if (dropdown.length === 0) {
156
- // No dropdown found, not continuing
157
- return;
158
- }
159
-
160
- this.close.call(this, this.S('[' + this.attr_name() + '-content]').not(dropdown));
161
-
162
- if (dropdown.hasClass(this.settings.active_class)) {
163
- this.close.call(this, dropdown);
164
- if (dropdown.data('target') !== target.get(0))
165
- this.open.call(this, dropdown, target);
166
- } else {
167
- this.open.call(this, dropdown, target);
168
- }
169
- },
170
-
171
- resize : function () {
172
- var dropdown = this.S('[' + this.attr_name() + '-content].open'),
173
- target = this.S("[" + this.attr_name() + "='" + dropdown.attr('id') + "']");
174
-
175
- if (dropdown.length && target.length) {
176
- this.css(dropdown, target);
177
- }
178
- },
179
-
180
- css : function (dropdown, target) {
181
- var left_offset = Math.max((target.width() - dropdown.width()) / 2, 8),
182
- settings = target.data(this.attr_name(true) + '-init') || this.settings;
183
-
184
- this.clear_idx();
185
-
186
- if (this.small()) {
187
- var p = this.dirs.bottom.call(dropdown, target, settings);
188
-
189
- dropdown.attr('style', '').removeClass('drop-left drop-right drop-top').css({
190
- position : 'absolute',
191
- width: '95%',
192
- 'max-width': 'none',
193
- top: p.top
194
- });
195
-
196
- dropdown.css(Foundation.rtl ? 'right':'left', left_offset);
197
- } else {
198
-
199
- this.style(dropdown, target, settings);
200
- }
201
-
202
- return dropdown;
203
- },
204
-
205
- style : function (dropdown, target, settings) {
206
- var css = $.extend({position: 'absolute'},
207
- this.dirs[settings.align].call(dropdown, target, settings));
208
-
209
- dropdown.attr('style', '').css(css);
210
- },
211
-
212
- // return CSS property object
213
- // `this` is the dropdown
214
- dirs : {
215
- // Calculate target offset
216
- _base : function (t) {
217
- var o_p = this.offsetParent(),
218
- o = o_p.offset(),
219
- p = t.offset();
220
-
221
- p.top -= o.top;
222
- p.left -= o.left;
223
-
224
- return p;
225
- },
226
- top: function (t, s) {
227
- var self = Foundation.libs.dropdown,
228
- p = self.dirs._base.call(this, t);
229
-
230
- this.addClass('drop-top');
231
-
232
- if (t.outerWidth() < this.outerWidth() || self.small() || this.hasClass(s.mega_menu)) {
233
- self.adjust_pip(this,t,s,p);
234
- }
235
-
236
- if (Foundation.rtl) {
237
- return {left: p.left - this.outerWidth() + t.outerWidth(),
238
- top: p.top - this.outerHeight()};
239
- }
240
-
241
- return {left: p.left, top: p.top - this.outerHeight()};
242
- },
243
- bottom: function (t,s) {
244
- var self = Foundation.libs.dropdown,
245
- p = self.dirs._base.call(this, t);
246
-
247
- if (t.outerWidth() < this.outerWidth() || self.small() || this.hasClass(s.mega_menu)) {
248
- self.adjust_pip(this,t,s,p);
249
- }
250
-
251
- if (self.rtl) {
252
- return {left: p.left - this.outerWidth() + t.outerWidth(), top: p.top + t.outerHeight()};
253
- }
254
-
255
- return {left: p.left, top: p.top + t.outerHeight()};
256
- },
257
- left: function (t, s) {
258
- var p = Foundation.libs.dropdown.dirs._base.call(this, t);
259
-
260
- this.addClass('drop-left');
261
-
262
- return {left: p.left - this.outerWidth(), top: p.top};
263
- },
264
- right: function (t, s) {
265
- var p = Foundation.libs.dropdown.dirs._base.call(this, t);
266
-
267
- this.addClass('drop-right');
268
-
269
- return {left: p.left + t.outerWidth(), top: p.top};
270
- }
271
- },
272
-
273
- // Insert rule to style psuedo elements
274
- adjust_pip : function (dropdown,target,settings,position) {
275
- var sheet = Foundation.stylesheet,
276
- pip_offset_base = 8;
277
-
278
- if (dropdown.hasClass(settings.mega_class)) {
279
- pip_offset_base = position.left + (target.outerWidth()/2) - 8;
280
- }
281
- else if (this.small()) {
282
- pip_offset_base += position.left - 8;
283
- }
284
-
285
- this.rule_idx = sheet.cssRules.length;
286
-
287
- var sel_before = '.f-dropdown.open:before',
288
- sel_after = '.f-dropdown.open:after',
289
- css_before = 'left: ' + pip_offset_base + 'px;',
290
- css_after = 'left: ' + (pip_offset_base - 1) + 'px;';
291
-
292
- if (sheet.insertRule) {
293
- sheet.insertRule([sel_before, '{', css_before, '}'].join(' '), this.rule_idx);
294
- sheet.insertRule([sel_after, '{', css_after, '}'].join(' '), this.rule_idx + 1);
295
- } else {
296
- sheet.addRule(sel_before, css_before, this.rule_idx);
297
- sheet.addRule(sel_after, css_after, this.rule_idx + 1);
298
- }
299
- },
300
-
301
- // Remove old dropdown rule index
302
- clear_idx : function () {
303
- var sheet = Foundation.stylesheet;
304
-
305
- if (this.rule_idx) {
306
- sheet.deleteRule(this.rule_idx);
307
- sheet.deleteRule(this.rule_idx);
308
- delete this.rule_idx;
309
- }
310
- },
311
-
312
- small : function () {
313
- return matchMedia(Foundation.media_queries.small).matches &&
314
- !matchMedia(Foundation.media_queries.medium).matches;
315
- },
316
-
317
- off: function () {
318
- this.S(this.scope).off('.fndtn.dropdown');
319
- this.S('html, body').off('.fndtn.dropdown');
320
- this.S(window).off('.fndtn.dropdown');
321
- this.S('[data-dropdown-content]').off('.fndtn.dropdown');
322
- },
323
-
324
- reflow : function () {}
325
- };
326
- }(jQuery, window, window.document));
@@ -1,74 +0,0 @@
1
- ;(function ($, window, document, undefined) {
2
- 'use strict';
3
-
4
- Foundation.libs.equalizer = {
5
- name : 'equalizer',
6
-
7
- version : '5.4.6',
8
-
9
- settings : {
10
- use_tallest: true,
11
- before_height_change: $.noop,
12
- after_height_change: $.noop,
13
- equalize_on_stack: false
14
- },
15
-
16
- init : function (scope, method, options) {
17
- Foundation.inherit(this, 'image_loaded');
18
- this.bindings(method, options);
19
- this.reflow();
20
- },
21
-
22
- events : function () {
23
- this.S(window).off('.equalizer').on('resize.fndtn.equalizer', function(e){
24
- this.reflow();
25
- }.bind(this));
26
- },
27
-
28
- equalize: function(equalizer) {
29
- var isStacked = false,
30
- vals = equalizer.find('[' + this.attr_name() + '-watch]:visible'),
31
- settings = equalizer.data(this.attr_name(true)+'-init');
32
-
33
- if (vals.length === 0) return;
34
- var firstTopOffset = vals.first().offset().top;
35
- settings.before_height_change();
36
- equalizer.trigger('before-height-change').trigger('before-height-change.fndth.equalizer');
37
- vals.height('inherit');
38
- vals.each(function(){
39
- var el = $(this);
40
- if (el.offset().top !== firstTopOffset) {
41
- isStacked = true;
42
- }
43
- });
44
-
45
- if (settings.equalize_on_stack === false) {
46
- if (isStacked) return;
47
- };
48
-
49
- var heights = vals.map(function(){ return $(this).outerHeight(false) }).get();
50
-
51
- if (settings.use_tallest) {
52
- var max = Math.max.apply(null, heights);
53
- vals.css('height', max);
54
- } else {
55
- var min = Math.min.apply(null, heights);
56
- vals.css('height', min);
57
- }
58
- settings.after_height_change();
59
- equalizer.trigger('after-height-change').trigger('after-height-change.fndtn.equalizer');
60
- },
61
-
62
- reflow : function () {
63
- var self = this;
64
-
65
- this.S('[' + this.attr_name() + ']', this.scope).each(function(){
66
- var $eq_target = $(this);
67
- self.image_loaded(self.S('img', this), function(){
68
- self.equalize($eq_target)
69
- });
70
- });
71
- }
72
- };
73
- })(jQuery, window, window.document);
74
-