MediaWiki:Common.js: Unterschied zwischen den Versionen
Aus WacheWiki
Zur Navigation springenZur Suche springen (Die Seite wurde neu angelegt: „→Das folgende JavaScript wird für alle Benutzer geladen.: var customizeToolbar = function() { →Your code goes here: $( '#wpTextbox1' ).bind( '…“) |
|||
| Zeile 1: | Zeile 1: | ||
/* Das folgende JavaScript wird für alle Benutzer geladen. */ | /* Das folgende JavaScript wird für alle Benutzer geladen. */ | ||
var customizeToolbar = function() { | var customizeToolbar = function() { | ||
| + | |||
| + | hookEvent( 'load', function(){ | ||
| + | // To add a toolbar section: | ||
| + | $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | ||
| + | 'sections': { | ||
| + | 'emoticons': { | ||
| + | 'type': 'toolbar', // Can also be 'booklet' | ||
| + | 'label': 'Emoticons' | ||
| + | // or 'labelMsg': 'section-emoticons-label' for a localized label | ||
| + | } | ||
| + | } | ||
| + | } ); | ||
| + | |||
| + | |||
| + | // To add a group to an existing toolbar section: | ||
| + | $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | ||
| + | 'section': 'emoticons', | ||
| + | 'groups': { | ||
| + | 'faces': { | ||
| + | 'label': 'Faces' // or use labelMsg for a localized label, see above | ||
| + | } | ||
| + | } | ||
| + | } ); | ||
| + | |||
| + | // To add a button to an existing toolbar group: | ||
| + | $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | ||
| + | 'section': 'emoticons', | ||
| + | 'group': 'faces', | ||
| + | 'tools': { | ||
| + | 'smile': { | ||
| + | label: 'Smile!', // or use labelMsg for a localized label, see above | ||
| + | type: 'button', | ||
| + | icon: 'http://upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png', | ||
| + | action: { | ||
| + | type: 'encapsulate', | ||
| + | options: { | ||
| + | pre: ":)" // text to be inserted | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | } ); | ||
| + | }); | ||
| + | |||
/* Your code goes here */ | /* Your code goes here */ | ||
| − | + | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
}; | }; | ||
Version vom 24. Juni 2012, 14:10 Uhr
/* Das folgende JavaScript wird für alle Benutzer geladen. */
var customizeToolbar = function() {
hookEvent( 'load', function(){
// To add a toolbar section:
$j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'sections': {
'emoticons': {
'type': 'toolbar', // Can also be 'booklet'
'label': 'Emoticons'
// or 'labelMsg': 'section-emoticons-label' for a localized label
}
}
} );
// To add a group to an existing toolbar section:
$j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'emoticons',
'groups': {
'faces': {
'label': 'Faces' // or use labelMsg for a localized label, see above
}
}
} );
// To add a button to an existing toolbar group:
$j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'emoticons',
'group': 'faces',
'tools': {
'smile': {
label: 'Smile!', // or use labelMsg for a localized label, see above
type: 'button',
icon: 'http://upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png',
action: {
type: 'encapsulate',
options: {
pre: ":)" // text to be inserted
}
}
}
}
} );
});
/* Your code goes here */
};
/* Check if we are in edit mode and the required modules are available and then customize the toolbar */
if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) {
mw.loader.using( 'user.options', function () {
if ( mw.user.options.get('usebetatoolbar') ) {
mw.loader.using( 'ext.wikiEditor.toolbar', function () {
$(document).ready( customizeToolbar );
} );
}
} );
}