mediawiki-extensions-Visual.../modules/ve/ce/nodes/ve.ce.AlienNode.js
Trevor Parscal db9f941fa6 Rename this.$ to this.$element, and this.$$ to this.$
Objectives:
* Rename this.$ to this.$element
* Rename this.$$ to this.$
* Get rid of the need to use this.frame.$$
* Rename OO.ui.Element.get$$ to OO.ui.Element.getJQuery

Changes: (using Sublime Text regex patterns)
* Replace "get$$" with "getJQuery"
* Replace "\.(\$)([^\$a-zA-Z])" with ".$element$2"
* Replace "\.(\$\$)" with ".$"
* Replace "'$$'" with "'$'"
* Set this.$ to null in constructor of OO.ui.Window
* Set this.$ to this.frame.$ in initialize method of OO.ui.Window
* Replace "\.(frame.\$)([^\$a-zA-Z])" with ".\$$2"

Bonus:
* Use this.$() in a bunch of places where $() was erroneously used

Change-Id: If3d870124ab8d10f8223532cda95c2b2b075db94
2013-11-03 23:03:49 -08:00

112 lines
2.7 KiB
JavaScript

/*!
* VisualEditor ContentEditable AlienNode, AlienBlockNode and AlienInlineNode classes.
*
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* ContentEditable alien node.
*
* @class
* @abstract
* @extends ve.ce.LeafNode
* @mixins ve.ce.ProtectedNode
* @mixins ve.ce.GeneratedContentNode
*
* @constructor
* @param {ve.dm.AlienNode} model Model to observe
* @param {Object} [config] Configuration options
*/
ve.ce.AlienNode = function VeCeAlienNode( model, config ) {
// Parent constructor
ve.ce.LeafNode.call( this, model, config );
// Mixin constructors
ve.ce.ProtectedNode.call( this );
ve.ce.GeneratedContentNode.call( this );
// DOM changes
this.$element.addClass( 've-ce-alienNode' );
};
/* Inheritance */
OO.inheritClass( ve.ce.AlienNode, ve.ce.LeafNode );
OO.mixinClass( ve.ce.AlienNode, ve.ce.ProtectedNode );
OO.mixinClass( ve.ce.AlienNode, ve.ce.GeneratedContentNode );
/* Static Properties */
ve.ce.AlienNode.static.name = 'alien';
ve.ce.AlienNode.static.$phantomTemplate = ve.ce.AlienNode.static.$phantomTemplate.clone()
.addClass( 've-ce-alienNode-phantom' )
.attr( 'title', ve.msg( 'visualeditor-aliennode-tooltip' ) );
/* Methods */
ve.ce.AlienNode.prototype.generateContents = function ( config ) {
var deferred = $.Deferred();
deferred.resolve( ( config && config.domElements ) || this.model.getAttribute( 'domElements' ) || [] );
return deferred.promise();
};
/* Concrete subclasses */
/**
* ContentEditable alien block node.
*
* @class
* @extends ve.ce.AlienNode
* @constructor
* @param {ve.dm.AlienBlockNode} model Model to observe
*/
ve.ce.AlienBlockNode = function VeCeAlienBlockNode( model ) {
// Parent constructor
ve.ce.AlienNode.call( this, model );
// DOM changes
this.$element.addClass( 've-ce-alienBlockNode' );
};
/* Inheritance */
OO.inheritClass( ve.ce.AlienBlockNode, ve.ce.AlienNode );
/* Static Properties */
ve.ce.AlienBlockNode.static.name = 'alienBlock';
/**
* ContentEditable alien inline node.
*
* @class
* @extends ve.ce.AlienNode
* @constructor
* @param {ve.dm.AlienInlineNode} model Model to observe
*/
ve.ce.AlienInlineNode = function VeCeAlienInlineNode( model ) {
// Parent constructor
ve.ce.AlienNode.call( this, model );
// DOM changes
this.$element.addClass( 've-ce-alienInlineNode' );
};
/* Inheritance */
OO.inheritClass( ve.ce.AlienInlineNode, ve.ce.AlienNode );
/* Static Properties */
ve.ce.AlienInlineNode.static.name = 'alienInline';
/* Registration */
ve.ce.nodeFactory.register( ve.ce.AlienNode );
ve.ce.nodeFactory.register( ve.ce.AlienBlockNode );
ve.ce.nodeFactory.register( ve.ce.AlienInlineNode );