User:Luciform/monobook.js

mod_util = {};

mod_util.addLoadEvent = function (func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function { if (oldonload) { oldonload; }     func; } } }

mod_util.delay_functions_ = {}; // this is to make it IE compatible mod_util.delay_function_number_ = 0;

mod_util.delayRetry = function( boolFnWhat, delay, tries ) { if(!boolFnWhat && tries) { var fName = "fn_" + mod_util.delay_function_number_++; mod_util.delay_functions_[fName] = function { mod_util.delayRetry( boolFnWhat, delay, tries-1 ); delete mod_util.delay_functions_[fName]; };   // window.setTimeout( mod_util.delayRetry, delay, boolFnWhat, delay, tries-1 ); window.setTimeout("mod_util.delay_functions_['"+fName+"']", delay); } };

var mod_SideBarHide = { hideList: ["p-navigation","p-interaction","p-search","p-tb", "p-lang","donate","anontip","anon-banner","p-logo"], //"p-personal", visible: false, showBtn: null, // the show-hide button el_hide_helper: function(els, value) { var nKills = els.length; for(var i=0; i<nKills; ++i) { var el = document.getElementById(els[i]); if(el) { if(!el.style) { alert(els[i]); continue; } if(!value) el.style.display = "none"; else { el.style.display = ""; //delete el.style.display; }     }    }  },  check_loaded: function { var contentElement = document.getElementById("content"); if(!contentElement || !mod_SideBarHide.showBtn) { return null; }   return contentElement; }, hide_side_bar: function { var contEl = this.check_loaded; if(!contEl) return; this.el_hide_helper(this.hideList, false); this.visible = false; contEl.style.marginLeft = "0px"; this.showBtn.style.left = "5px"; return false; }, show_side_bar: function { var contEl = this.check_loaded; if(!contEl) return; this.el_hide_helper(this.hideList, true); this.visible = true; contEl.style.marginLeft = "12.2em"; this.showBtn.style.left = "12.2em"; }, toggle_side_bar: function { if(this.visible) this.hide_side_bar; else this.show_side_bar; }, create_button: function { if(this.showBtn) return; var parEl = document.getElementById("p-personal"); if(!parEl || !parEl.firstChild) return; var btn = document.createElement("div"); this.showBtn = btn; btn.style.float = "left"; btn.style.fontSize = "small"; btn.style.position = "absolute"; btn.style.left = "12.2em"; btn.innerHTML = "&laquo;"; parEl.insertBefore(btn,parEl.firstChild); }, init: function { // CAVEAT: "this" only works if function is called directly with the module object // - hence we use the full module name here mod_SideBarHide.create_button; mod_SideBarHide.hide_side_bar; return false; } };

mod_util.delayRetry( mod_SideBarHide.init,  200,  8 );

mod_util.addLoadEvent( mod_SideBarHide.init );