Lista haseł | Kategorie artykułów | Prześlij plik | Lista plików | Pomoc | Kontakt
Pnikut.net
Aby utworzyć nowe konto użytkownika należy postępować zgodnie z zaleceniami na stronie Tworzenie konta użytkownika.

MediaWiki:Gadget-small-sections.js

Z Wiki.Pnikuczanie
Skocz do: nawigacji, wyszukiwania

Uwaga: aby zobaczyć zmiany po zapisaniu, może zajść potrzeba wyczyszczenia pamięci podręcznej przeglądarki.

  • Firefox / Safari: Przytrzymaj Shift podczas klikania Odśwież bieżącą stronę, lub naciśnij klawisze Ctrl+F5 lub Ctrl+R (⌘-R na komputerze Mac)
  • Google Chrome: Naciśnij Ctrl-Shift-R (⌘-Shift-R na komputerze Mac)
  • Internet Explorer: Przytrzymaj Ctrl jednocześnie klikając Odśwież lub naciśnij klawisze Ctrl+F5
  • Opera: Wyczyść pamięć podręczną w Narzędzia → Preferencje
// <pre>
// Author: [[pl:User:Beau]]
var sectionCripplingGadget = {
	version: 9,
	crippledSections: {},

	/**
	 * Inicjacja gadżetu
	 */
	init: function() {
		// Tylko przestrzeń główna i użytkowników
		if ( mw.config.get( 'wgNamespaceNumber' ) !== 0 && mw.config.get( 'wgNamespaceNumber' ) !== 2 ) {
			return;
		}

		//if ( mw.user.options.get( 'gadget-small-references', 0 ) == 1 ) {
		//	this.crippledSections['Przypisy'] = 'section-references';
		//}
		if ( mw.user.options.get( 'gadget-small-notes', 0 ) == 1 ) {
			this.crippledSections['Uwagi'] = 'section-notes';
		}
		if ( mw.user.options.get( 'gadget-small-bibliography', 0 ) == 1 ) {
			this.crippledSections['Bibliografia'] = 'section-bibliography';
		}
		if ( mw.user.options.get( 'gadget-small-external-links', 0 ) == 1 ) {
			this.crippledSections['Linki zewnętrzne'] = 'section-external-links';
		}
		if ( mw.user.options.get( 'gadget-small-see-also', 0 ) == 1 ) {
			this.crippledSections['Zobacz też'] = 'section-see-also';
		}

		var contentText = null;

		if ( mw.config.get( 'wgAction' ) === 'view' ) {
			// Czytanie
			contentText = document.getElementById( 'mw-content-text' );
		} else if ( mw.config.get( 'wgAction' ) === 'submit' ) {
			// Podgląd edycji
			contentText = jQuery( '#wikiPreview' ).children().eq( 1 )[0];
		}

		if ( !contentText ) {
			return;
		}

		var stylize = null;
		var currentNode = contentText.firstChild;

		var numberHeadings = ( mw.user.options.get( 'numberheadings', 0 ) == 1 );

		while ( currentNode ) {
			if ( currentNode.tagName && currentNode.tagName.match( /^H[1-6]$/ ) ) {
				stylize = null;

				var text = jQuery.trim( jQuery( currentNode ).children( '.mw-headline' ).text() );
				if ( numberHeadings ) {
					// Usuń numerację
					text = text.replace( /^\d+\s*/g, '' );
				}
				stylize = this.crippledSections[text];
			} else if ( stylize !== null ) {
				$currentNode = jQuery( currentNode );
				if ( !$currentNode.hasClass( 'do-not-make-smaller' ) ) {
					$currentNode.addClass( "section-small " + stylize );
				}
			}
			currentNode = currentNode.nextSibling;
		}
	}
};

jQuery( document ).ready( function() {
	sectionCripplingGadget.init()
} );
// </pre>