2016-12-18 19:04:20 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor user interface MWTemplatesUsedPage class.
|
|
|
|
*
|
2023-12-01 16:06:11 +00:00
|
|
|
* @copyright See AUTHORS.txt
|
2016-12-18 19:04:20 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MediaWiki meta dialog TemplatesUsed page.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends OO.ui.PageLayout
|
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @param {string} name Unique symbolic name of page
|
|
|
|
* @param {Object} [config] Configuration options
|
2018-04-04 20:37:32 +00:00
|
|
|
* @cfg {jQuery} [$overlay] Overlay to render dropdowns in
|
2016-12-18 19:04:20 +00:00
|
|
|
*/
|
|
|
|
ve.ui.MWTemplatesUsedPage = function VeUiMWTemplatesUsedPage() {
|
2019-02-22 18:50:46 +00:00
|
|
|
var page = this,
|
|
|
|
target = ve.init.target;
|
|
|
|
|
2016-12-18 19:04:20 +00:00
|
|
|
// Parent constructor
|
|
|
|
ve.ui.MWTemplatesUsedPage.super.apply( this, arguments );
|
|
|
|
|
|
|
|
// Properties
|
|
|
|
this.templatesUsedFieldset = new OO.ui.FieldsetLayout( {
|
|
|
|
label: ve.msg( 'visualeditor-templatesused-tool' ),
|
2017-07-06 16:52:56 +00:00
|
|
|
icon: 'puzzle'
|
2016-12-18 19:04:20 +00:00
|
|
|
} );
|
|
|
|
|
2022-01-11 22:42:12 +00:00
|
|
|
this.templatesUsedFieldset.$group.addClass( [
|
2023-10-31 21:06:04 +00:00
|
|
|
'mw-body-content'
|
2022-01-11 22:42:12 +00:00
|
|
|
] );
|
|
|
|
|
2019-02-22 18:50:46 +00:00
|
|
|
target.getContentApi().get( {
|
|
|
|
action: 'visualeditor',
|
|
|
|
paction: 'templatesused',
|
|
|
|
page: target.getPageName(),
|
|
|
|
uselang: mw.config.get( 'wgUserLanguage' )
|
|
|
|
} ).then( function ( response ) {
|
|
|
|
var templatesUsed = $.parseHTML( response.visualeditor );
|
|
|
|
if ( templatesUsed.length && $( templatesUsed ).find( 'li' ).length ) {
|
|
|
|
return templatesUsed;
|
|
|
|
} else {
|
2019-11-02 05:06:28 +00:00
|
|
|
return ve.createDeferred().reject().promise();
|
2019-02-22 18:50:46 +00:00
|
|
|
}
|
|
|
|
} ).then( function ( templatesUsed ) {
|
2021-10-25 15:51:29 +00:00
|
|
|
// templatesUsed is an array of nodes
|
|
|
|
// eslint-disable-next-line no-jquery/no-append-html
|
2022-01-11 22:42:12 +00:00
|
|
|
page.templatesUsedFieldset.$group.append( templatesUsed );
|
|
|
|
ve.targetLinksToNewWindow( page.templatesUsedFieldset.$group[ 0 ] );
|
2019-02-22 18:50:46 +00:00
|
|
|
}, function () {
|
2022-01-11 22:42:12 +00:00
|
|
|
page.templatesUsedFieldset.$group.append(
|
2016-12-18 19:04:20 +00:00
|
|
|
$( '<em>' ).text( ve.msg( 'visualeditor-dialog-meta-templatesused-noresults' ) )
|
|
|
|
);
|
2019-02-22 18:50:46 +00:00
|
|
|
} );
|
2016-12-18 19:04:20 +00:00
|
|
|
|
|
|
|
// Initialization
|
|
|
|
this.$element.append( this.templatesUsedFieldset.$element );
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
OO.inheritClass( ve.ui.MWTemplatesUsedPage, OO.ui.PageLayout );
|
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2021-09-15 10:10:56 +00:00
|
|
|
ve.ui.MWTemplatesUsedPage.prototype.setupOutlineItem = function () {
|
|
|
|
this.outlineItem
|
|
|
|
.setIcon( 'puzzle' )
|
|
|
|
.setLabel( ve.msg( 'visualeditor-templatesused-tool' ) );
|
2016-12-18 19:04:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.ui.MWTemplatesUsedPage.prototype.focus = function () {
|
|
|
|
// No controls, just focus the whole page instead of the first link
|
2019-01-18 21:03:38 +00:00
|
|
|
this.$element[ 0 ].focus();
|
2016-12-18 19:04:20 +00:00
|
|
|
};
|
2018-10-28 19:18:40 +00:00
|
|
|
|
|
|
|
ve.ui.MWTemplatesUsedPage.prototype.getFieldsets = function () {
|
|
|
|
return [
|
|
|
|
this.templatesUsedFieldset
|
|
|
|
];
|
|
|
|
};
|