MediaWiki:Common.js
Z ωικι.matfyz.cz
Poznámka: Po uložení musíte smazat cache vašeho prohlížeče, jinak změny neuvidíte.
- Firefox / Safari: Při kliknutí na Aktualizovat držte Shift nebo stiskněte Ctrl-F5 nebo Ctrl-R (na Macu ⌘-R).
- Google Chrome: Stiskněte Ctrl-Shift-R (na Macu ⌘-Shift-R).
- Internet Explorer: Při kliknutí na Aktualizovat držte Ctrl nebo stiskněte Ctrl-F5.
- Opera: Smažte obsah cache v menu Nástroje → Nastavení.
/* Zde uvedený JavaScript bude použit pro všechny uživatele při načtení každé stránky. */
(function ($, mw) {
function addChars() {
$( '#wpTextbox1' ).bind( 'wikiEditor-toolbar-buildSection-characters', function( event, section ) {
var removeVals = ['¡','¿','†','‡','¶','¤','₳','฿','₵','¢','₡','₢','$','₫','₯','€','₠','₣','ƒ','₴','₭','₤','ℳ','₥','₦','№','₧','₰','£','៛','₨','₪','৳','₮','₩','¥'];
for (var i = removeVals.length -1; i >= 0; i--)
section.pages.symbols.characters.splice(section.pages.symbols.characters.indexOf(removeVals[i]),1);
section.pages.symbols.characters.push(
'⟨',
'⟩',
'∩',
'∪',
'∧',
'∨',
'∞',
'∑',
'∏',
'∈',
'∉',
'∅',
'ℕ',
'ℝ',
'∀',
'∃',
'∄',
'⇔',
'⇐',
'⇒',
'↓',
'↑',
'̅ ',
'⃗',
'¬',
'💡',
'🎓',
'−',
'×',
'÷',
'≈',
'⊂',
'⊆',
'≡',
'≅',
'⁰','¹','²','³','⁴','⁵','⁶','⁷','⁸','⁹','⁺','⁻','⁼','⁽','⁾','₀','₁','₂','₃','₄','₅','₆','₇','₈','₉','₊','₋','₌','₍','₎',
'ₐ','ₑ','ₕ','ᵢ','ⱼ','ₖ','ₗ','ₘ','ₙ','ₒ','ₚ','ᵣ','ₛ','ₜ','ᵤ','ᵥ','ₓ','ⁱ','ʲ','ᵏ','ˡ','ᵐ','ⁿ'
);
});
}
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() {
addChars();
});
}
});
}
}(jQuery, mediaWiki));
/**
* WikiEditor specific
*
* Custom buttons ONLY when Prefs set to - Enable enhanced editing toolbar - is selected,
* Enable wizards for... - must not be selected. Show [old]edit toolbar - should be off.
* based upon - https://github.com/he7d3r/mw-gadget-ExtraEditButtons
*/
var iconPathWE = mw.config.get( 'wgExtensionAssetsPath' ) + '/WikiEditor/modules/images/toolbar/';
var iconPathPRP = mw.config.get( 'wgExtensionAssetsPath' ) + '/ProofreadPage/modules/page/images/';
var fileNamespace = mw.config.get( 'wgFormattedNamespaces' )[6];
var customizeToolbar = function() {
$( '#wpTextbox1' )
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'format',
'tools': {
'underline': {
'labelMsg': 'wikieditor-toolbar-tool-underline',
'label': 'Underline',
'id': 'underline',
'filters': [ 'body:not(.ns-2, .ns-8, .ns-828)' ],
'type': 'button',
'icon': '//upload.wikimedia.org/wikipedia/commons/8/8b/Button_underline_he.png',
'action': {
'type': 'encapsulate',
'options': {
'pre': "<u>",
'periMsg': 'wikieditor-toolbar-tool-underline-example',
'post': "</u>"
}
}
},
'strikeout': {
'labelMsg': 'wikieditor-toolbar-tool-strikeout',
'label': 'Strike out',
'id': 'strikeout',
'filters': [ 'body:not(.ns-2, .ns-8, .ns-828)' ],
'type': 'button',
'icon': '//upload.wikimedia.org/wikipedia/commons/6/6d/Vector_strikeout.png',
'action': {
'type': 'encapsulate',
'options': {
'pre': "<s>",
'periMsg': 'wikieditor-toolbar-tool-strikeout-example',
'post': "</s>"
}
}
},
'formula': {
'labelMsg': 'wikieditor-toolbar-tool-formula',
'label': 'Strike out',
'id': 'formula',
'filters': [ 'body:not(.ns-2, .ns-8, .ns-828)' ],
'type': 'button',
'icon': '/extensions/Math/images/button_math2.png',
'action': {
'type': 'encapsulate',
'options': {
'pre': "<math>",
'post': "</math>"
}
}
},
'pre': {
'labelMsg': 'wikieditor-toolbar-tool-pre',
'label': 'Code',
'id': 'pre',
'filters': [ 'body:not(.ns-2, .ns-8, .ns-828)' ],
'type': 'button',
'icon': '//wiki.matfyz.cz/images/3/38/Code.png',
'action': {
'type': 'encapsulate',
'options': {
'pre': "<pre>",
'post': "</pre>"
}
}
},
'nowiki': {
'labelMsg': 'wikieditor-toolbar-tool-nowiki',
'label': 'nowiki',
'id': 'nowiki',
'filters': [ 'body:not(.ns-2, .ns-8, .ns-828)' ],
'type': 'button',
'icon': '//wiki.matfyz.cz/extensions/WikiEditor/modules/images/toolbar/button-sprite.svg',
'offset': [-70, -70],
'action': {
'type': 'encapsulate',
'options': {
'pre': "<nowiki>",
'post': "</nowiki>"
}
}
},
'todo': {
'labelMsg': 'wikieditor-toolbar-tool-todo',
'label': 'TODO',
'id': 'todo',
'filters': [ 'body:not(.ns-2, .ns-8, .ns-828)' ],
'type': 'button',
'icon': '//wiki.matfyz.cz/images/b/b6/Todo.png',
'action': {
'type': 'encapsulate',
'options': {
'pre': "{{TODO|",
'post': "}}"
}
}
},
'collapse': {
'labelMsg': 'wikieditor-toolbar-tool-collapse',
'label': 'collapse',
'id': 'collapse',
'filters': [ 'body:not(.ns-2, .ns-8, .ns-828)' ],
'type': 'button',
'icon': '//wiki.matfyz.cz/images/c/ca/Toggle-expand.png',
'action': {
'type': 'encapsulate',
'options': {
'pre': "{{collapse|",
'post': "| }}"
}
}
},
'bulb': {
'labelMsg': 'wikieditor-toolbar-tool-bulb',
'label': 'Žárovka',
'id': 'bulb',
'filters': [ 'body:not(.ns-2, .ns-8, .ns-828)' ],
'type': 'button',
'icon': '//wiki.matfyz.cz/images/b/b3/Bulb.png',
'action': {
'type': 'replace',
'options': {
'peri': '💡',
'selectPeri': false
}
}
}
}
} );
};
/* Check for edit mode and required modules are available. Then, customize */
if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) {
mw.loader.using( 'user.options', function () {
if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
$.when(
mw.loader.using( ['ext.wikiEditor.toolbar'] ),
$.ready
).then( customizeToolbar );
}
} );
}