]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Tabs: account updateHistory only if deepLink:true.
authorArian Xhezairi <arian@xhezairi.com>
Fri, 25 Nov 2016 02:00:04 +0000 (03:00 +0100)
committerArian Xhezairi <arian@xhezairi.com>
Fri, 25 Nov 2016 02:00:04 +0000 (03:00 +0100)
docs/pages/tabs.md
js/foundation.tabs.js

index 9f2c1c56ee51f2694ffb578466239473396fea26..a9fa7972a3ea992d033921055c6bdbf0e37753db 100644 (file)
@@ -156,13 +156,13 @@ Add the attribute `data-deep-link="true" to a tabstrip to allow anchoring to and
 
 ```html_example
 <ul class="tabs" data-deep-link="true" data-tabs id="deeplinked-tabs">
-  <li class="tabs-title is-active"><a href="#panel1c" aria-selected="true">Tab 1</a></li>
+  <li class="tabs-title is-active"><a href="#panel1d" aria-selected="true">Tab 1</a></li>
   <li class="tabs-title"><a href="#panel2d">Tab 2</a></li>
   <li class="tabs-title"><a href="#panel3d">Tab 3</a></li>
   <li class="tabs-title"><a href="#panel4d">Tab 4</a></li>
 </ul>
 
-<div class="tabs-content" data-tabs-content="collapsing-tabs">
+<div class="tabs-content" data-tabs-content="deeplinked-tabs">
   <div class="tabs-panel is-active" id="panel1d">
     <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
   </div>
index 39ca0f7cc53b40fad6783b84b352f8331ee33c8f..a6a607bc687648d1a09319a4d641fd246134f3d5 100644 (file)
@@ -237,11 +237,16 @@ class Tabs {
     this._openTab($target);
 
     //either replace or update browser history
-    var anchor = $target.find('a').attr('href');
-    if (this.options.updateHistory) {
-      history.pushState({}, "", anchor);
+    if (this.options.deepLink) {
+      var anchor = $target.find('a').attr('href');
+
+      if (this.options.updateHistory) {
+        history.pushState({}, '', anchor);
+      } else {
+        history.replaceState({}, '', anchor);
+      }
     } else {
-      history.replaceState({}, "", anchor);
+      location.hash = '';
     }
 
     /**