]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Use pull request #11011 from ncoden/fix/hashchange-event-compatibility-10771 for...
authorNicolas Coden <nicolas@ncoden.fr>
Sat, 16 Jun 2018 07:26:04 +0000 (09:26 +0200)
committerNicolas Coden <nicolas@ncoden.fr>
Sat, 16 Jun 2018 07:26:04 +0000 (09:26 +0200)
4fbcb916b fix: use `hashchange` event instead of `popstate` for IE/Edge compatibility

Signed-off-by: Nicolas Coden <nicolas@ncoden.fr>
js/foundation.accordion.js
js/foundation.magellan.js
js/foundation.reveal.js
js/foundation.tabs.js

index 7ec830bfe124511af3e1932005e43ffe376effc6..f49345d08a1a7820677e222399a229b90a2fc874 100644 (file)
@@ -146,7 +146,7 @@ class Accordion extends Plugin {
       }
     });
     if(this.options.deepLink) {
-      $(window).on('popstate', this._checkDeepLink);
+      $(window).on('hashchange', this._checkDeepLink);
     }
   }
 
@@ -265,7 +265,7 @@ class Accordion extends Plugin {
     this.$element.find('[data-tab-content]').stop(true).slideUp(0).css('display', '');
     this.$element.find('a').off('.zf.accordion');
     if(this.options.deepLink) {
-      $(window).off('popstate', this._checkDeepLink);
+      $(window).off('hashchange', this._checkDeepLink);
     }
 
   }
index 049015fb11dc0d91e41e1f05f9f231f343c6995f..01f9785e7764d5da4834192988a522facac1d377 100644 (file)
@@ -108,7 +108,7 @@ class Magellan extends Plugin {
       }
     };
 
-    $(window).on('popstate', this._deepLinkScroll);
+    $(window).on('hashchange', this._deepLinkScroll);
   }
 
   /**
@@ -218,7 +218,7 @@ class Magellan extends Plugin {
       var hash = this.$active[0].getAttribute('href');
       window.location.hash.replace(hash, '');
     }
-    $(window).off('popstate', this._deepLinkScroll);
+    $(window).off('hashchange', this._deepLinkScroll);
   }
 }
 
index 32c5d49fc2876f4a1434cd785c8cf77f753d636a..15416909209f689bfe5c6fea5ed559e6844ffc7c 100644 (file)
@@ -169,12 +169,12 @@ class Reveal extends Plugin {
       });
     }
     if (this.options.deepLink) {
-      $(window).on(`popstate.zf.reveal:${this.id}`, this._handleState.bind(this));
+      $(window).on(`hashchange.zf.reveal:${this.id}`, this._handleState.bind(this));
     }
   }
 
   /**
-   * Handles modal methods on back/forward button clicks or any other event that triggers popstate.
+   * Handles modal methods on back/forward button clicks or any other event that triggers hashchange.
    * @private
    */
   _handleState(e) {
index adecdec345e83bc5e9800170c2135902b0b74e74..0bf884350480accd447f29f5193876e4f917868f 100644 (file)
@@ -94,7 +94,7 @@ class Tabs extends Plugin {
       }
     }
 
-     //current context-bound function to open tabs on page load or history popstate
+     //current context-bound function to open tabs on page load or history hashchange
     this._checkDeepLink = () => {
       var anchor = window.location.hash;
       //need a hash and a relevant anchor in this tabset
@@ -142,7 +142,7 @@ class Tabs extends Plugin {
     }
 
     if(this.options.deepLink) {
-      $(window).on('popstate', this._checkDeepLink);
+      $(window).on('hashchange', this._checkDeepLink);
     }
   }
 
@@ -390,7 +390,7 @@ class Tabs extends Plugin {
     }
 
     if (this.options.deepLink) {
-      $(window).off('popstate', this._checkDeepLink);
+      $(window).off('hashchange', this._checkDeepLink);
     }
 
   }