mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 00:00:49 +00:00
Merge "Remove listeners from deprecated search widget 'select' events"
This commit is contained in:
commit
c451470224
|
@ -175,19 +175,19 @@ ve.ui.MWReferenceDialog.prototype.onReferenceGroupInputChange = function () {
|
|||
};
|
||||
|
||||
/**
|
||||
* Handle search select events.
|
||||
* Handle search results choose events.
|
||||
*
|
||||
* @param {ve.dm.MWReferenceModel|null} ref Reference model or null if no item is selected
|
||||
* @param {ve.ui.MWReferenceResultWidget} item Chosen item
|
||||
*/
|
||||
ve.ui.MWReferenceDialog.prototype.onSearchSelect = function ( ref ) {
|
||||
if ( ref instanceof ve.dm.MWReferenceModel ) {
|
||||
if ( this.selectedNode instanceof ve.dm.MWReferenceNode ) {
|
||||
this.getFragment().removeContent();
|
||||
this.selectedNode = null;
|
||||
}
|
||||
this.useReference( ref );
|
||||
this.executeAction( 'insert' );
|
||||
ve.ui.MWReferenceDialog.prototype.onSearchResultsChoose = function ( item ) {
|
||||
var ref = item.getData();
|
||||
|
||||
if ( this.selectedNode instanceof ve.dm.MWReferenceNode ) {
|
||||
this.getFragment().removeContent();
|
||||
this.selectedNode = null;
|
||||
}
|
||||
this.useReference( ref );
|
||||
this.executeAction( 'insert' );
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -314,7 +314,7 @@ ve.ui.MWReferenceDialog.prototype.initialize = function () {
|
|||
this.search = new ve.ui.MWReferenceSearchWidget();
|
||||
|
||||
// Events
|
||||
this.search.connect( this, { select: 'onSearchSelect' } );
|
||||
this.search.getResults().connect( this, { choose: 'onSearchResultsChoose' } );
|
||||
|
||||
// Initialization
|
||||
this.panels.addItems( [ this.editPanel, this.searchPanel ] );
|
||||
|
|
|
@ -36,13 +36,6 @@ ve.ui.MWReferenceSearchWidget = function VeUiMWReferenceSearchWidget( config ) {
|
|||
|
||||
OO.inheritClass( ve.ui.MWReferenceSearchWidget, OO.ui.SearchWidget );
|
||||
|
||||
/* Events */
|
||||
|
||||
/**
|
||||
* @event select
|
||||
* @param {ve.dm.MWReferenceModel|null} data Reference model, null if no item is selected
|
||||
*/
|
||||
|
||||
/* Methods */
|
||||
|
||||
/**
|
||||
|
@ -59,29 +52,6 @@ ve.ui.MWReferenceSearchWidget.prototype.onQueryChange = function () {
|
|||
this.addResults();
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle select widget select events.
|
||||
*
|
||||
* @method
|
||||
* @param {OO.ui.OptionWidget} item Selected item
|
||||
* @fires select
|
||||
*/
|
||||
ve.ui.MWReferenceSearchWidget.prototype.onResultsSelect = function ( item ) {
|
||||
var data;
|
||||
|
||||
if ( item ) {
|
||||
data = item.getData();
|
||||
// Resolve indexed values
|
||||
if ( this.index[data] ) {
|
||||
data = this.index[data].reference;
|
||||
}
|
||||
} else {
|
||||
data = null;
|
||||
}
|
||||
|
||||
this.emit( 'select', data );
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the internal list and check if it contains any references
|
||||
* @param {ve.dm.InternalList} internalList Internal list
|
||||
|
@ -251,7 +221,7 @@ ve.ui.MWReferenceSearchWidget.prototype.addResults = function () {
|
|||
.text( item.name );
|
||||
items.push(
|
||||
new ve.ui.MWReferenceResultWidget( {
|
||||
data: i,
|
||||
data: item.reference,
|
||||
label: $citation.add( $name ).add( item.$element )
|
||||
} )
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue