mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-02 09:57:01 +00:00
01e02e888d
Change-Id: Ifc8183e047398fd7f4b0436e61768992a3a94612
60 lines
1.2 KiB
JavaScript
60 lines
1.2 KiB
JavaScript
/**
|
|
* Creates an ve.ce.ListNode object.
|
|
*
|
|
* @class
|
|
* @constructor
|
|
* @extends {ve.ce.BranchNode}
|
|
* @param {ve.dm.ListNode} model List model to view
|
|
*/
|
|
ve.ce.ListNode = function( model ) {
|
|
// Inheritance
|
|
var style = model.getElementAttribute( 'style' ),
|
|
type = ve.ce.ListNode.domNodeTypes[style];
|
|
ve.ce.BranchNode.call( this, model, $( '<' + type + '></' + type + '>' ) );
|
|
|
|
// Properties
|
|
this.currentStylesHash = null;
|
|
|
|
// DOM Changes
|
|
this.$.addClass( 've-ce-listNode' );
|
|
|
|
// Events
|
|
var _this = this;
|
|
this.model.on( 'update', function() {
|
|
_this.setStyle();
|
|
} );
|
|
};
|
|
|
|
/* Static Members */
|
|
|
|
ve.ce.ListNode.domNodeTypes = {
|
|
'bullet': 'ul',
|
|
'number': 'ol',
|
|
'definition': 'dl'
|
|
};
|
|
|
|
/* Methods */
|
|
|
|
ve.ce.ListNode.prototype.setStyle = function() {
|
|
var style = this.model.getElementAttribute( 'style' ),
|
|
type = ve.ce.ListItemNode.domNodeTypes[style];
|
|
if ( type === undefined ) {
|
|
throw 'Invalid style attribute for heading node: ' + style;
|
|
}
|
|
if ( style !== this.currentStyleHash ) {
|
|
this.currentStyleHash = style;
|
|
this.convertDomElement( type );
|
|
}
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.ce.DocumentNode.splitRules.list = {
|
|
'self': false,
|
|
'children': true
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
ve.extendClass( ve.ce.ListNode, ve.ce.BranchNode );
|