]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
modify tabs events to return content area as well as a link 9356/head
authorKevin Ball <kmball11@gmail.com>
Thu, 10 Nov 2016 19:26:52 +0000 (11:26 -0800)
committerKevin Ball <kmball11@gmail.com>
Thu, 10 Nov 2016 19:26:52 +0000 (11:26 -0800)
js/foundation.tabs.js

index f7bdd60fa6308b9a08fb96efdce917b39de46366..48152a9b8d42074aa6c10200e9c77c0825c229fe 100644 (file)
@@ -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");