MediaWiki:Glossar2.js: Unterschied zwischen den Versionen

Zur Navigation springen Zur Suche springen
Zeile 1: Zeile 1:
 
// s.a. vorlage:glossareintrag
 
// s.a. vorlage:glossareintrag
  
newRules[1].style.display = 'none'; //Glossar
+
newRules[2].style.display = 'none'; //Glossar
  
 
var gl = [], gl2 = [],  glSkt = [],  glJap = [], glossar, off;
 
var gl = [], gl2 = [],  glSkt = [],  glJap = [], glossar, off;
Zeile 30: Zeile 30:
 
     var suchtext = String(location.href).substring(String(location.href).indexOf('#')).replace(/#/,'');      
 
     var suchtext = String(location.href).substring(String(location.href).indexOf('#')).replace(/#/,'');      
 
     if (suchtext==anker.name&& suchtext.length>1) {
 
     if (suchtext==anker.name&& suchtext.length>1) {
       location.href=String(location.href).substring(0, String(location.href).indexOf('#'));
+
       location.href=location.href;
 
       gl[i].style.backgroundColor = "#fffccc";
 
       gl[i].style.backgroundColor = "#fffccc";
 
     }  
 
     }  

Version vom 14. Juli 2014, 11:41 Uhr

// s.a. vorlage:glossareintrag

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

var gl = [], gl2 = [],  glSkt = [],  glJap = [], glossar, off;

function set_Glossar() {
  var spans = document.getElementsByTagName('SPAN');
// Arrays füllen
  for (var i=0;i<spans.length;i++) {
    if (spans[i].className=='glossar') {
      gl[gl.length] = spans[i];
      if (spans[i].getElementsByTagName('SMALL')[0])
        gl2[gl2.length] = spans[i].getElementsByTagName('SMALL')[0].cloneNode(true);
    }
  }
  for (var i in gl) {
    gl[i].onclick = show_Tooltip;
    gl[i].onmouseout = gloss_OFF;
    gl[i].onmouseover = clear_OFF;
// Suchen und Finden
    var parentG = gl[i].parentNode.tagName == "LI" ? 
      gl[i].parentNode.parentNode : gl[i].parentNode;
    var anker=parentG.insertBefore(document.createElement("A"),
      parentG.firstChild);
    anker.name=gl[i].id||'';
    gl[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;
      gl[i].style.backgroundColor = "#fffccc";
    } 
  }
  function showGl() {
    this.parentNode.className = this.parentNode.className == 'show' ? 'hide' : 'show'
  };  
}

function hide_Tooltip() { 
  for (var i in gl) gl[i].id = ''; 
}

function show_Tooltip() { 
// g_body ansprechen
  var gBody=this.getElementsByTagName('SMALL')[0];
//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 == 'show_Tooltip') hide_Tooltip();
  else {hide_Tooltip(); this.id = 'show_Tooltip';}
}
function gloss_OFF()  { off= window.setTimeout('hide_Tooltip()', 500); }
function clear_OFF()  { if (off!='undefined') window.clearTimeout(off); }

// Script starten
set_Glossar();