Jump to content

User:GlasGhost/monobook.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.
/*! Returns the version of Internet Explorer or a -1  (indicating  the  use  of
another browser). This function is directly from
	http://msdn.microsoft.com/en-us/library/ms537509.aspx
*/function getInternetExplorerVersion(){
	var rv = -1; // Return value if not IE.
	if (navigator.appName == 'Microsoft Internet Explorer'){
		var ua = navigator.userAgent;
		var re	= new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
		if (re.exec(ua) != null)
			rv = parseFloat( RegExp.$1 );
	}
	return rv;
}/*___________________________________________________________________________*/

var MSIEV = getInternetExplorerVersion();

/*! override_CSS() uses the text value of $Css_Text$ to override  the  style  of
the specified document $Doc$ e.g. an IFrame; If not specified $Doc$ defaults  to
the current document. For the history of this function: look at monobook.js from
http://wiki.riteme.site/wiki/User:GlasGhost/Encyclopedia_feel_User_skin
*/function override_CSS(Css_Text, Doc){
	//Secure $Head$
	Doc = Doc||document;	var head = Doc.getElementsByTagName('head')[0];
	if(!head || head == null){
		head = Doc.createElement('div');
		Doc.body.appendChild(head);
	} if(!head || head == null){return false;}
	// create PendingStyle, override current css.
	var PendingStyle = Doc.createElement("style");
	PendingStyle.type = "text/css";
	if (MSIEV == -1){// The standard method
		PendingStyle.appendChild(Doc.createTextNode(Css_Text));
	}else if (MSIEV < 9){//IE6-8 use proprietary styleSheet.cssText instead
		PendingStyle.styleSheet.cssText = Css_Text;
		if (head.firstChild){// Add the new style with a higher priority
			head.insertBefore(PendingStyle, head.firstChild);
		}else { head.appendChild(PendingStyle); }
	}
	Doc.documentElement.appendChild(PendingStyle);
}/*___________________________________________________________________________*/

//importScript('User:Gerbrant/hidePane.js');//Special thanks to Gerbrant for this wonderful script

function setSize(){
	var tb = document.getElementById("p-lang");
	if(!tb) tb = document.getElementById("p-tb");
	document.getElementById("content").style.marginTop = tb.offsetTop + tb.offsetHeight + "px";
}
 
function myContains(e){
	do if(this === e) return true;
	while(e = e.parentNode);
	return false;
}

$(function(){
override_CSS("\
.portlet, #p-cactions, #p-personal{\
	float: left;\
	width: auto;\
	height: auto;\
	overflow: visible;\
	position: relative;\
	z-index: auto!important;\
	left: auto;\
	top: auto;\
	text-align: center;\
	line-height: normal;\
	padding: 0 0.5em;\
	margin: 0;\
	font-size: 100%;\
	white-space: nowrap;\
	border-collapse: separate\
}\
.portlet h5, #p-cactions h5, #p-personal h5{\
	display:inline;\
	white-space: nowrap;\
	padding: 0;\
	margin: 0\
}\
.portlet .pBody{display: none;}\
.portlet .pBody, #p-cactions .pBody, #p-personal .pBody{\
	position: absolute;\
	left: 0em;\
	top: 1.1em;\
	text-align: left;\
	white-space: nowrap\
}\
#column-one{\
	position: absolute;\
	left: 0;\
	top: 0;\
	padding: 0\
}\
#column-content{float: none; margin: 0}\
#column-content #content{\
	margin: 1.1em 0 0 0;\
	padding: 0 1em 1.5em 1em;\
	margin-left: 0\
}\
#p-cactions li, #p-personal li{display: list-item;}\
#p-logo{display: none}\
#footer{margin-left: 0}\
.hotportlet .pBody{display: block}\
.hotportlet, #p-cactions.hotportlet, #p-personal.hotportlet{ z-index:16!important}");

var os, bg, fg, sbg, sfg, bc;
try{ bg = Gerbrant.hidePane.background;   }catch(x){} if(! bg)  bg = "#f9f9f9 url(/skins-1.5/monobook/headbg.jpg) 0 0 no-repeat";
try{ fg = Gerbrant.hidePane.color;		}catch(x){} if(! fg)  fg = "#000000";
try{sbg = Gerbrant.hidePane.selBackground;}catch(x){} if(!sbg) sbg = "#3168b8";
try{sfg = Gerbrant.hidePane.selColor;	 }catch(x){} if(!sfg) sfg = "#ffffff";
try{ bc = Gerbrant.hidePane.borderColor;  }catch(x){} if(! bc)  bc = "#c0c0c0";
try{os = Gerbrant.hidePane.ownStyle;}catch(x){}

if(!os){override_CSS("\
.portlet .pBody, #p-cactions .pBody, #p-personal .pBody{\
	background: " + bg + ";\
	border: 1px solid " + bc + ";\
	padding: 0\
}\
.portlet *, #p-cactions *, #p-personal *{color: " + fg + "}\
.portlet h5, #p-cactions h5, #p-personal h5{text-transform: none}\
#p-interaction h5{text-transform: capitalize}\
.portlet ul, #p-cactions ul, #p-personal ul{\
	padding: 0;\
	margin: 0;\
	text-align: left;\
}\
.portlet li, #p-cactions li, #p-cactions li.selected, #p-personal li{\
	display: block;\
	background: none;\
	border: none;\
	padding-bottom: 0;\
	margin: 0\
}\
.portlet li a, #p-cactions li a, #p-cactions li.selected a, #p-personal li a{\
	display: block;\
	background: none;\
	color: " + fg + ";\
	border: none;\
	text-transform: none;\
	padding: 0 0.5em!important;\
}\
.portlet li a:visited{color: " + fg + ";}\
.portlet li a:hover, #p-cactions li a:hover, #p-personal li a:hover{\
	background: " + sbg + ";\
	color: " + sfg + ";\
	text-decoration: none\
}\
li#ca-watch, li#ca-unwatch{margin-left:0}\
li#pt-userpage, li#pt-anonuserpage{padding-left:0}\
#footer, #column-content #content{border-left:0}\
\
.hotportlet, #p-cactions.hotportlet, #p-personal.hotportlet{background: " + sbg + "}\
.hotportlet h5, #p-cactions.hotportlet h5, #p-personal.hotportlet h5,\
.hotportlet h5 *, #p-cactions.hotportlet h5 *, #p-personal.hotportlet h5 *{color: " + sfg + "}\
.ns-0 #p-cactions li a, .ns-0 #p-cactions li.selected a{background: none}\
.ns-0 #p-cactions li a:hover{background: " + sbg + "}\
\
/*IE fix*/\
#column-one, #p-cactions{z-index: auto}\
#p-navigation a{width: auto}\
.portlet li a{display: inline-block!important}");}

	var h;
	function hideMenu(){
		h.className = h.className.replace(/ hotportlet\b/, "");
		h = null;
	}
	function showMenu(e){
		if(h){
			if(h === e) return;
			hideMenu();
		}
		h = e;
		e.className += " hotportlet";
	}
 
	setSize();
	(function(orig){
		window.onresize = orig ? function()
		{
			setSize();
			orig.apply(this, arguments);
		} : setSize;
	})(window.onresize);
	var co = document.getElementById("column-one").childNodes;
	for(var i = 0; i < co.length; i++){
		var p = co[i];
		if (/(?:^| )portlet(?:$| )/.test(p.className)){
			if(!p.contains) p.contains = myContains;
			p.onmouseover = function(e){
				if(!e) e = event;
				f = e.fromElement;
				if(!f) f = e.relatedTarget;
				if(!f || !this.contains(f)) showMenu(this);
			};
			p.onmouseout = function(e){
				if(!e) e = event;
				t = e.toElement;
				if(!t) t = e.relatedTarget;
				if(h && (!t || !this.contains(t))) hideMenu();
			};
		}
	}
	var co = document.getElementById("bodyContent").getElementsByTagName("DIV");
	for(var i = 0; i < co.length; i++){
		if(co[i].className == "usermessage"){
			var a = document.createElement("IMG");
			a.src = "http://upload.wikimedia.org/wikipedia/commons/thumb/6/62/Mail-closed.svg/24px-Mail-closed.svg.png";
			a.style.Css_Text = "right:2;top:2;z-index:256;position:absolute";
			document.body.appendChild(a);
			break;
		}
	}

override_CSS(//GlasGhost New page styling
"h1, h2, h3, h4, h5 {font-family: 'Verdana','Helvetica',sans-serif; font-style: normal; font-weight:normal;}" +
"body, b {background: #none; font-style: normal; font-family: 'Cochin','GaramondNo8','Garamond','Big Caslon','Georgia','Times',serif;font-size: 11pt;}" +
"p { margin: 0pt; text-indent:2.5em;  margin-top: 0.3em; }" +
"a {	text-decoration: none; color: Navy; background: none;}" +
"a:visited {	color: #500050;}" +
"a:active {	color: #faa700;}" +
"a:hover {	text-decoration: underline;}" +
"a.stub {	color: #772233;}" +
"a.new, #p-personal a.new {	color: #ba0000;}" +
"a.new:visited, #p-personal a.new:visited {	color: #a55858;}" +
"a.new, #quickbar a.new { color: #CC2200; }" +
/* removes "From Wikipedia, the free encyclopedia" for those of you who actually know what site you are on */
"#siteSub { display: none; }" +
/* hides the speaker icon in some articles */
"#spoken-icon .image {	display:none;}" +
/* KHTMLFix.css */
"#column-content { margin-left: 0; }" +
/* Remove contents of the footer, but not the footer itself */
"#f-poweredbyico, #f-copyrightico {	display:none;}" +
/* Needed to show the star icon in a featured article correctly */
"#featured-star div div {	line-height: 10px;}" +
/* And the content expands to top and left */
"div.content {margin: 0; margin-top:2em; padding: 0; background:none;}" +
"#content div.thumb {border-color:white;}" +
/* Hiding the bar under the entry header */
"h1.firstHeading {	border-bottom: none;}" +
/* Used for US city entries */
"#coordinates {	 top:1.2em;}"
);//inserts the page styling
});