mediawiki-extensions-Visual.../modules/ve-mw/ui/pages/ve.ui.MWTemplatesUsedPage.js
Thiemo Kreuz dc2ce8ff59 Use OO.ui.PageLayout.setupOutlineItem instead of setOutlineItem
The separate setup method was introduced in 2014 via I7c3c133.
It appears like most of the code here was written before this
method existed. Let's update it.

* this.outlineItem is guaranteed to be set. No need for the `if`.
* The parent method is effectively abstract. There is no point in
  calling it, I would argue.
* The return value is never used. I.e. this method is never
  chained, and probably shouldn't.

Change-Id: Ida26ebdf09be74958936c3950ebdf6def9a69bc0
2021-09-15 12:18:13 +02:00

85 lines
2.2 KiB
JavaScript

/*!
* VisualEditor user interface MWTemplatesUsedPage class.
*
* @copyright 2011-2016 VisualEditor Team and others; see AUTHORS.txt
* @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
* @cfg {jQuery} [$overlay] Overlay to render dropdowns in
*/
ve.ui.MWTemplatesUsedPage = function VeUiMWTemplatesUsedPage() {
var page = this,
target = ve.init.target;
// Parent constructor
ve.ui.MWTemplatesUsedPage.super.apply( this, arguments );
// Properties
this.templatesUsedFieldset = new OO.ui.FieldsetLayout( {
label: ve.msg( 'visualeditor-templatesused-tool' ),
icon: 'puzzle'
} );
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 {
return ve.createDeferred().reject().promise();
}
} ).then( function ( templatesUsed ) {
page.templatesUsedFieldset.$element.append( templatesUsed );
ve.targetLinksToNewWindow( page.templatesUsedFieldset.$element[ 0 ] );
}, function () {
page.templatesUsedFieldset.$element.append(
$( '<em>' ).text( ve.msg( 'visualeditor-dialog-meta-templatesused-noresults' ) )
);
} );
// Initialization
this.$element.append( this.templatesUsedFieldset.$element );
};
/* Inheritance */
OO.inheritClass( ve.ui.MWTemplatesUsedPage, OO.ui.PageLayout );
/* Methods */
/**
* @inheritdoc
*/
ve.ui.MWTemplatesUsedPage.prototype.setupOutlineItem = function () {
this.outlineItem
.setIcon( 'puzzle' )
.setLabel( ve.msg( 'visualeditor-templatesused-tool' ) );
};
/**
* @inheritdoc
*/
ve.ui.MWTemplatesUsedPage.prototype.focus = function () {
// No controls, just focus the whole page instead of the first link
this.$element[ 0 ].focus();
};
ve.ui.MWTemplatesUsedPage.prototype.getFieldsets = function () {
return [
this.templatesUsedFieldset
];
};