MediaWiki:Metrolook.js
Jump to navigation
Jump to search
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
$(function(){
function hasDoubleByte(str) {
for (var i = 0, n = str.length; i < n; i++) {
if (str.charCodeAt( i ) > 255) { return true; }
}
return false;
}
/**********************************************************************************************
* Fix a bug where clicking on an title in the content did not scroll the screen to that section
*/
$(".tocnumber,.toctext").off("click").on("click",function(){
if (hasDoubleByte(this.textContent)){
var href = $(this).parent().attr("href");
window.location.replace(href);
setTimeout(function() {
$('html, body').animate({
scrollTop: '-=50'
}, 200);
},100);
}
});
/**********************************************************************
* Fix the title being hidden in the menu when jumping to the anchor
*/
if(location.hash && window.scrollY < document.documentElement.scrollHeight - document.body.clientHeight){
$('html, body').animate({
scrollTop: '-=50'
}, 200);
}
});