mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
Merge "Move index label generation to the model"
This commit is contained in:
commit
46f5f29839
|
@ -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() );
|
||||
};
|
||||
|
||||
/** */
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue