mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 16:20:52 +00:00
2f8b3e0d96
Change-Id: Ie92dab7411116d3410195c3fb0a3513c664c0c30
49 lines
1.1 KiB
JavaScript
49 lines
1.1 KiB
JavaScript
/*!
|
|
* VisualEditor ContentEditable MWTableNode class.
|
|
*
|
|
* @copyright 2011-2015 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* ContentEditable MW table node.
|
|
*
|
|
* @class
|
|
* @extends ve.ce.TableNode
|
|
*
|
|
* @constructor
|
|
* @param {ve.dm.MWTableNode} model Model to observe
|
|
* @param {Object} [config] Configuration options
|
|
*/
|
|
ve.ce.MWTableNode = function VeCeMWTableNode() {
|
|
// Parent constructor
|
|
ve.ce.MWTableNode.super.apply( this, arguments );
|
|
|
|
this.model.connect( this, { attributeChange: 'onAttributeChange' } );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.ce.MWTableNode, ve.ce.TableNode );
|
|
|
|
/* Static Properties */
|
|
|
|
ve.ce.MWTableNode.static.name = 'mwTable';
|
|
|
|
/* Methods */
|
|
|
|
ve.ce.MWTableNode.prototype.onAttributeChange = function ( key, from, to ) {
|
|
switch ( key ) {
|
|
case 'wikitable':
|
|
this.$element.toggleClass( 'wikitable', !!to );
|
|
break;
|
|
case 'sortable':
|
|
this.$element.toggleClass( 'sortable', !!to );
|
|
break;
|
|
}
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.ce.nodeFactory.register( ve.ce.MWTableNode );
|