MediaWiki:Navigation.js: Unterschied zwischen den Versionen

Zur Navigation springen Zur Suche springen
 
(39 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
 
+
var nav = $( "#nv" );
 +
var cont= $( "#content" );
 +
var search= $("<div id='search2'></div>").append($('#searchform'));
 +
var fixOK = 1;
 +
$('#chapters').append($(search));
 +
 
/***********************************
 
/***********************************
 
     Anpassen an Browserfenster, u.a.
 
     Anpassen an Browserfenster, u.a.
 
************************************/
 
************************************/
 
+
function sizeX() {
+
var toggleNav =  $( "<div id='tS' title='Navigation vergößern' class='fas fa-bars'></div>" )
 
+
  .click( function() {  $( nav ).toggleClass( 'nv_large' );  });
  var normW = 1024,
+
$( nav ).append(toggleNav );
    thisW = window.innerWidth ||  document.documentElement.offsetWidth || 0,
+
    rand_abstand = (thisW > normW)? Math.round((thisW - normW)/20*3) : 0;
+
/*        Handys und kleine Bildschirme        */
 
+
  document.body.style.paddingRight =
+
function sizeX() {
  document.body.style.paddingLeft =  
+
  document.getElementById("p-personal").style.marginLeft = 
+
var wiW = window.innerWidth ||  document.documentElement.offsetWidth || 0;
    rand_abstand+'px';
+
var wiH = window.innerHeight ||  document.documentElement.offsetHeight || 0;
 
+
   
  newRules[0].style.left =  // #siteNotice.fixed
+
$( nav ).removeClass( 'nv_large' );
    rand_abstand+10+'px';
+
 
+
if (wiW < wiH*0.7 || wiW < 940) {
  document.getElementById("footer").style.marginLeft = 
+
fixOK = 0; // fixed ausschalten
  document.getElementById("footer").style.marginRight = 
+
$ (cont).addClass( 'mobileeee' );  
    -rand_abstand+'px';
+
$ (nav).removeClass( 'fixed' );  
 
+
}
  document.getElementById("bodyContent").style.marginRight =   
+
else  {
  document.getElementById("bodyContent").style.marginLeft =
+
fixOK = 1; // fixed einschalten
      rand_abstand/2+'px';  
+
$ (cont).removeClass( 'mobileeee' );  
 +
}
 
}  
 
}  
  
Zeile 43: Zeile 49:
 
sizeY();
 
sizeY();
 
window.onresize = function() { sizeX(); };
 
window.onresize = function() { sizeX(); };
window.onresize = function() { sizeY(); };
+
// window.onresize = function() { sizeY(); };
  
 
/*****************
 
/*****************
Zeile 49: Zeile 55:
 
*****************/
 
*****************/
  
var nav = document.getElementById('nv');  
+
var nav2 = document.getElementById('nv');  
  
function findPos(b) {  //Position von b ( = nav) ermitteln
+
function findPos(b) {  //Position von b ( = nav2) ermitteln
 
   var a = 0;
 
   var a = 0;
 
   if(b.offsetParent)
 
   if(b.offsetParent)
Zeile 58: Zeile 64:
 
   return[a];
 
   return[a];
 
}
 
}
var nvY = findPos(nav);
+
var nvY = findPos(nav2);
  
function fixNv() {
+
function fixNv() {
 +
 
 +
if (!fixOK) return; 
 
     //Scrollposition ermitteln
 
     //Scrollposition ermitteln
 
   var scrY = document.documentElement.scrollTop || // Explorer 6 Strict
 
   var scrY = document.documentElement.scrollTop || // Explorer 6 Strict
Zeile 72: Zeile 80:
 
   else if(document.body)
 
   else if(document.body)
 
     scrY = document.body.scrollTop;
 
     scrY = document.body.scrollTop;
   if(typeof document.body.style.maxHeight != "undefined" && nav!='') // nur neuere Browser
+
   if(fixOK && typeof document.body.style.maxHeight != "undefined" && nav2!='') // nur neuere Browser
     nav.className = scrY > nvY - 16 ? "fixed" : "absolute";
+
     nav2.className = scrY > nvY - 30 ? "fixed" : "";
 +
  else nav2.className = "";
 
}
 
}
 +
  //Menü stabilisieren
 +
var toggleFix = $("<div title = 'Menü oben stabilisieren' id = 'tF' class='fa fa-arrow-up'></div>").click( function() { menuTop(); } );
 +
$( "#chapters" ).append( toggleFix ); 
  
 +
function menuTop() {
 +
  fixOK = 0;
 +
$( nav).removeClass( 'fixed' );
 +
}
 
function styleNv() {
 
function styleNv() {
 
   var selflink = document.getElementById('chapters').getElementsByTagName('STRONG')[0]||0;
 
   var selflink = document.getElementById('chapters').getElementsByTagName('STRONG')[0]||0;
   if (selflink && selflink.parentNode.parentNode.parentNode.parentNode.tagName == 'LI') {
+
   if (selflink && selflink.parentNode.parentNode.parentNode.tagName == 'LI') {
     selflink.parentNode.parentNode.parentNode.parentNode.className='self_parent';
+
     selflink.parentNode.parentNode.parentNode.className='self_parent';
 +
    //selflink.parentNode.parentNode.parentNode.className='selflink';
 
   }   
 
   }   
 
}  
 
}  
 
styleNv();
 
styleNv();
 +
 
window.onscroll = fixNv;
 
window.onscroll = fixNv;
  
/*****************
+
//Navigation Hover
        Tagline
+
 
*****************/
+
$('#chapters div[id]').on("touchstart", function (e) {
 +
'use strict'; //satisfy code inspectors
 +
var link = $(this); //preselect the link
 +
if (link.hasClass('hover')) {
 +
  return true;
 +
}
 +
else {
 +
  $('#chapters div[id]').removeClass('hover');
 +
  link.addClass('hover');
 +
  return false; //extra, and to make sure the function has consistent return points
 +
}
 +
});
  
function taglineLinks() {
+
/*
var t=document.getElementById('siteSub') || 0;
+
$('#chapters div[id] > ul').hide();
if (t) {
+
$('#chapters div[id]').on("hover", function (e) {
  var url= window.location.pathname.split('/');
+
   e.preventDefault;
  var home = url[0]+'/'+url[1]+'/'+url[2]+'/';
+
   $(this).children('ul').toggle('slow');
  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
 
         Top Arrows
Zeile 121: Zeile 137:
 
                 var h = c.getElementsByTagName("h" + level);
 
                 var h = c.getElementsByTagName("h" + level);
 
                 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
+
                         if (h[i].offsetTop>screen.availHeight) {  
                        if (mwh && mwh.className == "mw-headline" && mwh.offsetTop>screen.availHeight) {
+
var top= function( ) {window.scrollTo(0,0);}
                                var arrow = document.createElement("a");
+
var arrow = $("<a>top</a>").attr({
                                arrow.className = "toparrow noprint";
+
title: "zum Seitenanfang",
                                arrow.title= "zum Seitenanfang";
+
"class": "toparrow noprint"
                                arrow.appendChild(document.createTextNode("top↑"));
+
})  
                                arrow.href = "javascript:window.scrollTo(0,0); void 0;";
+
$(arrow).on( "click", top);
                                mwh.insertBefore(arrow, mwh.firstChild);
+
 
 +
arrow.appendTo( h[i] );
 
                         }
 
                         }
 
                 }
 
                 }
 
         }
 
         }
 
}
 
}
addOnloadHook(PageHomeArrows);
+
$(PageHomeArrows);

Aktuelle Version vom 12. August 2018, 14:23 Uhr

var nav = $( "#nv" ); 
var cont= $( "#content" ); 
var search= $("<div id='search2'></div>").append($('#searchform')); 
var fixOK = 1;
$('#chapters').append($(search));
 
/***********************************
    Anpassen an Browserfenster, u.a.
************************************/
 
var toggleNav =  $( "<div id='tS' title='Navigation vergößern' class='fas fa-bars'></div>" )
  .click( function() {  $( nav ).toggleClass( 'nv_large' );  });
$( nav ).append(toggleNav );
 
/*         Handys und kleine Bildschirme        */ 
 
function sizeX() {
 
var wiW = window.innerWidth ||  document.documentElement.offsetWidth || 0;
var wiH = window.innerHeight ||  document.documentElement.offsetHeight || 0;
 
$( nav ).removeClass( 'nv_large' );
 
if (wiW < wiH*0.7 || wiW < 940) {
 fixOK = 0;  // fixed ausschalten
 $ (cont).addClass( 'mobileeee' ); 
 $ (nav).removeClass( 'fixed' ); 
 }
else  {
 fixOK = 1;  // fixed einschalten
 $ (cont).removeClass( 'mobileeee' ); 
 }
} 

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 nav2 = document.getElementById('nv'); 

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

function fixNv() {	 

if (!fixOK) return;  
    //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(fixOK && typeof document.body.style.maxHeight != "undefined" && nav2!='') // nur neuere Browser
    nav2.className =  scrY > nvY - 30 ? "fixed" : "";
  else nav2.className = "";
}
   //Menü stabilisieren
var toggleFix = $("<div title = 'Menü oben stabilisieren' id = 'tF' class='fa fa-arrow-up'></div>").click( function() { menuTop(); } );
$( "#chapters" ).append( toggleFix );  

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

//Navigation Hover

$('#chapters div[id]').on("touchstart", function (e) {
 'use strict'; //satisfy code inspectors
 var link = $(this); //preselect the link
 if (link.hasClass('hover')) {
  return true;
 } 
 else {
  $('#chapters div[id]').removeClass('hover'); 
  link.addClass('hover'); 
  return false; //extra, and to make sure the function has consistent return points
 } 
});

/*
$('#chapters div[id] > ul').hide();
$('#chapters div[id]').on("hover", function (e) { 
  e.preventDefault;
  $(this).children('ul').toggle('slow');
});
*/
/*****************
         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) {
                        if (h[i].offsetTop>screen.availHeight) { 
var top= function( ) {window.scrollTo(0,0);}
var arrow = $("<a>top</a>").attr({ 
title: "zum Seitenanfang",
"class": "toparrow noprint"
}) 
$(arrow).on( "click", top);

arrow.appendTo( h[i] );
                        }
                }
        }
}
$(PageHomeArrows);