mediawiki-extensions-Templa.../modules/ext.templateDataGenerator.editPage.js
Moriel Schottlender df59f0179a Eventify TemplateDataGenerator and use oojs-ui
Change the ui/data behavior to work with oojs and event emitters,
and replace the gui from jquery ui to oojs-ui.

Changes made:
* Recreate the templatedata editor with oojs and ooui.
* Create a standalone templatedata model with internal validation.
* Allow the user to insert language-specific strings:
  * Allow adding arbitrary languages and values
  * Normalize output between language object and 'simple' string
  * Add new language code by searching for its name or code
* Import parameters from template code
  * If the template is in subpage and there is no code in the
    current page, the code will request the contents of the parent
    page.

Change-Id: I985ea03dfee58984ec22ec9a157a00968bfca878
2014-12-22 12:58:37 -05:00

31 lines
823 B
JavaScript

( function ( $, mw ) {
/**
* TemplateData Generator button fixture
* The button will appear on Template namespaces only, above the edit textbox
*
* @author Moriel Schottlender
*/
'use strict';
$( function () {
var config = {
isPageSubLevel: false
},
$textbox = $( '#wpTextbox1' ),
pageName = mw.config.get( 'wgPageName' );
// Check if there's an editor textarea and if we're in the proper namespace
if ( $textbox.length && mw.config.get( 'wgCanonicalNamespace' ) === 'Template' ) {
if ( pageName.indexOf( '/' ) > -1 ) {
config.parentPage = pageName.substr( 0, pageName.indexOf( '/' ) );
config.isPageSubLevel = pageName.indexOf( '/' ) > -1;
}
// Prepare the editor
mw.libs.tdgUi.init( $( '#mw-content-text' ), $textbox, config );
}
} );
}( jQuery, mediaWiki ) );