mediawiki-extensions-Visual.../modules/ve/ce/ve.ce.LeafNode.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

79 lines
2 KiB
JavaScript

/*!
* VisualEditor ContentEditable LeafNode class.
*
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* ContentEditable leaf node.
*
* Leaf nodes can not have any children.
*
* @abstract
* @extends ve.ce.Node
* @mixins ve.LeafNode
*
* @constructor
* @param {ve.dm.LeafNode} model Model to observe
* @param {Object} [config] Configuration options
*/
ve.ce.LeafNode = function VeCeLeafNode( model, config ) {
// Mixin constructor
ve.LeafNode.call( this );
// Parent constructor
ve.ce.Node.call( this, model, config );
// DOM changes
if ( model.isWrapped() ) {
this.$element.addClass( 've-ce-leafNode' );
}
};
/* Inheritance */
OO.inheritClass( ve.ce.LeafNode, ve.ce.Node );
OO.mixinClass( ve.ce.LeafNode, ve.LeafNode );
/* Static Properties */
ve.ce.LeafNode.static.tagName = 'span';
/* Methods */
/** */
ve.ce.LeafNode.prototype.onSetup = function () {
ve.ce.Node.prototype.onSetup.call( this );
this.$element.addClass( 've-ce-leafNode' );
};
/** */
ve.ce.LeafNode.prototype.onTeardown = function () {
ve.ce.Node.prototype.onTeardown.call( this );
this.$element.removeClass( 've-ce-leafNode' );
};
/**
* Get annotated HTML fragments.
*
* @see ve.ce.ContentBranchNode
*
* An HTML fragment can be:
* - a plain text string
* - a jQuery object
* - an array with a plain text string or jQuery object at index 0 and a ve.dm.AnnotationSet at index 1,
* i.e. ['textstring', ve.dm.AnnotationSet] or [$jQueryObj, ve.dm.AnnotationSet]
*
* The default implementation should be fine in most cases. A subclass only needs to override this
* if the annotations aren't necessarily the same across the entire node (like in ve.ce.TextNode).
*
* @method
* @returns {Array} Array of HTML fragments, i.e.
* [ string | jQuery | [string|jQuery, ve.dm.AnnotationSet] ]
*/
ve.ce.LeafNode.prototype.getAnnotatedHtml = function () {
return [ [ this.$element, this.getModel().getAnnotations() ] ];
};