]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
fix: collapse only own elements in accordion and tabs if they contain the target 11686/head
authorDaniel Ruf <daniel@daniel-ruf.de>
Wed, 20 Feb 2019 22:04:46 +0000 (23:04 +0100)
committerDaniel Ruf <daniel@daniel-ruf.de>
Wed, 20 Feb 2019 22:04:46 +0000 (23:04 +0100)
js/foundation.accordion.js
js/foundation.tabs.js

index a8aa3b43a849b75fd0ae9bf954ebc20d8be12714..d2e42f9169eee2c013f540948bdaa46225c1c7a9 100644 (file)
@@ -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), () => {
index cf86e5d4e69c3efdb2e06445ac1015186f759f09..ffc6a0c4abb8e100c9cb16aa1fe9e13f4dab2618 100644 (file)
@@ -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();