Jump to content

User:Codehydro/Auto CSS image crop/script.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
acic = "Auto CSS image crop";

function loadAutoCrop() {
	importScript('User:Codehydro/' + acic + '/functions.js');
	initReady();
}

function initReady() {
	if(window.initAutoCrop) {
		if(!window.autocrop) {
			efs = editform.style.cssText = "width:60%;float:left;";
			editform.parentNode.insertBefore(document.createElement("div"), editform.nextSibling).id = "autocrop";
			croptog.innerHTML = cropTogText[1];
			cropOpen = true;
			croptog.onclick = function() {
				autocrop.style.display = cropOpen ? "none" : "";
				editform.style.cssText = cropOpen ? "" : efs;
				croptog.innerHTML = cropTogText[cropOpen ? 0 : 1];
				cropOpen = !cropOpen;
			};
		}
		initAutoCrop();
		if(window.editform) window[autocrop.insertBefore(document.createElement("span"), cform).id = "cropdoc"].innerHTML = "<a href='/wiki/User:Codehydro/" + acic + "' target='_blank'>Help</a>";
	} else setTimeout(initReady, 9);
}
if(window.autocrop) {
	loadAutoCrop();
} else if(window.editform && !window.DisableAutoCropEverywhere) {
	(cropEditCSS = (document.head || document.getElementsByTagName("head")[0]).appendChild(document.createElement("style"))).type = "text/css";
	(cropEditCSS.styleSheet || cropEditCSS)[cropEditCSS.styleSheet ? "cssText" : "innerHTML"] = "#croptog,#cropdoc,#autocrop{outline:1px solid;}#croptog{cursor:pointer;z-index:8;right:18px}#cform,#sizeinfo,#pc,#autotemp{margin-left:4px;}#autocrop{padding-top:3em;width:40%;height:auto;overflow:hidden}#cropdoc{margin-top:-3em;right:15em;}#croptog,#cropdoc{position:absolute;background-color:#eee;padding:0 0.5em;}#cropdoc a{text-decoration:none;color:#000;}";
	window[editform.insertBefore(document.createElement("div"), editform.firstChild).id = "croptog"].innerHTML = (cropTogText = ["Open " + acic, "Hide " + acic])[0];
	croptog.onclick = loadAutoCrop;
}