MediaWiki:Wikia.js

/* */ /** * * Custom preload templates for the new Wikia editor * * @author Grunny * @version 0.0.1 * */

function customPreloadTemplates {

if ( mw.config.get( 'wgAction' ) !== 'edit' || !$( 'div.module_content' ).length ) { return; }

var	preloadOptionsHtml = '', $preloadOptionsList;

$( 'div.module_content:first' ).append( ' Standard preloads: ' );

$.get( wgScript, { title: 'Template:Stdpreloads', action: 'raw', ctype: 'text/plain' }, function( data ) {		var lines = data.split( '\n' );		for( var i in lines ) {			var value = ( lines[i].indexOf( '-- ' ) === 0 ) ? lines[i].substring(3) : "";			preloadOptionsHtml += '' + lines[i] + ' ';		}		$preloadOptionsList = $( ' ' ).attr( 'id', 'stdSummaries' ).html( preloadOptionsHtml ).change( function { var value = $( this ).val; if ( value !== '' ) { value = 'Template:' + value + '/preload'; value = value.replace( ' ', '_' ); $.get( wgScript, { title: value, action: 'raw', ctype: 'text/plain' }, function( data ) {					var editTextBox = document.getElementById( 'cke_wpTextbox1' ) ? document.getElementsByClassName( 'cke_source' )[0] : document.getElementById( 'wpTextbox1' );					if ( editTextBox ) {						insertAtCursor( editTextBox, data );					}				} ); }		} );

$( 'div#lf-preload' ).append( $preloadOptionsList ); } );

} $( customPreloadTemplates ); /* */