User:Soxra/monobook.js: Difference between revisions
From the Kingdom Hearts Wiki, the Kingdom Hearts encyclopedia
Jump to navigationJump to search
(For hardcore testing!) |
(BLIND FAITH EDIT :D) |
||
Line 32: | Line 32: | ||
/* Recent Changes Preview */ | /* Recent Changes Preview */ | ||
$(".page-Special_RecentChanges").each(function() { | $(".page-Special_RecentChanges").each(function() { | ||
var currTimer = undefined; | |||
var currAjax = undefined; | var currAjax = undefined; | ||
$("head").append($("<link rel='stylesheet' href='http://www.khwiki.net/load.php?debug=false&lang=en&modules=mediawiki.legacy.diff&only=styles&skin=monobook&*' type='text/css'/>")); | $("head").append($("<link rel='stylesheet' href='http://www.khwiki.net/load.php?debug=false&lang=en&modules=mediawiki.legacy.diff&only=styles&skin=monobook&*' type='text/css'/>")); | ||
$("<div/>",{ | $("<div/>",{ | ||
id:"rc-preview-div", | id:"rc-preview-div", | ||
style:"position:absolute;height:300px;width: | style:"position:absolute;height:300px;width:55%;background:#fff;border:1px solid #888;z-index:500;padding:10px", | ||
}).hide().appendTo("body"); | }).hide().appendTo("body"); | ||
$("table.mw-enhanced-rc a").live("mouseover",function() { | $("table.mw-enhanced-rc a").live("mouseover",function() { | ||
var subtxt = $(this).text().substr(-7); | var subtxt = $(this).text().substr(-7); | ||
if (subtxt == "diff" || subtxt == "prev" || subtxt == "changes") { | if (subtxt == "diff" || subtxt == "prev" || subtxt == "changes") { | ||
if (currAjax) | |||
currAjax.abort(); | |||
if (currTimer) | |||
clearTimeout(currTimer); | |||
var otop = $(this).offset().top; | var otop = $(this).offset().top; | ||
var oleft = $(this).offset().left; | var oleft = $(this).offset().left; | ||
Line 58: | Line 61: | ||
while (msg.charCodeAt(0) < 32) | while (msg.charCodeAt(0) < 32) | ||
msg = msg.substr(1); | msg = msg.substr(1); | ||
$("div#rc-preview-div").html("<div style='height: | if (currTimer) | ||
clearTimeout(currTimer); | |||
$("div#rc-preview-div").html("<div style='height:300px;font-size:110%;width:auto;overflow-y:auto'><table class='diff'>"+$(msg).find("table.diff").html()+"</table></div>").mouseout(function() { | |||
$("div#rc-preview-div").hide().html(""); | |||
}).find("#mw-diff-otitle4, #mw-diff-ntitle4").hide(); | |||
}, | }, | ||
}); | }); | ||
} | } | ||
}).live("mouseout",function() { | }).live("mouseout",function() { | ||
currTimer = setTimeout(function() { | |||
$("div#rc-preview-div").hide().html(""); | |||
},3000); | |||
}); | }); | ||
}); | }); | ||
}); | }); |
Revision as of 06:50, 23 January 2012
$(document).ready(function() {
/* Force input boxes to have input box class */
$(":text, input[type='text'], input[type='password'], input[type='search'], textarea, input#wpSummary").addClass("input-text-box");
/* Recent Changes slider */
$(".page-Special_RecentChanges span.mw-changeslist-expanded a, .page-Special_RecentChanges span:not(.mw-changeslist-expanded) a").live("mouseover",function() {
$(this).attr("onclick","");
}).live("click",function() {
var num = $(this).parent().attr("id").split("-")[3];
var $openarrow = $("#mw-rc-openarrow-"+num);
var $closearrow = $("#mw-rc-closearrow-"+num);
var $subentries = $("#mw-rc-subentries-"+num);
$openarrow.css("visibility","visible").removeClass("mw-changeslist-hidden mw-changeslist-expanded");
$closearrow.css("visibility","visible").removeClass("mw-changeslist-hidden mw-changeslist-expanded");
$subentries.css("visibility","visible").removeClass("mw-changeslist-expanded");
if ($subentries.is(":hidden") || $subentries.hasClass("mw-changeslist-hidden")) {
$openarrow.hide();
$closearrow.show();
$subentries.hide().removeClass("mw-changeslist-hidden").slideDown(300);
} else {
$openarrow.show();
$closearrow.hide();
$subentries.slideUp(300);
}
return false;
});
/* Recent Changes Preview */
$(".page-Special_RecentChanges").each(function() {
var currTimer = undefined;
var currAjax = undefined;
$("head").append($("<link rel='stylesheet' href='http://www.khwiki.net/load.php?debug=false&lang=en&modules=mediawiki.legacy.diff&only=styles&skin=monobook&*' type='text/css'/>"));
$("<div/>",{
id:"rc-preview-div",
style:"position:absolute;height:300px;width:55%;background:#fff;border:1px solid #888;z-index:500;padding:10px",
}).hide().appendTo("body");
$("table.mw-enhanced-rc a").live("mouseover",function() {
var subtxt = $(this).text().substr(-7);
if (subtxt == "diff" || subtxt == "prev" || subtxt == "changes") {
if (currAjax)
currAjax.abort();
if (currTimer)
clearTimeout(currTimer);
var otop = $(this).offset().top;
var oleft = $(this).offset().left;
var wide = $(this).width();
$("div#rc-preview-div").css({
top:otop-150,
left:oleft+wide+5,
}).html("Loading...").show();
currAjax = $.ajax({
url:"http://www.khwiki.net/index.php",
method:"GET",
data:$(this).attr("href").substr(11),
dataType:"text",
success:function(msg, status, obj) {
while (msg.charCodeAt(0) < 32)
msg = msg.substr(1);
if (currTimer)
clearTimeout(currTimer);
$("div#rc-preview-div").html("<div style='height:300px;font-size:110%;width:auto;overflow-y:auto'><table class='diff'>"+$(msg).find("table.diff").html()+"</table></div>").mouseout(function() {
$("div#rc-preview-div").hide().html("");
}).find("#mw-diff-otitle4, #mw-diff-ntitle4").hide();
},
});
}
}).live("mouseout",function() {
currTimer = setTimeout(function() {
$("div#rc-preview-div").hide().html("");
},3000);
});
});
});