window.codeEditorHeight = window.codeEditorHeight || 700;
$(function(){
var inited = false;
var attempts = 0;
function loop(){//we may have to wait for code editor to load
if ($(".wikiEditor-ui-text div").first().is(".ui-resizable")) {
if (!inited){
$(".tool[rel='codeEditor'] a").first().click(loop);
inited = true;
}
//do resize
$(".wikiEditor-ui-text div").first().css("height",
window.codeEditorHeight.toString() + "px");
//resizing the edit window causes part of the edit window to appear empty
//calling the resize event fixes this.
window.dispatchEvent(new Event("resize"));
attempts = 0;//reset attempt tracker
} else if (attempts < 100) {//try again later
attempts++;
window.setTimeout(loop, 50);
}//after 100 attempts (min 5 seconds), give up
else {
attempts = 0;//reset attempt tracker
}
}
if ((mw.config.get("wgAction") === "edit" ||
mw.config.get("wgAction") === "submit") //are we in edit mode
&& ["javascript", "css", "Scribunto"].indexOf(mw.config.get("wgPageContentModel")) !== -1) {//and on a code page?
loop();
}
});