User:670839245/common.js
From the Super Mario Wiki, the Mario encyclopedia
Jump to navigationJump 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.
newNav = function (sTitle, sHref, sTarget, sAccesskey) {
// 寻找元素;不用两个 var 定义变量可以压缩更小。
var ns = $('div#p-namespaces ul'),
but = ns.find('li:first').clone ();
// 进行新按钮设定
but.removeClass ().find('a').text (sTitle).attr({
'title': sTitle + (sAccesskey?' [alt-shift-'+sAccesskey+']':''),
'href': (typeof(sHref)=='string'?sHref:'javascript:void(0);'),
'target': (sTarget||'_self'),
'accesskey': (sAccesskey||'')
}).click ((typeof(sHref) == 'function')?sHref:function(){});
// 插入新按钮进去:
ns.append (but);
}
window.readMode = false;
var normalMode = [
$('div#content').css ('margin-left'),
$('div#content').css ('border-radius'),
$('div#mw-head').css ('padding'),
$('div#mw-head-base').css ('margin-top'),
$('div#mw-head-base').css ('background-image'),
];
newNav ('阅读模式', function () {
var rM = window.readMode = !window.readMode;
if (rM) {
// 阅读模式
$('#mw-panel,div#headwrap,div#footer').hide();
$('div#content').css ({'margin-left':'0', 'border-radius':'0'});
$('div#mw-head').css ('padding', '0');
$('div#mw-head-base').css ({'margin-top':'-21.55em', 'background-image':'none'});
} else {
$('#mw-panel,div#headwrap,div#footer').show();
$('div#content').css ({'margin-left':normalMode[0], 'border-radius':normalMode[1]});
$('div#mw-head').css ('padding', normalMode[2]);
$('div#mw-head-base').css ({'margin-top':normalMode[3], 'background-image':normalMode[4]});
}
});