r89956 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89955‎ | r89956 | r89957 >
Date:11:16, 13 June 2011
Author:wikinaut
Status:resolved
Tags:
Comment:
follow up patch to r89950 r89952 r89953 r89955 : moved div clearing inside call back function maybeFetch so that this is also done when coming from timeouts
Modified paths:
  • /trunk/phase3/resources/jquery/jquery.suggestions.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/jquery/jquery.suggestions.js
@@ -72,20 +72,18 @@
7373 */
7474 update: function( context, delayed ) {
7575 // Only fetch if the value in the textbox changed and is not empty
 76+ // if the textbox is empty then clear the result div, but leave other settings intouched
7677 function maybeFetch() {
77 - if ( ( context.data.$textbox.val().length != 0 ) && ( context.data.$textbox.val() !== context.data.prevText ) ) {
78 - context.data.prevText = context.data.$textbox.val();
 78+ if ( context.data.$textbox.val().length == 0 ) {
 79+ context.data.$container.hide();
 80+ context.data.prevText = '';
 81+ } else if ( context.data.$textbox.val() !== context.data.prevText ) {
7982 if ( typeof context.config.fetch == 'function' ) {
8083 context.config.fetch.call( context.data.$textbox, context.data.$textbox.val() );
8184 }
8285 }
8386 }
8487
85 - // clear result div if the value in the textbox is empty
86 - if ( context.data.$textbox.val().length == 0 ) {
87 - context.data.$container.hide();
88 - }
89 -
9088 // Cancel previous call
9189 if ( context.data.timerID != null ) {
9290 clearTimeout( context.data.timerID );

Follow-up revisions

RevisionCommit summaryAuthorDate
r89957resinserted context.data.prevText = context.data..val(); which was accidentia...wikinaut11:32, 13 June 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r89950do not sent api requests for empty inputs, e.g. after a character input follo...wikinaut08:41, 13 June 2011
r89952corrected commentwikinaut09:41, 13 June 2011
r89953corrected commentwikinaut09:43, 13 June 2011
r89955essage=corrected my mistake when comparing if textbox length is empty, or not.wikinaut09:56, 13 June 2011

Status & tagging log