mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
Merge "Handle media select widget empty queries properly"
This commit is contained in:
commit
a60e469b03
|
@ -80,8 +80,8 @@ ve.inheritClass( ve.ui.MWMediaSelectWidget, ve.ui.Widget );
|
||||||
ve.ui.MWMediaSelectWidget.prototype.onInputChange = function () {
|
ve.ui.MWMediaSelectWidget.prototype.onInputChange = function () {
|
||||||
var i, len;
|
var i, len;
|
||||||
|
|
||||||
if ( this.loading || this.input.getValue() === '' ) {
|
if ( this.loading ) {
|
||||||
return;
|
this.request.abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset
|
// Reset
|
||||||
|
@ -124,7 +124,12 @@ ve.ui.MWMediaSelectWidget.prototype.onResultsScroll = function () {
|
||||||
* @method
|
* @method
|
||||||
*/
|
*/
|
||||||
ve.ui.MWMediaSelectWidget.prototype.queryMediaSources = function () {
|
ve.ui.MWMediaSelectWidget.prototype.queryMediaSources = function () {
|
||||||
var i, len, source;
|
var i, len, source,
|
||||||
|
value = this.input.getValue();
|
||||||
|
|
||||||
|
if ( value === '' ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for ( i = 0, len = this.sources.length; i < len; i++ ) {
|
for ( i = 0, len = this.sources.length; i < len; i++ ) {
|
||||||
source = this.sources[i];
|
source = this.sources[i];
|
||||||
|
@ -141,7 +146,7 @@ ve.ui.MWMediaSelectWidget.prototype.queryMediaSources = function () {
|
||||||
'format': 'json',
|
'format': 'json',
|
||||||
'action': 'query',
|
'action': 'query',
|
||||||
'generator': 'search',
|
'generator': 'search',
|
||||||
'gsrsearch': this.input.getValue(),
|
'gsrsearch': value,
|
||||||
'gsrnamespace': 6,
|
'gsrnamespace': 6,
|
||||||
'gsrlimit': 15,
|
'gsrlimit': 15,
|
||||||
'gsroffset': source.gsroffset,
|
'gsroffset': source.gsroffset,
|
||||||
|
@ -181,7 +186,12 @@ ve.ui.MWMediaSelectWidget.prototype.onMediaQueryDone = function ( source, data )
|
||||||
|
|
||||||
var page, title,
|
var page, title,
|
||||||
items = [],
|
items = [],
|
||||||
pages = data.query.pages;
|
pages = data.query.pages,
|
||||||
|
value = this.input.getValue();
|
||||||
|
|
||||||
|
if ( value === '' ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( data['query-continue'] && data['query-continue'].search ) {
|
if ( data['query-continue'] && data['query-continue'].search ) {
|
||||||
source.gsroffset = data['query-continue'].search.gsroffset;
|
source.gsroffset = data['query-continue'].search.gsroffset;
|
||||||
|
|
Loading…
Reference in a new issue