MediaWiki:Vector.js: Unterschied zwischen den Versionen

Aus MoBaDaten
Wechseln zu: Navigation, Suche
 
(41 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
/* Das folgende JavaScript wird für Benutzer geladen, die den Vector-Skin verwenden. Allgemeingültiges JavaScript bitte in [[MediaWiki:Common.js]] eintragen. */
 
 
/* Der Grossteil der Codes befindet sich in [[MediaWiki:Common.js]] */
 
 
 
  /*
 
  /*
 
   * moveEditsection
 
   * moveEditsection
Zeile 15: Zeile 11:
 
   *
 
   *
 
   * dbenzhuser (de:Benutzer:Dbenzhuser)
 
   * dbenzhuser (de:Benutzer:Dbenzhuser)
   * Angepasst nach Vorschlag von http://de.wikipedia.org/w/index.php?title=MediaWiki_Diskussion:Vector.js&oldid=75510836
+
   * Angepasst nach Vorschlag von https://de.wikipedia.org/w/index.php?title=MediaWiki_Diskussion:Vector.js&oldid=75510836
 
   */
 
   */
  addOnloadHook(
+
  $( function () {
  function () {
 
 
     if (typeof oldEditsectionLinks != 'undefined' && oldEditsectionLinks)   
 
     if (typeof oldEditsectionLinks != 'undefined' && oldEditsectionLinks)   
 
       return;
 
       return;
     appendCSS(".editsection{float:none;margin-left:0}");
+
     appendCSS("#bodyContent .editsection{float:none;margin-left:0}");
     var elt, item;
+
     var elt, item, numChilds;
 
     var root=document.getElementById("content");
 
     var root=document.getElementById("content");
 
     for (var i=1; i <= 6; ++i) {
 
     for (var i=1; i <= 6; ++i) {
Zeile 29: Zeile 24:
 
         item=list[j];
 
         item=list[j];
 
         numChilds=item.childNodes.length;
 
         numChilds=item.childNodes.length;
         if (numChilds > 1 && item.firstChild.className == "editsection")
+
         if (numChilds > 1 && item.firstChild.className === "editsection")
 
         {
 
         {
 
           // Zuerst das Leerzeichen von hinter dem Bearbeiten Link davor
 
           // Zuerst das Leerzeichen von hinter dem Bearbeiten Link davor
Zeile 41: Zeile 36:
 
  });
 
  });
  
/*
+
/* ================================================================ */
  * showTopicon
+
 
  * Funktion zum Anzeigen von Bewertungskästchen im rechten oberen Bereich des Artikels,
+
var customizeToolbar = function() {
  * um exzellente bzw. lesenswerte Artikel, ausgezeichnete Bilder und dergleichen zu kennzeichnen.
+
/* ###### Unterstrichen */
  *
+
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
  * Abschaltbar für angemeldete Benutzer, einfach 'dontShowTopicons = true' in die eigene vector.js aufnehmen
+
        'section': 'main',
  *
+
        'group': 'format',
  * Der Code basiert auf der Lösung der frWP
+
        'tools': {
  */
+
                'underlined': {
var dontShowTopicons = false;
+
                        label: 'Unterstrichen', // or use labelMsg for a localized label, see above
addOnloadHook(
+
                        type: 'button',
  function() {
+
                        icon: 'http://www.mobadaten.info/MoBaDatenInfo/images/1/13/Toolbaricon_regular_U_underline.png',
    if (dontShowTopicons) return;
+
                        action: {
    var h1 = document.getElementById("firstHeading");
+
                                type: 'encapsulate',
    var bc = document.getElementById("bodyContent");
+
                                options: {
    if (!h1 || !bc)
+
                                        pre: "<u>", // text to be inserted
      return;
+
                                        periMsg: "Unterstrichener Text",
    var icons = getElementsByClassName(bc, "div", "topicon");
+
                                        post: "</u>"
    for (var j = icons.length; j > 0; --j) {
+
                                }
      var icon = icons[j-1];
+
                        }
      h1.parentNode.insertBefore(icon, h1);
+
                }
      icon.style.cssFloat = icon.style.styleFloat = "right";
+
        }
      icon.style.marginLeft = "3px";
+
} );
      icon.style.display = "block";
+
/* ###### Festes Leerzeichen */
    }
+
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
});
+
        'section': 'advanced',
 +
        'group': 'format',
 +
        'tools': {
 +
                'hardspace': {
 +
                        label: 'Festes Leerzeichen',
 +
                        type: 'button',
 +
                        icon: 'http://www.mobadaten.info/MoBaDatenInfo/images/1/1b/Button_hardspace_clear.png',
 +
                        action: {
 +
                                type : 'encapsulate',
 +
                                options: {
 +
                                        pre: "{{~}}"
 +
                                }
 +
                        }
 +
                }
 +
        }
 +
} );
 +
/* ###### Zeilenumbruch */
 +
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 +
        'section': 'advanced',
 +
        'group': 'format',
 +
        'tools': {
 +
                'wordwrap': {
 +
                        label: 'Zeilenumbruch',
 +
                        type: 'button',
 +
                        icon: 'http://www.mobadaten.info/MoBaDatenInfo/images/0/09/Button_wordwrap_clear.png',
 +
                        action: {
 +
                                type : 'encapsulate',
 +
                                options: {
 +
                                        pre: "{{+}}"
 +
                                }
 +
                        }
 +
                }
 +
        }
 +
} );
 +
/* ###### Zeilenumbruch */
 +
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 +
        'section': 'advanced',
 +
        'group': 'format',
 +
        'tools': {
 +
                'endoffloat': {
 +
                        label: 'Fließtextende (für linksseitige Objekte)',
 +
                        type: 'button',
 +
                        icon: 'http://www.mobadaten.info/MoBaDatenInfo/images/5/5d/Button_EndOfFloat_clear.png',
 +
                        action: {
 +
                                type : 'encapsulate',
 +
                                options: {
 +
                                        pre: "{{+clr}}"
 +
                                }
 +
                        }
 +
                }
 +
        }
 +
} );
 +
/* ###### Zeilenumbruch rechts*/
 +
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 +
        'section': 'advanced',
 +
        'group': 'format',
 +
        'tools': {
 +
                'endoffloatright': {
 +
                        label: 'Fließtextende (für rechtsseitige Objekte)',
 +
                        type: 'button',
 +
                        icon: 'http://www.mobadaten.info/MoBaDatenInfo/images/c/c1/Button_EndOfFloatRight_clear.png',
 +
                        action: {
 +
                                type : 'encapsulate',
 +
                                options: {
 +
                                        pre: "{{+clr+}}"
 +
                                }
 +
                        }
 +
                }
 +
        }
 +
} );
 +
/* ###### Gruppe Verschiedenes */
 +
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 +
        'section': 'advanced',
 +
        'groups': {
 +
                'misc': {
 +
                        'label': 'Diverses' // or use labelMsg for a localized label, see above
 +
                }
 +
        }
 +
} );
 +
/* ###### Quellenangabe */
 +
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 +
        'section': 'advanced',
 +
        'group': 'misc',
 +
        'tools': {
 +
                'tmplsrc': {
 +
                        label: 'Quellenangabe', // or use labelMsg for a localized label, see above
 +
                        type: 'button',
 +
                        icon: 'http://www.mobadaten.info/MoBaDatenInfo/images/2/29/Button_fuente_clear.png',
 +
                        action: {
 +
                                type: 'encapsulate',
 +
                                options: {
 +
                                        pre: "{{Source|", // text to be inserted
 +
                                        periMsg: "Hersteller-Kurzzeichen oder andere Quellenangabe",
 +
                                        post: "}}"
 +
                                }
 +
                        }
 +
                }
 +
        }
 +
} );
 +
/* ###### NEM-Epochenangabe */
 +
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 +
        'section': 'advanced',
 +
        'group': 'misc',
 +
        'tools': {
 +
                'epoch': {
 +
                        label: 'Epochenangabe (NEM)', // or use labelMsg for a localized label, see above
 +
                        type: 'button',
 +
                        icon: 'http://www.mobadaten.info/MoBaDatenInfo/images/4/40/Vector_toolbar_hourglass_NEM.png',
 +
                        action: {
 +
                                type: 'encapsulate',
 +
                                options: {
 +
                                        pre: "{{Epoche|", // text to be inserted
 +
                                        periMsg: "Epochennummer 1…6",
 +
                                        post: "}}"
 +
                                }
 +
                        }
 +
                }
 +
        }
 +
} );
 +
/* ###### GB-Epochenangabe */
 +
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 +
        'section': 'advanced',
 +
        'group': 'misc',
 +
        'tools': {
 +
                'epoch': {
 +
                        label: 'Epochenangabe (GB)', // or use labelMsg for a localized label, see above
 +
                        type: 'button',
 +
                        icon: 'http://www.mobadaten.info/MoBaDatenInfo/images/2/26/Vector_toolbar_hourglass_GB.png',
 +
                        action: {
 +
                                type: 'encapsulate',
 +
                                options: {
 +
                                        pre: "{{Epoche-GB|", // text to be inserted
 +
                                        periMsg: "Epochennummer 1…11",
 +
                                        post: "}}"
 +
                                }
 +
                        }
 +
                }
 +
        }
 +
} );
 +
/* ###### USA-Epochenangabe */
 +
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 +
        'section': 'advanced',
 +
        'group': 'misc',
 +
        'tools': {
 +
                'epoch': {
 +
                        label: 'Epochenangabe (Nordamerika)', // or use labelMsg for a localized label, see above
 +
                        type: 'button',
 +
                        icon: 'http://www.mobadaten.info/MoBaDatenInfo/images/7/7e/Vector_toolbar_hourglass_USA.png',
 +
                        action: {
 +
                                type: 'encapsulate',
 +
                                options: {
 +
                                        pre: "{{Epoche-USA|", // text to be inserted
 +
                                        periMsg: "Era W, S, T, D, M",
 +
                                        post: "}}"
 +
                                }
 +
                        }
 +
                }
 +
        }
 +
} );
 +
/* ###### FULLPAGENAME einfügen */
 +
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 +
        'section': 'advanced',
 +
        'group': 'misc',
 +
        'tools': {
 +
                'fullpagename': {
 +
                        label: 'Seitennamen einfügen', // or use labelMsg for a localized label, see above
 +
                        type: 'button',
 +
                        icon: 'http://www.mobadaten.info/MoBaDatenInfo/images/d/d3/Vector_toolbar_fullpagename.png',
 +
                        action: {
 +
                                type: 'encapsulate',
 +
                                options: {
 +
                                        pre: "{{sub", // text to be inserted
 +
                                        post: "st:FULLPAGENAME}}"
 +
                                }
 +
                        }
 +
                }
 +
        }
 +
} );
 +
/* ###### Typografische Anführungszeichen */
 +
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 +
        'section': 'advanced',
 +
        'group': 'misc',
 +
        'tools': {
 +
                'endoffloat': {
 +
                        label: 'Typografische Anführungszeichen',
 +
                        type: 'button',
 +
                        icon: 'http://www.mobadaten.info/MoBaDatenInfo/images/1/1c/German_quotation_marks.png',
 +
                        action: {
 +
                                type : 'encapsulate',
 +
                                options: {
 +
                                        pre: "\u201e", // text to be inserted
 +
                                        periMsg: "Text",
 +
                                        post: "\u201c"
 +
                                }
 +
                        }
 +
                }
 +
        }
 +
} );
 +
};
 +
// Ende var customizeToolbar
 +
 +
/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
 +
if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) {
 +
mw.loader.using( 'user.options' ).then( function () {
 +
// This can be the string "0" if the user disabled the preference ([[phab:T54542#555387]])
 +
if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
 +
$.when(
 +
mw.loader.using( 'ext.wikiEditor' ), $.ready
 +
).then( customizeToolbar );
 +
}
 +
} );
 +
}

Aktuelle Version vom 13. Dezember 2021, 23:06 Uhr

 /*
  * moveEditsection
  * Dieses Script verschiebt die [Bearbeiten]-Buttons vom rechten Fensterrand
  * direkt rechts neben die jeweiligen Überschriften.
  * This script moves the [edit]-buttons from the right border of the window
  * directly right next to the corresponding headings.
  *
  * Zum Abschalten die folgende Zeile (ohne führendes Sternchen) in die eigene
  * vector.js (zu finden unter [[Special:Mypage/vector.js|Benutzer:Name/vector.js]]) kopieren:
  * var oldEditsectionLinks = true;
  *
  * dbenzhuser (de:Benutzer:Dbenzhuser)
  * Angepasst nach Vorschlag von https://de.wikipedia.org/w/index.php?title=MediaWiki_Diskussion:Vector.js&oldid=75510836
  */
 $( function () {
    if (typeof oldEditsectionLinks != 'undefined' && oldEditsectionLinks)   
      return;
    appendCSS("#bodyContent .editsection{float:none;margin-left:0}");
    var elt, item, numChilds;
    var root=document.getElementById("content");
    for (var i=1; i <= 6; ++i) {
      var list=root.getElementsByTagName("h" + i);
      for (var j=0, je=list.length; j < je; ++j) {
        item=list[j];
        numChilds=item.childNodes.length;
        if (numChilds > 1 && item.firstChild.className === "editsection")
        {
          // Zuerst das Leerzeichen von hinter dem Bearbeiten Link davor
            item.insertBefore(item.firstChild.nextSibling, item.firstChild);
          // Danach die große Rotation: Alles nach vorn, bis auf die beiden Elemente
          while (--numChilds > 1)
            item.insertBefore(item.lastChild, item.firstChild); // Überschrift vor Bearbeitenlink
        }
      }
    }
 });

/* ================================================================ */

var customizeToolbar = function() {
/* ###### Unterstrichen */
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
         'section': 'main',
         'group': 'format',
         'tools': {
                 'underlined': {
                         label: 'Unterstrichen', // or use labelMsg for a localized label, see above
                         type: 'button',
                         icon: 'http://www.mobadaten.info/MoBaDatenInfo/images/1/13/Toolbaricon_regular_U_underline.png',
                         action: {
                                 type: 'encapsulate',
                                 options: {
                                         pre: "<u>", // text to be inserted
                                         periMsg: "Unterstrichener Text",
                                         post: "</u>"
                                 }
                         }
                 }
         }
} );
/* ###### Festes Leerzeichen */
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        'section': 'advanced',
        'group': 'format',
        'tools': {
                'hardspace': {
                        label: 'Festes Leerzeichen',
                        type: 'button',
                        icon: 'http://www.mobadaten.info/MoBaDatenInfo/images/1/1b/Button_hardspace_clear.png',
                        action: {
                                type : 'encapsulate',
                                options: {
                                        pre: "{{~}}"
                                }
                        }
                }
        }
} );
/* ###### Zeilenumbruch */
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        'section': 'advanced',
        'group': 'format',
        'tools': {
                'wordwrap': {
                        label: 'Zeilenumbruch',
                        type: 'button',
                        icon: 'http://www.mobadaten.info/MoBaDatenInfo/images/0/09/Button_wordwrap_clear.png',
                        action: {
                                type : 'encapsulate',
                                options: {
                                        pre: "{{+}}"
                                }
                        }
                }
        }
} );
/* ###### Zeilenumbruch */
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        'section': 'advanced',
        'group': 'format',
        'tools': {
                'endoffloat': {
                        label: 'Fließtextende (für linksseitige Objekte)',
                        type: 'button',
                        icon: 'http://www.mobadaten.info/MoBaDatenInfo/images/5/5d/Button_EndOfFloat_clear.png',
                        action: {
                                type : 'encapsulate',
                                options: {
                                        pre: "{{+clr}}"
                                }
                        }
                }
        }
} );
/* ###### Zeilenumbruch rechts*/
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        'section': 'advanced',
        'group': 'format',
        'tools': {
                'endoffloatright': {
                        label: 'Fließtextende (für rechtsseitige Objekte)',
                        type: 'button',
                        icon: 'http://www.mobadaten.info/MoBaDatenInfo/images/c/c1/Button_EndOfFloatRight_clear.png',
                        action: {
                                type : 'encapsulate',
                                options: {
                                        pre: "{{+clr+}}"
                                }
                        }
                }
        }
} );
/* ###### Gruppe Verschiedenes */
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        'section': 'advanced',
        'groups': {
                'misc': {
                        'label': 'Diverses' // or use labelMsg for a localized label, see above
                }
        }
} );
/* ###### Quellenangabe */
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        'section': 'advanced',
        'group': 'misc',
        'tools': {
                'tmplsrc': {
                        label: 'Quellenangabe', // or use labelMsg for a localized label, see above
                        type: 'button',
                        icon: 'http://www.mobadaten.info/MoBaDatenInfo/images/2/29/Button_fuente_clear.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "{{Source|", // text to be inserted
                                        periMsg: "Hersteller-Kurzzeichen oder andere Quellenangabe",
                                        post: "}}"
                                }
                        }
                }
        }
} );
/* ###### NEM-Epochenangabe */
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        'section': 'advanced',
        'group': 'misc',
        'tools': {
                'epoch': {
                        label: 'Epochenangabe (NEM)', // or use labelMsg for a localized label, see above
                        type: 'button',
                        icon: 'http://www.mobadaten.info/MoBaDatenInfo/images/4/40/Vector_toolbar_hourglass_NEM.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "{{Epoche|", // text to be inserted
                                        periMsg: "Epochennummer 1…6",
                                        post: "}}"
                                }
                        }
                }
        }
} );
/* ###### GB-Epochenangabe */
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        'section': 'advanced',
        'group': 'misc',
        'tools': {
                'epoch': {
                        label: 'Epochenangabe (GB)', // or use labelMsg for a localized label, see above
                        type: 'button',
                        icon: 'http://www.mobadaten.info/MoBaDatenInfo/images/2/26/Vector_toolbar_hourglass_GB.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "{{Epoche-GB|", // text to be inserted
                                        periMsg: "Epochennummer 1…11",
                                        post: "}}"
                                }
                        }
                }
        }
} );
/* ###### USA-Epochenangabe */
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        'section': 'advanced',
        'group': 'misc',
        'tools': {
                'epoch': {
                        label: 'Epochenangabe (Nordamerika)', // or use labelMsg for a localized label, see above
                        type: 'button',
                        icon: 'http://www.mobadaten.info/MoBaDatenInfo/images/7/7e/Vector_toolbar_hourglass_USA.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "{{Epoche-USA|", // text to be inserted
                                        periMsg: "Era W, S, T, D, M",
                                        post: "}}"
                                }
                        }
                }
        }
} );
/* ###### FULLPAGENAME einfügen */
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        'section': 'advanced',
        'group': 'misc',
        'tools': {
                'fullpagename': {
                        label: 'Seitennamen einfügen', // or use labelMsg for a localized label, see above
                        type: 'button',
                        icon: 'http://www.mobadaten.info/MoBaDatenInfo/images/d/d3/Vector_toolbar_fullpagename.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "{{sub", // text to be inserted
                                        post: "st:FULLPAGENAME}}"
                                }
                        }
                }
        }
} );
/* ###### Typografische Anführungszeichen */
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        'section': 'advanced',
        'group': 'misc',
        'tools': {
                'endoffloat': {
                        label: 'Typografische Anführungszeichen',
                        type: 'button',
                        icon: 'http://www.mobadaten.info/MoBaDatenInfo/images/1/1c/German_quotation_marks.png',
                        action: {
                                type : 'encapsulate',
                                options: {
                                        pre: "\u201e", // text to be inserted
                                        periMsg: "Text",
                                        post: "\u201c"
                                }
                        }
                }
        }
} );
};
// Ende var customizeToolbar
 
/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) {
	mw.loader.using( 'user.options' ).then( function () {
		// This can be the string "0" if the user disabled the preference ([[phab:T54542#555387]])
		if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
			$.when(
				mw.loader.using( 'ext.wikiEditor' ), $.ready
			).then( customizeToolbar );
		}
	} );
}