2013-08-07 05:21:10 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor ContentEditable MWAlienExtensionNode class.
|
|
|
|
*
|
2016-01-03 22:56:59 +00:00
|
|
|
* @copyright 2011-2016 VisualEditor Team and others; see AUTHORS.txt
|
2013-08-07 05:21:10 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ContentEditable MediaWiki alien extension node.
|
|
|
|
*
|
|
|
|
* @class
|
2015-03-23 15:49:38 +00:00
|
|
|
* @abstract
|
2015-06-05 17:59:00 +00:00
|
|
|
* @mixins OO.ui.mixin.IconElement
|
2013-08-07 05:21:10 +00:00
|
|
|
*
|
|
|
|
* @constructor
|
2013-09-25 10:21:09 +00:00
|
|
|
* @param {Object} [config] Configuration options
|
2013-08-07 05:21:10 +00:00
|
|
|
*/
|
2015-03-20 21:39:54 +00:00
|
|
|
ve.ce.MWAlienExtensionNode = function VeCeMWAlienExtensionNode( config ) {
|
|
|
|
// Mixin constructors
|
2015-06-05 17:59:00 +00:00
|
|
|
OO.ui.mixin.IconElement.call( this, config );
|
2015-03-23 15:49:38 +00:00
|
|
|
|
|
|
|
// Events
|
|
|
|
this.connect( this, { setup: 'onAlienSetup' } );
|
2013-08-07 05:21:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
2015-03-23 15:49:38 +00:00
|
|
|
OO.initClass( ve.ce.MWAlienExtensionNode );
|
2013-08-07 05:21:10 +00:00
|
|
|
|
2015-06-05 17:59:00 +00:00
|
|
|
OO.mixinClass( ve.ce.MWAlienExtensionNode, OO.ui.mixin.IconElement );
|
2015-03-20 21:39:54 +00:00
|
|
|
|
2015-03-23 15:49:38 +00:00
|
|
|
/* Static members */
|
2013-08-07 05:21:10 +00:00
|
|
|
|
2013-12-20 23:25:24 +00:00
|
|
|
ve.ce.MWAlienExtensionNode.static.primaryCommandName = 'alienExtension';
|
|
|
|
|
2014-11-12 19:02:57 +00:00
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
2015-03-23 15:49:38 +00:00
|
|
|
* Handle setup events
|
2014-11-12 19:02:57 +00:00
|
|
|
*/
|
2015-03-23 15:49:38 +00:00
|
|
|
ve.ce.MWAlienExtensionNode.prototype.onAlienSetup = function () {
|
2015-03-20 21:39:54 +00:00
|
|
|
if ( !this.isVisible() ) {
|
|
|
|
this.setIcon( 'alienextension' );
|
|
|
|
this.$element.first().prepend( this.$icon );
|
|
|
|
} else {
|
|
|
|
this.setIcon( null );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2015-03-23 15:49:38 +00:00
|
|
|
* @inheritdoc ve.ce.MWExtensionNode
|
2015-03-20 21:39:54 +00:00
|
|
|
*/
|
|
|
|
ve.ce.MWAlienExtensionNode.prototype.render = function ( generatedContents ) {
|
2015-12-09 16:47:13 +00:00
|
|
|
// Since render is triggered before onSetup, we need to make sure that the
|
2015-03-20 21:39:54 +00:00
|
|
|
// icon is detached only when it is defined and is not null
|
|
|
|
if ( this.$icon ) {
|
|
|
|
this.$icon.detach();
|
|
|
|
}
|
|
|
|
// Call parent mixin
|
|
|
|
ve.ce.GeneratedContentNode.prototype.render.call( this, generatedContents );
|
|
|
|
|
|
|
|
// Since render replaces this.$element with a new node, we need to make sure
|
|
|
|
// our iconElement is defined again to be this.$element
|
2014-11-12 19:02:57 +00:00
|
|
|
this.$element.addClass( 've-ce-mwAlienExtensionNode' );
|
|
|
|
};
|
|
|
|
|
2015-03-23 15:49:38 +00:00
|
|
|
/* Static methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc ve.ce.MWExtensionNode
|
|
|
|
*/
|
|
|
|
ve.ce.MWAlienExtensionNode.static.getDescription = function ( model ) {
|
|
|
|
return model.getExtensionName();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ContentEditable MediaWiki alien inline extension node.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @abstract
|
|
|
|
* @extends ve.ce.MWInlineExtensionNode
|
|
|
|
* @mixins ve.ce.MWAlienExtensionNode
|
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @param {Object} [config] Configuration options
|
|
|
|
*/
|
|
|
|
ve.ce.MWAlienInlineExtensionNode = function VeCeMWAlienInlineExtensionNode( config ) {
|
|
|
|
// Parent constructor
|
|
|
|
ve.ce.MWAlienInlineExtensionNode.super.apply( this, arguments );
|
|
|
|
|
|
|
|
// Mixin constructors
|
|
|
|
ve.ce.MWAlienExtensionNode.call( this, config );
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
OO.inheritClass( ve.ce.MWAlienInlineExtensionNode, ve.ce.MWInlineExtensionNode );
|
|
|
|
|
|
|
|
OO.mixinClass( ve.ce.MWAlienInlineExtensionNode, ve.ce.MWAlienExtensionNode );
|
|
|
|
|
|
|
|
/* Static members */
|
|
|
|
|
|
|
|
ve.ce.MWAlienInlineExtensionNode.static.name = 'mwAlienInlineExtension';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ContentEditable MediaWiki alien block extension node.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @abstract
|
|
|
|
* @extends ve.ce.MWBlockExtensionNode
|
|
|
|
* @mixins ve.ce.MWAlienExtensionNode
|
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @param {ve.dm.MWAlienBlockExtensionNode} model Model to observe
|
|
|
|
* @param {Object} [config] Configuration options
|
|
|
|
*/
|
|
|
|
ve.ce.MWAlienBlockExtensionNode = function VeCeMWAlienBlockExtensionNode() {
|
|
|
|
// Parent constructor
|
|
|
|
ve.ce.MWAlienBlockExtensionNode.super.apply( this, arguments );
|
|
|
|
|
|
|
|
// Mixin constructors
|
|
|
|
ve.ce.MWAlienExtensionNode.call( this );
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
OO.inheritClass( ve.ce.MWAlienBlockExtensionNode, ve.ce.MWBlockExtensionNode );
|
|
|
|
|
|
|
|
OO.mixinClass( ve.ce.MWAlienBlockExtensionNode, ve.ce.MWAlienExtensionNode );
|
|
|
|
|
|
|
|
/* Static members */
|
|
|
|
|
|
|
|
ve.ce.MWAlienBlockExtensionNode.static.name = 'mwAlienBlockExtension';
|
|
|
|
|
2013-08-07 05:21:10 +00:00
|
|
|
/* Registration */
|
|
|
|
|
2015-03-23 15:49:38 +00:00
|
|
|
ve.ce.nodeFactory.register( ve.ce.MWAlienInlineExtensionNode );
|
|
|
|
ve.ce.nodeFactory.register( ve.ce.MWAlienBlockExtensionNode );
|