MediaWiki:Common.js: Unterschied zwischen den Versionen

Aus KiwiThek
Wechseln zu: Navigation, Suche
 
(123 dazwischenliegende Versionen von 2 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
//<source lang="JavaScript">
+
/**
+
  * MediaWiki:Common.js
/** Extra toolbar options ******************************************************
 
  *
 
*  Description: Adds extra buttons to the editing toolbar.
 
 
*  To disable this script, add <code>mwCustomEditButtons = [];<code> to [[Special:Mypage/monobook.js]].
 
 
*  Maintainers: [[User:MarkS]], [[User:Voice of All]], [[User:R. Koot]]
 
 
  */
 
  */
+
 
if (mwCustomEditButtons) {
+
// remove empty p-Tags & hide p-Tags only containing br-Tags
    mwCustomEditButtons.push({
+
$content = jQuery( '#content' );
        "imageFile": "http://upload.wikimedia.org/wikipedia/en/c/c8/Button_redirect.png",
+
$content.remove( 'p:empty' );
        "speedTip": "Redirect",
+
$content.find( 'p > br' ).each( function ( i, e ) {
        "tagOpen": "#REDIRECT [[",
+
$br = jQuery( e );
        "tagClose": "]]",
+
if (
        "sampleText": "Target page name"
+
$br.siblings().length === 0 &&
    });
+
$br.parent().text().trim().length === 0
+
) {
    mwCustomEditButtons.push({
+
$br.parent().hide()
        "imageFile": "http://upload.wikimedia.org/wikipedia/en/c/c9/Button_strike.png",
+
}
        "speedTip": "Strike",
+
} );
        "tagOpen": "<s>",
+
 
        "tagClose": "</s>",
+
// set language code
        "sampleText": "Strike-through text"
+
var languageCode = "de";
    });
+
var urlParameterDeEasy = "einfach";
+
if ( window.location.href.indexOf( urlParameterDeEasy ) > -1 ) {
    mwCustomEditButtons.push({
+
languageCode = "de-easy";
        "imageFile": "http://upload.wikimedia.org/wikipedia/en/1/13/Button_enter.png",
 
        "speedTip": "Line break",
 
        "tagOpen": "<br />",
 
        "tagClose": "",
 
        "sampleText": ""
 
    });
 
 
    mwCustomEditButtons.push({
 
        "imageFile": "http://upload.wikimedia.org/wikipedia/en/8/80/Button_upper_letter.png",
 
        "speedTip": "Superscript",
 
        "tagOpen": "<sup>",
 
        "tagClose": "</sup>",
 
        "sampleText": "Superscript text"
 
    });
 
 
    mwCustomEditButtons.push({
 
        "imageFile": "http://upload.wikimedia.org/wikipedia/en/7/70/Button_lower_letter.png",
 
        "speedTip": "Subscript",
 
        "tagOpen": "<sub>",
 
        "tagClose": "</sub>",
 
        "sampleText": "Subscript text"
 
    });
 
 
    mwCustomEditButtons.push({
 
        "imageFile": "http://upload.wikimedia.org/wikipedia/en/5/58/Button_small.png",
 
        "speedTip": "Small",
 
        "tagOpen": "<small>",
 
        "tagClose": "</small>",
 
        "sampleText": "Small Text"
 
    });
 
 
    mwCustomEditButtons.push({
 
        "imageFile": "http://upload.wikimedia.org/wikipedia/en/3/34/Button_hide_comment.png",
 
        "speedTip": "Insert hidden Comment",
 
        "tagOpen": "<!-- ",
 
        "tagClose": " -->",
 
        "sampleText": "Comment"
 
    });
 
 
    mwCustomEditButtons.push({
 
        "imageFile": "http://upload.wikimedia.org/wikipedia/en/1/12/Button_gallery.png",
 
        "speedTip": "Insert a picture gallery",
 
        "tagOpen": "\n<gallery>\n",
 
        "tagClose": "\n</gallery>",
 
        "sampleText": "Image:Example.jpg|Caption1\nImage:Example.jpg|Caption2"
 
    });
 
 
    mwCustomEditButtons.push({
 
        "imageFile": "http://upload.wikimedia.org/wikipedia/en/f/fd/Button_blockquote.png",
 
        "speedTip": "Insert block of quoted text",
 
        "tagOpen": "<blockquote>\n",
 
        "tagClose": "\n</blockquote>",
 
        "sampleText": "Block quote"
 
    });
 
 
    mwCustomEditButtons.push({
 
        "imageFile": "http://upload.wikimedia.org/wikipedia/en/6/60/Button_insert_table.png",
 
        "speedTip": "Insert a table",
 
        "tagOpen": '{| class="wikitable"\n|',
 
        "tagClose": "\n|}",
 
        "sampleText": "-\n! header 1\n! header 2\n! header 3\n|-\n| row 1, cell 1\n| row 1, cell 2\n| row 1, cell 3\n|-\n| row 2, cell 1\n| row 2, cell 2\n| row 2, cell 3"
 
    });
 
 
    mwCustomEditButtons.push({
 
        "imageFile": "http://upload.wikimedia.org/wikipedia/commons/7/79/Button_reflink.png",
 
        "speedTip": "Insert a reference",
 
        "tagOpen": "<ref>",
 
        "tagClose": "</ref>",
 
        "sampleText": "Insert footnote text here"
 
    });
 
 
}
 
}
+
jQuery( '#mw-content-text' ).attr( 'lang', languageCode );
+
jQuery( 'body' ).attr( 'lang', languageCode );
//fix edit summary prompt for undo
+
 
//this code fixes the fact that the undo function combined with the "no edit summary prompter" causes problems if leaving the
+
// increase body height to match sidebar height
//edit summary unchanged
+
var sidebarHeight = jQuery( '#mw-panel' ).outerHeight();
//this was added by [[User:Deskana]], code by [[User:Tra]]
+
var bodyHeight = jQuery( 'body.mediawiki' ).outerHeight();
//see bug 8912
+
if ( sidebarHeight > bodyHeight ) {
addOnloadHook(function () {
+
jQuery( '#footer' ).css( 'margin-bottom', sidebarHeight - bodyHeight );
    if (document.location.search.indexOf("undo=") != -1
+
} else {
        && document.getElementsByName('wpAutoSummary')[0]) {
+
jQuery( '#mw-panel' ).height( jQuery( 'body' ).height() )
        document.getElementsByName('wpAutoSummary')[0].value='1';
+
}
    }
+
 
})
+
// replace registration link
+
jQuery( '#pt-createaccount' )
/** Edittools javascript loader ************************************************
+
.attr( 'id', 'pt-gettingstarted' );
*
+
jQuery( '#pt-gettingstarted a' )
*  Description: Pulls in [[MediaWiki:Edittools.js]]. Includes a cache-bypassing
+
.attr( 'href', '/index.php/Kiwithek:Getting_Started' )
*  version number in the URL in order to allow any changes to the edittools to
+
.attr( 'title', 'Lies nach, wie du mit uns in Kontakt treten kannst um an der KiwiThek mitzuarbeiten.' )
*  be rapidly deployed to users.
+
.text( 'Getting Started' );
*
+
 
*  Note that, by default, this function does nothing unless the element with
+
// insert Bildinformationen template into uploaded file page
*  the ID "editpage-specialchars" (which contains the old edittools code in
+
var template = '{{Bildinformationen\n' +
*  [[MediaWiki:Edittools]], and will be retained as a placeholder in the new
+
'| Beschreibung = Bitte bearbeite mich und fülle die Bildinfos aus!\n' +
*  implementation) has a class named "edittools-version-NNN", where NNN is a
+
'| Urheber =\n' +
*  number. If the class name has "test" before the number, the code will only
+
'| Herausgeber =\n' +
*  run for users who have set "window.testJsEdittools = true" in their user JS.
+
'| QuelleText =\n' +
*  The "test" should be retained in the class name until the new edittools
+
'| QuelleUrl =\n' +
*  implementation is ready and fully tested, and until at least 30 days have
+
'| LizenzText =\n' +
*  passed since this loader stub was added (which will be in 27 June 2008).
+
'| LizenzUrl =\n' +
*
+
'| Originaltitel =\n' +
*  For compatibility with Alex Smotrov's original implementation, on which this
+
'| Bearbeitung =\n' +
*  code is loosely based (see [[mw:User talk:Alex Smotrov/edittools.js]]), this
+
'| GeoLand =\n' +
*  loader can also be disabled by setting "window.noDefaultEdittools = true".
+
'| GeoRegion =\n' +
*
+
'| GeoGPSNorth =\n' +
*  Maintainers: [[User:Ilmari Karonen]]
+
'| GeoGPSEast =\n' +
*/
+
'| Sonstiges =\n' +
+
'}}'
addOnloadHook(function () {
+
jQuery( '#wpUploadDescription' ).val(template)
    // needs to be deferred until the DOM has fully loaded
+
 
    var placeholder = document.getElementById("editpage-specialchars");
+
// Badge: Page created by children
    if (!placeholder || window.noDefaultEdittools) return;
+
var hasCreatedByChildrenCategory = jQuery('#catlinks').
    var match = /(?:^| )edittools-version-(\d+)(?: |$)/.exec(placeholder.className);
+
  text().
+
  indexOf('Seiten von Schulteams') >= 0
    // set window.testJsEdittools = true to enable testing before full deployment
+
if (hasCreatedByChildrenCategory) {
    if (!match && window.testJsEdittools)
+
  var $pageByChildrenNode = jQuery('<div class="badge badge--children"><img src="/resources/assets/klassenseite_logo.svg" alt="Diese Seite wurde von SchülerInnen erstellt" title="Diese Seite wurde von SchülerInnen erstellt"></div>')
        match = /(?:^| )edittools-version-(test\d+)(?: |$)/.exec(placeholder.className);
+
 
+
  jQuery($pageByChildrenNode).insertAfter('#firstHeading')
    if (!match) return;
+
}
    var url = wgScript + '?title=MediaWiki:Edittools.js&action=raw&ctype=text/javascript&nocache=' + match[1];
+
 
    importScriptURI(url);
+
jQuery('#footer-places-disclaimer').find('a')
});
+
  .attr('href', 'https://lehrerweb.wien/footer-nav/impressum')
+
  .attr('target', '_blank')
//</source>
 

Aktuelle Version vom 20. März 2024, 13:26 Uhr

/**
 * MediaWiki:Common.js
 */

// remove empty p-Tags & hide p-Tags only containing br-Tags
$content = jQuery( '#content' );
$content.remove( 'p:empty' );
$content.find( 'p > br' ).each( function ( i, e ) {
	$br = jQuery( e );
	if (
		$br.siblings().length === 0 &&
		$br.parent().text().trim().length === 0
	) {
		$br.parent().hide()
	}
} );

// set language code
var languageCode = "de";
var urlParameterDeEasy = "einfach";
if ( window.location.href.indexOf( urlParameterDeEasy ) > -1 ) {
	languageCode = "de-easy";
}
jQuery( '#mw-content-text' ).attr( 'lang', languageCode );
jQuery( 'body' ).attr( 'lang', languageCode );

// increase body height to match sidebar height
var sidebarHeight = jQuery( '#mw-panel' ).outerHeight();
var bodyHeight = jQuery( 'body.mediawiki' ).outerHeight();
if ( sidebarHeight > bodyHeight ) {
	jQuery( '#footer' ).css( 'margin-bottom', sidebarHeight - bodyHeight );
} else {
	jQuery( '#mw-panel' ).height( jQuery( 'body' ).height() )
}

// replace registration link
jQuery( '#pt-createaccount' )
	.attr( 'id', 'pt-gettingstarted' );
jQuery( '#pt-gettingstarted a' )
	.attr( 'href', '/index.php/Kiwithek:Getting_Started' )
	.attr( 'title', 'Lies nach, wie du mit uns in Kontakt treten kannst um an der KiwiThek mitzuarbeiten.' )
	.text( 'Getting Started' );

// insert Bildinformationen template into uploaded file page
var template = '{{Bildinformationen\n' +
	'| Beschreibung = Bitte bearbeite mich und fülle die Bildinfos aus!\n' +
	'| Urheber =\n' +
	'| Herausgeber =\n' +
	'| QuelleText =\n' +
	'| QuelleUrl =\n' +
	'| LizenzText =\n' +
	'| LizenzUrl =\n' +
	'| Originaltitel =\n' +
	'| Bearbeitung =\n' +
	'| GeoLand =\n' +
	'| GeoRegion =\n' +
	'| GeoGPSNorth =\n' +
	'| GeoGPSEast =\n' +
	'| Sonstiges =\n' +
	'}}'
jQuery( '#wpUploadDescription' ).val(template)

// Badge: Page created by children
var hasCreatedByChildrenCategory = jQuery('#catlinks').
  text().
  indexOf('Seiten von Schulteams') >= 0
if (hasCreatedByChildrenCategory) {
  var $pageByChildrenNode = jQuery('<div class="badge badge--children"><img src="/resources/assets/klassenseite_logo.svg" alt="Diese Seite wurde von SchülerInnen erstellt" title="Diese Seite wurde von SchülerInnen erstellt"></div>')

  jQuery($pageByChildrenNode).insertAfter('#firstHeading')
}

jQuery('#footer-places-disclaimer').find('a')
  .attr('href', 'https://lehrerweb.wien/footer-nav/impressum')
  .attr('target', '_blank')