MediaWiki:Navigation.js: Unterschied zwischen den Versionen

Zur Navigation springen Zur Suche springen
K
Zeile 85: Zeile 85:
 
window.onscroll = fixNv;
 
window.onscroll = fixNv;
  
 +
/*****************
 +
        Tagline
 +
*****************/
 +
 +
function taglineLinks() {
 +
var t=document.getElementById('siteSub') || 0;
 +
if (t) {
 +
  var url= window.location.pathname.split('/');
 +
  var home = url[0]+'/'+url[1]+'/'+url[2]+'/';
 +
  var tags = t.innerHTML.split('>');
 +
  var newT= aaa = '';
 +
  for (i=0; i<tags.length; i++) {
 +
  tags[i] = tags[i].replace(/^\s/, '').replace(/\s$/, '');
 +
  home+= i==1 ? tags[i] :
 +
    i==2 ? ':'+tags[i] : '';
 +
  aaa = '<a href=" ' + home + ' ">' + tags[i] + '</a>';
 +
  newT+= i == 0 ? aaa + ' &gt; ' :
 +
    (wgNamespaceNumber > 99 && i < tags.length-1) ? aaa + ' &gt; ' :
 +
      (i < tags.length-1) ? tags[i]  + ' &gt; ' : tags[i];
 +
  }
 +
  t.innerHTML=newT;
 +
}
 +
}
 +
taglineLinks();
 
/*****************
 
/*****************
 
         Top Arrows
 
         Top Arrows

Version vom 18. Januar 2012, 00:16 Uhr

/***********************************
    Anpassen an Browserfenster, u.a.
************************************/

function sizeX() {	

  var normW = 1024, 
    thisW = window.innerWidth ||  document.documentElement.offsetWidth || 0,
    rand_abstand = (thisW > normW)? Math.round((thisW - normW)/20*3) : 0;

  document.body.style.paddingRight = 
  document.body.style.paddingLeft =  
  document.getElementById("p-personal").style.marginLeft =  
    rand_abstand+'px';

  newRules[0].style.left =  // #siteNotice.fixed
    rand_abstand+10+'px';

  document.getElementById("footer").style.marginLeft =  
  document.getElementById("footer").style.marginRight =  
    -rand_abstand+'px';

  document.getElementById("bodyContent").style.marginRight =  
  document.getElementById("bodyContent").style.marginLeft =
      rand_abstand/2+'px'; 
} 

function sizeY() {
	//Maße und Elemente  
  var body_height = document.getElementById("footer").offsetTop + 70,
    screen_height = window.innerHeight ||
      document.documentElement.offsetHeight
    diff = screen_height - body_height;
   // Höhe anpassen
  var spacer =  document.getElementById("catlinks")? 
   document.getElementById("catlinks").parentNode.insertBefore(document.createElement("DIV"), document.getElementById("catlinks")) :
   document.getElementById("bodyContent").appendChild( document.createElement("DIV") );
   spacer.style.paddingTop = diff > 0 ? diff +"px" : 0;	
}

sizeX();
sizeY();
window.onresize = function() { sizeX(); };
window.onresize = function() { sizeY(); };

/*****************
         Navigation
*****************/

var nav = document.getElementById('nv'); 

function findPos(b) {  //Position von b ( = nav) ermitteln
  var a = 0;
  if(b.offsetParent)
    for(a = b.offsetTop;b = b.offsetParent;)
      a += b.offsetTop;
  return[a];
}
var nvY = findPos(nav);

function fixNv() {	
    //Scrollposition ermitteln	
  var scrY = document.documentElement.scrollTop || // Explorer 6 Strict
	document.body.scrollTop || //all other Explorers
	self.pageYOffset ||
	0;
  if(self.pageYOffset)
    scrY = self.pageYOffset;
  else if(document.documentElement && document.documentElement.scrollTop)
    scrY = document.documentElement.scrollTop;
  else if(document.body)
    scrY = document.body.scrollTop;
  if(typeof document.body.style.maxHeight != "undefined" && nav!='') // nur neuere Browser
    nav.className = scrY > nvY - 16 ? "fixed" : "absolute";
}

function styleNv() {
  var selflink = document.getElementById('chapters').getElementsByTagName('STRONG')[0]||0;
  if (selflink && selflink.parentNode.parentNode.parentNode.parentNode.tagName == 'LI') {
    selflink.parentNode.parentNode.parentNode.parentNode.className='self_parent';
  }  
} 
styleNv();
window.onscroll = fixNv;

/*****************
         Tagline
*****************/

function taglineLinks() {
 var t=document.getElementById('siteSub') || 0;
 if (t) {
  var url= window.location.pathname.split('/');
  var home = url[0]+'/'+url[1]+'/'+url[2]+'/';
  var tags = t.innerHTML.split('&gt;');
  var newT= aaa = ''; 
  for (i=0; i<tags.length; i++) {
   tags[i] = tags[i].replace(/^\s/, '').replace(/\s$/, '');
   home+= i==1 ? tags[i] :
    i==2 ? ':'+tags[i] : '';
   aaa = '<a href=" ' + home + ' ">' + tags[i] + '</a>';
   newT+= i == 0 ? aaa + ' &gt; ' :
     (wgNamespaceNumber > 99 && i < tags.length-1) ? aaa + ' &gt; ' :
       (i < tags.length-1) ? tags[i]  + ' &gt; ' : tags[i];
   }
  t.innerHTML=newT;
 }
}
taglineLinks();
/*****************
         Top Arrows
*****************/

function PageHomeArrows()
{
        //if (!wgNamespaceNumber || wgNamespaceNumber <100) return;
        var c = document.getElementById("bodyContent") || document.getElementById("mw_content") || document.getElementById("article");
        if (!c) return;
        for (var level = 2; level <= 3; ++level) {
                var h = c.getElementsByTagName("h" + level);
                for (var i = 0; i < h.length; ++i) {
                        var mwh = h[i].lastChild; // moveEditsection not run yet
                        if (mwh && mwh.className == "mw-headline" && mwh.offsetTop>screen.availHeight) {
                                var arrow = document.createElement("a");
                                arrow.className = "toparrow noprint";
                                arrow.title= "zum Seitenanfang";
                                arrow.appendChild(document.createTextNode("top↑"));
                                arrow.href = "javascript:window.scrollTo(0,0); void 0;";
                                mwh.insertBefore(arrow, mwh.firstChild);
                        }
                }
        }
}
addOnloadHook(PageHomeArrows);