Merge "Move index label generation to the model"

This commit is contained in:
jenkins-bot 2013-12-16 13:17:26 +00:00 committed by Gerrit Code Review
commit 46f5f29839
2 changed files with 26 additions and 6 deletions

View file

@ -92,12 +92,7 @@ ve.ce.MWReferenceNode.prototype.onInternalListUpdate = function ( groupsChanged
* @method
*/
ve.ce.MWReferenceNode.prototype.update = function () {
var listIndex = this.model.getAttribute( 'listIndex' ),
listGroup = this.model.getAttribute( 'listGroup' ),
refGroup = this.model.getAttribute( 'refGroup' ),
position = this.internalList.getIndexPosition( listGroup, listIndex );
this.$link.text( '[' + ( refGroup ? refGroup + ' ' : '' ) + ( position + 1 ) + ']' );
this.$link.text( this.model.getIndexLabel() );
};
/** */

View file

@ -215,6 +215,22 @@ ve.dm.MWReferenceNode.static.remapInternalListKeys = function ( dataElement, int
}
};
/**
* Gets the index label for the reference
* @static
* @param {Object} dataElement Element data
* @param {ve.dm.InternalList} internalList Internal list
* @returns {string} Reference label
*/
ve.dm.MWReferenceNode.static.getIndexLabel = function ( dataElement, internalList ) {
var listIndex = dataElement.attributes.listIndex,
listGroup = dataElement.attributes.listGroup,
refGroup = dataElement.attributes.refGroup,
position = internalList.getIndexPosition( listGroup, listIndex );
return '[' + ( refGroup ? refGroup + ' ' : '' ) + ( position + 1 ) + ']';
};
/* Methods */
/**
@ -236,6 +252,15 @@ ve.dm.MWReferenceNode.prototype.getInternalItem = function () {
return this.getDocument().getInternalList().getItemNode( this.getAttribute( 'listIndex' ) );
};
/**
* Gets the index label for the reference
* @method
* @returns {string} Reference label
*/
ve.dm.MWReferenceNode.prototype.getIndexLabel = function () {
return this.constructor.static.getIndexLabel( this.element, this.getDocument().getInternalList() );
};
/**
* Handle the node being attached to the root
* @method