MediaViki:Gadget-MwToolbar.js

Vikipediya, azad ensiklopediya
Naviqasiyaya keç Axtarışa keç

Qeyd: Dəyişiklikləri yayımladıqdan sonra etdiyiniz dəyişikliklərin görünməsi üçün brauzerinizin keşinin təmizlənməsi lazım ola bilər.

  • Firefox / Safari: Reload düyməsinə basılı tutarkən Shift düyməsinə basın, və ya Ctrl+F5 və ya Ctrl+R (Mac üçün ⌘-R )
  • Google Chrome: Ctrl-Shift-R (Mac üçün ⌘-Shift-R)
  • Internet Explorer / Edge: Ctrl düyməsini basılı tutarkən Refresh düyməsinə basın, və ya sadəcə Ctrl+F5
  • Opera: Ctrl+F5.
( 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 );