Bmansurov has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/306446

Change subject: Beta: clear the loading icon when a new search is started
......................................................................

Beta: clear the loading icon when a new search is started

Make sure the previous spinner is hidden when starting a new
search and aborting the previous one. Also, hide the spinner
even when there are no results from the API.

Follow up on I93ef856b6820d1b64dea8a5b4105476f5545f6ad.

Bug: T137068
Change-Id: I7b23c2b5601c9884906ee2635ff6e0f5da535e29
---
M resources/mobile.search/SearchOverlay.js
1 file changed, 12 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/46/306446/1

diff --git a/resources/mobile.search/SearchOverlay.js 
b/resources/mobile.search/SearchOverlay.js
index 52bbe2e..a7cb85e 100644
--- a/resources/mobile.search/SearchOverlay.js
+++ b/resources/mobile.search/SearchOverlay.js
@@ -249,11 +249,14 @@
                                // Show a spinner on top of search results
                                this.$spinner = this.$( '.spinner-container' );
                                M.on( 'search-start', function ( searchData ) {
+                                       if ( timer ) {
+                                               clearTimeout( timer );
+                                       }
                                        timer = setTimeout( function () {
                                                self.$spinner.show();
                                        }, 2000 - searchData.delay );
                                } );
-                               M.on( 'search-results', function () {
+                               M.on( 'search-end', function () {
                                        self.$spinner.hide();
                                        clearTimeout( timer );
                                } );
@@ -264,7 +267,7 @@
                                        self.resetSearch();
                                        self.$spinner.show();
                                } );
-                               M.on( 'search-results', function () {
+                               M.on( 'search-end', function () {
                                        self.$searchFeedback.show();
                                        self.$spinner.hide();
                                } );
@@ -375,6 +378,13 @@
                                                                        
results: data.results
                                                                } );
                                                        }
+                                                       /**
+                                                        * @event search-end 
Fired after the search API response is received
+                                                        * @property {Object} 
data related to the current search
+                                                        */
+                                                       M.emit( 'search-end', {
+                                                               query: query
+                                                       } );
                                                } );
                                        }, delay );
                                } else {

-- 
To view, visit https://gerrit.wikimedia.org/r/306446
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7b23c2b5601c9884906ee2635ff6e0f5da535e29
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Bmansurov <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to