From: Daniel Ruf Date: Wed, 20 Feb 2019 22:04:46 +0000 (+0100) Subject: fix: collapse only own elements in accordion and tabs if they contain the target X-Git-Tag: v6.6.0~3^2~11^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1605e3770a5fd92014f2e424885be3a2341aaff2;p=thirdparty%2Ffoundation%2Ffoundation-sites.git fix: collapse only own elements in accordion and tabs if they contain the target --- diff --git a/js/foundation.accordion.js b/js/foundation.accordion.js index a8aa3b43a..d2e42f916 100644 --- a/js/foundation.accordion.js +++ b/js/foundation.accordion.js @@ -84,18 +84,18 @@ class Accordion extends Plugin { // Whether the anchor element that has been found is part of this element var isOwnAnchor = !!($anchor.length && $link.length); - // If there is an anchor for the hash, open it (if not already active) - if ($anchor && $link && $link.length) { - if (!$link.parent('[data-accordion-item]').hasClass('is-active')) { - this._openSingleTab($anchor); - }; - } - // Otherwise, close everything - else { - this._closeAllTabs(); - } - if (isOwnAnchor) { + // If there is an anchor for the hash, open it (if not already active) + if ($anchor && $link && $link.length) { + if (!$link.parent('[data-accordion-item]').hasClass('is-active')) { + this._openSingleTab($anchor); + }; + } + // Otherwise, close everything + else { + this._closeAllTabs(); + } + // Roll up a little to show the titles if (this.options.deepLinkSmudge) { onLoad($(window), () => { diff --git a/js/foundation.tabs.js b/js/foundation.tabs.js index cf86e5d4e..ffc6a0c4a 100644 --- a/js/foundation.tabs.js +++ b/js/foundation.tabs.js @@ -119,16 +119,16 @@ class Tabs extends Plugin { // Whether the anchor element that has been found is part of this element var isOwnAnchor = !!($anchor.length && $link.length); - // If there is an anchor for the hash, select it - if ($anchor && $anchor.length && $link && $link.length) { - this.selectTab($anchor, true); - } - // Otherwise, collapse everything - else { - this._collapse(); - } - if (isOwnAnchor) { + // If there is an anchor for the hash, select it + if ($anchor && $anchor.length && $link && $link.length) { + this.selectTab($anchor, true); + } + // Otherwise, collapse everything + else { + this._collapse(); + } + // Roll up a little to show the titles if (this.options.deepLinkSmudge) { var offset = this.$element.offset();