mediawiki-extensions-Templa.../modules/ext.templateDataGenerator.editPage.js
James D. Forrester 64a39ae460 Add a grunt checker for jshint, jscs, csslint, and banana and pass them
There was a pre-existing jshint config (.jshintrc) file that this upgrades based
on the equivalent files for VisualEditor and OOjs UI.

Change-Id: I3ecb0e65cc7ff090b7457be895917fbd8b8afd18
2014-06-03 20:16:18 -07:00

44 lines
1.1 KiB
JavaScript

( function ( $, mw ) {
/**
* TemplateData Generator button fixture
* The button will appear on Template namespaces only, above the edit textbox
*
* @author Moriel Schottlender
*/
'use strict';
$( document ).ready(function () {
var tmplDataGen, editboxObjects,
$textbox = $( '#wpTextbox1' );
// Check if there's an editor textarea and if we're in the proper namespace
if ( $textbox.length > 0 && mw.config.get( 'wgCanonicalNamespace' ) === 'Template' ) {
tmplDataGen = mw.libs.templateDataGenerator;
editboxObjects = tmplDataGen.init();
// Add the button and modal element to the document
$( '#mw-content-text' )
.prepend(
editboxObjects.$modalBox,
editboxObjects.$errorBox,
editboxObjects.$editButton
);
$( '.tdg-editscreen-main-button' ).click( function () {
var $modalBox = tmplDataGen.createModal( $textbox.val() );
// open the dialog
$modalBox.dialog( 'open' );
// respond to modal close event
$modalBox.on( 'TemplateDataGeneratorDone', function ( e, output ) {
$textbox.val( output );
} );
} );
}
} );
}( jQuery, mediaWiki ) );