MediaWiki:Common.js

aus GlossarWiki, der Glossar-Datenbank der Fachhochschule Augsburg
Version vom 24. Mai 2019, 12:15 Uhr von Kowa (Diskussion | Beiträge)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)

Hinweis: Leeren Sie nach dem Veröffentlichen den Browser-Cache, um die Änderungen sehen zu können.

  • Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
  • Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
  • Internet Explorer / Edge: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
  • Opera: Gehen Sie zu Menü → Einstellungen (Opera → Einstellungen auf dem Mac) und dann auf Datenschutz & Sicherheit → Browserdaten löschen → Gespeicherte Bilder und Dateien.
/* Das folgende JavaScript wird für alle Benutzer geladen. */
mw.config.set('tableSorterCollation', {'ä':'ae', 'ö' : 'oe', 'ß': 'ss', 'ü':'ue'});

//<source lang="javascript">
// Faster Collapsible Containers
// Maintainer: [[User:Darklama]]
 
// images to use for hide/show states
var collapse_action_hide = '//upload.wikimedia.org/wikipedia/commons/1/10/MediaWiki_Vector_skin_action_arrow.png';
var collapse_action_show = '//upload.wikimedia.org/wikipedia/commons/4/41/MediaWiki_Vector_skin_right_arrow.png';
 
// toggle state of collapsible boxes
function collapsible_boxes()
{
	$('div.collapsible').each( function() {
		var $that = $(this); //, css_width = $that.css('width'), attr_width = $that.attr('width');
		var which = $that.hasClass('selected') ? collapse_action_show : collapse_action_hide;
 
		//if ( (!css_width || css_width == 'auto') && (!attr_width || attr_width == 'auto') ) {
		//	$that.css('width', $that.width() );
		//}
 
		$(this).children('.title').each( function() {
			$(this).prepend('<span class="action"><a><img src="'+which+'" /></a></span>').click( function() {
				var which = $that.toggleClass('selected').hasClass('selected')
					? collapse_action_show : collapse_action_hide;
				$(this).find('span.action img').attr('src', which);
				if ( which == collapse_action_show ) {
					$(this).siblings(':not(.title)').hide(); //stop(true, true).fadeOut();
				} else {
					$(this).siblings(':not(.title)').show(); //stop(true, true).fadeIn();
				}
			}).click();
		});
	});
 
	$( "table.collapsible" ).each( function() {
		var $table = $(this), rows = this.rows, cell = rows.item(0).cells.item(0);
		var which = $table.hasClass('selected') ? collapse_action_show : collapse_action_hide;
		var css_width = $table.css('width'), attr_width = $table.attr('width');
 
		if ( (!css_width || css_width == 'auto') && (!attr_width || attr_width == 'auto') ) {
			$table.css('width', $table.width() );
		}
 
		$(cell).prepend('<span class="action"><a><img src="'+which+'" /></a></span>');
		$(rows.item(0)).click( function() {
			var which = $table.toggleClass('selected').hasClass('selected')
				? collapse_action_show : collapse_action_hide;
			$(cell).find('span.action img').attr('src', which);
			if ( which == collapse_action_show ) {
				$(rows).next().stop(true, true).fadeOut();
			} else {
				$(rows).next().stop(true, true).fadeIn();
			}
		}).click();
	});
}
 
/*
		TOOLTIP
*/

	$( function()
	{
		var targets = $( '[rel~=tooltip]' ),
			target	= false,
			tooltip = false,
			title	= false;

		targets.bind( 'mouseenter', function()
		{
			target	= $( this );
			tip		= target.attr( 'title' );
			tooltip	= $( '<div id="tooltip"></div>' );

			if( !tip || tip == '' )
				return false;

			target.removeAttr( 'title' );
			tooltip.css( 'opacity', 0 )
				   .html( tip )
				   .appendTo( 'body' );

			var init_tooltip = function()
			{
				if( $( window ).width() < tooltip.outerWidth() * 1.5 )
					tooltip.css( 'max-width', $( window ).width() / 2 );
				else
					tooltip.css( 'max-width', 340 );

				var pos_left = target.offset().left + ( target.outerWidth() / 2 ) - ( tooltip.outerWidth() / 2 ),
					pos_top	 = target.offset().top - tooltip.outerHeight() - 20;

				if( pos_left < 0 )
				{
					pos_left = target.offset().left + target.outerWidth() / 2 - 20;
					tooltip.addClass( 'left' );
				}
				else
					tooltip.removeClass( 'left' );

				if( pos_left + tooltip.outerWidth() > $( window ).width() )
				{
					pos_left = target.offset().left - tooltip.outerWidth() + target.outerWidth() / 2 + 20;
					tooltip.addClass( 'right' );
				}
				else
					tooltip.removeClass( 'right' );

				if( pos_top < 0 )
				{
					var pos_top	 = target.offset().top + target.outerHeight();
					tooltip.addClass( 'top' );
				}
				else
					tooltip.removeClass( 'top' );

				tooltip.css( { left: pos_left, top: pos_top } )
					   .animate( { top: '+=10', opacity: 1 }, 50 );
			};

			init_tooltip();
			$( window ).resize( init_tooltip );

			var remove_tooltip = function()
			{
				tooltip.animate( { top: '-=10', opacity: 0 }, 50, function()
				{
					$( this ).remove();
				});

				target.attr( 'title', tip );
			};

			target.bind( 'mouseleave', remove_tooltip );
			tooltip.bind( 'click', remove_tooltip );
		});
	});

$(document).ready( collapsible_boxes );
 
//</source>