zurb-foundation-5 5.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.bowerrc +3 -0
- data/.editorconfig +9 -0
- data/.gitignore +46 -0
- data/.travis.yml +34 -0
- data/CONTRIBUTING.md +55 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +16 -0
- data/Gruntfile.js +222 -0
- data/LICENSE +22 -0
- data/README.md +44 -0
- data/bower.json +20 -0
- data/composer.json +9 -0
- data/foundation.gemspec +21 -0
- data/humans.txt +8 -0
- data/js/foundation/foundation.abide.js +299 -0
- data/js/foundation/foundation.accordion.js +54 -0
- data/js/foundation/foundation.alert.js +43 -0
- data/js/foundation/foundation.clearing.js +531 -0
- data/js/foundation/foundation.dropdown.js +306 -0
- data/js/foundation/foundation.equalizer.js +68 -0
- data/js/foundation/foundation.interchange.js +331 -0
- data/js/foundation/foundation.joyride.js +849 -0
- data/js/foundation/foundation.js +609 -0
- data/js/foundation/foundation.magellan.js +173 -0
- data/js/foundation/foundation.offcanvas.js +50 -0
- data/js/foundation/foundation.orbit.js +606 -0
- data/js/foundation/foundation.reveal.js +427 -0
- data/js/foundation/foundation.slider.js +200 -0
- data/js/foundation/foundation.tab.js +168 -0
- data/js/foundation/foundation.tooltip.js +272 -0
- data/js/foundation/foundation.topbar.js +422 -0
- data/karma.conf.js +114 -0
- data/lib/foundation/engine.rb +20 -0
- data/lib/foundation/generators/USAGE +15 -0
- data/lib/foundation/generators/install_generator.rb +54 -0
- data/lib/foundation/generators/templates/application.html.erb +47 -0
- data/lib/foundation/generators/templates/application.html.haml +31 -0
- data/lib/foundation/generators/templates/application.html.slim +35 -0
- data/lib/foundation/sprockets.rb +4 -0
- data/lib/foundation/version.rb +3 -0
- data/lib/scss.js +114 -0
- data/lib/zurb-foundation.rb +33 -0
- data/package.json +48 -0
- data/robots.txt +4 -0
- data/run-tests.sh +83 -0
- data/sache.json +5 -0
- data/scss/foundation.scss +45 -0
- data/scss/foundation/_functions.scss +101 -0
- data/scss/foundation/_settings.scss +1279 -0
- data/scss/foundation/components/_accordion.scss +52 -0
- data/scss/foundation/components/_alert-boxes.scss +126 -0
- data/scss/foundation/components/_block-grid.scss +132 -0
- data/scss/foundation/components/_breadcrumbs.scss +127 -0
- data/scss/foundation/components/_button-groups.scss +108 -0
- data/scss/foundation/components/_buttons.scss +222 -0
- data/scss/foundation/components/_clearing.scss +247 -0
- data/scss/foundation/components/_dropdown-buttons.scss +129 -0
- data/scss/foundation/components/_dropdown.scss +248 -0
- data/scss/foundation/components/_flex-video.scss +51 -0
- data/scss/foundation/components/_forms.scss +496 -0
- data/scss/foundation/components/_global.scss +365 -0
- data/scss/foundation/components/_grid.scss +261 -0
- data/scss/foundation/components/_inline-lists.scss +56 -0
- data/scss/foundation/components/_joyride.scss +220 -0
- data/scss/foundation/components/_keystrokes.scss +61 -0
- data/scss/foundation/components/_labels.scss +104 -0
- data/scss/foundation/components/_magellan.scss +34 -0
- data/scss/foundation/components/_offcanvas.scss +381 -0
- data/scss/foundation/components/_orbit.scss +415 -0
- data/scss/foundation/components/_pagination.scss +150 -0
- data/scss/foundation/components/_panels.scss +91 -0
- data/scss/foundation/components/_pricing-tables.scss +150 -0
- data/scss/foundation/components/_progress-bars.scss +79 -0
- data/scss/foundation/components/_range-slider.scss +148 -0
- data/scss/foundation/components/_reveal-new.scss +0 -0
- data/scss/foundation/components/_reveal.scss +216 -0
- data/scss/foundation/components/_side-nav.scss +93 -0
- data/scss/foundation/components/_split-buttons.scss +191 -0
- data/scss/foundation/components/_sub-nav.scss +125 -0
- data/scss/foundation/components/_switch.scss +294 -0
- data/scss/foundation/components/_tables.scss +97 -0
- data/scss/foundation/components/_tabs.scss +105 -0
- data/scss/foundation/components/_thumbs.scss +68 -0
- data/scss/foundation/components/_tooltips.scss +140 -0
- data/scss/foundation/components/_top-bar.scss +640 -0
- data/scss/foundation/components/_type.scss +493 -0
- data/scss/foundation/components/_visibility.scss +345 -0
- data/scss/foundation/test.html +0 -0
- data/scss/normalize.scss +423 -0
- data/spec/abide/abide.js +173 -0
- data/spec/abide/advanced.html +22 -0
- data/spec/abide/basic.html +13 -0
- data/spec/accordion/accordion.js +94 -0
- data/spec/accordion/basic.html +39 -0
- data/spec/accordion/grid.html +44 -0
- data/spec/accordion/multiexpand.html +20 -0
- data/spec/alert/alert.js +35 -0
- data/spec/alert/basic.html +4 -0
- data/spec/clearing/222.gif +0 -0
- data/spec/clearing/777.gif +0 -0
- data/spec/clearing/basic.html +5 -0
- data/spec/clearing/ccc.gif +0 -0
- data/spec/clearing/clearing.js +55 -0
- data/spec/dropdown/basic.html +10 -0
- data/spec/dropdown/dropdown.js +65 -0
- data/spec/equalizer/basic.html +24 -0
- data/spec/equalizer/equalizer.js +30 -0
- data/spec/framework/framework.js +14 -0
- data/spec/helpers.js +37 -0
- data/spec/interchange/basic.html +3 -0
- data/spec/interchange/interchange.js +60 -0
- data/spec/joyride/joyride.js +14 -0
- data/spec/magellan/magellan.js +14 -0
- data/spec/offcanvas/offcanvas.js +14 -0
- data/spec/orbit/orbit.js +14 -0
- data/spec/reveal/reveal.js +14 -0
- data/spec/tab/tab.js +14 -0
- data/spec/tooltip/tooltip.js +14 -0
- data/spec/topbar/multidropdown.html +60 -0
- data/spec/topbar/sticky.html +31 -0
- data/spec/topbar/topbar.js +96 -0
- metadata +238 -0
@@ -0,0 +1,168 @@
|
|
1
|
+
/*jslint unparam: true, browser: true, indent: 2 */
|
2
|
+
;(function ($, window, document, undefined) {
|
3
|
+
'use strict';
|
4
|
+
|
5
|
+
Foundation.libs.tab = {
|
6
|
+
name : 'tab',
|
7
|
+
|
8
|
+
version : '5.2.2',
|
9
|
+
|
10
|
+
settings : {
|
11
|
+
active_class: 'active',
|
12
|
+
callback : function () {},
|
13
|
+
deep_linking: false,
|
14
|
+
scroll_to_content: true,
|
15
|
+
is_hover: false
|
16
|
+
},
|
17
|
+
|
18
|
+
default_tab_hashes: [],
|
19
|
+
|
20
|
+
init : function (scope, method, options) {
|
21
|
+
var self = this,
|
22
|
+
S = this.S;
|
23
|
+
|
24
|
+
this.bindings(method, options);
|
25
|
+
this.handle_location_hash_change();
|
26
|
+
|
27
|
+
// Store the default active tabs which will be referenced when the
|
28
|
+
// location hash is absent, as in the case of navigating the tabs and
|
29
|
+
// returning to the first viewing via the browser Back button.
|
30
|
+
S('[' + this.attr_name() + '] > dd.active > a', this.scope).each(function () {
|
31
|
+
self.default_tab_hashes.push(this.hash);
|
32
|
+
});
|
33
|
+
},
|
34
|
+
|
35
|
+
events : function () {
|
36
|
+
var self = this,
|
37
|
+
S = this.S;
|
38
|
+
|
39
|
+
S(this.scope)
|
40
|
+
.off('.tab')
|
41
|
+
// Click event: tab title
|
42
|
+
.on('click.fndtn.tab', '[' + this.attr_name() + '] > dd > a', function (e) {
|
43
|
+
var settings = S(this).closest('[' + self.attr_name() +']').data(self.attr_name(true) + '-init');
|
44
|
+
if (!settings.is_hover || Modernizr.touch) {
|
45
|
+
e.preventDefault();
|
46
|
+
e.stopPropagation();
|
47
|
+
self.toggle_active_tab(S(this).parent());
|
48
|
+
}
|
49
|
+
})
|
50
|
+
// Hover event: tab title
|
51
|
+
.on('mouseenter.fndtn.tab', '[' + this.attr_name() + '] > dd > a', function (e) {
|
52
|
+
var settings = S(this).closest('[' + self.attr_name() +']').data(self.attr_name(true) + '-init');
|
53
|
+
if (settings.is_hover) self.toggle_active_tab(S(this).parent());
|
54
|
+
});
|
55
|
+
|
56
|
+
// Location hash change event
|
57
|
+
S(window).on('hashchange.fndtn.tab', function (e) {
|
58
|
+
e.preventDefault();
|
59
|
+
self.handle_location_hash_change();
|
60
|
+
});
|
61
|
+
},
|
62
|
+
|
63
|
+
handle_location_hash_change : function () {
|
64
|
+
var self = this,
|
65
|
+
S = this.S;
|
66
|
+
|
67
|
+
S('[' + this.attr_name() + ']', this.scope).each(function () {
|
68
|
+
var settings = S(this).data(self.attr_name(true) + '-init');
|
69
|
+
if (settings.deep_linking) {
|
70
|
+
// Match the location hash to a label
|
71
|
+
var hash = self.scope.location.hash;
|
72
|
+
if (hash != '') {
|
73
|
+
// Check whether the location hash references a tab content div or
|
74
|
+
// another element on the page (inside or outside the tab content div)
|
75
|
+
var hash_element = S(hash);
|
76
|
+
if (hash_element.hasClass('content') && hash_element.parent().hasClass('tab-content')) {
|
77
|
+
// Tab content div
|
78
|
+
self.toggle_active_tab($('[' + self.attr_name() + '] > dd > a[href=' + hash + ']').parent());
|
79
|
+
} else {
|
80
|
+
// Not the tab content div. If inside the tab content, find the
|
81
|
+
// containing tab and toggle it as active.
|
82
|
+
var hash_tab_container_id = hash_element.closest('.content').attr('id');
|
83
|
+
if (hash_tab_container_id != undefined) {
|
84
|
+
self.toggle_active_tab($('[' + self.attr_name() + '] > dd > a[href=#' + hash_tab_container_id + ']').parent(), hash);
|
85
|
+
}
|
86
|
+
}
|
87
|
+
} else {
|
88
|
+
// Reference the default tab hashes which were initialized in the init function
|
89
|
+
for (var ind in self.default_tab_hashes) {
|
90
|
+
self.toggle_active_tab($('[' + self.attr_name() + '] > dd > a[href=' + self.default_tab_hashes[ind] + ']').parent());
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
});
|
95
|
+
},
|
96
|
+
|
97
|
+
toggle_active_tab: function (tab, location_hash) {
|
98
|
+
var S = this.S,
|
99
|
+
tabs = tab.closest('[' + this.attr_name() + ']'),
|
100
|
+
anchor = tab.children('a').first(),
|
101
|
+
target_hash = '#' + anchor.attr('href').split('#')[1],
|
102
|
+
target = S(target_hash),
|
103
|
+
siblings = tab.siblings(),
|
104
|
+
settings = tabs.data(this.attr_name(true) + '-init');
|
105
|
+
|
106
|
+
// allow usage of data-tab-content attribute instead of href
|
107
|
+
if (S(this).data(this.data_attr('tab-content'))) {
|
108
|
+
target_hash = '#' + S(this).data(this.data_attr('tab-content')).split('#')[1];
|
109
|
+
target = S(target_hash);
|
110
|
+
}
|
111
|
+
|
112
|
+
if (settings.deep_linking) {
|
113
|
+
// Get the scroll Y position prior to moving to the hash ID
|
114
|
+
var cur_ypos = $('body,html').scrollTop();
|
115
|
+
|
116
|
+
// Update the location hash to preserve browser history
|
117
|
+
// Note that the hash does not need to correspond to the
|
118
|
+
// tab content ID anchor; it can be an ID inside or outside of the tab
|
119
|
+
// content div.
|
120
|
+
if (location_hash != undefined) {
|
121
|
+
window.location.hash = location_hash;
|
122
|
+
} else {
|
123
|
+
window.location.hash = target_hash;
|
124
|
+
}
|
125
|
+
|
126
|
+
if (settings.scroll_to_content) {
|
127
|
+
// If the user is requesting the content of a tab, then scroll to the
|
128
|
+
// top of the title area; otherwise, scroll to the element within
|
129
|
+
// the content area as defined by the hash value.
|
130
|
+
if (location_hash == undefined || location_hash == target_hash) {
|
131
|
+
tab.parent()[0].scrollIntoView();
|
132
|
+
} else {
|
133
|
+
S(target_hash)[0].scrollIntoView();
|
134
|
+
}
|
135
|
+
} else {
|
136
|
+
// Adjust the scrollbar to the Y position prior to setting the hash
|
137
|
+
// Only do this for the tab content anchor, otherwise there will be
|
138
|
+
// conflicts with in-tab anchor links nested in the tab-content div
|
139
|
+
if (location_hash == undefined || location_hash == target_hash) {
|
140
|
+
$('body,html').scrollTop(cur_ypos);
|
141
|
+
}
|
142
|
+
}
|
143
|
+
}
|
144
|
+
|
145
|
+
// WARNING: The activation and deactivation of the tab content must
|
146
|
+
// occur after the deep linking in order to properly refresh the browser
|
147
|
+
// window (notably in Chrome).
|
148
|
+
tab.addClass(settings.active_class).triggerHandler('opened');
|
149
|
+
siblings.removeClass(settings.active_class);
|
150
|
+
target.siblings().removeClass(settings.active_class).end().addClass(settings.active_class);
|
151
|
+
settings.callback(tab);
|
152
|
+
target.triggerHandler('toggled', [tab]);
|
153
|
+
tabs.triggerHandler('toggled', [target]);
|
154
|
+
},
|
155
|
+
|
156
|
+
data_attr: function (str) {
|
157
|
+
if (this.namespace.length > 0) {
|
158
|
+
return this.namespace + '-' + str;
|
159
|
+
}
|
160
|
+
|
161
|
+
return str;
|
162
|
+
},
|
163
|
+
|
164
|
+
off : function () {},
|
165
|
+
|
166
|
+
reflow : function () {}
|
167
|
+
};
|
168
|
+
}(jQuery, this, this.document));
|
@@ -0,0 +1,272 @@
|
|
1
|
+
;(function ($, window, document, undefined) {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
Foundation.libs.tooltip = {
|
5
|
+
name : 'tooltip',
|
6
|
+
|
7
|
+
version : '5.2.2',
|
8
|
+
|
9
|
+
settings : {
|
10
|
+
additional_inheritable_classes : [],
|
11
|
+
tooltip_class : '.tooltip',
|
12
|
+
append_to: 'body',
|
13
|
+
touch_close_text: 'Tap To Close',
|
14
|
+
disable_for_touch: false,
|
15
|
+
hover_delay: 200,
|
16
|
+
tip_template : function (selector, content) {
|
17
|
+
return '<span data-selector="' + selector + '" class="'
|
18
|
+
+ Foundation.libs.tooltip.settings.tooltip_class.substring(1)
|
19
|
+
+ '">' + content + '<span class="nub"></span></span>';
|
20
|
+
}
|
21
|
+
},
|
22
|
+
|
23
|
+
cache : {},
|
24
|
+
|
25
|
+
init : function (scope, method, options) {
|
26
|
+
Foundation.inherit(this, 'random_str');
|
27
|
+
this.bindings(method, options);
|
28
|
+
},
|
29
|
+
|
30
|
+
events : function (instance) {
|
31
|
+
var self = this,
|
32
|
+
S = self.S;
|
33
|
+
|
34
|
+
self.create(this.S(instance));
|
35
|
+
|
36
|
+
$(this.scope)
|
37
|
+
.off('.tooltip')
|
38
|
+
.on('mouseenter.fndtn.tooltip mouseleave.fndtn.tooltip touchstart.fndtn.tooltip MSPointerDown.fndtn.tooltip',
|
39
|
+
'[' + this.attr_name() + ']', function (e) {
|
40
|
+
var $this = S(this),
|
41
|
+
settings = $.extend({}, self.settings, self.data_options($this)),
|
42
|
+
is_touch = false;
|
43
|
+
|
44
|
+
if (Modernizr.touch && /touchstart|MSPointerDown/i.test(e.type) && S(e.target).is('a')) {
|
45
|
+
return false;
|
46
|
+
}
|
47
|
+
|
48
|
+
if (/mouse/i.test(e.type) && self.ie_touch(e)) return false;
|
49
|
+
|
50
|
+
if ($this.hasClass('open')) {
|
51
|
+
if (Modernizr.touch && /touchstart|MSPointerDown/i.test(e.type)) e.preventDefault();
|
52
|
+
self.hide($this);
|
53
|
+
} else {
|
54
|
+
if (settings.disable_for_touch && Modernizr.touch && /touchstart|MSPointerDown/i.test(e.type)) {
|
55
|
+
return;
|
56
|
+
} else if(!settings.disable_for_touch && Modernizr.touch && /touchstart|MSPointerDown/i.test(e.type)) {
|
57
|
+
e.preventDefault();
|
58
|
+
S(settings.tooltip_class + '.open').hide();
|
59
|
+
is_touch = true;
|
60
|
+
}
|
61
|
+
|
62
|
+
if (/enter|over/i.test(e.type)) {
|
63
|
+
this.timer = setTimeout(function () {
|
64
|
+
var tip = self.showTip($this);
|
65
|
+
}.bind(this), self.settings.hover_delay);
|
66
|
+
} else if (e.type === 'mouseout' || e.type === 'mouseleave') {
|
67
|
+
clearTimeout(this.timer);
|
68
|
+
self.hide($this);
|
69
|
+
} else {
|
70
|
+
self.showTip($this);
|
71
|
+
}
|
72
|
+
}
|
73
|
+
})
|
74
|
+
.on('mouseleave.fndtn.tooltip touchstart.fndtn.tooltip MSPointerDown.fndtn.tooltip', '[' + this.attr_name() + '].open', function (e) {
|
75
|
+
if (/mouse/i.test(e.type) && self.ie_touch(e)) return false;
|
76
|
+
|
77
|
+
if($(this).data('tooltip-open-event-type') == 'touch' && e.type == 'mouseleave') {
|
78
|
+
return;
|
79
|
+
}
|
80
|
+
else if($(this).data('tooltip-open-event-type') == 'mouse' && /MSPointerDown|touchstart/i.test(e.type)) {
|
81
|
+
self.convert_to_touch($(this));
|
82
|
+
} else {
|
83
|
+
self.hide($(this));
|
84
|
+
}
|
85
|
+
})
|
86
|
+
.on('DOMNodeRemoved DOMAttrModified', '[' + this.attr_name() + ']:not(a)', function (e) {
|
87
|
+
self.hide(S(this));
|
88
|
+
});
|
89
|
+
},
|
90
|
+
|
91
|
+
ie_touch : function (e) {
|
92
|
+
// How do I distinguish between IE11 and Windows Phone 8?????
|
93
|
+
return false;
|
94
|
+
},
|
95
|
+
|
96
|
+
showTip : function ($target) {
|
97
|
+
var $tip = this.getTip($target);
|
98
|
+
|
99
|
+
return this.show($target);
|
100
|
+
},
|
101
|
+
|
102
|
+
getTip : function ($target) {
|
103
|
+
var selector = this.selector($target),
|
104
|
+
settings = $.extend({}, this.settings, this.data_options($target)),
|
105
|
+
tip = null;
|
106
|
+
|
107
|
+
if (selector) {
|
108
|
+
tip = this.S('span[data-selector="' + selector + '"]' + settings.tooltip_class);
|
109
|
+
}
|
110
|
+
|
111
|
+
return (typeof tip === 'object') ? tip : false;
|
112
|
+
},
|
113
|
+
|
114
|
+
selector : function ($target) {
|
115
|
+
var id = $target.attr('id'),
|
116
|
+
dataSelector = $target.attr(this.attr_name()) || $target.attr('data-selector');
|
117
|
+
|
118
|
+
if ((id && id.length < 1 || !id) && typeof dataSelector != 'string') {
|
119
|
+
dataSelector = this.random_str(6);
|
120
|
+
$target.attr('data-selector', dataSelector);
|
121
|
+
}
|
122
|
+
|
123
|
+
return (id && id.length > 0) ? id : dataSelector;
|
124
|
+
},
|
125
|
+
|
126
|
+
create : function ($target) {
|
127
|
+
var self = this,
|
128
|
+
settings = $.extend({}, this.settings, this.data_options($target)),
|
129
|
+
tip_template = this.settings.tip_template;
|
130
|
+
|
131
|
+
if (typeof settings.tip_template === 'string' && window.hasOwnProperty(settings.tip_template)) {
|
132
|
+
tip_template = window[settings.tip_template];
|
133
|
+
}
|
134
|
+
|
135
|
+
var $tip = $(tip_template(this.selector($target), $('<div></div>').html($target.attr('title')).html())),
|
136
|
+
classes = this.inheritable_classes($target);
|
137
|
+
|
138
|
+
$tip.addClass(classes).appendTo(settings.append_to);
|
139
|
+
|
140
|
+
if (Modernizr.touch) {
|
141
|
+
$tip.append('<span class="tap-to-close">'+settings.touch_close_text+'</span>');
|
142
|
+
$tip.on('touchstart.fndtn.tooltip MSPointerDown.fndtn.tooltip', function(e) {
|
143
|
+
self.hide($target);
|
144
|
+
});
|
145
|
+
}
|
146
|
+
|
147
|
+
$target.removeAttr('title').attr('title','');
|
148
|
+
},
|
149
|
+
|
150
|
+
reposition : function (target, tip, classes) {
|
151
|
+
var width, nub, nubHeight, nubWidth, column, objPos;
|
152
|
+
|
153
|
+
tip.css('visibility', 'hidden').show();
|
154
|
+
|
155
|
+
width = target.data('width');
|
156
|
+
nub = tip.children('.nub');
|
157
|
+
nubHeight = nub.outerHeight();
|
158
|
+
nubWidth = nub.outerHeight();
|
159
|
+
|
160
|
+
if (this.small()) {
|
161
|
+
tip.css({'width' : '100%' });
|
162
|
+
} else {
|
163
|
+
tip.css({'width' : (width) ? width : 'auto'});
|
164
|
+
}
|
165
|
+
|
166
|
+
objPos = function (obj, top, right, bottom, left, width) {
|
167
|
+
return obj.css({
|
168
|
+
'top' : (top) ? top : 'auto',
|
169
|
+
'bottom' : (bottom) ? bottom : 'auto',
|
170
|
+
'left' : (left) ? left : 'auto',
|
171
|
+
'right' : (right) ? right : 'auto',
|
172
|
+
}).end();
|
173
|
+
};
|
174
|
+
|
175
|
+
objPos(tip, (target.offset().top + target.outerHeight() + 10), 'auto', 'auto', target.offset().left);
|
176
|
+
|
177
|
+
if (this.small()) {
|
178
|
+
objPos(tip, (target.offset().top + target.outerHeight() + 10), 'auto', 'auto', 12.5, $(this.scope).width());
|
179
|
+
tip.addClass('tip-override');
|
180
|
+
objPos(nub, -nubHeight, 'auto', 'auto', target.offset().left);
|
181
|
+
} else {
|
182
|
+
var left = target.offset().left;
|
183
|
+
if (Foundation.rtl) {
|
184
|
+
nub.addClass('rtl');
|
185
|
+
left = target.offset().left + target.outerWidth() - tip.outerWidth();
|
186
|
+
}
|
187
|
+
objPos(tip, (target.offset().top + target.outerHeight() + 10), 'auto', 'auto', left);
|
188
|
+
tip.removeClass('tip-override');
|
189
|
+
if (classes && classes.indexOf('tip-top') > -1) {
|
190
|
+
if (Foundation.rtl) nub.addClass('rtl');
|
191
|
+
objPos(tip, (target.offset().top - tip.outerHeight()), 'auto', 'auto', left)
|
192
|
+
.removeClass('tip-override');
|
193
|
+
} else if (classes && classes.indexOf('tip-left') > -1) {
|
194
|
+
objPos(tip, (target.offset().top + (target.outerHeight() / 2) - (tip.outerHeight() / 2)), 'auto', 'auto', (target.offset().left - tip.outerWidth() - nubHeight))
|
195
|
+
.removeClass('tip-override');
|
196
|
+
nub.removeClass('rtl');
|
197
|
+
} else if (classes && classes.indexOf('tip-right') > -1) {
|
198
|
+
objPos(tip, (target.offset().top + (target.outerHeight() / 2) - (tip.outerHeight() / 2)), 'auto', 'auto', (target.offset().left + target.outerWidth() + nubHeight))
|
199
|
+
.removeClass('tip-override');
|
200
|
+
nub.removeClass('rtl');
|
201
|
+
}
|
202
|
+
}
|
203
|
+
|
204
|
+
tip.css('visibility', 'visible').hide();
|
205
|
+
},
|
206
|
+
|
207
|
+
small : function () {
|
208
|
+
return matchMedia(Foundation.media_queries.small).matches &&
|
209
|
+
!matchMedia(Foundation.media_queries.medium).matches;
|
210
|
+
},
|
211
|
+
|
212
|
+
inheritable_classes : function ($target) {
|
213
|
+
var settings = $.extend({}, this.settings, this.data_options($target)),
|
214
|
+
inheritables = ['tip-top', 'tip-left', 'tip-bottom', 'tip-right', 'radius', 'round'].concat(settings.additional_inheritable_classes),
|
215
|
+
classes = $target.attr('class'),
|
216
|
+
filtered = classes ? $.map(classes.split(' '), function (el, i) {
|
217
|
+
if ($.inArray(el, inheritables) !== -1) {
|
218
|
+
return el;
|
219
|
+
}
|
220
|
+
}).join(' ') : '';
|
221
|
+
|
222
|
+
return $.trim(filtered);
|
223
|
+
},
|
224
|
+
|
225
|
+
convert_to_touch : function($target) {
|
226
|
+
var self = this,
|
227
|
+
$tip = self.getTip($target),
|
228
|
+
settings = $.extend({}, self.settings, self.data_options($target));
|
229
|
+
|
230
|
+
if ($tip.find('.tap-to-close').length === 0) {
|
231
|
+
$tip.append('<span class="tap-to-close">'+settings.touch_close_text+'</span>');
|
232
|
+
$tip.on('click.fndtn.tooltip.tapclose touchstart.fndtn.tooltip.tapclose MSPointerDown.fndtn.tooltip.tapclose', function(e) {
|
233
|
+
self.hide($target);
|
234
|
+
});
|
235
|
+
}
|
236
|
+
|
237
|
+
$target.data('tooltip-open-event-type', 'touch');
|
238
|
+
},
|
239
|
+
|
240
|
+
show : function ($target) {
|
241
|
+
var $tip = this.getTip($target);
|
242
|
+
|
243
|
+
if ($target.data('tooltip-open-event-type') == 'touch') {
|
244
|
+
this.convert_to_touch($target);
|
245
|
+
}
|
246
|
+
|
247
|
+
this.reposition($target, $tip, $target.attr('class'));
|
248
|
+
$target.addClass('open');
|
249
|
+
$tip.fadeIn(150);
|
250
|
+
},
|
251
|
+
|
252
|
+
hide : function ($target) {
|
253
|
+
var $tip = this.getTip($target);
|
254
|
+
|
255
|
+
$tip.fadeOut(150, function() {
|
256
|
+
$tip.find('.tap-to-close').remove();
|
257
|
+
$tip.off('click.fndtn.tooltip.tapclose touchstart.fndtn.tooltip.tapclose MSPointerDown.fndtn.tapclose');
|
258
|
+
$target.removeClass('open');
|
259
|
+
});
|
260
|
+
},
|
261
|
+
|
262
|
+
off : function () {
|
263
|
+
var self = this;
|
264
|
+
this.S(this.scope).off('.fndtn.tooltip');
|
265
|
+
this.S(this.settings.tooltip_class).each(function (i) {
|
266
|
+
$('[' + self.attr_name() + ']').eq(i).attr('title', $(this).text());
|
267
|
+
}).remove();
|
268
|
+
},
|
269
|
+
|
270
|
+
reflow : function () {}
|
271
|
+
};
|
272
|
+
}(jQuery, this, this.document));
|
@@ -0,0 +1,422 @@
|
|
1
|
+
;(function ($, window, document, undefined) {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
Foundation.libs.topbar = {
|
5
|
+
name : 'topbar',
|
6
|
+
|
7
|
+
version: '5.2.2',
|
8
|
+
|
9
|
+
settings : {
|
10
|
+
index : 0,
|
11
|
+
sticky_class : 'sticky',
|
12
|
+
custom_back_text: true,
|
13
|
+
back_text: 'Back',
|
14
|
+
is_hover: true,
|
15
|
+
mobile_show_parent_link: false,
|
16
|
+
scrolltop : true, // jump to top when sticky nav menu toggle is clicked
|
17
|
+
sticky_on : 'all'
|
18
|
+
},
|
19
|
+
|
20
|
+
init : function (section, method, options) {
|
21
|
+
Foundation.inherit(this, 'add_custom_rule register_media throttle');
|
22
|
+
var self = this;
|
23
|
+
|
24
|
+
self.register_media('topbar', 'foundation-mq-topbar');
|
25
|
+
|
26
|
+
this.bindings(method, options);
|
27
|
+
|
28
|
+
self.S('[' + this.attr_name() + ']', this.scope).each(function () {
|
29
|
+
var topbar = $(this),
|
30
|
+
settings = topbar.data(self.attr_name(true) + '-init'),
|
31
|
+
section = self.S('section', this),
|
32
|
+
titlebar = topbar.children().filter('ul').first();
|
33
|
+
topbar.data('index', 0);
|
34
|
+
var topbarContainer = topbar.parent();
|
35
|
+
if(topbarContainer.hasClass('fixed') || self.is_sticky(topbar, topbarContainer, settings) ) {
|
36
|
+
self.settings.sticky_class = settings.sticky_class;
|
37
|
+
self.settings.sticky_topbar = topbar;
|
38
|
+
topbar.data('height', topbarContainer.outerHeight());
|
39
|
+
topbar.data('stickyoffset', topbarContainer.offset().top);
|
40
|
+
} else {
|
41
|
+
topbar.data('height', topbar.outerHeight());
|
42
|
+
}
|
43
|
+
|
44
|
+
if (!settings.assembled) self.assemble(topbar);
|
45
|
+
|
46
|
+
if (settings.is_hover) {
|
47
|
+
self.S('.has-dropdown', topbar).addClass('not-click');
|
48
|
+
} else {
|
49
|
+
self.S('.has-dropdown', topbar).removeClass('not-click');
|
50
|
+
}
|
51
|
+
|
52
|
+
// Pad body when sticky (scrolled) or fixed.
|
53
|
+
self.add_custom_rule('.f-topbar-fixed { padding-top: ' + topbar.data('height') + 'px }');
|
54
|
+
|
55
|
+
if (topbarContainer.hasClass('fixed')) {
|
56
|
+
self.S('body').addClass('f-topbar-fixed');
|
57
|
+
}
|
58
|
+
});
|
59
|
+
|
60
|
+
},
|
61
|
+
|
62
|
+
is_sticky: function (topbar, topbarContainer, settings) {
|
63
|
+
var sticky = topbarContainer.hasClass(settings.sticky_class);
|
64
|
+
|
65
|
+
if (sticky && settings.sticky_on === 'all') {
|
66
|
+
return true;
|
67
|
+
} else if (sticky && this.small() && settings.sticky_on === 'small') {
|
68
|
+
return true;
|
69
|
+
} else if (sticky && this.medium() && settings.sticky_on === 'medium') {
|
70
|
+
return true;
|
71
|
+
} else if (sticky && this.large() && settings.sticky_on === 'large') {
|
72
|
+
return true;
|
73
|
+
}
|
74
|
+
|
75
|
+
return false;
|
76
|
+
},
|
77
|
+
|
78
|
+
toggle: function (toggleEl) {
|
79
|
+
var self = this;
|
80
|
+
|
81
|
+
if (toggleEl) {
|
82
|
+
var topbar = self.S(toggleEl).closest('[' + this.attr_name() + ']');
|
83
|
+
} else {
|
84
|
+
var topbar = self.S('[' + this.attr_name() + ']');
|
85
|
+
}
|
86
|
+
|
87
|
+
var settings = topbar.data(this.attr_name(true) + '-init');
|
88
|
+
|
89
|
+
var section = self.S('section, .section', topbar);
|
90
|
+
|
91
|
+
if (self.breakpoint()) {
|
92
|
+
if (!self.rtl) {
|
93
|
+
section.css({left: '0%'});
|
94
|
+
$('>.name', section).css({left: '100%'});
|
95
|
+
} else {
|
96
|
+
section.css({right: '0%'});
|
97
|
+
$('>.name', section).css({right: '100%'});
|
98
|
+
}
|
99
|
+
|
100
|
+
self.S('li.moved', section).removeClass('moved');
|
101
|
+
topbar.data('index', 0);
|
102
|
+
|
103
|
+
topbar
|
104
|
+
.toggleClass('expanded')
|
105
|
+
.css('height', '');
|
106
|
+
}
|
107
|
+
|
108
|
+
if (settings.scrolltop) {
|
109
|
+
if (!topbar.hasClass('expanded')) {
|
110
|
+
if (topbar.hasClass('fixed')) {
|
111
|
+
topbar.parent().addClass('fixed');
|
112
|
+
topbar.removeClass('fixed');
|
113
|
+
self.S('body').addClass('f-topbar-fixed');
|
114
|
+
}
|
115
|
+
} else if (topbar.parent().hasClass('fixed')) {
|
116
|
+
if (settings.scrolltop) {
|
117
|
+
topbar.parent().removeClass('fixed');
|
118
|
+
topbar.addClass('fixed');
|
119
|
+
self.S('body').removeClass('f-topbar-fixed');
|
120
|
+
|
121
|
+
window.scrollTo(0,0);
|
122
|
+
} else {
|
123
|
+
topbar.parent().removeClass('expanded');
|
124
|
+
}
|
125
|
+
}
|
126
|
+
} else {
|
127
|
+
if(self.is_sticky(topbar, topbar.parent(), settings)) {
|
128
|
+
topbar.parent().addClass('fixed');
|
129
|
+
}
|
130
|
+
|
131
|
+
if(topbar.parent().hasClass('fixed')) {
|
132
|
+
if (!topbar.hasClass('expanded')) {
|
133
|
+
topbar.removeClass('fixed');
|
134
|
+
topbar.parent().removeClass('expanded');
|
135
|
+
self.update_sticky_positioning();
|
136
|
+
} else {
|
137
|
+
topbar.addClass('fixed');
|
138
|
+
topbar.parent().addClass('expanded');
|
139
|
+
self.S('body').addClass('f-topbar-fixed');
|
140
|
+
}
|
141
|
+
}
|
142
|
+
}
|
143
|
+
},
|
144
|
+
|
145
|
+
timer : null,
|
146
|
+
|
147
|
+
events : function (bar) {
|
148
|
+
var self = this,
|
149
|
+
S = this.S;
|
150
|
+
|
151
|
+
S(this.scope)
|
152
|
+
.off('.topbar')
|
153
|
+
.on('click.fndtn.topbar', '[' + this.attr_name() + '] .toggle-topbar', function (e) {
|
154
|
+
e.preventDefault();
|
155
|
+
self.toggle(this);
|
156
|
+
})
|
157
|
+
.on('click.fndtn.topbar','.top-bar .top-bar-section li a[href^="#"],[' + this.attr_name() + '] .top-bar-section li a[href^="#"]',function (e) {
|
158
|
+
var li = $(this).closest('li');
|
159
|
+
if(self.breakpoint() && !li.hasClass('back') && !li.hasClass('has-dropdown'))
|
160
|
+
{
|
161
|
+
self.toggle();
|
162
|
+
}
|
163
|
+
})
|
164
|
+
.on('click.fndtn.topbar', '[' + this.attr_name() + '] li.has-dropdown', function (e) {
|
165
|
+
var li = S(this),
|
166
|
+
target = S(e.target),
|
167
|
+
topbar = li.closest('[' + self.attr_name() + ']'),
|
168
|
+
settings = topbar.data(self.attr_name(true) + '-init');
|
169
|
+
|
170
|
+
if(target.data('revealId')) {
|
171
|
+
self.toggle();
|
172
|
+
return;
|
173
|
+
}
|
174
|
+
|
175
|
+
if (self.breakpoint()) return;
|
176
|
+
if (settings.is_hover && !Modernizr.touch) return;
|
177
|
+
|
178
|
+
e.stopImmediatePropagation();
|
179
|
+
|
180
|
+
if (li.hasClass('hover')) {
|
181
|
+
li
|
182
|
+
.removeClass('hover')
|
183
|
+
.find('li')
|
184
|
+
.removeClass('hover');
|
185
|
+
|
186
|
+
li.parents('li.hover')
|
187
|
+
.removeClass('hover');
|
188
|
+
} else {
|
189
|
+
li.addClass('hover');
|
190
|
+
|
191
|
+
$(li).siblings().removeClass('hover');
|
192
|
+
|
193
|
+
if (target[0].nodeName === 'A' && target.parent().hasClass('has-dropdown')) {
|
194
|
+
e.preventDefault();
|
195
|
+
}
|
196
|
+
}
|
197
|
+
})
|
198
|
+
.on('click.fndtn.topbar', '[' + this.attr_name() + '] .has-dropdown>a', function (e) {
|
199
|
+
if (self.breakpoint()) {
|
200
|
+
|
201
|
+
e.preventDefault();
|
202
|
+
|
203
|
+
var $this = S(this),
|
204
|
+
topbar = $this.closest('[' + self.attr_name() + ']'),
|
205
|
+
section = topbar.find('section, .section'),
|
206
|
+
dropdownHeight = $this.next('.dropdown').outerHeight(),
|
207
|
+
$selectedLi = $this.closest('li');
|
208
|
+
|
209
|
+
topbar.data('index', topbar.data('index') + 1);
|
210
|
+
$selectedLi.addClass('moved');
|
211
|
+
|
212
|
+
if (!self.rtl) {
|
213
|
+
section.css({left: -(100 * topbar.data('index')) + '%'});
|
214
|
+
section.find('>.name').css({left: 100 * topbar.data('index') + '%'});
|
215
|
+
} else {
|
216
|
+
section.css({right: -(100 * topbar.data('index')) + '%'});
|
217
|
+
section.find('>.name').css({right: 100 * topbar.data('index') + '%'});
|
218
|
+
}
|
219
|
+
|
220
|
+
topbar.css('height', $this.siblings('ul').outerHeight(true) + topbar.data('height'));
|
221
|
+
}
|
222
|
+
});
|
223
|
+
|
224
|
+
S(window).off('.topbar').on('resize.fndtn.topbar', self.throttle(function () {
|
225
|
+
self.resize.call(self);
|
226
|
+
}, 50)).trigger('resize');
|
227
|
+
|
228
|
+
S('body').off('.topbar').on('click.fndtn.topbar touchstart.fndtn.topbar', function (e) {
|
229
|
+
var parent = S(e.target).closest('li').closest('li.hover');
|
230
|
+
|
231
|
+
if (parent.length > 0) {
|
232
|
+
return;
|
233
|
+
}
|
234
|
+
|
235
|
+
S('[' + self.attr_name() + '] li.hover').removeClass('hover');
|
236
|
+
});
|
237
|
+
|
238
|
+
// Go up a level on Click
|
239
|
+
S(this.scope).on('click.fndtn.topbar', '[' + this.attr_name() + '] .has-dropdown .back', function (e) {
|
240
|
+
e.preventDefault();
|
241
|
+
|
242
|
+
var $this = S(this),
|
243
|
+
topbar = $this.closest('[' + self.attr_name() + ']'),
|
244
|
+
section = topbar.find('section, .section'),
|
245
|
+
settings = topbar.data(self.attr_name(true) + '-init'),
|
246
|
+
$movedLi = $this.closest('li.moved'),
|
247
|
+
$previousLevelUl = $movedLi.parent();
|
248
|
+
|
249
|
+
topbar.data('index', topbar.data('index') - 1);
|
250
|
+
|
251
|
+
if (!self.rtl) {
|
252
|
+
section.css({left: -(100 * topbar.data('index')) + '%'});
|
253
|
+
section.find('>.name').css({left: 100 * topbar.data('index') + '%'});
|
254
|
+
} else {
|
255
|
+
section.css({right: -(100 * topbar.data('index')) + '%'});
|
256
|
+
section.find('>.name').css({right: 100 * topbar.data('index') + '%'});
|
257
|
+
}
|
258
|
+
|
259
|
+
if (topbar.data('index') === 0) {
|
260
|
+
topbar.css('height', '');
|
261
|
+
} else {
|
262
|
+
topbar.css('height', $previousLevelUl.outerHeight(true) + topbar.data('height'));
|
263
|
+
}
|
264
|
+
|
265
|
+
setTimeout(function () {
|
266
|
+
$movedLi.removeClass('moved');
|
267
|
+
}, 300);
|
268
|
+
});
|
269
|
+
},
|
270
|
+
|
271
|
+
resize : function () {
|
272
|
+
var self = this;
|
273
|
+
self.S('[' + this.attr_name() + ']').each(function () {
|
274
|
+
var topbar = self.S(this),
|
275
|
+
settings = topbar.data(self.attr_name(true) + '-init');
|
276
|
+
|
277
|
+
var stickyContainer = topbar.parent('.' + self.settings.sticky_class);
|
278
|
+
var stickyOffset;
|
279
|
+
|
280
|
+
if (!self.breakpoint()) {
|
281
|
+
var doToggle = topbar.hasClass('expanded');
|
282
|
+
topbar
|
283
|
+
.css('height', '')
|
284
|
+
.removeClass('expanded')
|
285
|
+
.find('li')
|
286
|
+
.removeClass('hover');
|
287
|
+
|
288
|
+
if(doToggle) {
|
289
|
+
self.toggle(topbar);
|
290
|
+
}
|
291
|
+
}
|
292
|
+
|
293
|
+
if(self.is_sticky(topbar, stickyContainer, settings)) {
|
294
|
+
if(stickyContainer.hasClass('fixed')) {
|
295
|
+
// Remove the fixed to allow for correct calculation of the offset.
|
296
|
+
stickyContainer.removeClass('fixed');
|
297
|
+
|
298
|
+
stickyOffset = stickyContainer.offset().top;
|
299
|
+
if(self.S(document.body).hasClass('f-topbar-fixed')) {
|
300
|
+
stickyOffset -= topbar.data('height');
|
301
|
+
}
|
302
|
+
|
303
|
+
topbar.data('stickyoffset', stickyOffset);
|
304
|
+
stickyContainer.addClass('fixed');
|
305
|
+
} else {
|
306
|
+
stickyOffset = stickyContainer.offset().top;
|
307
|
+
topbar.data('stickyoffset', stickyOffset);
|
308
|
+
}
|
309
|
+
}
|
310
|
+
|
311
|
+
});
|
312
|
+
},
|
313
|
+
|
314
|
+
breakpoint : function () {
|
315
|
+
return !matchMedia(Foundation.media_queries['topbar']).matches;
|
316
|
+
},
|
317
|
+
|
318
|
+
small : function () {
|
319
|
+
return matchMedia(Foundation.media_queries['small']).matches;
|
320
|
+
},
|
321
|
+
|
322
|
+
medium : function () {
|
323
|
+
return matchMedia(Foundation.media_queries['medium']).matches;
|
324
|
+
},
|
325
|
+
|
326
|
+
large : function () {
|
327
|
+
return matchMedia(Foundation.media_queries['large']).matches;
|
328
|
+
},
|
329
|
+
|
330
|
+
assemble : function (topbar) {
|
331
|
+
var self = this,
|
332
|
+
settings = topbar.data(this.attr_name(true) + '-init'),
|
333
|
+
section = self.S('section', topbar),
|
334
|
+
titlebar = $(this).children().filter('ul').first();
|
335
|
+
|
336
|
+
// Pull element out of the DOM for manipulation
|
337
|
+
section.detach();
|
338
|
+
|
339
|
+
self.S('.has-dropdown>a', section).each(function () {
|
340
|
+
var $link = self.S(this),
|
341
|
+
$dropdown = $link.siblings('.dropdown'),
|
342
|
+
url = $link.attr('href');
|
343
|
+
|
344
|
+
if (!$dropdown.find('.title.back').length) {
|
345
|
+
if (settings.mobile_show_parent_link && url && url.length > 1) {
|
346
|
+
var $titleLi = $('<li class="title back js-generated"><h5><a href="javascript:void(0)"></a></h5></li><li><a class="parent-link js-generated" href="' + url + '">' + $link.text() +'</a></li>');
|
347
|
+
} else {
|
348
|
+
var $titleLi = $('<li class="title back js-generated"><h5><a href="javascript:void(0)"></a></h5></li>');
|
349
|
+
}
|
350
|
+
|
351
|
+
// Copy link to subnav
|
352
|
+
if (settings.custom_back_text == true) {
|
353
|
+
$('h5>a', $titleLi).html(settings.back_text);
|
354
|
+
} else {
|
355
|
+
$('h5>a', $titleLi).html('« ' + $link.html());
|
356
|
+
}
|
357
|
+
$dropdown.prepend($titleLi);
|
358
|
+
}
|
359
|
+
});
|
360
|
+
|
361
|
+
// Put element back in the DOM
|
362
|
+
section.appendTo(topbar);
|
363
|
+
|
364
|
+
// check for sticky
|
365
|
+
this.sticky();
|
366
|
+
|
367
|
+
this.assembled(topbar);
|
368
|
+
},
|
369
|
+
|
370
|
+
assembled : function (topbar) {
|
371
|
+
topbar.data(this.attr_name(true), $.extend({}, topbar.data(this.attr_name(true)), {assembled: true}));
|
372
|
+
},
|
373
|
+
|
374
|
+
height : function (ul) {
|
375
|
+
var total = 0,
|
376
|
+
self = this;
|
377
|
+
|
378
|
+
$('> li', ul).each(function () { total += self.S(this).outerHeight(true); });
|
379
|
+
|
380
|
+
return total;
|
381
|
+
},
|
382
|
+
|
383
|
+
sticky : function () {
|
384
|
+
var $window = this.S(window),
|
385
|
+
self = this;
|
386
|
+
|
387
|
+
this.S(window).on('scroll', function() {
|
388
|
+
self.update_sticky_positioning();
|
389
|
+
});
|
390
|
+
},
|
391
|
+
|
392
|
+
update_sticky_positioning: function() {
|
393
|
+
var klass = '.' + this.settings.sticky_class,
|
394
|
+
$window = this.S(window),
|
395
|
+
self = this;
|
396
|
+
|
397
|
+
if (self.settings.sticky_topbar && self.is_sticky(this.settings.sticky_topbar,this.settings.sticky_topbar.parent(), this.settings)) {
|
398
|
+
var distance = this.settings.sticky_topbar.data('stickyoffset');
|
399
|
+
if (!self.S(klass).hasClass('expanded')) {
|
400
|
+
if ($window.scrollTop() > (distance)) {
|
401
|
+
if (!self.S(klass).hasClass('fixed')) {
|
402
|
+
self.S(klass).addClass('fixed');
|
403
|
+
self.S('body').addClass('f-topbar-fixed');
|
404
|
+
}
|
405
|
+
} else if ($window.scrollTop() <= distance) {
|
406
|
+
if (self.S(klass).hasClass('fixed')) {
|
407
|
+
self.S(klass).removeClass('fixed');
|
408
|
+
self.S('body').removeClass('f-topbar-fixed');
|
409
|
+
}
|
410
|
+
}
|
411
|
+
}
|
412
|
+
}
|
413
|
+
},
|
414
|
+
|
415
|
+
off : function () {
|
416
|
+
this.S(this.scope).off('.fndtn.topbar');
|
417
|
+
this.S(window).off('.fndtn.topbar');
|
418
|
+
},
|
419
|
+
|
420
|
+
reflow : function () {}
|
421
|
+
};
|
422
|
+
}(jQuery, this, this.document));
|