mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-13 17:53:09 +00:00
Merge "Rename function to getIndexLabel to clarify that it's presentation"
This commit is contained in:
commit
8ef86b2f0f
|
@ -275,7 +275,7 @@ ve.ce.MWReferencesListNode.prototype.renderListItem = function ( nodes, internal
|
||||||
);
|
);
|
||||||
|
|
||||||
const $li = $( '<li>' )
|
const $li = $( '<li>' )
|
||||||
.css( '--footnote-number', `"${ this.docRefs.getIndexNumber( refGroup, key ) }."` )
|
.css( '--footnote-number', `"${ this.docRefs.getIndexLabel( refGroup, key ) }."` )
|
||||||
.append( this.renderBacklinks( keyedNodes, refGroup ), ' ' );
|
.append( this.renderBacklinks( keyedNodes, refGroup ), ' ' );
|
||||||
|
|
||||||
// Generate reference HTML from first item in key
|
// Generate reference HTML from first item in key
|
||||||
|
|
|
@ -114,14 +114,14 @@ ve.dm.MWDocumentReferences.static.contentLangDigits = function ( num ) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Should be refactored to store index numbers as a simple property
|
* @deprecated Should be refactored to store formatted index numbers as a simple
|
||||||
* in each ref node after document transaction.
|
* property on each CE ref node after document transaction.
|
||||||
* @param {string} groupName Ref group without prefix
|
* @param {string} groupName Ref group without prefix
|
||||||
* @param {string} listKey Ref key with prefix
|
* @param {string} listKey Ref key with prefix
|
||||||
* @return {string} Rendered index number string which can be used as a footnote
|
* @return {string} Rendered index number string which can be used as a footnote
|
||||||
* marker or reflist item number.
|
* marker or reflist item number.
|
||||||
*/
|
*/
|
||||||
ve.dm.MWDocumentReferences.prototype.getIndexNumber = function ( groupName, listKey ) {
|
ve.dm.MWDocumentReferences.prototype.getIndexLabel = function ( groupName, listKey ) {
|
||||||
return ( this.cachedByGroup[ 'mwReference/' + groupName ] || {} )[ listKey ];
|
return ( this.cachedByGroup[ 'mwReference/' + groupName ] || {} )[ listKey ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -339,7 +339,7 @@ ve.dm.MWReferenceNode.static.getIndexLabel = function ( dataElement, internalLis
|
||||||
ve.dm.MWReferenceNode.static.findIndexNumber = function ( dataElement, internalList ) {
|
ve.dm.MWReferenceNode.static.findIndexNumber = function ( dataElement, internalList ) {
|
||||||
return ve.getProp( dataElement, 'internal', 'overrideIndex' ) ||
|
return ve.getProp( dataElement, 'internal', 'overrideIndex' ) ||
|
||||||
ve.dm.MWDocumentReferences.static.refsForDoc( internalList.getDocument() )
|
ve.dm.MWDocumentReferences.static.refsForDoc( internalList.getDocument() )
|
||||||
.getIndexNumber( dataElement.attributes.refGroup, dataElement.attributes.listKey );
|
.getIndexLabel( dataElement.attributes.refGroup, dataElement.attributes.listKey );
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -170,7 +170,7 @@ ve.ui.MWReferenceSearchWidget.prototype.buildSearchIndex = function () {
|
||||||
const listKey = node.getAttribute( 'listKey' );
|
const listKey = node.getAttribute( 'listKey' );
|
||||||
// remove `mwReference/` prefix
|
// remove `mwReference/` prefix
|
||||||
const group = groupName.slice( 12 );
|
const group = groupName.slice( 12 );
|
||||||
const footnoteNumber = docRefs.getIndexNumber( group, listKey );
|
const footnoteNumber = docRefs.getIndexLabel( group, listKey );
|
||||||
const citation = ( group ? group + ' ' : '' ) + footnoteNumber;
|
const citation = ( group ? group + ' ' : '' ) + footnoteNumber;
|
||||||
|
|
||||||
// Use [\s\S]* instead of .* to catch esoteric whitespace (T263698)
|
// Use [\s\S]* instead of .* to catch esoteric whitespace (T263698)
|
||||||
|
|
|
@ -17,8 +17,8 @@ QUnit.test( 'first simple test', ( assert ) => {
|
||||||
|
|
||||||
assert.strictEqual( firstListKey, 'auto/0' );
|
assert.strictEqual( firstListKey, 'auto/0' );
|
||||||
assert.strictEqual( fooGroupListKey, 'auto/2' );
|
assert.strictEqual( fooGroupListKey, 'auto/2' );
|
||||||
assert.strictEqual( docRefs.getIndexNumber( '', firstListKey ), '1' );
|
assert.strictEqual( docRefs.getIndexLabel( '', firstListKey ), '1' );
|
||||||
assert.strictEqual( docRefs.getIndexNumber( 'foo', fooGroupListKey ), '1' );
|
assert.strictEqual( docRefs.getIndexLabel( 'foo', fooGroupListKey ), '1' );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
QUnit.test( 'extends test', ( assert ) => {
|
QUnit.test( 'extends test', ( assert ) => {
|
||||||
|
@ -35,10 +35,10 @@ QUnit.test( 'extends test', ( assert ) => {
|
||||||
const firstListKey = groupedRefs[ '' ][ 0 ].getAttribute( 'listKey' );
|
const firstListKey = groupedRefs[ '' ][ 0 ].getAttribute( 'listKey' );
|
||||||
assert.strictEqual( firstListKey, 'auto/1' );
|
assert.strictEqual( firstListKey, 'auto/1' );
|
||||||
// FIXME: Documents incorrect behavior, should be '2'.
|
// FIXME: Documents incorrect behavior, should be '2'.
|
||||||
assert.strictEqual( docRefs.getIndexNumber( '', firstListKey ), '1' );
|
assert.strictEqual( docRefs.getIndexLabel( '', firstListKey ), '1' );
|
||||||
|
|
||||||
const subrefListKey = groupedRefs[ 'literal/ldr' ][ 0 ].getAttribute( 'listKey' );
|
const subrefListKey = groupedRefs[ 'literal/ldr' ][ 0 ].getAttribute( 'listKey' );
|
||||||
assert.strictEqual( subrefListKey, 'auto/0' );
|
assert.strictEqual( subrefListKey, 'auto/0' );
|
||||||
// FIXME: Documents incorrect behavior, should be '1.1'.
|
// FIXME: Documents incorrect behavior, should be '1.1'.
|
||||||
assert.strictEqual( docRefs.getIndexNumber( '', subrefListKey ), '2.1' );
|
assert.strictEqual( docRefs.getIndexLabel( '', subrefListKey ), '2.1' );
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -11,7 +11,7 @@ function getInternalListMock( groups, mockWithNode ) {
|
||||||
const refDocMock = {
|
const refDocMock = {
|
||||||
getAllGroupNames: () => ( Object.keys( groups ) ),
|
getAllGroupNames: () => ( Object.keys( groups ) ),
|
||||||
getGroupRefsByParents: () => ( { '': [ node ] } ),
|
getGroupRefsByParents: () => ( { '': [ node ] } ),
|
||||||
getIndexNumber: () => ( 1 ),
|
getIndexLabel: () => ( '1' ),
|
||||||
getItemNode: () => ( node )
|
getItemNode: () => ( node )
|
||||||
};
|
};
|
||||||
const docMock = {
|
const docMock = {
|
||||||
|
|
Loading…
Reference in a new issue