MediaWiki:Common.js — различия между версиями
Материал Psylab.info - энциклопедии психодиагностики
м |
м |
||
Строка 105: | Строка 105: | ||
} | } | ||
− | /* | + | /* Добавление дополнительных кнопок в WikiEditor на страницах LiquidThreads' */ |
mw.hook( 'ext.lqt.textareaCreated' ).add( customizeToolbar ); | mw.hook( 'ext.lqt.textareaCreated' ).add( customizeToolbar ); | ||
+ | |||
+ | |||
+ | /* Добавление RefToolbar в WikiEditor */ | ||
+ | if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 && window.refToolbarInstalled === undefined ) { | ||
+ | if ( mw.user.options.get( 'usebetatoolbar' ) && mw.user.options.get( 'usebetatoolbar-cgd' ) ) { | ||
+ | $.getScript( '//en.wikipedia.org/w/index.php?title=MediaWiki:RefToolbarBase.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400', function() { | ||
+ | // Enhanced editing toolbar is on with dialogs. Load standard refToolbar. | ||
+ | mw.loader.using( 'ext.wikiEditor.toolbar', function () { | ||
+ | mw.loader.load( '//en.wikipedia.org/w/index.php?title=MediaWiki:RefToolbar.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400' ); | ||
+ | }); | ||
+ | }); | ||
+ | } else if (mw.user.options.get( 'usebetatoolbar' ) ) { | ||
+ | // Dialogs are off. Load refToolbar 2.0 without dialogs. | ||
+ | mw.loader.using( 'ext.wikiEditor.toolbar', function () { | ||
+ | mw.loader.load( '//en.wikipedia.org/w/index.php?title=MediaWiki:RefToolbarNoDialogs.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400' ); | ||
+ | }); | ||
+ | } else { | ||
+ | // Enhanced editing toolbar is off. Load legacy refToolbar 1.0. | ||
+ | mw.loader.load( '//en.wikipedia.org/w/index.php?title=MediaWiki:RefToolbarLegacy.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400' ); | ||
+ | } | ||
+ | window.refToolbarInstalled = true; | ||
+ | } |
Версия 12:46, 22 февраля 2014
/* Дополнительные кнопки в WikiEditor */ var customizeToolbar = function() { $('#wpTextbox1').wikiEditor('addToToolbar', { section: 'advanced', group: 'format', tools: { "math": { label: 'Кавычки', type: 'button', icon: '//upload.wikimedia.org/wikipedia/commons/a/ac/Norwegian_quote_sign.png', action: { type: 'encapsulate', options: { pre: "«", post: "»" } } } } }); $('#wpTextbox1').wikiEditor('addToToolbar', { section: 'advanced', group: 'format', tools: { "math": { label: 'Math', type: 'button', icon: '//upload.wikimedia.org/wikipedia/commons/3/38/Button_Math.png', action: { type: 'encapsulate', options: { pre: "<math>", post: "</math>" } } } } }); $('#wpTextbox1').wikiEditor('addToToolbar', { section: 'advanced', group: 'format', tools: { "math": { label: 'Code', type: 'button', icon: '//upload.wikimedia.org/wikipedia/commons/6/62/Toolbar_code.png', action: { type: 'encapsulate', options: { pre: "<code>", post: "</code>" } } } } }); $('#wpTextbox1').wikiEditor('addToToolbar', { section: 'advanced', group: 'format', tools: { "math": { label: 'Pre', type: 'button', icon: '//upload.wikimedia.org/wikipedia/commons/b/b9/Toolbar_pre_vector.png', action: { type: 'encapsulate', options: { pre: "<pre>", post: "</pre>" } } } } }); $('#wpTextbox1').wikiEditor('addToToolbar', { section: 'advanced', group: 'format', tools: { "math": { label: 'Шаблон', type: 'button', icon: '//upload.wikimedia.org/wikipedia/commons/d/dd/Vector_toolbar_template_button.png', action: { type: 'encapsulate', options: { pre: "{{", post: "}}" } } } } }); }; /* 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 ); }); } }); } /* Добавление дополнительных кнопок в WikiEditor на страницах LiquidThreads' */ mw.hook( 'ext.lqt.textareaCreated' ).add( customizeToolbar ); /* Добавление RefToolbar в WikiEditor */ if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 && window.refToolbarInstalled === undefined ) { if ( mw.user.options.get( 'usebetatoolbar' ) && mw.user.options.get( 'usebetatoolbar-cgd' ) ) { $.getScript( '//en.wikipedia.org/w/index.php?title=MediaWiki:RefToolbarBase.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400', function() { // Enhanced editing toolbar is on with dialogs. Load standard refToolbar. mw.loader.using( 'ext.wikiEditor.toolbar', function () { mw.loader.load( '//en.wikipedia.org/w/index.php?title=MediaWiki:RefToolbar.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400' ); }); }); } else if (mw.user.options.get( 'usebetatoolbar' ) ) { // Dialogs are off. Load refToolbar 2.0 without dialogs. mw.loader.using( 'ext.wikiEditor.toolbar', function () { mw.loader.load( '//en.wikipedia.org/w/index.php?title=MediaWiki:RefToolbarNoDialogs.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400' ); }); } else { // Enhanced editing toolbar is off. Load legacy refToolbar 1.0. mw.loader.load( '//en.wikipedia.org/w/index.php?title=MediaWiki:RefToolbarLegacy.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400' ); } window.refToolbarInstalled = true; }