MediaWiki:Gadget-MwToolbar.js
Jump to navigation
Jump to search
Qeyd: Yaddaşa verdikdən sonra dəyişikliklərin görünməsi üçün brauzerinizin keşindən yan keçilməsi lazım ola bilər. Mozilla / Firefox / Safari: Reload düyməsini basarkən eyni vaxtda Shift-i basılı tutun və ya Ctrl-Shift-R-a basın. (Apple Mac-da Cmd-Shift-R). İE: Refresh düyməsini basarkən eyni vaxtda Ctrl-i basılı tutun və ya Ctrl-F5-ə basın. Conqueror: Sadəcə Reload düyməsinə və ya F5-ə basın. Opera brauzeri redaktorları Tools→Preferences-dən cache-lərini tamamilə təmizləməli ola bilərlər.
( function ( $, mw, undefined ) {
var toolbar, $currentFocused;
mw.libs.toolbar = {
/**
* 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
}
);
}
}
};
$( function () {
// Used to determine where to insert tags
$currentFocused = $( '#wpTextbox1' );
// Apply to dynamically created textboxes as well as normal ones
$( document ).on( 'focus', 'textarea, input:text', function () {
$currentFocused = $( this );
} );
} );
} )( jQuery, mediaWiki );