MediaWiki:Common.js: Porovnání verzí

Řádek 40: Řádek 40:
 
// Add the customizations to LiquidThreads' edit toolbar, if available
 
// Add the customizations to LiquidThreads' edit toolbar, if available
 
mw.hook( 'ext.lqt.textareaCreated' ).add( customizeToolbar );
 
mw.hook( 'ext.lqt.textareaCreated' ).add( customizeToolbar );
 
/**
 
* Add a "My sandbox" link to the personal portlet menu.
 
* Dependencies: mediawiki.util, mediawiki.Title, mediawiki.Uri
 
*
 
* @source mediawiki.org/wiki/Snippets/MySandbox
 
* @version 3
 
*/
 
( function ( mw, $ ) {
 
 
$( document ).ready( function () {
 
var conf, title, url;
 
 
// Customize/Translate this to your needs
 
conf = {
 
subpageName: 'sandbox',
 
portletLabel: 'Sandbox',
 
portletTooltip: 'Go to your sandbox',
 
editintroPagename: 'Template:User_sandbox',
 
preloadPagename: 'Template:User_sandbox/preload'
 
};
 
// Don't alter the code below
 
 
// Use Special:MyPage (as opposed to mw.user.getName()) so that it
 
// works for logged-out users as well.
 
title = new mw.Title( 'Special:MyPage/' + conf.subpageName );
 
 
url = new mw.Uri( title.getUrl() );
 
url.extend({
 
action: 'edit',
 
redlink: 1,
 
editintro: new mw.Title( conf.editintroPagename ),
 
preload: new mw.Title( conf.preloadPagename )
 
});
 
 
mw.util.addPortletLink(
 
'p-personal',
 
url,
 
conf.portletLabel,
 
'pt-sandbox',
 
conf.portletTooltip,
 
null,
 
'#pt-preferences'
 
);
 
});
 
}( mediaWiki, jQuery ) );
 

Verze z 12. 2. 2014, 11:08

/* Zde uvedený JavaScript bude použit pro všechny uživatele při načtení každé stránky.  */


var customizeToolbar = function() {
        /* Your code goes here */
 if (jQuery.inArray("sysop",wgUserGroups)!=-1){
    $('#wpTextbox1').wikiEditor('addToToolbar', {
        section: 'advanced',
        group: 'insert',
        tools: {
            buttonId: {
                label: 'Pouze pro učitele',
                type: 'button',
                icon: '/images/b/b6/Button_article_de_qualite.png',
                action: {
                    type: 'encapsulate',
                    options: {
                        pre: "{{Zkontrolováno|{{subst:REVISIONTIMESTAMP",
                        peri: "",
                        post: " }}}}"
                    }
                }
            }
        }
    });
}
/*Konec*/
};
 
/* Check if view is in edit mode and that the required modules are available. 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 );
                        } );
                }
        } );
}
// Add the customizations to LiquidThreads' edit toolbar, if available
mw.hook( 'ext.lqt.textareaCreated' ).add( customizeToolbar );