From: Kevin Ball Date: Tue, 24 Jan 2017 00:41:54 +0000 (-0800) Subject: Merge branch 'fix-tabs-deeplink-abs-url' of git://github.com/designerno1/foundation... X-Git-Tag: 6.3.1~26^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1e15589d62ede9a6eae9402e940be7c4394525dc;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Merge branch 'fix-tabs-deeplink-abs-url' of git://github.com/designerno1/foundation-sites into designerno1-fix-tabs-deeplink-abs-url --- 1e15589d62ede9a6eae9402e940be7c4394525dc diff --cc js/foundation.tabs.js index 8ac3fd8cb,51e2e9819..16b53e242 --- a/js/foundation.tabs.js +++ b/js/foundation.tabs.js @@@ -76,8 -76,34 +76,8 @@@ class Tabs }); }); } - - //use browser to open a tab, if it exists in this tabset - if (_this.options.deepLink) { - var anchor = window.location.hash; - //need a hash and a relevant anchor in this tabset - if(anchor.length) { - var $link = $elem.find('[href$="'+anchor+'"]'); - if ($link.length) { - _this.selectTab($(anchor)); - - //roll up a little to show the titles - if (_this.options.deepLinkSmudge) { - $(window).load(function() { - var offset = $elem.offset(); - $('html, body').animate({ scrollTop: offset.top }, _this.options.deepLinkSmudgeDelay); - }); - } -- - /** - * Fires when the zplugin has deeplinked at pageload - * @event Tabs#deeplink - */ - $elem.trigger('deeplink.zf.tabs', [$link, $(anchor)]); - } - } - } }); + if(this.options.matchHeight) { var $images = this.$tabContent.find('img'); @@@ -88,35 -114,6 +88,35 @@@ } } + //current context-bound function to open tabs on page load or history popstate + this._checkDeepLink = () => { + var anchor = window.location.hash; + //need a hash and a relevant anchor in this tabset + if(anchor.length) { - var $link = this.$element.find('[href="'+anchor+'"]'); ++ var $link = this.$element.find('[href$="'+anchor+'"]'); + if ($link.length) { + this.selectTab($(anchor), true); + + //roll up a little to show the titles + if (this.options.deepLinkSmudge) { + var offset = this.$element.offset(); + $('html, body').animate({ scrollTop: offset.top }, this.options.deepLinkSmudgeDelay); + } + + /** + * Fires when the zplugin has deeplinked at pageload + * @event Tabs#deeplink + */ + this.$element.trigger('deeplink.zf.tabs', [$link, $(anchor)]); + } + } + } + + //use browser to open a tab, if it exists in this tabset + if (this.options.deepLink) { + this._checkDeepLink(); + } + this._events(); } @@@ -319,9 -310,9 +319,9 @@@ idStr = `#${idStr}`; } - var $target = this.$tabTitles.find(`[href="${idStr}"]`).parent(`.${this.options.linkClass}`); + var $target = this.$tabTitles.find(`[href$="${idStr}"]`).parent(`.${this.options.linkClass}`); - this._handleTabChange($target); + this._handleTabChange($target, historyHandled); }; /** * Sets the height of each panel to the height of the tallest panel. @@@ -339,10 -327,9 +339,10 @@@ .find(`.${this.options.panelClass}`) .css('height', '') .each(function() { + var panel = $(this), - isActive = panel.hasClass(`${this.options.panelActiveClass}`); + isActive = panel.hasClass(`${_this.options.panelActiveClass}`); // get the options from the parent instead of trying to get them from the child - + if (!isActive) { panel.css({'visibility': 'hidden', 'display': 'block'}); }