1
0
mirror of https://github.com/Hutchy68/pivot.git synced 2024-11-23 10:59:03 +01:00

Making Font Awesome 'preload' a feature as this does not effect everyone. Absolute latest Foundation 5 js from their repo to fix all JQMigrate warnings.

This commit is contained in:
Tom Hutchison 2018-02-15 12:42:07 -05:00
parent 52aecafbc9
commit 65964dc883
18 changed files with 147 additions and 85 deletions

View File

@ -24,6 +24,7 @@ class SkinPivot extends SkinTemplate {
'wikiName' => &$GLOBALS['wgSitename'], 'wikiName' => &$GLOBALS['wgSitename'],
'wikiNameDesktop' => &$GLOBALS['wgSitename'], 'wikiNameDesktop' => &$GLOBALS['wgSitename'],
'navbarIcon' => false, 'navbarIcon' => false,
'preloadFontAwesome' => false,
'showFooterIcons' => false, 'showFooterIcons' => false,
'addThisPUBID' => '', 'addThisPUBID' => '',
'useAddThisShare' => '', 'useAddThisShare' => '',
@ -38,8 +39,9 @@ class SkinPivot extends SkinTemplate {
$viewport_meta = 'width=device-width, user-scalable=yes, initial-scale=1.0'; $viewport_meta = 'width=device-width, user-scalable=yes, initial-scale=1.0';
$out->addMeta('viewport', $viewport_meta); $out->addMeta('viewport', $viewport_meta);
$out->addModuleScripts('skins.pivot.js'); $out->addModuleScripts('skins.pivot.js');
if ( $wgPivotFeatures['preloadFontAwesome'] ) {
$out->addHeadItem('font', '<link rel="preload" href="'.$wgLocalStylePath.'/pivot/assets/fonts/fontawesome-webfont.woff2?v=4.7.0" as="font" type="font/woff2" crossorigin="anonymous" />'); $out->addHeadItem('font', '<link rel="preload" href="'.$wgLocalStylePath.'/pivot/assets/fonts/fontawesome-webfont.woff2?v=4.7.0" as="font" type="font/woff2" crossorigin="anonymous" />');
}
} }
} }
@ -114,7 +116,7 @@ class pivotTemplate extends BaseTemplate {
</form> </form>
</li> </li>
<?php $this->renderSidebar() ?> <?php $location="-off-canvas";$this->renderSidebar() ?>
</ul> </ul>
</aside> </aside>
@ -159,7 +161,7 @@ class pivotTemplate extends BaseTemplate {
</form> </form>
</li> </li>
<?php $this->renderSidebar() ?> <?php $location="";$this->renderSidebar() ?>
</ul> </ul>
</div> </div>
@ -292,11 +294,11 @@ class pivotTemplate extends BaseTemplate {
function renderSidebar() { function renderSidebar() {
$sidebar = $this->getSidebar(); $sidebar = $this->getSidebar();
foreach ($sidebar as $boxName => $box) { foreach ($sidebar as $boxName => $box) {
echo '<li><label class="sidebar" id="'.Sanitizer::escapeId( $box['id'] ).'"';echo Linker::tooltip( $box['id'] ).'>'.htmlspecialchars( $box['header'] ).'</label></li>'; echo '<li><label class="sidebar" id="'.Sanitizer::escapeId( $box['id'] ).$location.'"';echo Linker::tooltip( $box['id'] ).'>'.htmlspecialchars( $box['header'] ).'</label></li>';
if ( is_array( $box['content'] ) ) { if ( is_array( $box['content'] ) ) {
foreach ($box['content'] as $key => $item) { echo $this->makeListItem($key, $item); } foreach ($box['content'] as $key => $item) { echo $this->makeListItem($key, $item); }
} }
} }
} return; }
} }
?> ?>

View File

@ -4,7 +4,7 @@
Foundation.libs.abide = { Foundation.libs.abide = {
name : 'abide', name : 'abide',
version : '5.5.3', version : '{{VERSION}}',
settings : { settings : {
live_validate : true, // validate the form as you go live_validate : true, // validate the form as you go
@ -154,7 +154,7 @@
validate : function (els, e, is_ajax) { validate : function (els, e, is_ajax) {
var validations = this.parse_patterns(els), var validations = this.parse_patterns(els),
validation_count = validations.length, validation_count = validations.length,
form = this.S(els[0]).closest('form'), form = this.S(els.length ? els[0] : e.target).closest('form'),
submit_event = /submit/.test(e.type); submit_event = /submit/.test(e.type);
// Has to count up to make sure the focus gets applied to the top error // Has to count up to make sure the focus gets applied to the top error

View File

@ -4,7 +4,7 @@
Foundation.libs.accordion = { Foundation.libs.accordion = {
name : 'accordion', name : 'accordion',
version : '5.5.3', version : '{{VERSION}}',
settings : { settings : {
content_class : 'content', content_class : 'content',
@ -25,16 +25,18 @@
S(this.scope) S(this.scope)
.off('.fndtn.accordion') .off('.fndtn.accordion')
.on('click.fndtn.accordion', '[' + this.attr_name() + '] > dd > a, [' + this.attr_name() + '] > li > a', function (e) { .on('click.fndtn.accordion', '[' + this.attr_name() + '] > dd > a:not(.follow), [' + this.attr_name() + '] > li > a:not(.follow)', function (e) {
var accordion = S(this).closest('[' + self.attr_name() + ']'), var accordion = S(this).closest('[' + self.attr_name() + ']'),
groupSelector = self.attr_name() + '=' + accordion.attr(self.attr_name()), groupSelector = self.attr_name() + '=' + accordion.attr(self.attr_name()),
settings = accordion.data(self.attr_name(true) + '-init') || self.settings, settings = accordion.data(self.attr_name(true) + '-init') || self.settings,
target = S('#' + this.href.split('#')[1]), contentAttr = S(this).context.attributes['data-content'],
target = S('#' + (contentAttr ? contentAttr.value : this.href.split('#')[1])),
aunts = $('> dd, > li', accordion), aunts = $('> dd, > li', accordion),
siblings = aunts.children('.' + settings.content_class), siblings = aunts.children('.' + settings.content_class),
active_content = siblings.filter('.' + settings.active_class); active_content = siblings.filter('.' + settings.active_class);
e.preventDefault(); e.preventDefault();
e.stopPropagation();
if (accordion.attr(self.attr_name())) { if (accordion.attr(self.attr_name())) {
siblings = siblings.add('[' + groupSelector + '] dd > ' + '.' + settings.content_class + ', [' + groupSelector + '] li > ' + '.' + settings.content_class); siblings = siblings.add('[' + groupSelector + '] dd > ' + '.' + settings.content_class + ', [' + groupSelector + '] li > ' + '.' + settings.content_class);

View File

@ -4,7 +4,7 @@
Foundation.libs.alert = { Foundation.libs.alert = {
name : 'alert', name : 'alert',
version : '5.5.3', version : '{{VERSION}}',
settings : { settings : {
callback : function () {} callback : function () {}

View File

@ -4,7 +4,7 @@
Foundation.libs.clearing = { Foundation.libs.clearing = {
name : 'clearing', name : 'clearing',
version : '5.5.3', version : '{{VERSION}}',
settings : { settings : {
templates : { templates : {

View File

@ -4,7 +4,7 @@
Foundation.libs.dropdown = { Foundation.libs.dropdown = {
name : 'dropdown', name : 'dropdown',
version : '5.5.3', version : '{{VERSION}}',
settings : { settings : {
active_class : 'open', active_class : 'open',
@ -13,6 +13,7 @@
align : 'bottom', align : 'bottom',
is_hover : false, is_hover : false,
hover_timeout : 150, hover_timeout : 150,
no_pip : false,
opened : function () {}, opened : function () {},
closed : function () {} closed : function () {}
}, },
@ -298,15 +299,13 @@
} }
//miss right //miss right
if (o_left + outerWidth > o_left + actualMarginWidth && o_left - actualMarginWidth > outerWidth) { if (o_left + outerWidth > o_left + actualMarginWidth && o_left - actualMarginWidth > outerWidth - o_left) {
p.missRight = true; p.missRight = true;
p.missLeft = false;
} }
//miss left //miss left
if (o_left - outerWidth <= 0) { if (o_left - outerWidth <= 0) {
p.missLeft = true; p.missLeft = true;
p.missRight = false;
} }
} }
@ -315,89 +314,121 @@
top : function (t, s) { top : function (t, s) {
var self = Foundation.libs.dropdown, var self = Foundation.libs.dropdown,
p = self.dirs._base.call(this, t, s); p = self.dirs._base.call(this, t, s),
tOuterHeight = t.outerHeight(),
tOuterWidth = t.outerWidth(),
thisOuterHeight = this.outerHeight(),
thisOuterWidth = this.outerWidth();
this.addClass('drop-top'); this.addClass('drop-top');
if (p.missTop == true) { if (p.missTop == true) {
p.top = p.top + t.outerHeight() + this.outerHeight(); p.top = p.top + tOuterHeight + thisOuterHeight;
this.removeClass('drop-top'); this.removeClass('drop-top');
} }
if (p.missRight == true) { if (p.missRight == true) {
p.left = p.left - this.outerWidth() + t.outerWidth(); p.left = p.left - thisOuterWidth + tOuterWidth;
} }
if (t.outerWidth() < this.outerWidth() || self.small() || this.hasClass(s.mega_menu)) { if (!s.no_pip && tOuterWidth < thisOuterWidth || self.small() || this.hasClass(s.mega_menu)) {
self.adjust_pip(this, t, s, p); self.adjust_pip(this, t, s, p);
} }
if (Foundation.rtl) { if (Foundation.rtl) {
return {left : p.left - this.outerWidth() + t.outerWidth(), return {left : p.left - thisOuterWidth + tOuterWidth,
top : p.top - this.outerHeight()}; top : p.top - thisOuterHeight};
} }
return {left : p.left, top : p.top - this.outerHeight()}; return {left : p.left, top : p.top - thisOuterHeight};
}, },
bottom : function (t, s) { bottom : function (t, s) {
var self = Foundation.libs.dropdown, var self = Foundation.libs.dropdown,
p = self.dirs._base.call(this, t, s); p = self.dirs._base.call(this, t, s),
tOuterHeight = t.outerHeight(),
tOuterWidth = t.outerWidth(),
thisOuterHeight = this.outerHeight(),
thisOuterWidth = this.outerWidth();;
if (p.missRight == true) { if (p.missRight == true) {
p.left = p.left - this.outerWidth() + t.outerWidth(); p.left = p.left - thisOuterWidth + tOuterWidth;
} }
if (t.outerWidth() < this.outerWidth() || self.small() || this.hasClass(s.mega_menu)) { if (!s.no_pip && tOuterWidth < thisOuterWidth || self.small() || this.hasClass(s.mega_menu)) {
self.adjust_pip(this, t, s, p); self.adjust_pip(this, t, s, p);
} }
if (self.rtl) { if (self.rtl) {
return {left : p.left - this.outerWidth() + t.outerWidth(), top : p.top + t.outerHeight()}; return {left : p.left - thisOuterWidth + tOuterWidth, top : p.top + tOuterHeight};
} }
return {left : p.left, top : p.top + t.outerHeight()}; return {left : p.left, top : p.top + tOuterHeight};
}, },
left : function (t, s) { left : function (t, s) {
var p = Foundation.libs.dropdown.dirs._base.call(this, t, s); var p = Foundation.libs.dropdown.dirs._base.call(this, t, s);
var self = Foundation.libs.dropdown,
tOuterHeight = t.outerHeight(),
tOuterWidth = t.outerWidth(),
thisOuterHeight = this.outerHeight(),
thisOuterWidth = this.outerWidth();
this.addClass('drop-left'); this.addClass('drop-left');
if (p.missLeft == true) { if (p.missLeft === true) {
p.left = p.left + this.outerWidth(); p.left = p.left + thisOuterWidth;
p.top = p.top + t.outerHeight(); p.top = p.top + tOuterHeight;
this.removeClass('drop-left'); this.removeClass('drop-left');
} }
return {left : p.left - this.outerWidth(), top : p.top}; if (p.missRight === true && p.missLeft === true && p.leftRightFlag == false) {
p.left = p.left - tOuterWidth;
this.removeClass('drop-left');
self.adjust_pip(this,t,s,p);
}
return {left : p.left - thisOuterWidth, top : p.top};
}, },
right : function (t, s) { right : function (t, s) {
var p = Foundation.libs.dropdown.dirs._base.call(this, t, s); var p = Foundation.libs.dropdown.dirs._base.call(this, t, s);
var self = Foundation.libs.dropdown,
tOuterHeight = t.outerHeight(),
tOuterWidth = t.outerWidth(),
thisOuterHeight = this.outerHeight(),
thisOuterWidth = this.outerWidth();
this.addClass('drop-right'); this.addClass('drop-right');
if (p.missRight == true) { if (p.missRight === true && p.missLeft == false) {
p.left = p.left - this.outerWidth(); p.left = p.left - thisOuterWidth;
p.top = p.top + t.outerHeight(); p.top = p.top + tOuterHeight;
this.removeClass('drop-right'); this.removeClass('drop-right');
} else { } else {
p.triggeredRight = true; p.triggeredRight = true;
} }
var self = Foundation.libs.dropdown; if (p.missLeft === true && p.missRight === true && p.leftRightFlag === false) {
p.left = p.left - thisOuterWidth;
p.top = p.top + tOuterHeight;
this.removeClass('drop-right');
p.triggeredRight = false;
}
if (t.outerWidth() < this.outerWidth() || self.small() || this.hasClass(s.mega_menu)) {
if (tOuterWidth < thisOuterWidth || self.small() || this.hasClass(s.mega_menu)) {
self.adjust_pip(this,t,s,p); self.adjust_pip(this,t,s,p);
} }
return {left : p.left + t.outerWidth(), top : p.top}; return {left : p.left + tOuterWidth, top : p.top};
} }
}, },
// Insert rule to style psuedo elements // Insert rule to style psuedo elements
adjust_pip : function (dropdown, target, settings, position) { adjust_pip : function (dropdown, target, settings, position) {
if (settings.no_pip === true) return;
var sheet = Foundation.stylesheet, var sheet = Foundation.stylesheet,
pip_offset_base = 8; pip_offset_base = 8;

View File

@ -4,7 +4,7 @@
Foundation.libs.equalizer = { Foundation.libs.equalizer = {
name : 'equalizer', name : 'equalizer',
version : '5.5.3', version : '{{VERSION}}',
settings : { settings : {
use_tallest : true, use_tallest : true,

View File

@ -4,7 +4,7 @@
Foundation.libs.interchange = { Foundation.libs.interchange = {
name : 'interchange', name : 'interchange',
version : '5.5.3', version : '{{VERSION}}',
cache : {}, cache : {},

View File

@ -6,7 +6,7 @@
Foundation.libs.joyride = { Foundation.libs.joyride = {
name : 'joyride', name : 'joyride',
version : '5.5.3', version : '{{VERSION}}',
defaults : { defaults : {
expose : false, // turn on or off the expose feature expose : false, // turn on or off the expose feature
@ -668,8 +668,8 @@
expose.css({ expose.css({
top : el.offset().top, top : el.offset().top,
left : el.offset().left, left : el.offset().left,
width : el.outerWidth(true), width : el.outerWidth(),
height : el.outerHeight(true) height : el.outerHeight()
}); });
exposeCover = $(this.settings.template.expose_cover); exposeCover = $(this.settings.template.expose_cover);

View File

@ -106,7 +106,7 @@
var self = this, var self = this,
bind = function(){ bind = function(){
var $this = S(this), var $this = S(this),
should_bind_events = !$this.data(self.attr_name(true) + '-init'); should_bind_events = !S(self).data(self.attr_name(true) + '-init');
$this.data(self.attr_name(true) + '-init', $.extend({}, self.settings, (options || method), self.data_options($this))); $this.data(self.attr_name(true) + '-init', $.extend({}, self.settings, (options || method), self.data_options($this)));
if (should_bind_events) { if (should_bind_events) {
@ -300,7 +300,7 @@
window.Foundation = { window.Foundation = {
name : 'Foundation', name : 'Foundation',
version : '5.5.3', version : '{{VERSION}}',
media_queries : { media_queries : {
'small' : new MediaQuery('.foundation-mq-small'), 'small' : new MediaQuery('.foundation-mq-small'),
@ -342,7 +342,7 @@
} }
} }
S(window).load(function () { S(window).on('load', function () {
S(window) S(window)
.trigger('resize.fndtn.clearing') .trigger('resize.fndtn.clearing')
.trigger('resize.fndtn.dropdown') .trigger('resize.fndtn.dropdown')

View File

@ -4,7 +4,7 @@
Foundation.libs['magellan-expedition'] = { Foundation.libs['magellan-expedition'] = {
name : 'magellan-expedition', name : 'magellan-expedition',
version : '5.5.3', version : '{{VERSION}}',
settings : { settings : {
active_class : 'active', active_class : 'active',
@ -32,7 +32,7 @@
S(self.scope) S(self.scope)
.off('.magellan') .off('.magellan')
.on('click.fndtn.magellan', '[' + self.add_namespace('data-magellan-arrival') + '] a[href*=#]', function (e) { .on('click.fndtn.magellan', '[' + self.add_namespace('data-magellan-arrival') + '] a[href^="#"]', function (e) {
var sameHost = ((this.hostname === location.hostname) || !this.hostname), var sameHost = ((this.hostname === location.hostname) || !this.hostname),
samePath = self.filterPathname(location.pathname) === self.filterPathname(this.pathname), samePath = self.filterPathname(location.pathname) === self.filterPathname(this.pathname),
testHash = this.hash.replace(/(:|\.|\/)/g, '\\$1'), testHash = this.hash.replace(/(:|\.|\/)/g, '\\$1'),
@ -80,7 +80,7 @@
$('[' + this.attr_name() + '=fixed]', self.scope).each(function (idx, el) { $('[' + this.attr_name() + '=fixed]', self.scope).each(function (idx, el) {
var expedition = $(this), var expedition = $(this),
settings = expedition.data('magellan-expedition-init'), settings = expedition.data('magellan-expedition-init'),
styles = expedition.attr('styles'), // save styles styles = expedition.attr('style'), // save styles
top_offset, fixed_top; top_offset, fixed_top;
expedition.attr('style', ''); expedition.attr('style', '');

View File

@ -4,7 +4,7 @@
Foundation.libs.offcanvas = { Foundation.libs.offcanvas = {
name : 'offcanvas', name : 'offcanvas',
version : '5.5.3', version : '{{VERSION}}',
settings : { settings : {
open_method : 'move', open_method : 'move',

View File

@ -407,7 +407,7 @@
Foundation.libs.orbit = { Foundation.libs.orbit = {
name : 'orbit', name : 'orbit',
version : '5.5.3', version : '{{VERSION}}',
settings : { settings : {
animation : 'slide', animation : 'slide',

View File

@ -6,7 +6,7 @@
Foundation.libs.reveal = { Foundation.libs.reveal = {
name : 'reveal', name : 'reveal',
version : '5.5.3', version : '{{VERSION}}',
locked : false, locked : false,
@ -19,6 +19,7 @@
multiple_opened : false, multiple_opened : false,
bg_class : 'reveal-modal-bg', bg_class : 'reveal-modal-bg',
root_element : 'body', root_element : 'body',
no_scroll: false,
open : function(){}, open : function(){},
opened : function(){}, opened : function(){},
close : function(){}, close : function(){},
@ -49,7 +50,7 @@
S = self.S; S = self.S;
S(this.scope) S(this.scope)
.off('.reveal') .off('.fndtn.reveal')
.on('click.fndtn.reveal', '[' + this.add_namespace('data-reveal-id') + ']:not([disabled])', function (e) { .on('click.fndtn.reveal', '[' + this.add_namespace('data-reveal-id') + ']:not([disabled])', function (e) {
e.preventDefault(); e.preventDefault();
@ -171,6 +172,14 @@
modal.attr('tabindex','0').attr('aria-hidden','false'); modal.attr('tabindex','0').attr('aria-hidden','false');
if(settings.no_scroll){//added 10/9/15, prevents annoying scroll positioning bug with position: absolute; reveals
var $body = $('body');
$body.on('open.fndtn.reveal', function(){
$body.css('overflow', 'hidden')
.off('open.fndtn.reveal');
});
}
this.key_up_on(modal); // PATCH #3: turning on key up capture only when a reveal window is open this.key_up_on(modal); // PATCH #3: turning on key up capture only when a reveal window is open
// Prevent namespace event from triggering twice // Prevent namespace event from triggering twice
@ -178,7 +187,8 @@
if (e.namespace !== 'fndtn.reveal') return; if (e.namespace !== 'fndtn.reveal') return;
}); });
modal.on('open.fndtn.reveal').trigger('open.fndtn.reveal'); modal.trigger('open.fndtn.reveal');
if (open_modal.length < 1) { if (open_modal.length < 1) {
this.toggle_bg(modal, true); this.toggle_bg(modal, true);
@ -256,6 +266,14 @@
modal.removeAttr('tabindex','0').attr('aria-hidden','true'); modal.removeAttr('tabindex','0').attr('aria-hidden','true');
if(settings.no_scroll){//added 10/9/15, prevents annoying scroll positioning bug with position: absolute; reveals
var $body = $('body');
$body.on('close.fndtn.reveal', function(){
$body.css('overflow', 'auto')
.off('close.fndtn.reveal');
});
}
this.locked = true; this.locked = true;
this.key_up_off(modal); // PATCH #3: turning on key up capture only when a reveal window is open this.key_up_off(modal); // PATCH #3: turning on key up capture only when a reveal window is open

View File

@ -4,13 +4,13 @@
Foundation.libs.slider = { Foundation.libs.slider = {
name : 'slider', name : 'slider',
version : '5.5.3', version : '{{VERSION}}',
settings : { settings : {
start : 0, start : 0,
end : 100, end : 100,
step : 1, step : 1,
precision : 2, precision : 0,
initial : null, initial : null,
display_selector : '', display_selector : '',
vertical : false, vertical : false,

View File

@ -4,7 +4,7 @@
Foundation.libs.tab = { Foundation.libs.tab = {
name : 'tab', name : 'tab',
version : '5.5.3', version : '{{VERSION}}',
settings : { settings : {
active_class : 'active', active_class : 'active',
@ -102,19 +102,19 @@
var hash_element = S(hash); var hash_element = S(hash);
if (hash_element.hasClass('content') && hash_element.parent().hasClass('tabs-content')) { if (hash_element.hasClass('content') && hash_element.parent().hasClass('tabs-content')) {
// Tab content div // Tab content div
self.toggle_active_tab($('[' + self.attr_name() + '] > * > a[href=' + hash + ']').parent()); self.toggle_active_tab($('[' + self.attr_name() + '] > * > a[href=\\' + hash + ']').parent());
} else { } else {
// Not the tab content div. If inside the tab content, find the // Not the tab content div. If inside the tab content, find the
// containing tab and toggle it as active. // containing tab and toggle it as active.
var hash_tab_container_id = hash_element.closest('.content').attr('id'); var hash_tab_container_id = hash_element.closest('.content').attr('id');
if (hash_tab_container_id != undefined) { if (hash_tab_container_id != undefined) {
self.toggle_active_tab($('[' + self.attr_name() + '] > * > a[href=#' + hash_tab_container_id + ']').parent(), hash); self.toggle_active_tab($('[' + self.attr_name() + '] > * > a[href=\\#' + hash_tab_container_id + ']').parent(), hash);
} }
} }
} else { } else {
// Reference the default tab hashes which were initialized in the init function // Reference the default tab hashes which were initialized in the init function
for (var ind = 0; ind < self.default_tab_hashes.length; ind++) { for (var ind = 0; ind < self.default_tab_hashes.length; ind++) {
self.toggle_active_tab($('[' + self.attr_name() + '] > * > a[href=' + self.default_tab_hashes[ind] + ']').parent()); self.toggle_active_tab($('[' + self.attr_name() + '] > * > a[href=\\' + self.default_tab_hashes[ind] + ']').parent());
} }
} }
} }

View File

@ -4,7 +4,7 @@
Foundation.libs.tooltip = { Foundation.libs.tooltip = {
name : 'tooltip', name : 'tooltip',
version : '5.5.3', version : '{{VERSION}}',
settings : { settings : {
additional_inheritable_classes : [], additional_inheritable_classes : [],
@ -194,7 +194,7 @@
tip_template = window[settings.tip_template]; tip_template = window[settings.tip_template];
} }
var $tip = $(tip_template(this.selector($target), $('<div></div>').html($target.attr('title')).html())), var $tip = $(tip_template(this.selector($target), $('<div></div>').html($target.attr('title')).text())),
classes = this.inheritable_classes($target); classes = this.inheritable_classes($target);
$tip.addClass(classes).appendTo(settings.append_to); $tip.addClass(classes).appendTo(settings.append_to);

View File

@ -4,7 +4,7 @@
Foundation.libs.topbar = { Foundation.libs.topbar = {
name : 'topbar', name : 'topbar',
version : '5.5.3', version : '{{VERSION}}',
settings : { settings : {
index : 0, index : 0,
@ -134,7 +134,7 @@
} }
} }
} else { } else {
if (self.is_sticky(topbar, topbar.parent(), settings)) { if (self.is_sticky(topbar, topbar.parent(), settings) && topbar.parent().offset().top === 0) {
topbar.parent().addClass('fixed'); topbar.parent().addClass('fixed');
} }
@ -199,7 +199,7 @@
e.stopImmediatePropagation(); e.stopImmediatePropagation();
if (li.hasClass('hover')) { if (li.hasClass('hover') && (settings.is_hover || li.children('a').first().hasClass('last-clicked'))) {
li li
.removeClass('hover') .removeClass('hover')
.find('li') .find('li')
@ -214,6 +214,10 @@
if (target[0].nodeName === 'A' && target.parent().hasClass('has-dropdown')) { if (target[0].nodeName === 'A' && target.parent().hasClass('has-dropdown')) {
e.preventDefault(); e.preventDefault();
if(!settings.is_hover){
topbar.find('.last-clicked').removeClass('last-clicked');
target.addClass('last-clicked');
}
} }
} }
}) })
@ -245,19 +249,25 @@
S(window).off('.topbar').on('resize.fndtn.topbar', self.throttle(function () { S(window).off('.topbar').on('resize.fndtn.topbar', self.throttle(function () {
self.resize.call(self); self.resize.call(self);
}, 50)).trigger('resize.fndtn.topbar').load(function () { }, 50)).trigger('resize.fndtn.topbar').on('load', function () {
// Ensure that the offset is calculated after all of the pages resources have loaded // Ensure that the offset is calculated after all of the pages resources have loaded
S(this).trigger('resize.fndtn.topbar'); S(this).trigger('resize.fndtn.topbar');
}); });
S('body').off('.topbar').on('click.fndtn.topbar', function (e) { S('body').off('.topbar').on('click.fndtn.topbar', function (e) {
var parent = S(e.target).closest('li').closest('li.hover'); var parent = S(e.target).closest('li').closest('li.hover'),
topbar = S(e.target).closest('[' + self.attr_name() + ']'),
settings = topbar.data(self.attr_name(true) + '-init');
if (parent.length > 0) { if (parent.length > 0) {
return; return;
} }
S('[' + self.attr_name() + '] li.hover').removeClass('hover'); S('[' + self.attr_name() + '] li.hover').removeClass('hover');
if(settings && !settings.is_hover){
S('[' + self.attr_name() + '] a.last-clicked').removeClass('last-clicked');
}
}); });
// Go up a level on Click // Go up a level on Click
@ -298,15 +308,14 @@
$(this).parents('.has-dropdown').addClass('hover'); $(this).parents('.has-dropdown').addClass('hover');
}) })
.blur(function () { .blur(function () {
$(this).parents('.has-dropdown').removeClass('hover'); $(this).removeClass('last-clicked').parents('.has-dropdown').removeClass('hover');
}); });
}, },
resize : function () { resize : function () {
var self = this; var self = this;
self.S('[' + this.attr_name() + ']').each(function () { self.S('[' + this.attr_name() + ']').each(function () {
var topbar = self.S(this), var topbar = self.S(this);
settings = topbar.data(self.attr_name(true) + '-init');
var stickyContainer = topbar.parent('.' + self.settings.sticky_class); var stickyContainer = topbar.parent('.' + self.settings.sticky_class);
var stickyOffset; var stickyOffset;
@ -324,7 +333,7 @@
} }
} }
if (self.is_sticky(topbar, stickyContainer, settings)) { if (self.is_sticky(topbar, stickyContainer, self.settings)) {
if (stickyContainer.hasClass('fixed')) { if (stickyContainer.hasClass('fixed')) {
// Remove the fixed to allow for correct calculation of the offset. // Remove the fixed to allow for correct calculation of the offset.
stickyContainer.removeClass('fixed'); stickyContainer.removeClass('fixed');
@ -377,14 +386,14 @@
if (!$dropdown.find('.title.back').length) { if (!$dropdown.find('.title.back').length) {
if (settings.mobile_show_parent_link == true && url) { if (settings.mobile_show_parent_link === true && url) {
$titleLi = $('<li class="title back js-generated"><h5><a href="javascript:void(0)"></a></h5></li><li class="parent-link hide-for-medium-up"><a class="parent-link js-generated" href="' + url + '">' + $link.html() +'</a></li>'); $titleLi = $('<li class="title back js-generated"><h5><a href="javascript:void(0)"></a></h5></li><li class="parent-link hide-for-medium-up"><a class="parent-link js-generated" href="' + url + '">' + $link.html() +'</a></li>');
} else { } else {
$titleLi = $('<li class="title back js-generated"><h5><a href="javascript:void(0)"></a></h5>'); $titleLi = $('<li class="title back js-generated"><h5><a href="javascript:void(0)"></a></h5>');
} }
// Copy link to subnav // Copy link to subnav
if (settings.custom_back_text == true) { if (settings.custom_back_text === true) {
$('h5>a', $titleLi).html(settings.back_text); $('h5>a', $titleLi).html(settings.back_text);
} else { } else {
$('h5>a', $titleLi).html('&laquo; ' + $link.html()); $('h5>a', $titleLi).html('&laquo; ' + $link.html());