MediaWiki:Common.js: Unterschied zwischen den Versionen

Zur Navigation springen Zur Suche springen
Zeile 179: Zeile 179:
  
 
}( jQuery, mediaWiki ) );
 
}( jQuery, mediaWiki ) );
 +
 +
 +
/*****************
 +
        Zitieren
 +
*****************/
 +
$('#z_hide').hide();
 +
$(document).on('click', '#zitieren', function() {
 +
  $(this).toggleClass('zShow');
 +
  $('#z_hide').slideToggle('slow');
 +
});
 +
$(document).on('click', '#z_X, a[href*="#zitieren"]', function() {
 +
    $('#zitieren').trigger('click');
 +
});

Version vom 18. Dezember 2018, 14:18 Uhr

for (var i in wgUserGroups)
 if (wgUserGroups[i] === 'sysop')
  var sysopRights = true; 

/********************* 
	GLOSSAR 
*********************/ 

// s.a. vorlage:glossar  
$('.glossar').each(function(){
  var child = $(this).find('.g_box')
    , parent = $(this).closest('p, li') ; 
  $( parent).css("position", "relative");   
 
  var diff = ($(this).width() - $(child).width()) / 2
    , left = $(this).position().left + diff
    , right = $(parent).width() - ($(this).position().left + $(child).width() + 14);
 
   if ( left < -10) {
     $( child).css("left", diff - left -10 + 'px'); 
   }
    if (right < 0 ) { 
     $( child).css("left", right + 'px');
   }
 
  $( this ).click(function(){ $( child).slideToggle('slow'); });
  $( this ).mouseleave(function(){ $(child).slideUp('slow'); }); 
 
});
 
/***********************************
   NAVIGATION
************************************/

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

/***********************************
       Change redirected address line 
***********************************/
( function ( $, mw ) {
	if ( !window.history || !window.history.replaceState ) {
		return;
	}
 
	mw.loader.using( 'jquery.mwExtension', function () {
		var articlePathRE, pathQuery, path;
 
		articlePathRE = new RegExp(
			'^' +
			$.escapeRE( mw.config.get( 'wgArticlePath' ) ).replace( '\\$1', mw.config.get( 'wgArticlePath' ).indexOf( '?' ) >= -1 ? '([^?]*)' : '([^&]*)' ) +
			'$'
		);
		pathQuery = location.pathname + ( location.search ? '?' + location.search : '' );
		// Only execute on paths matching the article path (don't squash query arguments)
		if ( articlePathRE.test( pathQuery ) ) {
			path = mw.util.wikiGetlink( mw.config.get( 'wgPageName' ) );
			path += window.location.hash || '';
			window.history.replaceState( {}, document.title, path );
		}
	} );

}( jQuery, mediaWiki ) );


/*****************
         Zitieren
*****************/
$('#z_hide').hide();
$(document).on('click', '#zitieren', function() {
   $(this).toggleClass('zShow');
   $('#z_hide').slideToggle('slow');
});
$(document).on('click', '#z_X, a[href*="#zitieren"]', function() {
    $('#zitieren').trigger('click');
});