mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-25 23:05:35 +00:00
5a4eea63a5
It was falling back to the default ve.ui.Inspector title message, which doesn't exist. The message was right there in the i18n file, it just wasn't being used. Change-Id: I0676829d5787fa0f1d7ed7481b1dc55437237dd4
100 lines
2.6 KiB
JavaScript
100 lines
2.6 KiB
JavaScript
/*!
|
|
* VisualEditor UserInterface MWAlienExtensionInspector class.
|
|
*
|
|
* @copyright 2011-2014 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* MediaWiki alien extension inspector.
|
|
*
|
|
* @class
|
|
* @extends ve.ui.MWExtensionInspector
|
|
*
|
|
* @constructor
|
|
* @param {ve.ui.WindowSet} windowSet Window set this inspector is part of
|
|
* @param {Object} [config] Configuration options
|
|
*/
|
|
ve.ui.MWAlienExtensionInspector = function VeUiMWAlienExtensionInspector( windowSet, config ) {
|
|
// Parent constructor
|
|
ve.ui.MWExtensionInspector.call( this, windowSet, config );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.ui.MWAlienExtensionInspector, ve.ui.MWExtensionInspector );
|
|
|
|
/* Static properties */
|
|
|
|
ve.ui.MWAlienExtensionInspector.static.name = 'alienExtension';
|
|
|
|
ve.ui.MWAlienExtensionInspector.static.icon = 'alienextension';
|
|
|
|
ve.ui.MWAlienExtensionInspector.static.title =
|
|
OO.ui.deferMsg( 'visualeditor-mwalienextensioninspector-title' );
|
|
|
|
ve.ui.MWAlienExtensionInspector.static.nodeView = ve.ce.MWAlienExtensionNode;
|
|
|
|
ve.ui.MWAlienExtensionInspector.static.nodeModel = ve.dm.MWAlienExtensionNode;
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
ve.ui.MWAlienExtensionInspector.prototype.getTitle = function () {
|
|
return this.surface.getView().getFocusedNode().getModel().getExtensionName();
|
|
};
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
ve.ui.MWAlienExtensionInspector.prototype.initialize = function () {
|
|
// Parent method
|
|
ve.ui.MWExtensionInspector.prototype.initialize.call( this );
|
|
|
|
var key, attributeInput, field,
|
|
attributes = this.surface.getView().getFocusedNode().model.getAttribute( 'mw' ).attrs;
|
|
|
|
this.attributeInputs = {};
|
|
|
|
if ( attributes && !ve.isEmptyObject( attributes ) ) {
|
|
for ( key in attributes ) {
|
|
attributeInput = new OO.ui.TextInputWidget( {
|
|
'$': this.$,
|
|
'value': attributes[key]
|
|
} );
|
|
this.attributeInputs[key] = attributeInput;
|
|
field = new OO.ui.FieldLayout(
|
|
attributeInput,
|
|
{
|
|
'$': this.$,
|
|
'align': 'left',
|
|
'label': key
|
|
}
|
|
);
|
|
this.$form.append( field.$element.addClass( 've-ui-mwAlienExtensionInspector-attributes' ) );
|
|
}
|
|
}
|
|
};
|
|
|
|
/** */
|
|
ve.ui.MWAlienExtensionInspector.prototype.updateMwData = function ( mwData ) {
|
|
// Parent method
|
|
ve.ui.MWExtensionInspector.prototype.updateMwData.call( this, mwData );
|
|
|
|
var key;
|
|
|
|
if ( !ve.isEmptyObject( this.attributeInputs ) ) {
|
|
// Make sure we have an attrs object to populate
|
|
mwData.attrs = mwData.attrs || {};
|
|
for ( key in this.attributeInputs ) {
|
|
mwData.attrs[key] = this.attributeInputs[key].getValue();
|
|
}
|
|
}
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.ui.inspectorFactory.register( ve.ui.MWAlienExtensionInspector );
|