SPR-980: close meta box after click on TOC anchor
This commit is contained in:
parent
c5e825b2e3
commit
c6a2583846
2 changed files with 100 additions and 29 deletions
|
@ -195,3 +195,65 @@
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// + + + + + + + + + + + + + + + + + + + + + + + + + + + +
|
||||
// shuffle func for random values
|
||||
// + + + + + + + + + + + + + + + + + + + + + + + + + + + +
|
||||
Array.prototype.shuffle = function(){
|
||||
var tmp, rand;
|
||||
for(var i =0; i < this.length; i++){
|
||||
rand = Math.floor(Math.random() * this.length);
|
||||
tmp = this[i];
|
||||
this[i] = this[rand];
|
||||
this[rand] =tmp;
|
||||
}
|
||||
};
|
||||
|
||||
// + + + + + + + + + + + + + + + + + + + + + + + + + + + +
|
||||
// js trim func for ie
|
||||
// + + + + + + + + + + + + + + + + + + + + + + + + + + + +
|
||||
if(typeof String.prototype.trim !== 'function') {
|
||||
String.prototype.trim = function() {
|
||||
return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* simplify setting and getting state out of a node
|
||||
* $("#my_id").data("my_data_attr") equals $$("#my_id").my_data_attr and
|
||||
* $("#my_id").data("my_data_attr", "my_data_val") equals $$("#my_id").my_data_attr = my_data_val
|
||||
* you can also do
|
||||
* $$("#my_id").my_data_val = $$("#my_id").my_data_val + 1.
|
||||
*/
|
||||
var $$ = function(param) {
|
||||
var node = $(param)[0];
|
||||
var id = $.data(node);
|
||||
$.cache[id] = $.cache[id] || {};
|
||||
$.cache[id].node = node;
|
||||
return $.cache[id];
|
||||
};
|
||||
var alertFB = false;
|
||||
if (typeof console === "undefined" || typeof console.log === "undefined") {
|
||||
console = {};
|
||||
if (alertFB) {
|
||||
console.log = function(msg) {
|
||||
alert(msg);
|
||||
};
|
||||
} else {
|
||||
console.log = function() {};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* custom event handler ‘show’/’hide’ events for using .on()
|
||||
*/
|
||||
(function ($) {
|
||||
$.each(['show', 'hide'], function (i, e) {
|
||||
var el = $.fn[e];
|
||||
$.fn[e] = function () {
|
||||
this.trigger(e);
|
||||
return el.apply(this, arguments);
|
||||
};
|
||||
});
|
||||
})(jQuery);
|
||||
|
|
|
@ -22,13 +22,8 @@
|
|||
isopen = $tab.attr('aria-expanded') === 'true';
|
||||
|
||||
// disable all existing tabs
|
||||
$metaBox.find('.meta-tabs li')
|
||||
.removeClass('active')
|
||||
.find('a')
|
||||
.attr('aria-expanded', 'false');
|
||||
$metaBox.find('.meta-content .tab-pane')
|
||||
.removeClass('active')
|
||||
.attr('aria-hidden', 'false');
|
||||
disableExistingTabs($metaBox);
|
||||
|
||||
|
||||
if (isopen) return; // tab was open, we closed it. we're done
|
||||
|
||||
|
@ -41,6 +36,11 @@
|
|||
.addClass('active')
|
||||
.attr('aria-hidden', 'false');
|
||||
|
||||
}).find('.meta-content').on('click', 'a[href*="#"]', function (e) {
|
||||
disableExistingTabs($metaBox);
|
||||
/* uses custome event handler hide see spc.js */
|
||||
}).find('#tagging__edit').on('hide', function(e){
|
||||
disableExistingTabs($metaBox);
|
||||
});
|
||||
|
||||
/**
|
||||
|
@ -52,6 +52,15 @@
|
|||
$tocLink.trigger('click');
|
||||
}
|
||||
}
|
||||
},
|
||||
disableExistingTabs = function($metaBox) {
|
||||
$metaBox.find('.meta-tabs li')
|
||||
.removeClass('active')
|
||||
.find('a')
|
||||
.attr('aria-expanded', 'false');
|
||||
$metaBox.find('.meta-content .tab-pane')
|
||||
.removeClass('active')
|
||||
.attr('aria-hidden', 'false');
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue