MediaWiki:Common.js: Unterschied zwischen den Versionen

Aus OBS Wiki
Zur Navigation springen Zur Suche springen
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
 
(3 dazwischenliegende Versionen von einem anderen Benutzer werden nicht angezeigt)
Zeile 19: Zeile 19:
         }
         }
}
}
 
/* this does not work at all :( */
/*
// Book specific
// Book specific
var wgBookName = ( mw.config.get( 'wgPageName' ).split( '/', 1)[0] || '' ).split( ':', 2 ).join( ':' );
var wgBookName = ( mw.config.get( 'wgPageName' ).split( '/', 1)[0] || '' ).split( ':', 2 ).join( ':' );
Zeile 58: Zeile 59:
  }
  }
}
}
*/
// Faster Collapsible Containers
// Maintainer: [[User:Darklama]]
// images to use for hide/show states
var collapse_action_hide = 'https://upload.wikimedia.org/wikipedia/commons/1/10/MediaWiki_Vector_skin_action_arrow.png';
var collapse_action_show = 'https://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() {
        //Ausnahme für collapsible's die ein selflink besitzen müssen immer ausgeklappt sein
       
var $that = $(this), css_width = $that.css('width'), attr_width = $that.attr('width');
       
        //Wenn die div ein "selflink" besitzt muss es ausgeklappt sein (selected muss entfernt werden)
        //console.log($(this).value);
       
        $(this).children('.body').each( function() {
          if(this.innerHTML.indexOf('selflink') !== -1 ){
            //$(this).siblings(':not(.title)').stop(true, true).fadeIn();
            //$that.removeClass('selected');
            var which = $that.toggleClass('selected').hasClass('selected')
? collapse_action_show : collapse_action_hide;
            $(this).siblings(':not(.title)').stop(true, true).fadeOut();
            //$(this).children('.title').click();
            //alert(this.innerHTML);
          }
        });       
       
        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)').stop(true, true).fadeOut();
} else {
$(this).siblings(':not(.title)').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();
});
}
$(document).ready( collapsible_boxes );

Aktuelle Version vom 22. Mai 2018, 10:13 Uhr

/* Das folgende JavaScript wird für alle Benutzer geladen. */
/**
 * Redirect User:Name/skin.js and skin.css to the current skin's pages
 * (unless the 'skin' page really exists)
 * @source: http://www.mediawiki.org/wiki/Snippets/Redirect_skin.js
 * @rev: 2
 */
if ( mw.config.get( 'wgArticleId' ) == 0 && mw.config.get( 'wgNamespaceNumber' ) == 2 ) {
        var titleParts = mw.config.get( 'wgPageName' ).split( '/' );
        // Make sure there was a part before and after the slash
        // And that the latter is 'skin.js' or 'skin.css'
        if ( titleParts.length == 2 ) {
                var userSkinPage = titleParts.shift() + '/' + mw.config.get( 'skin' );
                if ( titleParts.slice(-1) == 'skin.js' ) {
                        window.location.href = mw.util.wikiGetlink( userSkinPage + '.js' );
                } else if ( titleParts.slice(-1) == 'skin.css' ) {
                        window.location.href = mw.util.wikiGetlink( userSkinPage + '.css' );
                }
        }
}
/* this does not work at all :( */
/*
// Book specific
var wgBookName = ( mw.config.get( 'wgPageName' ).split( '/', 1)[0] || '' ).split( ':', 2 ).join( ':' );
importStylesheet('MediaWiki:Common.css/' + wgBookName);

// makeCollapsible (remove when deployed)
importStylesheet('MediaWiki:JQuery-makeCollapsible.css');
importScript('MediaWiki:JQuery-makeCollapsible.js'); 

// Imported scripts
importScript('MediaWiki:Common.js/Relics.js');
importScript('MediaWiki:Common.js/ExtraTools.js');
importScript('MediaWiki:Common.js/CollapseElements.js');
importScript('MediaWiki:Common.js/NavigationTabs.js');
importScript('MediaWiki:Common.js/Displaytitle.js');
importScript('MediaWiki:Common.js/RandomBook.js');
importScript('MediaWiki:Common.js/Perbook.js');
importScript('MediaWiki:Common.js/tabs.js');
importScript('MediaWiki:Common.js/top.js');
importScript('MediaWiki:Common.js/review.js');
importScript('MediaWiki:Common.js/Categories.js');
importScript('MediaWiki:Common.js/use.js');

if ( mw.config.get( 'wgCanonicalSpecialPageName' ) == 'Watchlist' ) {
	importScript('MediaWiki:Common.js/WatchlistNotice.js');
} else if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit', 'upload'] ) != -1 ) {
	importScript('MediaWiki:Common.js/Special_characters.js');
	importScript('MediaWiki:Common.js/Toolbox.js');
}

// Load sysop-specific JavaScript/CSS from [[MediaWiki:Common.js/Sysop.js]] and [[MediaWiki:Common.css/Sysop.css]]
if ( $.inArray( 'sysop', wgUserGroups) > -1 ) {
 importStylesheet('MediaWiki:Common.css/Sysop.css');
 if ( !window.disableSysopJS ) {
  $(function(){
   importScript('MediaWiki:Common.js/Sysop.js');
  });
 }
}
*/

// Faster Collapsible Containers
// Maintainer: [[User:Darklama]]

// images to use for hide/show states
var collapse_action_hide = 'https://upload.wikimedia.org/wikipedia/commons/1/10/MediaWiki_Vector_skin_action_arrow.png';
var collapse_action_show = 'https://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() {
        //Ausnahme für collapsible's die ein selflink besitzen müssen immer ausgeklappt sein
        
		var $that = $(this), css_width = $that.css('width'), attr_width = $that.attr('width');		
        
        //Wenn die div ein "selflink" besitzt muss es ausgeklappt sein (selected muss entfernt werden)
        //console.log($(this).value);
        
        $(this).children('.body').each( function() {
           if(this.innerHTML.indexOf('selflink') !== -1 ){
             //$(this).siblings(':not(.title)').stop(true, true).fadeIn();
             //$that.removeClass('selected');
             var which = $that.toggleClass('selected').hasClass('selected')
					? collapse_action_show : collapse_action_hide;
             $(this).siblings(':not(.title)').stop(true, true).fadeOut();
             //$(this).children('.title').click();
             //alert(this.innerHTML);
           }
        });        
        
        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)').stop(true, true).fadeOut();
				} else {
					$(this).siblings(':not(.title)').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();
	});
}

$(document).ready( collapsible_boxes );