Wikipedista:OJJ/common.js
Vzhled
Poznámka: Po uložení musíte vyprázdnit mezipaměť vašeho prohlížeče, jinak změny neuvidíte.
/**
* Interface for the classic edit toolbar. *
* Adapted from MediaWiki Core, before it was removed from it on 2018-10-17
*/
( function () {
var toolbar, isReady, $toolbar, queue, slice, $currentFocused;
/**
* Internal helper that does the actual insertion of the button into the toolbar.
*
* For backwards-compatibility, passing `imageFile`, `speedTip`, `tagOpen`, `tagClose`,
* `sampleText` and `imageId` as separate arguments (in this order) is also supported.
*
* @private
*
* @param {Object} button Object with the following properties.
* You are required to provide *either* the `onClick` parameter, or the three parameters
* `tagOpen`, `tagClose` and `sampleText`, but not both (they're mutually exclusive).
* @param {string} [button.imageFile] Image to use for the button.
* @param {string} button.speedTip Tooltip displayed when user mouses over the button.
* @param {Function} [button.onClick] Function to be executed when the button is clicked.
* @param {string} [button.tagOpen]
* @param {string} [button.tagClose]
* @param {string} [button.sampleText] Alternative to `onClick`. `tagOpen`, `tagClose` and
* `sampleText` together provide the markup that should be inserted into page text at
* current cursor position.
* @param {string} [button.imageId] `id` attribute of the button HTML element. Can be
* used to define the image with CSS if it's not provided as `imageFile`.
* @param {string} [speedTip]
* @param {string} [tagOpen]
* @param {string} [tagClose]
* @param {string} [sampleText]
* @param {string} [imageId]
*/
function insertButton( button, speedTip, tagOpen, tagClose, sampleText, imageId ) {
var $button;
// Backwards compatibility
if ( typeof button !== 'object' ) {
button = {
imageFile: button,
speedTip: speedTip,
tagOpen: tagOpen,
tagClose: tagClose,
sampleText: sampleText,
imageId: imageId
};
}
if ( button.imageFile ) {
$button = $( '<img>' ).attr( {
src: button.imageFile,
alt: button.speedTip,
title: button.speedTip,
id: button.imageId || undefined,
'class': 'mw-toolbar-editbutton'
} );
} else {
$button = $( '<div>' ).attr( {
title: button.speedTip,
id: button.imageId || undefined,
'class': 'mw-toolbar-editbutton'
} );
}
$button.click( function ( e ) {
if ( button.onClick !== undefined ) {
button.onClick( e );
} else {
toolbar.insertTags( button.tagOpen, button.tagClose, button.sampleText );
}
return false;
} );
$toolbar.append( $button );
}
isReady = false;
$toolbar = false;
/**
* @private
* @property {Array}
* Contains button objects (and for backwards compatibility, it can
* also contains an arguments array for insertButton).
*/
queue = [];
slice = queue.slice;
toolbar = {
/**
* Add buttons to the toolbar.
*
* Takes care of race conditions and time-based dependencies by placing buttons in a queue if
* this method is called before the toolbar is created.
*
* For backwards-compatibility, passing `imageFile`, `speedTip`, `tagOpen`, `tagClose`,
* `sampleText` and `imageId` as separate arguments (in this order) is also supported.
*
* @inheritdoc #insertButton
*/
addButton: function () {
if ( isReady ) {
insertButton.apply( toolbar, arguments );
} else {
// Convert arguments list to array
queue.push( slice.call( arguments ) );
}
},
/**
* Add multiple buttons to the toolbar (see also #addButton).
*
* Example usage:
*
* addButtons( [ { .. }, { .. }, { .. } ] );
* addButtons( { .. }, { .. } );
*
* @param {...Object|Array} [buttons] An array of button objects or the first
* button object in a list of variadic arguments.
*/
addButtons: function ( buttons ) {
if ( !Array.isArray( buttons ) ) {
buttons = slice.call( arguments );
}
if ( isReady ) {
buttons.forEach( function ( button ) {
insertButton( button );
} );
} else {
// Push each button into the queue
queue.push.apply( queue, buttons );
}
},
/**
* Apply tagOpen/tagClose to selection in currently focused textarea.
*
* Uses `sampleText` if selection is empty.
*
* @param {string} tagOpen
* @param {string} tagClose
* @param {string} sampleText
*/
insertTags: function ( tagOpen, tagClose, sampleText ) {
if ( $currentFocused && $currentFocused.length ) {
$currentFocused.textSelection(
'encapsulateSelection', {
pre: tagOpen,
peri: sampleText,
post: tagClose
}
);
}
}
};
// For backwards compatibility. Used to be called from EditPage.php, maybe other places as well.
toolbar.init = $.noop;
// Expose API publicly
mw.toolbar = toolbar;
$( function () {
var $textBox, i, button;
// Used to determine where to insert tags
$currentFocused = $( '#wpTextbox1' );
// Populate the selector cache for $toolbar
$toolbar = $( '#toolbar' );
if ( $toolbar.length === 0 ) {
$textBox = $( '#wpTextbox1' );
if ( $textBox.length === 0 ) {
return;
}
$toolbar = $( '<div>' ).attr( { id: 'toolbar' } );
$toolbar.insertBefore( $textBox );
}
for ( i = 0; i < queue.length; i++ ) {
button = queue[ i ];
if ( Array.isArray( button ) ) {
// Forwarded arguments array from mw.toolbar.addButton
insertButton.apply( toolbar, button );
} else {
// Raw object from mw.toolbar.addButtons
insertButton( button );
}
}
// Clear queue
queue.length = 0;
// This causes further calls to addButton to go to insertion directly
// instead of to the queue.
// It is important that this is after the one and only loop through
// the queue
isReady = true;
// Apply to dynamically created textboxes as well as normal ones
$( document ).on( 'focus', 'textarea, input:text', function () {
$currentFocused = $( this );
} );
} );
}() );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/2/27/Vector_toolbar_signature_button.png",
speedTip: "Podpis",
tagOpen: "--~~"+"~~",
tagClose: "",
sampleText: "",
imageId: "mw-editbutton-signature"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/e/e2/Button_bold.png",
speedTip: "Tučný text",
tagOpen: "'''",
tagClose: "'''",
sampleText: "Tučný text",
imageId: "mw-editbutton-bold"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/1/1d/Button_italic.png",
speedTip: "Kurzíva",
tagOpen: "''",
tagClose: "''",
sampleText: "Kurzíva",
imageId: "mw-editbutton-italic"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/c/c0/Button_link.png",
speedTip: "Odkaz",
tagOpen: "[[",
tagClose: "]]",
sampleText: "",
imageId: "mw-editbutton-link"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/7/78/Button_head_A2.png",
speedTip: "Nadpis úrovně 2",
tagOpen: "== ",
tagClose: " ==",
sampleText: "Nadpis úrovně 2",
imageId: "mw-editbutton-headline"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/d/de/Button_image.png",
speedTip: "Obrázek",
tagOpen: "[[Image:",
tagClose: "|thumb|Popisek]]",
sampleText: "Exemple.jpg",
imageId: "mw-editbutton-image"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/c/cd/Button_mdash.png",
speedTip: "Pomlčka",
tagOpen: "−",
tagClose: "",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/7/71/TableCell.png",
speedTip: "Svislítko",
tagOpen: "|",
tagClose: "",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/6/6a/Button_sup_letter.png",
speedTip: "Horní index",
tagOpen: "<sup"+">",
tagClose: "</"+"sup>",
sampleText: "",
imageId: "mw-editbutton-nowiki"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/a/aa/Button_sub_letter.png",
speedTip: "Dolní index",
tagOpen: "<sub"+">",
tagClose: "</"+"sub>",
sampleText: "",
imageId: "mw-editbutton-nowiki"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/8/88/Btn_toolbar_enum.png",
speedTip: "Číslovaný seznam",
tagOpen: "#",
tagClose: "",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/1/11/Btn_toolbar_liste.png",
speedTip: "Odrážkový seznam",
tagOpen: "*",
tagClose: "",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/2/23/Quotes-Lithuanian.png",
speedTip: "Uvozovky",
tagOpen: "„",
tagClose: "”",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/5/50/Button_hellip.png",
speedTip: "Tři tečky",
tagOpen: "…",
tagClose: "",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/0/0d/Button_hr.png",
speedTip: "Čára",
tagOpen: "--"+"--",
tagClose: "",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/c/c6/Button_Kat.png",
speedTip: "Kategorie",
tagOpen: "[[Kategorie:",
tagClose: "]]",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/3/3b/Comment-button-bg.png",
speedTip: "Zakomentování",
tagOpen: "<!--",
tagClose: "-->",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/5/55/Button_nbsp_1.png",
speedTip: "Pevná mezera",
tagOpen: " ",
tagClose: "",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/c/cb/Button_wikipedia.png",
speedTip: "Závěrečné sekce",
tagOpen: "== Reference ==\n<references />\n== Externí odkazy ==\n* {{Commonscat}}\n* {{Wikidruhy|taxon=}}\n{{Portály|",
tagClose: "}}",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/0/0c/Button_P_template.png",
speedTip: "Pracuje se",
tagOpen: "\x7b\x7bPracuje se|",
tagClose: "}}",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/2/2e/Button_broom.png",
speedTip: "Upravit",
tagOpen: "\x7b\x7bUpravit}}",
tagClose: "",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/f/f3/Button_broom2.png",
speedTip: "Urgentně upravit",
tagOpen: "\x7b\x7bsubst:urgentně upravit}}",
tagClose: "",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/0/0b/Button_fuente.png",
speedTip: "Neověřeno",
tagOpen: "\x7b\x7bNeověřeno}}",
tagClose: "",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/b/b8/Bouton_Faut_sourcer.png",
speedTip: "Urgentně ověřit",
tagOpen: "\x7b\x7bsubst:urgentně ověřit}}",
tagClose: "",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/a/a5/Button_STUB.png",
speedTip: "Subpahýl",
tagOpen: "\x7b\x7bsubst:Subpahýl}}",
tagClose: "",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/5/50/Button_tidyman.png",
speedTip: "Významnost",
tagOpen: "\x7b\x7bsubst:Významnost}}",
tagClose: "",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/9/94/Button_zdroj.png",
speedTip: "Fakt?",
tagOpen: "\x7b\x7bsubst:fakt}}",
tagClose: "",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/5/58/Button_black_copyright.png",
speedTip: "Copyvio",
tagOpen: "\x7b\x7bcopyvio|zdroj=",
tagClose: "}}",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/d/d1/Button_mysignature.png",
speedTip: "Nepodepsáno",
tagOpen: "\x7b\x7bNepodepsáno|",
tagClose: "}}",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/4/49/Button_talk.png",
speedTip: "Ping",
tagOpen: "\x7b\x7bping|",
tagClose: "|s=1}}",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/f/fb/Spam4.png",
speedTip: "Spam",
tagOpen: "\x7b\x7bsubst:spam}} --\x7E\x7E\x7E\x7E",
tagClose: "",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/3/3d/EXPBT0.png",
speedTip: "Experimenty0",
tagOpen: "\x7b\x7bsubst:Experimenty0}} --\x7E\x7E\x7E\x7E",
tagClose: "",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/4/41/Button_userandarticle.png",
speedTip: "ExperimentyUP",
tagOpen: "\x7b\x7bsubst:ExperimentyUP}} --\x7E\x7E\x7E\x7E",
tagClose: "",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/b/b0/EXPBT1.png",
speedTip: "Experimenty1",
tagOpen: "\x7b\x7bsubst:Experimenty}} --\x7E\x7E\x7E\x7E",
tagClose: "",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/a/ae/EXPBT2.png",
speedTip: "Experimenty2",
tagOpen: "\x7b\x7bsubst:Experimenty2}} --\x7E\x7E\x7E\x7E",
tagClose: "",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/e/e5/EXPBT3.png",
speedTip: "Experimenty3",
tagOpen: "\x7b\x7bsubst:Experimenty3}} --\x7E\x7E\x7E\x7E",
tagClose: "",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/3/3a/EXPBT2-o.png",
speedTip: "Experimenty2o",
tagOpen: "\x7b\x7bsubst:Experimenty2o}} --\x7E\x7E\x7E\x7E",
tagClose: "",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/c/ca/EXPBT3-o.png",
speedTip: "Experimenty3o",
tagOpen: "\x7b\x7bsubst:Experimenty3o}} --\x7E\x7E\x7E\x7E",
tagClose: "",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/8/83/Button_biocitas.png",
speedTip: "Nevýznamná osoba",
tagOpen: "\x7b\x7bsubst:EVL}} --\x7E\x7E\x7E\x7E",
tagClose: "",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/a/a9/Button_tournesol.png",
speedTip: "Vítejte",
tagOpen: "\x7b\x7bsubst:vítejte",
tagClose: "}} --\x7E\x7E\x7E\x7E",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/3/39/Button_IP.png",
speedTip: "Sdílená IP škola",
tagOpen: "\x7b\x7b{{Sdílená IP školy|",
tagClose: "}}",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/a/a0/Button_keep.png",
speedTip: "Vyřízeno",
tagOpen: ": {{Wikipedie:Nástěnka správců/Vyřešeno}}, ",
tagClose: "--\x7E\x7E\x7E\x7E",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/8/83/Button_encrypted.png",
speedTip: "Dlouhodobě polozamčeno",
tagOpen: "{{Dlouhodobě polozamčeno}}",
tagClose: "",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/9/91/Button_cite_web.png",
speedTip: "Citace webu",
tagOpen: "<ref>\x7b\x7bCitace elektronické monografie\n | příjmení = \n | jméno = \n | odkaz na autora = \n | titul = \n | url = \n | datum vydání = \n | datum přístupu = | vydavatel = \n | jazyk = \n}}</ref>",
tagClose: "",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/e/ef/Button_cite_book.png",
speedTip: "Citace knihy",
tagOpen: "<ref>\x7b\x7bCitace monografie\n | příjmení = \n | jméno = \n | titul = \n | vydavatel = \n | místo = \n | rok = \n | strany = \n | počet stran = \n | isbn = \n | poznámka = \n}}</ref>",
tagClose: "",
sampleText: "",
imageId: "mw-editbutton-hr"
} );
mw.toolbar.addButton( {
imageFile: "/media/wikipedia/commons/4/49/Button_cite_journal.png",
speedTip: "Citace periodika",
tagOpen: "<ref>\x7b\x7bCitace periodika\n | příjmení = \n | jméno = \n | spoluautoři = \n | titul = \n | periodikum = \n | rok = \n | měsíc = \n | ročník = \n | číslo = \n | datum = \n | strany = \n | url = \n | issn = \n}}</ref>",
tagClose: "",
sampleText: "",
imageId: "mw-editbutton-hr"
} );