mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-12-01 10:46:36 +00:00
dc3b663e3b
Because the id doesn't affect the rendering of a math node, it is not needed in the hash object. Also removed event listener from the id input for the same reason. Bug: T112466 Change-Id: I4da07cb7c112ce9ab449a060132856a2d054e57f
78 lines
1.6 KiB
JavaScript
78 lines
1.6 KiB
JavaScript
/*!
|
|
* VisualEditor ContentEditable MWMathNode class.
|
|
*
|
|
* @copyright 2011-2015 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/*global MathJax, ve, OO */
|
|
|
|
/**
|
|
* ContentEditable MediaWiki math node.
|
|
*
|
|
* @class
|
|
* @extends ve.ce.MWInlineExtensionNode
|
|
*
|
|
* @constructor
|
|
* @param {ve.dm.MWMathNode} model Model to observe
|
|
* @param {Object} [config] Configuration options
|
|
*/
|
|
ve.ce.MWMathNode = function VeCeMWMathNode() {
|
|
// Parent constructor
|
|
ve.ce.MWMathNode.super.apply( this, arguments );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.ce.MWMathNode, ve.ce.MWInlineExtensionNode );
|
|
|
|
/* Static Properties */
|
|
|
|
ve.ce.MWMathNode.static.name = 'mwMath';
|
|
|
|
ve.ce.MWMathNode.static.primaryCommandName = 'math';
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
ve.ce.MWMathNode.prototype.onSetup = function () {
|
|
// Parent method
|
|
ve.ce.MWMathNode.super.prototype.onSetup.call( this );
|
|
|
|
// DOM changes
|
|
this.$element.addClass( 've-ce-mwMathNode' );
|
|
};
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
ve.ce.MWMathNode.prototype.afterRender = function () {
|
|
var $img,
|
|
node = this;
|
|
|
|
if ( this.$element.is( 'span.tex' ) ) {
|
|
// MathJax
|
|
MathJax.Hub.Queue(
|
|
[ 'Typeset', MathJax.Hub, this.$element[0] ],
|
|
[ this, this.emit, 'rerender' ]
|
|
);
|
|
} else {
|
|
$img = this.$element.filter( 'img.tex' );
|
|
// Rerender after image load
|
|
if ( $img.length ) {
|
|
$img.on( 'load', function () {
|
|
node.emit( 'rerender' );
|
|
} );
|
|
} else {
|
|
// Passing an empty string returns no image, so rerender immediately
|
|
this.emit( 'rerender' );
|
|
}
|
|
}
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.ce.nodeFactory.register( ve.ce.MWMathNode );
|