User:670839245/common.js: Difference between revisions
From the Super Mario Wiki, the Mario encyclopedia
Jump to navigationJump to search
m (Blanked the page) |
No edit summary |
||
Line 1: | Line 1: | ||
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]}); | |||
} | |||
}); |
Latest revision as of 17:59, March 18, 2013
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]});
}
});