2013-08-07 05:21:10 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor UserInterface MWAlienExtensionInspector class.
|
|
|
|
*
|
2014-01-05 12:05:05 +00:00
|
|
|
* @copyright 2011-2014 VisualEditor Team and others; see AUTHORS.txt
|
2013-08-07 05:21:10 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MediaWiki alien extension inspector.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.ui.MWExtensionInspector
|
|
|
|
*
|
|
|
|
* @constructor
|
2014-03-06 01:07:20 +00:00
|
|
|
* @param {ve.ui.Surface} surface Surface inspector is for
|
2013-09-25 10:21:09 +00:00
|
|
|
* @param {Object} [config] Configuration options
|
2013-08-07 05:21:10 +00:00
|
|
|
*/
|
2014-03-06 01:07:20 +00:00
|
|
|
ve.ui.MWAlienExtensionInspector = function VeUiMWAlienExtensionInspector( surface, config ) {
|
2013-08-07 05:21:10 +00:00
|
|
|
// Parent constructor
|
2014-03-06 01:07:20 +00:00
|
|
|
ve.ui.MWExtensionInspector.call( this, surface, config );
|
2013-08-07 05:21:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
2013-10-11 21:44:09 +00:00
|
|
|
OO.inheritClass( ve.ui.MWAlienExtensionInspector, ve.ui.MWExtensionInspector );
|
2013-08-07 05:21:10 +00:00
|
|
|
|
|
|
|
/* Static properties */
|
|
|
|
|
2013-08-27 23:28:29 +00:00
|
|
|
ve.ui.MWAlienExtensionInspector.static.name = 'alienExtension';
|
|
|
|
|
2013-08-07 05:21:10 +00:00
|
|
|
ve.ui.MWAlienExtensionInspector.static.icon = 'alienextension';
|
|
|
|
|
2014-02-20 03:44:26 +00:00
|
|
|
ve.ui.MWAlienExtensionInspector.static.title =
|
|
|
|
OO.ui.deferMsg( 'visualeditor-mwalienextensioninspector-title' );
|
|
|
|
|
2013-08-07 05:21:10 +00:00
|
|
|
ve.ui.MWAlienExtensionInspector.static.nodeView = ve.ce.MWAlienExtensionNode;
|
|
|
|
|
|
|
|
ve.ui.MWAlienExtensionInspector.static.nodeModel = ve.dm.MWAlienExtensionNode;
|
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
2013-11-05 00:29:50 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.ui.MWAlienExtensionInspector.prototype.getTitle = function () {
|
|
|
|
return this.surface.getView().getFocusedNode().getModel().getExtensionName();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2013-08-07 05:21:10 +00:00
|
|
|
ve.ui.MWAlienExtensionInspector.prototype.initialize = function () {
|
|
|
|
// Parent method
|
|
|
|
ve.ui.MWExtensionInspector.prototype.initialize.call( this );
|
|
|
|
|
2013-12-06 14:52:26 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
2013-08-07 05:21:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Registration */
|
|
|
|
|
2013-08-27 23:28:29 +00:00
|
|
|
ve.ui.inspectorFactory.register( ve.ui.MWAlienExtensionInspector );
|