]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
When a user refreshes the page on a deeplinked tab, they should stay on that tab... 6162/head
authorKevin Marren <kmarren@signal.co>
Tue, 30 Dec 2014 14:13:24 +0000 (08:13 -0600)
committerKevin Marren <kmarren@signal.co>
Tue, 30 Dec 2014 14:13:24 +0000 (08:13 -0600)
js/foundation/foundation.tab.js

index 5b780ea38eabc8971bc77ada5841f36f4e6a93dd..c7000e97db58434a6f400e4aac05a1c5ffb5356e 100644 (file)
           S = this.S;
 
       this.bindings(method, options);
+
+      // store the initial href, which is used to allow correct behaviour of the
+      // browser back button when deep linking is turned on.
+      self.entry_location = window.location.href;
+
       this.handle_location_hash_change();
 
       // Store the default active tabs which will be referenced when the
       S('[' + this.attr_name() + '] > .active > a', this.scope).each(function () {
         self.default_tab_hashes.push(this.hash);
       });
-
-      // store the initial href, which is used to allow correct behaviour of the
-      // browser back button when deep linking is turned on.
-      self.entry_location = window.location.href;
     },
 
     events : function () {
             // This function allows correct behaviour of the browser's back button when deep linking is enabled. Without it
             // the user would get continually redirected to the default hash.
             var is_entry_location = window.location.href === self.entry_location,
-                default_hash = settings.scroll_to_content ? self.default_tab_hashes[0] : 'fndtn-' + self.default_tab_hashes[0].replace('#', '')
+                default_hash = settings.scroll_to_content ? self.default_tab_hashes[0] : is_entry_location ? window.location.hash :'fndtn-' + self.default_tab_hashes[0].replace('#', '')
 
             if (!(is_entry_location && hash === default_hash)) {
               window.location.hash = hash;