r68095 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:< r68094‎ | r68095 | r68096 >
Date:18:08, 15 June 2010
Author:adam
Status:ok (Comments)
Tags:
Comment:
Incorporating Roans comments on r68053
Modified paths:
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/Vector/Vector.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.suggestions.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/Vector/Vector.hooks.php
——@@ -23,7 +23,7 @@
2424 array( 'src' => 'Vector.combined.js', 'version' => 52 ),
2525 ),
2626 'minified' => array(
27 - array( 'src' => 'Vector.combined.min.js', 'version' => 52 ),
 27+ array( 'src' => 'Vector.combined.min.js', 'version' => 53 ),
2828 ),
2929 );
3030 static $modules = array(
Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
——@@ -64,7 +64,7 @@
6565 array( 'src' => 'js/plugins/jquery.cookie.js', 'version' => 4 ),
6666 array( 'src' => 'js/plugins/jquery.delayedBind.js', 'version' => 1 ),
6767 array( 'src' => 'js/plugins/jquery.expandableField.js', 'version' => 17 ),
68 - array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 25 ),
 68+ array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 26 ),
6969 array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 36 ),
7070 array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 195 ),
7171 array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 53 ),
——@@ -80,10 +80,10 @@
8181 array( 'src' => 'js/thirdparty/contentCollector.js', 'version' => 2 ),
8282 ),
8383 'combined' => array(
84 - array( 'src' => 'js/plugins.combined.js', 'version' => 432 ),
 84+ array( 'src' => 'js/plugins.combined.js', 'version' => 433 ),
8585 ),
8686 'minified' => array(
87 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 433 ),
 87+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 434 ),
8888 ),
8989 ),
9090 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.suggestions.js
——@@ -218,7 +218,8 @@
219219 if ( result.get && selected.get( 0 ) == result.get( 0 ) ) {
220220 // if the currently selected item is equal to the result, exit please
221221 return true;
222 - } else if ( !result.get || selected.get( 0 ) != result.get( 0 ) ) {
 222+ }
 223+ if ( !result.get || selected.get( 0 ) != result.get( 0 ) ) {
223224 if ( result == 'prev' ) {
224225 if( selected.is( '.suggestions-special' ) ) {
225226 result = context.data.$container.find( '.suggestions-result:last' )
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
——@@ -1187,7 +1187,8 @@
11881188 if ( result.get && selected.get( 0 ) == result.get( 0 ) ) {
11891189 // if the currently selected item is equal to the result, exit please
11901190 return true;
1191 - } else if ( !result.get || selected.get( 0 ) != result.get( 0 ) ) {
 1191+ }
 1192+ if ( !result.get || selected.get( 0 ) != result.get( 0 ) ) {
11921193 if ( result == 'prev' ) {
11931194 if( selected.is( '.suggestions-special' ) ) {
11941195 result = context.data.$container.find( '.suggestions-result:last' )
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
——@@ -67,7 +67,8 @@
6868 $autoEllipseMe=$autoEllipseMe.add($result);}}
6969 if(expWidth>context.data.$container.width()){var maxWidth=context.config.maxExpandFactor*context.data.$textbox.width();context.data.$container.width(Math.min(expWidth,maxWidth));}
7070 $autoEllipseMe.autoEllipsis({hasSpan:true,tooltip:true,matchText:matchedText});}}
71 -break;case'maxRows':context.config[property]=Math.max(1,Math.min(100,value));break;case'delay':context.config[property]=Math.max(0,Math.min(1200,value));break;case'maxExpandFactor':context.config[property]=Math.max(1,value);break;case'submitOnClick':case'positionFromLeft':case'highlightInput':context.config[property]=value?true:false;break;}},highlight:function(context,result,updateTextbox){var selected=context.data.$container.find('.suggestions-result-current');if(result.get&&selected.get(0)==result.get(0)){return true;}else if(!result.get||selected.get(0)!=result.get(0)){if(result=='prev'){if(selected.is('.suggestions-special')){result=context.data.$container.find('.suggestions-result:last')}else{result=selected.prev();if(selected.length==0){if(context.data.$container.find('.suggestions-special').html()!=""){result=context.data.$container.find('.suggestions-special');}else{result=context.data.$container.find('.suggestions-results div:last');}}}}else if(result=='next'){if(selected.length==0){result=context.data.$container.find('.suggestions-results div:first');if(result.length==0&&context.data.$container.find('.suggestions-special').html()!=""){result=context.data.$container.find('.suggestions-special');}}else{result=selected.next();if(selected.is('.suggestions-special')){result=$([]);}else if(result.length==0&&context.data.$container.find('.suggestions-special').html()!=""){result=context.data.$container.find('.suggestions-special');}}}
 71+break;case'maxRows':context.config[property]=Math.max(1,Math.min(100,value));break;case'delay':context.config[property]=Math.max(0,Math.min(1200,value));break;case'maxExpandFactor':context.config[property]=Math.max(1,value);break;case'submitOnClick':case'positionFromLeft':case'highlightInput':context.config[property]=value?true:false;break;}},highlight:function(context,result,updateTextbox){var selected=context.data.$container.find('.suggestions-result-current');if(result.get&&selected.get(0)==result.get(0)){return true;}
 72+if(!result.get||selected.get(0)!=result.get(0)){if(result=='prev'){if(selected.is('.suggestions-special')){result=context.data.$container.find('.suggestions-result:last')}else{result=selected.prev();if(selected.length==0){if(context.data.$container.find('.suggestions-special').html()!=""){result=context.data.$container.find('.suggestions-special');}else{result=context.data.$container.find('.suggestions-results div:last');}}}}else if(result=='next'){if(selected.length==0){result=context.data.$container.find('.suggestions-results div:first');if(result.length==0&&context.data.$container.find('.suggestions-special').html()!=""){result=context.data.$container.find('.suggestions-special');}}else{result=selected.next();if(selected.is('.suggestions-special')){result=$([]);}else if(result.length==0&&context.data.$container.find('.suggestions-special').html()!=""){result=context.data.$container.find('.suggestions-special');}}}
7273 selected.removeClass('suggestions-result-current');result.addClass('suggestions-result-current');}
7374 if(updateTextbox){if(result.length==0){$.suggestions.restore(context);}else{context.data.$textbox.val(result.data('text'));context.data.$textbox.change();}
7475 context.data.$textbox.trigger('change');}

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r68053SimpleSearch - adding an early out to the hightlight function for repeated ca...adam02:48, 15 June 2010

Comments

#Comment by Catrope (talk | contribs)   18:12, 15 June 2010
-		} else if ( !result.get || selected.get( 0 ) != result.get( 0 ) ) {
+		}
+		if ( !result.get || selected.get( 0 ) != result.get( 0 ) ) {

I don't think you understood my previous CR comment. What I meant to say is that it's impossible for the first condition and the second condition to both be false: one of them has to be true. If we're still alive at your second if statement, the first must've been false (or we would've returned) so there's no point checking for something we already no is true.

In practical terms, I recommend changing to:

		if ( result.get && selected.get( 0 ) == result.get( 0 ) ) { 
 			// if the currently selected item is equal to the result, exit please
 			return true; 
		}
		Rest of code here, without another if or else block or whatever

Status & tagging log