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 */
$( '#wpTextbox1' ).bind( 'wikiEditor-toolbar-buildSection-main', function( event, section ) {
+
 
        // Add icons for bold (F) and italic (L) for Swedish (sv)
 
        // Don't overwrite them if they're already defined, so this hack can safely be removed once the
 
        // usability team incorporates these icons in the software
 
        if ( !( 'sv' in section.groups.format.tools.bold.icon ) ) {
 
                // There's already a bold F icon for German, use that one
 
                section.groups.format.tools.bold.icon['sv'] = 'format-bold-F.png';
 
                section.groups.format.tools.bold.offset['sv'] = [2, -214];
 
        }
 
        if ( !( 'sv' in section.groups.format.tools.italic.icon ) ) {
 
                // Use an icon from Commons for L
 
                section.groups.format.tools.italic.icon['sv'] = 'http://upload.wikimedia.org/wikipedia/commons/3/32/Toolbaricon_italic_L.png';
 
                section.groups.format.tools.italic.offset['sv'] = [2, -214];
 
        }
 
} );
 
 
};
 
};
 
   
 
   

Version vom 24. Juni 2012, 15: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 );
                        } );
                }
        } );
}