2015-02-17 23:56:44 +00:00
|
|
|
( function () {
|
2015-03-07 01:20:26 +00:00
|
|
|
/*!
|
2013-09-21 03:46:02 +00:00
|
|
|
* TemplateData Generator button fixture
|
|
|
|
* The button will appear on Template namespaces only, above the edit textbox
|
|
|
|
*
|
|
|
|
* @author Moriel Schottlender
|
|
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
|
2014-05-20 22:51:46 +00:00
|
|
|
$( function () {
|
2015-02-18 22:55:17 +00:00
|
|
|
var pieces, isDocPage,
|
|
|
|
pageName = mw.config.get( 'wgPageName' ),
|
|
|
|
config = {
|
|
|
|
pageName: pageName,
|
2014-10-11 05:22:21 +00:00
|
|
|
isPageSubLevel: false
|
|
|
|
},
|
2015-02-18 22:55:17 +00:00
|
|
|
$textbox = $( '#wpTextbox1' );
|
2013-09-21 03:46:02 +00:00
|
|
|
|
|
|
|
// Check if there's an editor textarea and if we're in the proper namespace
|
2014-05-20 22:51:46 +00:00
|
|
|
if ( $textbox.length && mw.config.get( 'wgCanonicalNamespace' ) === 'Template' ) {
|
2015-02-18 22:55:17 +00:00
|
|
|
pieces = pageName.split( '/' );
|
|
|
|
isDocPage = pieces.length > 1 && pieces[ pieces.length - 1 ] === 'doc';
|
|
|
|
|
|
|
|
config = {
|
|
|
|
pageName: pageName,
|
|
|
|
isPageSubLevel: pieces.length > 1,
|
|
|
|
parentPage: pageName,
|
|
|
|
isDocPage: isDocPage
|
|
|
|
};
|
2014-10-11 05:22:21 +00:00
|
|
|
|
2015-02-18 22:55:17 +00:00
|
|
|
// Only if we are in a doc page do we set the parent page to
|
|
|
|
// the one above. Otherwise, all parent pages are current pages
|
|
|
|
if ( isDocPage ) {
|
|
|
|
pieces.pop();
|
|
|
|
config.parentPage = pieces.join( '/' );
|
|
|
|
}
|
2014-10-11 05:22:21 +00:00
|
|
|
// Prepare the editor
|
|
|
|
mw.libs.tdgUi.init( $( '#mw-content-text' ), $textbox, config );
|
2013-09-21 03:46:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} );
|
|
|
|
|
2015-02-17 23:56:44 +00:00
|
|
|
}() );
|