MediaWiki:Gadget-Summaries.js

/** * Standard edit summaries * * @author Sikon     * @author Ryan PM  * @author Quarenon  * @author Eladkse  * @author Cqm      */

// define globals ( this.rswiki = this.rswiki || {} ).gadgets = this.rswiki.gadgets || {}; this.rswiki.scripts = this.rswiki.scripts || [];

/*global jQuery:true, mediaWiki:true, rswiki:true */


 * ( function ( $, mw, rswiki ) {

'use strict';

var stdSummaries = { /**        *         */        init: function  {

if ( mw.config.get( 'wgAction' ) !== 'edit' ) { return; }

// for easy tracking of which scripts have loaded rswiki.script.push( 'stdsummaries' );

stdSummaries.getSummaries;

},       /**         * Get the summaries from MediaWiki:Stdsummaries */       getSummaries: function  {

$.get( mw.config.get( 'wgScript' ), { title: 'MediaWiki:Stdsummaries', action: 'raw', ctype: 'text/plain' }, function ( data ) {

var summaries = data.split( '\n' ), options = '(Browse standard summaries) ', value, i;

for ( i = 0; i < summaries.length; i += 1 ) { switch ( 0 ) { case summaries[i].indexOf( '--' ): value = summaries[i].substring(2).trim; options += '' + value + ' '; break; // ignore lines starting with // so we can use comments case summaries[i].indexOf( '//' ): // ignore empty lines case summaries[i].length: break; default: value = summaries[i].trim; options += ' ' + value + ' '; break; }               }

stdSummaries.insertModule( options );

} );

},       /**         * Insert the summaries module * @param list string of option elements */       insertModule: function ( list ) {

var module = $( ' ' ) .attr( {                   id: 'stdSummaries'                } ) .append(                   $( ' ' )                    .attr( { id: 'stdSummaries-dropdown' } )                   .append( list )                    .change( function  { var val = $( this ).val;

if ( val === '(browse)' ) { return; }                       // @todo rte support $( '#wpSummary' ).val( val ); } )               );

$( '#wpSummaryLabel' ).after( module );

}   };

$( stdSummaries.init );

}( jQuery, mediaWiki, rswiki ) );

/*   $('.module_content #wpSummary').css({        'margin-bottom': '8px'    });

$('.module_content #stdSummaries').css({       'width': '258px',        'margin-bottom': '5px'    });



/* */