mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/TemplateData
synced 2024-11-12 09:24:17 +00:00
8c27921232
This adds a TemplateData manager to the edit page in the Template namespace. If a <templatedata> tag already exists, the tool will parse it and display it in a visual interface that the user can then manipulate in their own language. If there is no <templatedata> tag, the dialog will appear empty and allow users to add and tweak their desired template parameter data. The tool also allows rudimentary parameter import, which picks up the parameters from a current template into the GUI to make the user's life easier when producing TemplateData. The template documentation editor feature is off by default. To enable it use $wgTemplateDataUseGUI = true in LocalSettings. Bug: 50436 Change-Id: I863a8199c0b08cc52b320ed00dcba912dd2aeefc
44 lines
1.1 KiB
JavaScript
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 ) );
|