MediaWiki:Glossar.js: Unterschied zwischen den Versionen

Zur Navigation springen Zur Suche springen
K
K
Zeile 17: Zeile 17:
  
 
//Suchen und Finden
 
//Suchen und Finden
 +
/*
 
     var parentG = g[i].parentNode.tagName == "LI" ?  
 
     var parentG = g[i].parentNode.tagName == "LI" ?  
 
       g[i].parentNode.parentNode :  
 
       g[i].parentNode.parentNode :  
Zeile 33: Zeile 34:
 
       g[i].style.backgroundColor = "#fffccc";
 
       g[i].style.backgroundColor = "#fffccc";
 
     }  
 
     }  
 +
*/
 
   }
 
   }
 
}
 
}
Zeile 50: Zeile 52:
  
 
//Positionierung  
 
//Positionierung  
 +
/*
 
   var gBodyLeft = (this.offsetWidth - gBodyOffsetWidth)/2;
 
   var gBodyLeft = (this.offsetWidth - gBodyOffsetWidth)/2;
 
   var gBodyOffsetLeft = this.offsetLeft + gBodyLeft ;
 
   var gBodyOffsetLeft = this.offsetLeft + gBodyLeft ;
Zeile 59: Zeile 62:
 
     gBodyLeft = gBodyLeft + (MaxR-gBodyRight);
 
     gBodyLeft = gBodyLeft + (MaxR-gBodyRight);
 
   gBody.style.left = gBodyLeft +"px";
 
   gBody.style.left = gBodyLeft +"px";
 
+
*/
 
// anknipsen, ausknipsen
 
// anknipsen, ausknipsen
 
   if (this.id == 'showTooltip') hideTooltip();
 
   if (this.id == 'showTooltip') hideTooltip();

Version vom 5. Januar 2012, 00:22 Uhr

// s.a. vorlage:glossareintrag

newRules[1].style.display = 'none'; //Glossar

var g = [], off;

function setGlossar() {
  var spans = document.getElementsByTagName('SPAN');
  for (var i=0;i<spans.length;i++) 
    if (spans[i].className=='glossar2') 
      g[g.length] = spans[i];
  for (var i=0;i<g.length;i++) {
    g[i].onclick = showTooltip;
    g[i].onmouseout = glossOFF;
    g[i].onmouseover = clearOFF;
    //g[i].id = 'hideG';

//Suchen und Finden
/*
    var parentG = g[i].parentNode.tagName == "LI" ? 
      g[i].parentNode.parentNode : 
      (g[i].parentNode.previousSibling.tagName == "H2" || g[i].parentNode.previousSibling.tagName == "H3") ?
        g[i].parentNode.previousSibling :
        g[i].parentNode;
    var anker=parentG.insertBefore(document.createElement("A"),
      parentG.firstChild);
    anker.name=g[i].id||'';
    g[i].id= '';
    anker.id=anker.name;
    if (String(location.href).indexOf('#')!=-1) 
    var suchtext = String(location.href).substring(String(location.href).indexOf('#')).replace(/#/,'');     
    if (suchtext==anker.name&& suchtext.length>1) {
      location.href=location.href;
      g[i].style.backgroundColor = "#fffccc";
    } 
*/
  }
}
function hideTooltip() { 
 for (var i in g) g[i].id = ''; 
}

function showTooltip() { 
// g_body ansprechen
  var gBody=this.getElementsByTagName('SMALL')[1];
//Glossarweite berechnen
  var em=this.parentNode.appendChild(document.createElement('div'));
  em.style.width=150+"pt";
  var gBodyOffsetWidth = em.offsetWidth;
  var MinL= em.offsetLeft-10;
  this.parentNode.removeChild(em);

//Positionierung 
/*
  var gBodyLeft = (this.offsetWidth - gBodyOffsetWidth)/2;
  var gBodyOffsetLeft = this.offsetLeft + gBodyLeft ;
  var gBodyRight = gBodyOffsetLeft + gBodyOffsetWidth;
  var MaxR = MinL+10+this.parentNode.offsetWidth+10;
  if (gBodyOffsetLeft < MinL && this.parentNode.tagName == "P")
    gBodyLeft = gBodyLeft + (MinL - gBodyOffsetLeft);
  if (gBodyRight > MaxR  && this.parentNode.offsetWidth > gBodyOffsetWidth ) 
    gBodyLeft = gBodyLeft + (MaxR-gBodyRight);
  gBody.style.left = gBodyLeft +"px";
*/
// anknipsen, ausknipsen
  if (this.id == 'showTooltip') hideTooltip();
  else {hideTooltip(); this.id = 'showTooltip';}
}
function glossOFF()  { off= window.setTimeout('hideTooltip()', 500); }
function clearOFF()  { if (off!='undefined') window.clearTimeout(off); }

// Script starten
addOnloadHook(setGlossar);