$content.attr({'role': 'tabpanel', 'aria-labelledby': linkId, 'aria-hidden': true, 'id': id});
});
+
var $initActive = this.$element.find('.is-active').children('[data-tab-content]');
this.firstTimeInit = true;
- if($initActive.length){
+ if ($initActive.length) {
+ // Save up the initial hash to return to it later when going back in history
+ this._initialAnchor = $initActive.prev('a').attr('href');
+
this.down($initActive, this.firstTimeInit);
this.firstTimeInit = false;
}
this._checkDeepLink = () => {
var anchor = window.location.hash;
+
+ // if there is no anchor, return to the initial panel
+ if (!anchor.length && this._initialAnchor) {
+ anchor = this._initialAnchor;
+ }
+
//need a hash and a relevant anchor in this tabset
if(anchor.length) {
var $link = this.$element.find('[href$="'+anchor+'"]'),
'aria-labelledby': linkId
});
+ // Save up the initial hash to return to it later when going back in history
+ if (isActive) {
+ _this._initialAnchor = `#${hash}`;
+ }
+
if(!isActive) {
$tabContent.attr('aria-hidden', 'true');
}
});
}
});
+
if(this.options.matchHeight) {
var $images = this.$tabContent.find('img');
//current context-bound function to open tabs on page load or history hashchange
this._checkDeepLink = () => {
var anchor = window.location.hash;
+
+ // if there is no anchor, return to the initial tab
+ if (!anchor.length && this._initialAnchor) {
+ anchor = this._initialAnchor;
+ }
+
//need a hash and a relevant anchor in this tabset
- if(anchor.length) {
+ if (anchor.length) {
var anchorNoHash = (anchor.indexOf('#') >= 0 ? anchor.slice(1) : anchor);
var $link = this.$element.find(`[href$="${anchor}"],[data-tabs-target="${anchorNoHash}"]`).first();
if ($link.length) {