MediaWiki:Common.js: Porovnání verzí
Bez shrnutí editace |
Bez shrnutí editace |
||
Řádek 174: | Řádek 174: | ||
sampleText: '42' | sampleText: '42' | ||
}); | }); | ||
//Default sort tabulek | |||
function isSortedTablePage() { | |||
return ( wgPageName == "Castor 2017/Adresář" || wgPageName == "Other_Page_To_Sort" ); | |||
} | |||
jQuery( document ).ready( function( $ ) { | |||
// wrapped in "mw.loader.using" so this doesn't execute until Tablesorter has loaded | |||
mw.loader.using( 'jquery.tablesorter', function() { | |||
if( isSortedTablePage() ) $('table.sortable').tablesorter( {sortList: [ { 0: 'asc'} ]} ) | |||
// or look for tables with an ID attribute of "sortMe" on any page | |||
// $( '#sortMe' ).tablesorter( {sortList: [ { 0: 'asc'} ]} ) | |||
} ); | |||
} ); |
Verze z 28. 2. 2017, 21:10
/* Zde uvedený JavaScript bude použit pro všechny uživatele při načtení každé stránky. */ // install [[Wikipedia:User:Cacycle/wikEd]] in-browser text editor //importScriptURI('resources/wikEd.js'); (function ($, mw) { "use strict"; var queue = [], $toolbar; function insertButton(btnObj) { $toolbar.wikiEditor('addToToolbar', btnObj); } function handleQueue() { var i; if (!$toolbar) { return; } for (i = 0; i < queue.length; i += 1) { insertButton(queue[i]); } queue = []; } function check() { $toolbar = ($.wikiEditor && $.fn.wikiEditor && $('#wpTextbox1').length) ? $('#wpTextbox1') : false; handleQueue(); } // Only on editpage if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1) { /** * krInsertWikiEditorButton * * @param options {Object} An object with options: * - section {String} (optional) The name of the section in the WikiEditor. Defaults to 'main' * - group {String} (optional) The name of the group in the WikiEditor. Defaults to 'insert' * - id {String} (required) Unique id (ie. 'my-button') * - icon {String} (recommended) URL to the icon, should be square about 21 to 22px * - label {String} (required) Tooltip displayed when hovering button * - insertBefore {String} (optional) Wikitext to be inserted before the cursor on-click * - sampleText {String} (optional) Text inserted in place of the cursor if no text was selected * - insertAfter {String} (optional) Wikitext to be inserted after the cursor on-click * - callback {Function} (optional) Called when the button is clicked * - autoSummary {mixed} (optional) Null or an Object with the following properties: * - summary {String} (required) Edit summary that should be used * - position {String} (optional) 'append', 'prepend' or 'replace' * - delimiter {String} (optional) delimiter between the (possibly) current summary and the to-be-inserted summary */ window.krInsertWikiEditorButton = function (options) { // Defaults options = $.extend({ 'section': 'main', 'group': 'insert', 'id': null, 'icon': '//upload.wikimedia.org/wikipedia/commons/thumb/f/f0/Toolbaricon_bold_!.png/21px-Toolbaricon_bold_!.png', 'label': '', 'insertBefore': '', 'sampleText': '', 'insertAfter': '', 'callback': null, 'autoSummary': { 'summary': null, 'position': 'append', 'delimiter': '; ' } }, options); // Required if (!options.id || !options.label) { return false; } var btnObj = { 'section': options.section, 'group': options.group, 'tools': {} }; btnObj.tools[options.id] = { label: options.label, type: 'button', icon: options.icon, action: { type: 'callback', execute: function () { // encapsulateSelection $toolbar.textSelection('encapsulateSelection', { pre: options.insertBefore, peri: options.sampleText, post: options.insertAfter }); // Auto summary if (options.autoSummary && options.autoSummary.summary) { var $summary = $('#wpSummary'), currentSum = $summary.val(); if (!$.trim(currentSum)) { $summary.val(options.autoSummary.summary); } else { switch (options.autoSummary.position) { case 'prepend': $summary.val( options.autoSummary.summary + options.autoSummary.delimiter + currentSum ); break; case 'replace': $summary.val(options.autoSummary.summary); break; default: // 'append' $summary.val( currentSum + options.autoSummary.delimiter + options.autoSummary.summary ); } } } // Callback if ($.isFunction(options.callback)) { options.callback(); } } } }; if ($toolbar) { insertButton(btnObj); } else { queue[queue.length] = btnObj; } }; $(document).ready(check); $(window).load(check); } else { // No-op function to avoid errors on other pages window.krInsertWikiEditorButton = function () {}; } }(jQuery, mediaWiki)); // Happy face krInsertWikiEditorButton({ id: "mw-customeditbutton-myspecialbutton", icon: "//www.gewiki.cz/images/6/67/Brouk-icon.jpg", label: 'Nevím si rady/potřebuji pomoct: Vloží Brouka, který upozorní správce, že stránka potřebuje doupravit', insertBefore: '{{Brouk|', insertAfter: '}}', sampleText: 'Důvod, proč vkládám Brouka' }); krInsertWikiEditorButton({ id: "mw-customeditbutton-otherfile", icon: "//www.gewiki.cz/images/c/c0/Toolbar-ikonka2.png", label: 'Vložit odkaz na jiný soubor než obrázek', insertBefore: '[[:Soubor:', insertAfter: '|Název odkazu]]', sampleText: 'NázevSouboruNaGewiki' }); krInsertWikiEditorButton({ id: "mw-customeditbutton-ik", icon: "//www.gewiki.cz/images/e/e3/Toolbar-IK-ikonka.png", label: 'Vložit instruktorskou kompetenci', insertBefore: '{{Ik15|', insertAfter: '}}', sampleText: '1.1' }); krInsertWikiEditorButton({ id: "mw-customeditbutton-vzk", icon: "//www.gewiki.cz/images/7/78/Vzk-ikonka.jpg", label: 'Vložit vůdcovskou kompetenci', insertBefore: '{{Vzk|', insertAfter: '}}', sampleText: '42' }); //Default sort tabulek function isSortedTablePage() { return ( wgPageName == "Castor 2017/Adresář" || wgPageName == "Other_Page_To_Sort" ); } jQuery( document ).ready( function( $ ) { // wrapped in "mw.loader.using" so this doesn't execute until Tablesorter has loaded mw.loader.using( 'jquery.tablesorter', function() { if( isSortedTablePage() ) $('table.sortable').tablesorter( {sortList: [ { 0: 'asc'} ]} ) // or look for tables with an ID attribute of "sortMe" on any page // $( '#sortMe' ).tablesorter( {sortList: [ { 0: 'asc'} ]} ) } ); } );