From f12bbc8f386d823b5c05d3c930cbbfe6c44d3c86 Mon Sep 17 00:00:00 2001 From: Kevin Ball Date: Thu, 10 Nov 2016 11:26:52 -0800 Subject: [PATCH] modify tabs events to return content area as well as a link --- js/foundation.tabs.js | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) 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"); -- 2.47.2