Jump to content

User:Js/bottomSidebar.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.
if (skin == 'monobook' || skin=='simple') {
 var bottomSidebarPanel = window.bottomSidebarPanel || '1em'
 var isIE6 = (navigator.appName=="Microsoft Internet Explorer" && navigator.appVersion.substr(22, 1)=="6")
 var bottomSidebarSheet = bsAppendCSS('\
#column-content {float:none; margin-left:0}\
#column-content #content {margin-left:2px}\
#column-one {position:static; padding-top: 10px}\
.portlet {float:left}\
#p-personal ul {text-align:left}\
#p-cactions {left:0}\
#p-lang {float:right}\
#footer {margin-left: 0}\
#p-logo {display:none}')
 if (bottomSidebarSheet.sheet) bottomSidebarSheet = bottomSidebarSheet.sheet //for Safari
 //call the script
 if (doneOnloadHook) popupSidebarInit() 
 else hookEvent('load', popupSidebarInit)
 // //else if (isIE6)  ... else addOnloadHook(popupSidebarInit)
}

function popupSidebarInit(){
 var bottomSidebarMode = window.bottomSidebarMode || 0
 document.getElementById('p-logo').style.display = 'none' // bsAppendCSS('#p-logo {display:none}')
 var colOne = document.getElementById('column-one')
 switch (bottomSidebarMode){
 case 0: 
 case 1:
   var panel = document.createElement('div')
   panel.id = 'column-panel'
   panel.style.cssText = 'left:0; top:0; position:fixed; height:100%; z-index:100; cursor:move;\
   background:none; width:'+bottomSidebarPanel
   if (isIE6){ panel.style.position = 'absolute';  panel.style.height = document.body.scrollHeight + 'px'}
   document.body.appendChild(panel)
   if (bottomSidebarMode==1){
     addHandler(panel, 'mouseover', showFixedSidebar)
     addHandler(document.getElementById('content'), 'mouseover', hideFixedSidebar)
   }else
     addHandler(document.body, 'click', bodyClick)
   break
 case 2:
   var link = document.createElement('span')
   link.appendChild(document.createTextNode('<>'))
   link.style.cssText = 'color:#797; font-weight:bold; font-size:15px; cursor:pointer;\
   left:0px; top:0px; padding:2px; z-index:100; position:fixed'
   if (isIE6) link.style.position = 'absolute'
   addHandler(link, 'click', switchSidebar)
   document.body.appendChild(link)
   break
 }

function bodyClick(e){
 e = e || window.event
 var targ = e.target || e.srcElement
 if (targ.id == 'column-panel') switchSidebar()
 else if (targ.id && targ.nodeName == 'DIV') hideFixedSidebar()
}

function showFixedSidebar(){
 bottomSidebarSheet.disabled = true
 colOne.style.paddingTop = windowScrolled() + 1 + 'px' 
}
function hideFixedSidebar(){
 bottomSidebarSheet.disabled = false
 colOne.style.paddingTop = ''
}
function switchSidebar(){ if (bottomSidebarSheet.disabled) hideFixedSidebar(); else showFixedSidebar() }

function windowScrolled(){
 if (self.pageYOffset) return self.pageYOffset // all except IE
 else if (document.documentElement && document.documentElement.scrollTop)	// Explorer 6 Strict
  return document.documentElement.scrollTop
 else if (document.body) return document.body.scrollTop //all other IE 
}

}

function bsAppendCSS(text){
 var s = document.createElement('style')
 s.setAttribute('type', 'text/css')
 if (s.styleSheet) s.styleSheet.cssText = text //IE
 else s.appendChild(document.createTextNode(text))
 document.getElementsByTagName('head')[0].appendChild(s)
 return s
}