]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Merge branch 'fix-tabs-deeplink-abs-url' of git://github.com/designerno1/foundation...
authorKevin Ball <kmball11@gmail.com>
Tue, 24 Jan 2017 00:41:54 +0000 (16:41 -0800)
committerKevin Ball <kmball11@gmail.com>
Tue, 24 Jan 2017 00:41:54 +0000 (16:41 -0800)
1  2 
js/foundation.tabs.js

index 8ac3fd8cb360c625c50b516711d50c8e348a1c87,51e2e98190c9b74bd5f461ac77dbec7e032a85fd..16b53e242b0f04ea7a1b4259d41c8c8cbafe2bcc
@@@ -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');
  
        }
      }
  
-         var $link = this.$element.find('[href="'+anchor+'"]');
 +     //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+'"]');
 +        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();
    }
  
        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.
        .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'});
          }