From: Kevin Ball Date: Thu, 10 Nov 2016 19:26:52 +0000 (-0800) Subject: modify tabs events to return content area as well as a link X-Git-Tag: v6.3-rc1~21^2~3^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F9356%2Fhead;p=thirdparty%2Ffoundation%2Ffoundation-sites.git modify tabs events to return content area as well as a link --- diff --git a/js/foundation.tabs.js b/js/foundation.tabs.js index f7bdd60fa..48152a9b8 100644 --- a/js/foundation.tabs.js +++ b/js/foundation.tabs.js @@ -77,23 +77,25 @@ class Tabs { if (_this.options.deepLink) { var anchor = window.location.hash; //need a hash and a relevant anchor in this tabset - if (anchor.length && $elem.find('[href="'+anchor+'"]').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', [$(anchor)]); + 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)]); + } } } }); @@ -239,12 +241,12 @@ class Tabs { } else { history.replaceState({}, "", anchor); } - + /** * Fires when the plugin has successfully changed tabs. * @event Tabs#change */ - this.$element.trigger('change.zf.tabs', [$target]); + this.$element.trigger('change.zf.tabs', [$target, $targetContent]); //fire to children a mutation event $targetContent.find("[data-mutate]").trigger("mutateme.zf.trigger");