Difference between revisions of "MediaWiki:Common.js"

From Terminals
Jump to: navigation, search
m (experimental new terminal boilerplate)
m (change icon name)
Line 26: Line 26:
 
                         label: 'New Terminal',
 
                         label: 'New Terminal',
 
                         type: 'button',
 
                         type: 'button',
                         icon: 'reference',
+
                         icon: 'articleAdd',
 
                         action: {
 
                         action: {
 
                             type: 'encapsulate',
 
                             type: 'encapsulate',

Revision as of 01:41, 22 March 2026

/* Any JavaScript here will be loaded for all users on every page load. */

/**
 * Automatically tick the minor edit check box
 *
 * @source: http://www.mediawiki.org/wiki/Snippets/Mark_minor_edit
 * @rev: 2
 */
jQuery( document ).ready( function( $ ) {
    if( mw.config.get( 'wgAction' ) === 'edit' ) {
        document.getElementById( 'wpMinoredit' ).checked = true;
    }
});

/*
 * Add a button to insert new terminal page boilerplate.
 */
mw.loader.using(['jquery.wikiEditor'], function() {
    $(function() {
        $('#wpTextbox1').on('wikiEditor-toolbar-doneInitialSections', function() {
            $('#wpTextbox1').wikiEditor('addToToolbar', {
                section: 'main',
                group: 'insert',
                tools: {
                    'boilerplate': {
                        label: 'New Terminal',
                        type: 'button',
                        icon: 'articleAdd',
                        action: {
                            type: 'encapsulate',
                            options: {
                                pre: '{{your boilerplate text here}}'
                            }
                        }
                    }
                }
            });
        });
    });
});