mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-23 22:45:20 +00:00
Fix empty previews in reference reuse dialog
This fixes a minor inconsistency: A reference that comes from a template and is already reused outside of the template is only partially available to VE, and previewed with a warning message because of this: "This reference is defined in a template or other generated block, and for now can only be previewed in source mode." This was missing in the reuse dialog. Note this patch is not meant to make any design decision, but to use the existing design consistently. You can test this with and without the Citoid extension. It works in both cases. Bug: T336372 Change-Id: I962cf111b1882bcd736f1090ca17d2b176495d2f
This commit is contained in:
parent
d6fbd0cc11
commit
889c2ea011
|
@ -122,8 +122,6 @@ ve.ui.MWReferenceSearchWidget.prototype.buildIndex = function () {
|
|||
return;
|
||||
}
|
||||
|
||||
var text;
|
||||
|
||||
this.index = [];
|
||||
var groupNames = Object.keys( groups ).sort();
|
||||
|
||||
|
@ -146,10 +144,7 @@ ve.ui.MWReferenceSearchWidget.prototype.buildIndex = function () {
|
|||
// Only increment counter for real references
|
||||
n++;
|
||||
var refModel = ve.dm.MWReferenceModel.static.newFromReferenceNode( refNode );
|
||||
var view = new ve.ui.MWPreviewElement(
|
||||
this.internalList.getItemNode( refModel.getListIndex() ),
|
||||
{ useView: true }
|
||||
);
|
||||
var itemNode = this.internalList.getItemNode( refModel.getListIndex() );
|
||||
|
||||
var refGroup = refModel.getGroup();
|
||||
var citation = ( refGroup && refGroup.length ? refGroup + ' ' : '' ) + n;
|
||||
|
@ -163,16 +158,25 @@ ve.ui.MWReferenceSearchWidget.prototype.buildIndex = function () {
|
|||
// immediately rendered, but we shouldn't trust that on principle to
|
||||
// account for edge cases.
|
||||
|
||||
var $element;
|
||||
// Make visible text, citation and reference name searchable
|
||||
text = [ view.$element.text().toLowerCase(), citation, name ].join( ' ' );
|
||||
// Make URLs searchable
|
||||
// eslint-disable-next-line no-loop-func
|
||||
view.$element.find( 'a[href]' ).each( function () {
|
||||
text += ' ' + this.getAttribute( 'href' );
|
||||
} );
|
||||
var text = citation + ' ' + name;
|
||||
if ( itemNode.length ) {
|
||||
$element = new ve.ui.MWPreviewElement( itemNode, { useView: true } ).$element;
|
||||
text = $element.text().toLowerCase() + ' ' + text;
|
||||
// Make URLs searchable
|
||||
// eslint-disable-next-line no-loop-func
|
||||
$element.find( 'a[href]' ).each( function () {
|
||||
text += ' ' + this.getAttribute( 'href' );
|
||||
} );
|
||||
} else {
|
||||
$element = $( '<span>' )
|
||||
.addClass( 've-ce-mwReferencesListNode-muted' )
|
||||
.text( ve.msg( 'cite-ve-referenceslist-missingref-in-list' ) );
|
||||
}
|
||||
|
||||
this.index.push( {
|
||||
$element: view.$element,
|
||||
$element: $element,
|
||||
text: text,
|
||||
reference: refModel,
|
||||
citation: citation,
|
||||
|
|
Loading…
Reference in a new issue