2013-08-07 05:21:10 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor UserInterface MWAlienExtensionInspector class.
|
|
|
|
*
|
2015-01-08 23:54:03 +00:00
|
|
|
* @copyright 2011-2015 VisualEditor Team and others; see AUTHORS.txt
|
2013-08-07 05:21:10 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2014-07-14 21:32:49 +00:00
|
|
|
* Inspector for editing alienated MediaWiki extensions.
|
2013-08-07 05:21:10 +00:00
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.ui.MWExtensionInspector
|
|
|
|
*
|
|
|
|
* @constructor
|
2013-09-25 10:21:09 +00:00
|
|
|
* @param {Object} [config] Configuration options
|
2013-08-07 05:21:10 +00:00
|
|
|
*/
|
2015-03-27 18:56:16 +00:00
|
|
|
ve.ui.MWAlienExtensionInspector = function VeUiMWAlienExtensionInspector() {
|
2013-08-07 05:21:10 +00:00
|
|
|
// Parent constructor
|
2015-03-27 18:56:16 +00:00
|
|
|
ve.ui.MWAlienExtensionInspector.super.apply( this, arguments );
|
2014-04-04 17:42:13 +00:00
|
|
|
|
|
|
|
// Properties
|
|
|
|
this.attributeInputs = {};
|
|
|
|
this.$attributes = null;
|
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';
|
|
|
|
|
2015-03-23 15:49:38 +00:00
|
|
|
ve.ui.MWAlienExtensionInspector.static.modelClasses = [
|
|
|
|
ve.dm.MWAlienInlineExtensionNode,
|
|
|
|
ve.dm.MWAlienBlockExtensionNode
|
|
|
|
];
|
2013-08-07 05:21:10 +00:00
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
2013-11-05 00:29:50 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2013-08-07 05:21:10 +00:00
|
|
|
ve.ui.MWAlienExtensionInspector.prototype.initialize = function () {
|
|
|
|
// Parent method
|
2014-04-04 17:42:13 +00:00
|
|
|
ve.ui.MWExtensionInspector.prototype.initialize.apply( this, arguments );
|
2013-08-07 05:21:10 +00:00
|
|
|
|
2015-04-09 23:47:15 +00:00
|
|
|
this.$attributes = $( '<div>' ).addClass( 've-ui-mwAlienExtensionInspector-attributes' );
|
2014-07-14 21:32:49 +00:00
|
|
|
this.form.$element.append( this.$attributes );
|
2014-04-04 17:42:13 +00:00
|
|
|
};
|
2013-12-06 14:52:26 +00:00
|
|
|
|
2014-04-04 17:42:13 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2014-05-31 04:47:08 +00:00
|
|
|
ve.ui.MWAlienExtensionInspector.prototype.getSetupProcess = function ( data ) {
|
|
|
|
return ve.ui.MWAlienExtensionInspector.super.prototype.getSetupProcess.call( this, data )
|
|
|
|
.next( function () {
|
|
|
|
var key, attributeInput, field,
|
2015-03-23 15:09:49 +00:00
|
|
|
attributes = this.selectedNode.getAttribute( 'mw' ).attrs;
|
2014-05-31 04:47:08 +00:00
|
|
|
|
|
|
|
if ( attributes && !ve.isEmptyObject( attributes ) ) {
|
|
|
|
for ( key in attributes ) {
|
|
|
|
attributeInput = new OO.ui.TextInputWidget( {
|
2015-08-19 17:33:02 +00:00
|
|
|
value: attributes[ key ]
|
2014-05-31 04:47:08 +00:00
|
|
|
} );
|
2015-08-19 17:33:02 +00:00
|
|
|
this.attributeInputs[ key ] = attributeInput;
|
2014-05-31 04:47:08 +00:00
|
|
|
field = new OO.ui.FieldLayout(
|
|
|
|
attributeInput,
|
|
|
|
{
|
2014-08-22 20:50:48 +00:00
|
|
|
align: 'left',
|
|
|
|
label: key
|
2014-05-31 04:47:08 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
this.$attributes.append( field.$element );
|
2013-12-06 14:52:26 +00:00
|
|
|
}
|
2014-05-31 04:47:08 +00:00
|
|
|
}
|
2014-07-14 21:32:49 +00:00
|
|
|
|
2015-03-23 15:09:49 +00:00
|
|
|
this.title.setLabel( this.selectedNode.getExtensionName() );
|
2014-05-31 04:47:08 +00:00
|
|
|
}, this );
|
2013-12-06 14:52:26 +00:00
|
|
|
};
|
|
|
|
|
2014-04-04 17:42:13 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2014-05-31 04:47:08 +00:00
|
|
|
ve.ui.MWAlienExtensionInspector.prototype.getTeardownProcess = function ( data ) {
|
|
|
|
return ve.ui.MWAlienExtensionInspector.super.prototype.getTeardownProcess.call( this, data )
|
2015-01-05 17:58:31 +00:00
|
|
|
.next( function () {
|
2014-05-31 04:47:08 +00:00
|
|
|
this.$attributes.empty();
|
|
|
|
this.attributeInputs = {};
|
|
|
|
}, this );
|
2014-04-04 17:42:13 +00:00
|
|
|
};
|
|
|
|
|
2013-12-06 14:52:26 +00:00
|
|
|
/** */
|
|
|
|
ve.ui.MWAlienExtensionInspector.prototype.updateMwData = function ( mwData ) {
|
|
|
|
// Parent method
|
2014-05-31 04:47:08 +00:00
|
|
|
ve.ui.MWAlienExtensionInspector.super.prototype.updateMwData.call( this, mwData );
|
2013-12-06 14:52:26 +00:00
|
|
|
|
|
|
|
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 ) {
|
2015-08-19 17:33:02 +00:00
|
|
|
mwData.attrs[ key ] = this.attributeInputs[ key ].getValue();
|
2013-12-06 14:52:26 +00:00
|
|
|
}
|
|
|
|
}
|
2013-08-07 05:21:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Registration */
|
|
|
|
|
2014-04-21 22:31:21 +00:00
|
|
|
ve.ui.windowFactory.register( ve.ui.MWAlienExtensionInspector );
|