Common.js: Unterschied zwischen den Versionen
Aus INOVe
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
Zeile 1: | Zeile 1: | ||
/* Das folgende JavaScript wird für alle Benutzer geladen. */ | /* Das folgende JavaScript wird für alle Benutzer geladen. */ | ||
Zeile 179: | Zeile 177: | ||
} ); | } ); | ||
} | } | ||
function ModifySidebar( action, section, name, link ) { | |||
try { | |||
switch ( section ) { | |||
case 'languages': | |||
var target = 'p-lang'; | |||
break; | |||
case 'toolbox': | |||
var target = 'p-tb'; | |||
break; | |||
case 'navigation': | |||
var target = 'p-navigation'; | |||
break; | |||
default: | |||
var target = 'p-' + section; | |||
break; | |||
} | |||
if ( action == 'add' ) { | |||
var node = document.getElementById( target ) | |||
.getElementsByTagName( 'div' )[0] | |||
.getElementsByTagName( 'ul' )[0]; | |||
var aNode = document.createElement( 'a' ); | |||
var liNode = document.createElement( 'li' ); | |||
aNode.appendChild( document.createTextNode( name ) ); | |||
aNode.setAttribute( 'href', link ); | |||
liNode.appendChild( aNode ); | |||
liNode.className = 'plainlinks'; | |||
node.appendChild( liNode ); | |||
} | |||
if ( action == 'remove' ) { | |||
var list = document.getElementById( target ) | |||
.getElementsByTagName( 'div' )[0] | |||
.getElementsByTagName( 'ul' )[0]; | |||
var listelements = list.getElementsByTagName( 'li' ); | |||
for ( var i = 0; i < listelements.length; i++ ) { | |||
if ( | |||
listelements[i].getElementsByTagName( 'a' )[0].innerHTML == name || | |||
listelements[i].getElementsByTagName( 'a' )[0].href == link | |||
) | |||
{ | |||
list.removeChild( listelements[i] ); | |||
} | |||
} | |||
} | |||
} catch( e ) { | |||
// let's just ignore what's happened | |||
return; | |||
} | |||
} | |||
function CustomizeModificationsOfSidebar() { | |||
// adds [[Special:CategoryTree|Special:CategoryTree]] to toolbox | |||
ModifySidebar( 'add', 'toolbox', 'CategoryTree', 'https://en.wikipedia.org/wiki/Special:CategoryTree' ); | |||
// removes [[Special:Upload|Special:Upload]] from toolbox | |||
ModifySidebar( 'remove', 'toolbox', 'Upload file', 'https://en.wikipedia.org/wiki/Special:Upload' ); | |||
} | |||
jQuery( CustomizeModificationsOfSidebar ); |
Version vom 5. Januar 2021, 13:34 Uhr
/* Das folgende JavaScript wird für alle Benutzer geladen. */ var customizeToolbar = function () { $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { 'section': 'advanced', 'groups': { 'spezial': { 'label': 'Spezial' // or use labelMsg for a localized label, see above } } } ); $('#wpTextbox1').wikiEditor('addToToolbar', { section: 'advanced', group: 'spezial', tools: { "external": { label: 'Externer Link Icon', type: 'button', icon: 'https://upload.wikimedia.org/wikipedia/commons/6/67/OOjs_UI_icon_external-link-ltr.svg', action: { type: 'encapsulate', options: { pre: '{{Externer Link Icon}}' } } } } }); $('#wpTextbox1').wikiEditor('addToToolbar', { section: 'advanced', group: 'insert', tools: { "Video": { label: 'Video einbetten', type: 'button', icon: 'https://upload.wikimedia.org/wikipedia/commons/6/64/Video_Camera_-_The_Noun_Project.svg', action: { type: 'encapsulate', options: { pre: '{{#ev:youtube|', peri: 'Link zum Youtube-Video', post: '|400|right|Videounterschrift}}' } } } } }); $('#wpTextbox1').wikiEditor('addToToolbar', { section: 'advanced', group: 'insert', tools: { "Karte": { label: 'Karte', type: 'button', icon: 'https://upload.wikimedia.org/wikipedia/commons/b/b4/OOjs_UI_icon_map-ltr.svg', action: { type: 'encapsulate', options: { pre: '{{#display_map:', peri: "Beispielstraße 1, Lüneburg~'''Überschrift (optional)'''~Kurze Beschreibung (optional); ggf. zweiter Marker evt. mit Koordinaten wie z. B. 53.23697, 10.40292", post: '|fullscreen=on|scrollzoom=off}}' } } } } }); $('#wpTextbox1').wikiEditor('addToToolbar', { section: 'advanced', group: 'spezial', tools: { "seo": { label: 'Suchmaschinenoptimierung', type: 'button', icon: 'https://upload.wikimedia.org/wikipedia/commons/5/56/Antu_tag-places-black.svg', action: { type: 'encapsulate', options: { pre: "{{#seo:|description=", peri: "Kurze Beschreibung des Artikels für Suchmaschinen und Linkvorschau in Messengern", post: "}}" } } } } }); $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { section: 'advanced', group: 'main', groups: { list: { tools: { templates: { label: 'Gitter', type: 'select', list: { 'Gittereins': { label: '2 Spalten', action: { type: 'encapsulate', options: { pre: '<div class="row"><div class="large-6 columns">Inhalt der 1. Spalte</div><div class="large-6 columns">Inhalt der 2. Spalte</div></div>' } } }, 'Gitterzwei': { label: '3 Spalten', action: { type: 'encapsulate', options: { pre: '<div class="row"><div class="large-4 columns">Inhalt der 1. Spalte</div><div class="large-4 columns">Inhalt der 2. Spalte</div><div class="large-4 columns">Inhalt der 3. Spalte</div></div>' } } }, 'Gitterdrei': { label: '2er + Überschrift', action: { type: 'encapsulate', options: { pre: '<div class="row"><div class="large-6 columns"><h3 class="subheader">1. Überschrift</h3>Inhalt der 1. Spalte</div><div class="large-6 columns"><h3 class="subheader">2. Überschrift</h3>Inhalt der 2. Spalte</div></div>' } } }, 'Gittervier': { label: '3er + Überschrift', action: { type: 'encapsulate', options: { pre: '<div class="row"><div class="large-4 columns"><h3 class="subheader">1. Überschrift</h3>Inhalt der 1. Spalte</div><div class="large-4 columns"><h3 class="subheader">2. Überschrift</h3>Inhalt der 2. Spalte</div><div class="large-4 columns"><h3 class="subheader">3. Überschrift</h3>Inhalt der 3. Spalte</div></div>' } } }, } } } } } } ); /* Remove button for <big> */ $( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', { 'section': 'advanced', 'group': 'size', 'tool': 'big' }); /* Remove button for <small> */ $( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', { 'section': 'advanced', 'group': 'size', 'tool': 'small' }); /* Remove button for <br> */ $( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', { 'section': 'advanced', 'group': 'format', 'tool': 'newline' }); }; /* 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 ); } } ); } function ModifySidebar( action, section, name, link ) { try { switch ( section ) { case 'languages': var target = 'p-lang'; break; case 'toolbox': var target = 'p-tb'; break; case 'navigation': var target = 'p-navigation'; break; default: var target = 'p-' + section; break; } if ( action == 'add' ) { var node = document.getElementById( target ) .getElementsByTagName( 'div' )[0] .getElementsByTagName( 'ul' )[0]; var aNode = document.createElement( 'a' ); var liNode = document.createElement( 'li' ); aNode.appendChild( document.createTextNode( name ) ); aNode.setAttribute( 'href', link ); liNode.appendChild( aNode ); liNode.className = 'plainlinks'; node.appendChild( liNode ); } if ( action == 'remove' ) { var list = document.getElementById( target ) .getElementsByTagName( 'div' )[0] .getElementsByTagName( 'ul' )[0]; var listelements = list.getElementsByTagName( 'li' ); for ( var i = 0; i < listelements.length; i++ ) { if ( listelements[i].getElementsByTagName( 'a' )[0].innerHTML == name || listelements[i].getElementsByTagName( 'a' )[0].href == link ) { list.removeChild( listelements[i] ); } } } } catch( e ) { // let's just ignore what's happened return; } } function CustomizeModificationsOfSidebar() { // adds [[Special:CategoryTree|Special:CategoryTree]] to toolbox ModifySidebar( 'add', 'toolbox', 'CategoryTree', 'https://en.wikipedia.org/wiki/Special:CategoryTree' ); // removes [[Special:Upload|Special:Upload]] from toolbox ModifySidebar( 'remove', 'toolbox', 'Upload file', 'https://en.wikipedia.org/wiki/Special:Upload' ); } jQuery( CustomizeModificationsOfSidebar );