MediaWiki:Common.js: Unterschied zwischen den Versionen

Zur Navigation springen Zur Suche springen
Zeile 8: Zeile 8:
 
                 for (var i = 0; i < h.length; ++i) {
 
                 for (var i = 0; i < h.length; ++i) {
 
                         var mwh = h[i].lastChild; // moveEditsection not run yet
 
                         var mwh = h[i].lastChild; // moveEditsection not run yet
                         if (mwh && mwh.className == "mw-headline" && mwh.offsetTop>screen.height) {
+
                         if (mwh && mwh.className == "mw-headline" && mwh.offsetTop>screen.availHeight) {
 
                                 var arrow = document.createElement("a");
 
                                 var arrow = document.createElement("a");
 
                                 arrow.className = "toparrow noprint";
 
                                 arrow.className = "toparrow noprint";

Version vom 14. September 2010, 15:40 Uhr

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);


////Buttons f. Bearbeitungsfenster ganz unten!

var sysopRights = false;
for (i in wgUserGroups) 
  if (wgUserGroups[i]== "sysop")
    sysopRights = true;
//Nach dem Einloggen wieder zur Ausgangsseite:

if (wgCanonicalSpecialPageName == "Userlogin")
	addOnloadHook( function() { document.location = document.getElementById('mw-returnto').getElementsByTagName('a')[0].href; } );

// Welche Scripts für welche Seiten...

var jsOK = false;
var useNewJs = [
  newJS_Spaces = [wgNamespaceNumber,4,100,102,104,106,108,110,112,],
  newJS_Pages = [wgPageName,'Hauptseite']
];

function setJsOK(array) {
  for (var i in array)  
    for (var n=1; n<array[i].length; n++) 
      if (array[i][n] == array[i][0]) jsOK = true;
}

setJsOK(useNewJs); 
if (!wgIsArticle || wgAction != "view") jsOK = false;

window.onload= function() {
  sizeY();
  if (jsOK) {
    nv = document.getElementById('chapters'); 
    nvY = findPos(nv);
    fixNv();
    styleNv();
  
    getThumbs();  
    setGlossar(); 
    setShowtalk();
  }
};
	
function sizeY() {
	//Maße und Elemente  
  var body_width = document.body.offsetWidth,
    body_height = document.body.offsetHeight,
    screen_height = window.innerHeight ||
      document.documentElement.offsetHeight;
    var spacer = document.getElementById("content").appendChild( document.createElement("DIV") );
   // Höhe anpassen
   spacer = document.getElementById("thisway") || spacer;
    spacer.style.paddingTop = (body_height+10) < screen_height ?
      screen_height-(body_height+10) +"px" : 0;	
}

if (jsOK)
{ //eigentliches Script ab hier. Achtung auf "}" !

function showTocToggle() { return; } //Funktion überschreiben...

function toggleMsg() { 
jsMessage=document.getElementById('mw-js-message')||false;
//alert(jsMessage);
if (jsMessage) jsMessage.style.display='none';
}
window.onclick = toggleMsg;

///////// var für Maße und Elemente///////////////  

var body_width, body_height, screen_height;

/***********************************
       Stylesheet changes
***********************************/

document.write (
    '<style>' +
    ' #column-content {}' + //0
    ' #column-one {}' + //1
    ' #toc{}' +  //2
    ' #column-content #content #bodyContent{}' + //3
    ' #sidebar {}' + //4
    ' #p-personal{}' + //5 
    ' #p-cactions {}' + //6 
    ' #dropdown {}' + //7 
    ' .glossar2:hover .g_body{}' + //8
    ' .sysop {}' + //9
    ' </style>'
    );   
var newCSS = document.styleSheets[document.styleSheets.length-1],
  newRules = newCSS.cssRules || newCSS.rules;  // für alle Browser ansprechbar

/***********************************
    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;
  if (newRules) { 
      //--------- neue Abstaende --------------- 
    newRules[0].style.marginRight =  // #column-content
    newRules[0].style.marginLeft = 
    //newRules[1].style.left =  // #column-one
    //newRules[2].style.marginRight =  //#toc
    newRules[4].style.marginLeft =  // #sidebar
    //newRules[5].style.marginLeft =   //#p-personal
    //newRules[6].style.marginLeft =  //#p-cactions
    newRules[7].style.marginLeft =  //#dropdown
      rand_abstand+'px';
    newRules[3].style.marginRight =  //#bodyContent
    newRules[3].style.marginLeft =
      rand_abstand/2+'px'; 

      //---------- Glossar, falls JS ----------------
    newRules[8].style.display = 'none';  //.glossar2:hover .g_body

      //---------- falls Sysop ----------------
   if (wgUserGroups && wgUserGroups.length>0) 
    for (var i in wgUserGroups)
      if (wgUserGroups[i] == 'sysop')
        newRules[9].style.display='block';
  }
} 
sizeX();
window.onresize = function() {sizeX();};

//die wichtigsten Funktionen:

/*** NAVIGATION ***/
importScript('mediawiki:navigation.js');

/*** POPUPS ***/
importScript('mediawiki:popup.js');

/*** GLOSSAR ***/
importScript('mediawiki:glossar.js');

/*** KOMMENTAR ***/
importScript('mediawiki:kommentare.js'); 

}// ende "jsOK"

//Vielleicht für später
//importStylesheet('mediawiki:abc' + wgCanonicalNamespace + '.css'); 
//importScript('mediawiki:abc' + wgCanonicalNamespace + '.js');


//////////////////////////
//—‚ ‘„ “ōŌūŪ&shy;&nbsp;
//////////////////////////
mwCustomEditButtons[mwCustomEditButtons.length] =
  {"imageFile": "/rel_jap/w/skins/common/images/no.gif",
    "speedTip": "",
    "tagOpen": "",
    "tagClose": "",
    "sampleText": ""};
mwCustomEditButtons[mwCustomEditButtons.length] =
  {"imageFile": "/rel_jap/w/skins/common/images/ndash.jpg",
    "speedTip": "kurzer Bindestrich (n–dash)",
    "tagOpen": "–",
    "tagClose": "",
    "sampleText": ""};
mwCustomEditButtons[mwCustomEditButtons.length] =
  {"imageFile": "/rel_jap/w/skins/common/images/mdash.jpg",
    "speedTip": "Text zwischen langen Bindestrichen (m—dash)",
    "tagOpen": "— ",
    "tagClose": " — ",
    "sampleText": "Text"};
mwCustomEditButtons[mwCustomEditButtons.length] =
  {"imageFile": "/rel_jap/w/skins/common/images/hyphens1_dt.jpg",
    "speedTip": "dt. Anführungszeichen einfach",
    "tagOpen": "‚",
    "tagClose": "‘",
    "sampleText": ""};
mwCustomEditButtons[mwCustomEditButtons.length] =
  {"imageFile": "/rel_jap/w/skins/common/images/hyphens2_dt.jpg",
    "speedTip": "dt. Anführungszeichen doppelt",
    "tagOpen": "„",
    "tagClose": "“",
    "sampleText": ""};
mwCustomEditButtons[mwCustomEditButtons.length] =
  {"imageFile": "/rel_jap/w/skins/common/images/oo.jpg",
    "speedTip": "langes o, klein",
    "tagOpen": "ō",
    "tagClose": "",
    "sampleText": ""};
mwCustomEditButtons[mwCustomEditButtons.length] =
  {"imageFile": "/rel_jap/w/skins/common/images/oo_gr.jpg",
    "speedTip": "langes O, gross",
    "tagOpen": "Ō",
    "tagClose": "",
    "sampleText": ""};
mwCustomEditButtons[mwCustomEditButtons.length] =
  {"imageFile": "/rel_jap/w/skins/common/images/uu.jpg",
    "speedTip": "langes u, klein",
    "tagOpen": "ū",
    "tagClose": "",
    "sampleText": ""};
mwCustomEditButtons[mwCustomEditButtons.length] =
  {"imageFile": "/rel_jap/w/skins/common/images/uu_gr.jpg",
    "speedTip": "langes U, gross",
    "tagOpen": "Ū",
    "tagClose": "",
    "sampleText": ""};
mwCustomEditButtons[mwCustomEditButtons.length] =
  {"imageFile": "/rel_jap/w/skins/common/images/shy.jpg",
    "speedTip": "stummes Trennzeichen",
    "tagOpen": "·",
    "tagClose": "",
    "sampleText": ""};
mwCustomEditButtons[mwCustomEditButtons.length] =
  {"imageFile": "/rel_jap/w/skins/common/images/nbsp.jpg",
    "speedTip": "festes Leerzeichen (no breaking space)",
    "tagOpen": "&nbsp;",
    "tagClose": "",
    "sampleText": ""};
mwCustomEditButtons[mwCustomEditButtons.length] =
  {"imageFile": "/rel_jap/w/skins/common/images/ref.jpg",
    "speedTip": "Fussnoten",
    "tagOpen": "<ref>",
    "tagClose": "</ref>",
    "sampleText": "Text"};

/*********** WIKI GADGETS *****************/