r66642 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66641‎ | r66642 | r66643 >
Date:17:48, 19 May 2010
Author:adam
Status:ok
Tags:
Comment:
Improvements to SimpleSearch. Adding an option to switch between right/left oriented positioning of the results, and removing some unnecissary code
Modified paths:
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/Vector/Modules/SimpleSearch/SimpleSearch.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/Vector/Vector.combined.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/Vector/Vector.combined.min.js (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/Modules/SimpleSearch/SimpleSearch.js
@@ -75,7 +75,7 @@
7676 }
7777 },
7878 delay: 120,
79 - expandToLeft: !$j( 'body' ).is( 'rtl' )
 79+ positionFromLeft: $j( 'body' ).is( '.rtl' )
8080 } );
8181 $j( '#searchInput' ).suggestions( {
8282 result: {
Index: trunk/extensions/UsabilityInitiative/Vector/Vector.hooks.php
@@ -16,13 +16,13 @@
1717 array( 'src' => 'Modules/CollapsibleTabs/CollapsibleTabs.js', 'version' => 8 ),
1818 array( 'src' => 'Modules/EditWarning/EditWarning.js', 'version' => 8 ),
1919 array( 'src' => 'Modules/FooterCleanup/FooterCleanup.js', 'version' => 5 ),
20 - array( 'src' => 'Modules/SimpleSearch/SimpleSearch.js', 'version' => 10 ),
 20+ array( 'src' => 'Modules/SimpleSearch/SimpleSearch.js', 'version' => 11 ),
2121 ),
2222 'combined' => array(
23 - array( 'src' => 'Vector.combined.js', 'version' => 30 ),
 23+ array( 'src' => 'Vector.combined.js', 'version' => 31 ),
2424 ),
2525 'minified' => array(
26 - array( 'src' => 'Vector.combined.min.js', 'version' => 30 ),
 26+ array( 'src' => 'Vector.combined.min.js', 'version' => 31 ),
2727 ),
2828 );
2929 static $modules = array(
Index: trunk/extensions/UsabilityInitiative/Vector/Vector.combined.js
@@ -336,7 +336,7 @@
337337 }
338338 },
339339 delay: 120,
340 - expandToLeft: !$j( 'body' ).is( 'rtl' )
 340+ positionFromLeft: $j( 'body' ).is( '.rtl' )
341341 } );
342342 $j( '#searchInput' ).suggestions( {
343343 result: {
Index: trunk/extensions/UsabilityInitiative/Vector/Vector.combined.min.js
@@ -14,5 +14,5 @@
1515 +transclusionCount
1616 +'</strong> other pages.</label>');$j('.mw-templatesUsedExplanation').remove();$j('.collapsible-list label').click(function(){$j(this).parent().toggleClass('expanded').toggleClass('collapsed').find('ul').slideToggle('fast');return false;}).trigger('click');$j('#wpPreview, #wpDiff, .editHelp, #editpage-specialchars').remove();$j('#mw-editform-cancel').remove().appendTo('.editButtons');});if(wgVectorEnabledModules.simplesearch&&skin=='vector'&&typeof os_autoload_inputs!=='undefined'&&os_autoload_forms!=='undefined'){os_autoload_inputs=[];os_autoload_forms=[];}
1717 $j(document).ready(function(){if(!wgVectorEnabledModules.simplesearch||skin!='vector'){return true;}
18 -$j('div#simpleSearch > input#searchInput').each(function(){$j('<label />').text(mw.usability.getMsg('vector-simplesearch-search')).css({'display':'none','position':'absolute','bottom':0,'padding':'0.25em','color':'#999999','cursor':'text'}).css(($j('body').is('.rtl')?'right':'left'),0).click(function(){$j(this).parent().find('input#searchInput').focus();}).appendTo($j(this).parent());if($j(this).val()==''){$j(this).parent().find('label').fadeIn(100);}}).focus(function(){$j(this).parent().find('label').fadeOut(100);}).blur(function(){if($j(this).val()==''){$j(this).parent().find('label').fadeIn(100);}});$j('#searchInput, #searchInput2, #powerSearchText, #searchText').suggestions({fetch:function(query){var $this=$j(this);var request=$j.ajax({url:wgScriptPath+'/api.php',data:{'action':'opensearch','search':query,'namespace':0,'suggest':''},dataType:'json',success:function(data){$this.suggestions('suggestions',data[1]);}});$j(this).data('request',request);},cancel:function(){var request=$j(this).data('request');if(request&&typeof request.abort=='function'){request.abort();$j(this).removeData('request');}},result:{select:function($textbox){$textbox.closest('form').submit();}},delay:120,expandToLeft:!$j('body').is('rtl')});$j('#searchInput').suggestions({result:{select:function($textbox){$textbox.closest('form').submit();}},special:{render:function(query){if($j(this).children().size()==0){$j(this).show()
 18+$j('div#simpleSearch > input#searchInput').each(function(){$j('<label />').text(mw.usability.getMsg('vector-simplesearch-search')).css({'display':'none','position':'absolute','bottom':0,'padding':'0.25em','color':'#999999','cursor':'text'}).css(($j('body').is('.rtl')?'right':'left'),0).click(function(){$j(this).parent().find('input#searchInput').focus();}).appendTo($j(this).parent());if($j(this).val()==''){$j(this).parent().find('label').fadeIn(100);}}).focus(function(){$j(this).parent().find('label').fadeOut(100);}).blur(function(){if($j(this).val()==''){$j(this).parent().find('label').fadeIn(100);}});$j('#searchInput, #searchInput2, #powerSearchText, #searchText').suggestions({fetch:function(query){var $this=$j(this);var request=$j.ajax({url:wgScriptPath+'/api.php',data:{'action':'opensearch','search':query,'namespace':0,'suggest':''},dataType:'json',success:function(data){$this.suggestions('suggestions',data[1]);}});$j(this).data('request',request);},cancel:function(){var request=$j(this).data('request');if(request&&typeof request.abort=='function'){request.abort();$j(this).removeData('request');}},result:{select:function($textbox){$textbox.closest('form').submit();}},delay:120,positionFromLeft:$j('body').is('.rtl')});$j('#searchInput').suggestions({result:{select:function($textbox){$textbox.closest('form').submit();}},special:{render:function(query){if($j(this).children().size()==0){$j(this).show()
1919 $label=$j('<div />').addClass('special-label').text(mw.usability.getMsg('vector-simplesearch-containing')).appendTo($j(this));$query=$j('<div />').addClass('special-query').text(query).appendTo($j(this));$query.autoEllipsis();}else{$j(this).find('.special-query').empty().text(query).autoEllipsis();}},select:function($textbox){$textbox.closest('form').append($j('<input />').attr({'type':'hidden','name':'fulltext','value':1}));$textbox.closest('form').submit();}},$region:$j('#simpleSearch')});});
\ No newline at end of file
Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -72,7 +72,7 @@
7373 array( 'src' => 'js/plugins/jquery.delayedBind.js', 'version' => 1 ),
7474 array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 16 ),
7575 array( 'src' => 'js/plugins/jquery.expandableField.js', 'version' => 15 ),
76 - array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 16 ),
 76+ array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 17 ),
7777 array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 33 ),
7878 array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 187 ),
7979 array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 53 ),
@@ -85,10 +85,10 @@
8686 array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 5 ),
8787 ),
8888 'combined' => array(
89 - array( 'src' => 'js/plugins.combined.js', 'version' => 398 ),
 89+ array( 'src' => 'js/plugins.combined.js', 'version' => 399 ),
9090 ),
9191 'minified' => array(
92 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 398 ),
 92+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 399 ),
9393 ),
9494 ),
9595 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.suggestions.js
@@ -36,8 +36,8 @@
3737 * maxExpandFactor: Maximum suggestions box width relative to the textbox width. If set to e.g. 2, the suggestions box
3838 * will never be grown beyond 2 times the width of the textbox.
3939 * Type: Number, Range: 1 - infinity, Default: 2
40 - * expandToLeft: Whether to expand the suggestion box to the left rather than to the right
41 - * Type: Boolean, Default: false
 40+ * positionFromLeft: Wether to position the suggestion box with the left attribute or the right
 41+ * Type: Boolean, Default: true
4242 */
4343 ( function( $ ) {
4444
@@ -127,14 +127,22 @@
128128 // Rebuild the suggestions list
129129 context.data.$container.show();
130130 // Update the size and position of the list
131 - context.data.$container.css( {
 131+ var newCSS = {
132132 'top': context.config.$region.offset().top + context.config.$region.outerHeight(),
133133 'bottom': 'auto',
134134 'width': context.config.$region.outerWidth(),
135 - 'height': 'auto',
136 - 'left': context.config.$region.offset().left,
137 - 'right': 'auto'
138 - } );
 135+ 'height': 'auto'
 136+ }
 137+ if ( context.config.positionFromLeft ) {
 138+ console.log("LEFT");
 139+ newCSS['left'] = context.config.$region.offset().left;
 140+ newCSS['right'] = 'auto';
 141+ } else {
 142+ console.log("right");
 143+ newCSS['left'] = 'auto';
 144+ newCSS['right'] = $( 'body' ).width() - ( context.config.$region.offset().left + context.config.$region.outerWidth() );
 145+ }
 146+ context.data.$container.css( newCSS );
139147 var $results = context.data.$container.children( '.suggestions-results' );
140148 $results.empty();
141149 var expWidth = -1;
@@ -174,12 +182,6 @@
175183 }
176184 // Apply new width for results box, if any
177185 if ( expWidth != -1 ) {
178 - if ( context.config.expandToLeft ) {
179 - context.data.$container.css( 'left',
180 - context.data.$container.offset().left -
181 - ( expWidth - context.data.$container.width() )
182 - );
183 - }
184186 context.data.$container.width( expWidth );
185187 }
186188 // autoEllipse the results. Has to be done after changing the width
@@ -197,7 +199,7 @@
198200 context.config[property] = Math.max( 1, value );
199201 break;
200202 case 'submitOnClick':
201 - case 'expandToLeft':
 203+ case 'positionFromLeft':
202204 context.config[property] = value ? true : false;
203205 break;
204206 }
@@ -339,7 +341,7 @@
340342 if ( typeof context == 'undefined' || context == null ) {
341343 context = {
342344 config: {
343 - 'fetch' : function() {},
 345+ 'fetch' : function() {},
344346 'cancel': function() {},
345347 'special': {},
346348 'result': {},
@@ -349,7 +351,7 @@
350352 'delay': 120,
351353 'submitOnClick': false,
352354 'maxExpandFactor': 2,
353 - 'expandToLeft': false
 355+ 'positionFromLeft': true
354356 }
355357 };
356358 }
@@ -388,13 +390,22 @@
389391 'mouseDownOn': $( [] ),
390392 '$textbox': $(this)
391393 };
 394+ // Setup the css for positioning the results box
 395+ var newCSS = {
 396+ 'top': Math.round( context.data.$textbox.offset().top + context.data.$textbox.outerHeight() ),
 397+ 'width': context.data.$textbox.outerWidth(),
 398+ 'display': 'none'
 399+ }
 400+ if ( context.config.positionFromLeft ) {
 401+ newCSS['left'] = context.config.$region.offset().left;
 402+ newCSS['right'] = 'auto';
 403+ } else {
 404+ newCSS['left'] = 'auto';
 405+ newCSS['right'] = $( 'body' ).width() - ( context.config.$region.offset().left + context.config.$region.outerWidth() );
 406+ }
 407+
392408 context.data.$container = $( '<div />' )
393 - .css( {
394 - 'top': Math.round( context.data.$textbox.offset().top + context.data.$textbox.outerHeight() ),
395 - 'left': Math.round( context.data.$textbox.offset().left ),
396 - 'width': context.data.$textbox.outerWidth(),
397 - 'display': 'none'
398 - } )
 409+ .css( newCSS )
399410 .addClass( 'suggestions' )
400411 .append(
401412 $( '<div />' ).addClass( 'suggestions-results' )
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -5793,8 +5793,8 @@
57945794 * maxExpandFactor: Maximum suggestions box width relative to the textbox width. If set to e.g. 2, the suggestions box
57955795 * will never be grown beyond 2 times the width of the textbox.
57965796 * Type: Number, Range: 1 - infinity, Default: 2
5797 - * expandToLeft: Whether to expand the suggestion box to the left rather than to the right
5798 - * Type: Boolean, Default: false
 5797+ * positionFromLeft: Wether to position the suggestion box with the left attribute or the right
 5798+ * Type: Boolean, Default: true
57995799 */
58005800 ( function( $ ) {
58015801
@@ -5884,14 +5884,22 @@
58855885 // Rebuild the suggestions list
58865886 context.data.$container.show();
58875887 // Update the size and position of the list
5888 - context.data.$container.css( {
 5888+ var newCSS = {
58895889 'top': context.config.$region.offset().top + context.config.$region.outerHeight(),
58905890 'bottom': 'auto',
58915891 'width': context.config.$region.outerWidth(),
5892 - 'height': 'auto',
5893 - 'left': context.config.$region.offset().left,
5894 - 'right': 'auto'
5895 - } );
 5892+ 'height': 'auto'
 5893+ }
 5894+ if ( context.config.positionFromLeft ) {
 5895+ console.log("LEFT");
 5896+ newCSS['left'] = context.config.$region.offset().left;
 5897+ newCSS['right'] = 'auto';
 5898+ } else {
 5899+ console.log("right");
 5900+ newCSS['left'] = 'auto';
 5901+ newCSS['right'] = $( 'body' ).width() - ( context.config.$region.offset().left + context.config.$region.outerWidth() );
 5902+ }
 5903+ context.data.$container.css( newCSS );
58965904 var $results = context.data.$container.children( '.suggestions-results' );
58975905 $results.empty();
58985906 var expWidth = -1;
@@ -5931,12 +5939,6 @@
59325940 }
59335941 // Apply new width for results box, if any
59345942 if ( expWidth != -1 ) {
5935 - if ( context.config.expandToLeft ) {
5936 - context.data.$container.css( 'left',
5937 - context.data.$container.offset().left -
5938 - ( expWidth - context.data.$container.width() )
5939 - );
5940 - }
59415943 context.data.$container.width( expWidth );
59425944 }
59435945 // autoEllipse the results. Has to be done after changing the width
@@ -5954,7 +5956,7 @@
59555957 context.config[property] = Math.max( 1, value );
59565958 break;
59575959 case 'submitOnClick':
5958 - case 'expandToLeft':
 5960+ case 'positionFromLeft':
59595961 context.config[property] = value ? true : false;
59605962 break;
59615963 }
@@ -6096,7 +6098,7 @@
60976099 if ( typeof context == 'undefined' || context == null ) {
60986100 context = {
60996101 config: {
6100 - 'fetch' : function() {},
 6102+ 'fetch' : function() {},
61016103 'cancel': function() {},
61026104 'special': {},
61036105 'result': {},
@@ -6106,7 +6108,7 @@
61076109 'delay': 120,
61086110 'submitOnClick': false,
61096111 'maxExpandFactor': 2,
6110 - 'expandToLeft': false
 6112+ 'positionFromLeft': true
61116113 }
61126114 };
61136115 }
@@ -6145,13 +6147,22 @@
61466148 'mouseDownOn': $( [] ),
61476149 '$textbox': $(this)
61486150 };
 6151+ // Setup the css for positioning the results box
 6152+ var newCSS = {
 6153+ 'top': Math.round( context.data.$textbox.offset().top + context.data.$textbox.outerHeight() ),
 6154+ 'width': context.data.$textbox.outerWidth(),
 6155+ 'display': 'none'
 6156+ }
 6157+ if ( context.config.positionFromLeft ) {
 6158+ newCSS['left'] = context.config.$region.offset().left;
 6159+ newCSS['right'] = 'auto';
 6160+ } else {
 6161+ newCSS['left'] = 'auto';
 6162+ newCSS['right'] = $( 'body' ).width() - ( context.config.$region.offset().left + context.config.$region.outerWidth() );
 6163+ }
 6164+
61496165 context.data.$container = $( '<div />' )
6150 - .css( {
6151 - 'top': Math.round( context.data.$textbox.offset().top + context.data.$textbox.outerHeight() ),
6152 - 'left': Math.round( context.data.$textbox.offset().left ),
6153 - 'width': context.data.$textbox.outerWidth(),
6154 - 'display': 'none'
6155 - } )
 6166+ .css( newCSS )
61566167 .addClass( 'suggestions' )
61576168 .append(
61586169 $( '<div />' ).addClass( 'suggestions-results' )
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -395,13 +395,13 @@
396396 if(typeof context.config.cancel=='function'){context.config.cancel.call(context.data.$textbox);}},restore:function(context){context.data.$textbox.val(context.data.prevText);},update:function(context,delayed){function maybeFetch(){if(context.data.$textbox.val()!==context.data.prevText){context.data.prevText=context.data.$textbox.val();if(typeof context.config.fetch=='function'){context.config.fetch.call(context.data.$textbox,context.data.$textbox.val());}}}
397397 if(context.data.timerID!=null){clearTimeout(context.data.timerID);}
398398 if(delayed){context.data.timerID=setTimeout(maybeFetch,context.config.delay);}else{maybeFetch();}
399 -$.suggestions.special(context);},special:function(context){if(typeof context.config.special.render=='function'){setTimeout(function(){$special=context.data.$container.find('.suggestions-special');context.config.special.render.call($special,context.data.$textbox.val());},1);}},configure:function(context,property,value){switch(property){case'fetch':case'cancel':case'special':case'result':case'$region':context.config[property]=value;break;case'suggestions':context.config[property]=value;if(typeof context.data!=='undefined'){if(context.data.$textbox.val().length==0){context.data.$container.hide();}else{context.data.$container.show();context.data.$container.css({'top':context.config.$region.offset().top+context.config.$region.outerHeight(),'bottom':'auto','width':context.config.$region.outerWidth(),'height':'auto','left':context.config.$region.offset().left,'right':'auto'});var $results=context.data.$container.children('.suggestions-results');$results.empty();var expWidth=-1;var $autoEllipseMe=$([]);for(var i=0;i<context.config.suggestions.length;i++){var $result=$('<div />').addClass('suggestions-result').attr('rel',i).data('text',context.config.suggestions[i]).mouseover(function(e){$.suggestions.highlight(context,$(this).closest('.suggestions-results div'),false);}).appendTo($results);if(typeof context.config.result.render=='function'){context.config.result.render.call($result,context.config.suggestions[i]);}else{$result.append($('<span />').css('whiteSpace','nowrap').text(context.config.suggestions[i]));var $span=$result.children('span');if($span.width()>$result.width()){expWidth=Math.max(expWidth,Math.min($span.width(),context.data.$textbox.width()*context.config.maxExpandFactor));}
 399+$.suggestions.special(context);},special:function(context){if(typeof context.config.special.render=='function'){setTimeout(function(){$special=context.data.$container.find('.suggestions-special');context.config.special.render.call($special,context.data.$textbox.val());},1);}},configure:function(context,property,value){switch(property){case'fetch':case'cancel':case'special':case'result':case'$region':context.config[property]=value;break;case'suggestions':context.config[property]=value;if(typeof context.data!=='undefined'){if(context.data.$textbox.val().length==0){context.data.$container.hide();}else{context.data.$container.show();var newCSS={'top':context.config.$region.offset().top+context.config.$region.outerHeight(),'bottom':'auto','width':context.config.$region.outerWidth(),'height':'auto'}
 400+if(context.config.positionFromLeft){console.log("LEFT");newCSS['left']=context.config.$region.offset().left;newCSS['right']='auto';}else{console.log("right");newCSS['left']='auto';newCSS['right']=$('body').width()-(context.config.$region.offset().left+context.config.$region.outerWidth());}
 401+context.data.$container.css(newCSS);var $results=context.data.$container.children('.suggestions-results');$results.empty();var expWidth=-1;var $autoEllipseMe=$([]);for(var i=0;i<context.config.suggestions.length;i++){var $result=$('<div />').addClass('suggestions-result').attr('rel',i).data('text',context.config.suggestions[i]).mouseover(function(e){$.suggestions.highlight(context,$(this).closest('.suggestions-results div'),false);}).appendTo($results);if(typeof context.config.result.render=='function'){context.config.result.render.call($result,context.config.suggestions[i]);}else{$result.append($('<span />').css('whiteSpace','nowrap').text(context.config.suggestions[i]));var $span=$result.children('span');if($span.width()>$result.width()){expWidth=Math.max(expWidth,Math.min($span.width(),context.data.$textbox.width()*context.config.maxExpandFactor));}
400402 $autoEllipseMe=$autoEllipseMe.add($result);}}
401 -if(expWidth!=-1){if(context.config.expandToLeft){context.data.$container.css('left',context.data.$container.offset().left-
402 -(expWidth-context.data.$container.width()));}
403 -context.data.$container.width(expWidth);}
 403+if(expWidth!=-1){context.data.$container.width(expWidth);}
404404 $autoEllipseMe.autoEllipsis({hasSpan:true,tooltip:true});}}
405 -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'expandToLeft':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)){if(result=='prev'){if(selected.is('.suggestions-special')){result=context.data.$container.find('.suggestions-results div: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');}}}
 405+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':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)){if(result=='prev'){if(selected.is('.suggestions-special')){result=context.data.$container.find('.suggestions-results div: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');}}}
406406 selected.removeClass('suggestions-result-current');result.addClass('suggestions-result-current');}
407407 if(updateTextbox){if(result.length==0){$.suggestions.restore(context);}else{context.data.$textbox.val(result.data('text'));context.data.$textbox.change();}
408408 context.data.$textbox.trigger('change');}
@@ -409,9 +409,11 @@
410410 preventDefault=true;break;case 38:if(wasVisible){$.suggestions.highlight(context,'prev',false);}
411411 preventDefault=wasVisible;break;case 27:context.data.$container.hide();$.suggestions.restore(context);$.suggestions.cancel(context);context.data.$textbox.trigger('change');preventDefault=wasVisible;break;case 13:context.data.$container.hide();preventDefault=wasVisible;selected=context.data.$container.find('.suggestions-result-current');if(selected.size()==0){$.suggestions.cancel(context);context.config.$region.closest('form').submit();}else if(selected.is('.suggestions-special')){if(typeof context.config.special.select=='function'){context.config.special.select.call(selected,context.data.$textbox);}}else{if(typeof context.config.result.select=='function'){$.suggestions.highlight(context,selected,true);context.config.result.select.call(selected,context.data.$textbox);}else{$.suggestions.highlight(context,selected,true);}}
412412 break;default:$.suggestions.update(context,true);break;}
413 -if(preventDefault){e.preventDefault();e.stopImmediatePropagation();}}};$.fn.suggestions=function(){var returnValue=null;var args=arguments;$(this).each(function(){var context=$(this).data('suggestions-context');if(typeof context=='undefined'||context==null){context={config:{'fetch':function(){},'cancel':function(){},'special':{},'result':{},'$region':$(this),'suggestions':[],'maxRows':7,'delay':120,'submitOnClick':false,'maxExpandFactor':2,'expandToLeft':false}};}
 413+if(preventDefault){e.preventDefault();e.stopImmediatePropagation();}}};$.fn.suggestions=function(){var returnValue=null;var args=arguments;$(this).each(function(){var context=$(this).data('suggestions-context');if(typeof context=='undefined'||context==null){context={config:{'fetch':function(){},'cancel':function(){},'special':{},'result':{},'$region':$(this),'suggestions':[],'maxRows':7,'delay':120,'submitOnClick':false,'maxExpandFactor':2,'positionFromLeft':true}};}
414414 if(args.length>0){if(typeof args[0]=='object'){for(var key in args[0]){$.suggestions.configure(context,key,args[0][key]);}}else if(typeof args[0]=='string'){if(args.length>1){$.suggestions.configure(context,args[0],args[1]);}else if(returnValue==null){returnValue=(args[0]in context.config?undefined:context.config[args[0]]);}}}
415 -if(typeof context.data=='undefined'){context.data={'timerID':null,'prevText':null,'visibleResults':0,'mouseDownOn':$([]),'$textbox':$(this)};context.data.$container=$('<div />').css({'top':Math.round(context.data.$textbox.offset().top+context.data.$textbox.outerHeight()),'left':Math.round(context.data.$textbox.offset().left),'width':context.data.$textbox.outerWidth(),'display':'none'}).addClass('suggestions').append($('<div />').addClass('suggestions-results').mousedown(function(e){context.data.mouseDownOn=$(e.target).closest('.suggestions-results div');}).mouseup(function(e){var $result=$(e.target).closest('.suggestions-results div');var $other=context.data.mouseDownOn;context.data.mouseDownOn=$([]);if($result.get(0)!=$other.get(0)){return;}
 415+if(typeof context.data=='undefined'){context.data={'timerID':null,'prevText':null,'visibleResults':0,'mouseDownOn':$([]),'$textbox':$(this)};var newCSS={'top':Math.round(context.data.$textbox.offset().top+context.data.$textbox.outerHeight()),'width':context.data.$textbox.outerWidth(),'display':'none'}
 416+if(context.config.positionFromLeft){newCSS['left']=context.config.$region.offset().left;newCSS['right']='auto';}else{newCSS['left']='auto';newCSS['right']=$('body').width()-(context.config.$region.offset().left+context.config.$region.outerWidth());}
 417+context.data.$container=$('<div />').css(newCSS).addClass('suggestions').append($('<div />').addClass('suggestions-results').mousedown(function(e){context.data.mouseDownOn=$(e.target).closest('.suggestions-results div');}).mouseup(function(e){var $result=$(e.target).closest('.suggestions-results div');var $other=context.data.mouseDownOn;context.data.mouseDownOn=$([]);if($result.get(0)!=$other.get(0)){return;}
416418 $.suggestions.highlight(context,$result,true);context.data.$container.hide();if(typeof context.config.result.select=='function'){context.config.result.select.call($result,context.data.$textbox);}
417419 context.data.$textbox.focus();})).append($('<div />').addClass('suggestions-special').mousedown(function(e){context.data.mouseDownOn=$(e.target).closest('.suggestions-special');}).mouseup(function(e){var $special=$(e.target).closest('.suggestions-special');var $other=context.data.mouseDownOn;context.data.mouseDownOn=$([]);if($special.get(0)!=$other.get(0)){return;}
418420 context.data.$container.hide();if(typeof context.config.special.select=='function'){context.config.special.select.call($special,context.data.$textbox);}

Follow-up revisions

RevisionCommit summaryAuthorDate
r66643Followup to r66642. Removing console code and a spelling mistakeadam17:51, 19 May 2010
r667081.16wmf4: Merge SimpleSearch fixes from trunk: r66565, rr66623, r66631, r6664...catrope21:00, 20 May 2010

Status & tagging log