From: Nicolas Coden Date: Sat, 16 Jun 2018 07:26:04 +0000 (+0200) Subject: Use pull request #11011 from ncoden/fix/hashchange-event-compatibility-10771 for... X-Git-Tag: v6.5.0-rc.1^2~112 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a293df41f552cdbbc3d1eee50be92f03f1b143b;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Use pull request #11011 from ncoden/fix/hashchange-event-compatibility-10771 for v6.5.0 4fbcb916b fix: use `hashchange` event instead of `popstate` for IE/Edge compatibility Signed-off-by: Nicolas Coden --- diff --git a/js/foundation.accordion.js b/js/foundation.accordion.js index 7ec830bfe..f49345d08 100644 --- a/js/foundation.accordion.js +++ b/js/foundation.accordion.js @@ -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); } } diff --git a/js/foundation.magellan.js b/js/foundation.magellan.js index 049015fb1..01f9785e7 100644 --- a/js/foundation.magellan.js +++ b/js/foundation.magellan.js @@ -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); } } diff --git a/js/foundation.reveal.js b/js/foundation.reveal.js index 32c5d49fc..154169092 100644 --- a/js/foundation.reveal.js +++ b/js/foundation.reveal.js @@ -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) { diff --git a/js/foundation.tabs.js b/js/foundation.tabs.js index adecdec34..0bf884350 100644 --- a/js/foundation.tabs.js +++ b/js/foundation.tabs.js @@ -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); } }