r66161 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66160‎ | r66161 | r66162 >
Date:21:12, 10 May 2010
Author:tparscal
Status:ok (Comments)
Tags:
Comment:
Fixed issue with pressing down arrow key not going to the special suggestion while no suggestions are present.
Modified paths:
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.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/UsabilityInitiative.hooks.php
@@ -70,7 +70,7 @@
7171 array( 'src' => 'js/plugins/jquery.color.js', 'version' => 1 ),
7272 array( 'src' => 'js/plugins/jquery.cookie.js', 'version' => 4 ),
7373 array( 'src' => 'js/plugins/jquery.delayedBind.js', 'version' => 1 ),
74 - array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 11 ),
 74+ array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 12 ),
7575 array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 30 ),
7676 array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 185 ),
7777 array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 53 ),
@@ -83,10 +83,10 @@
8484 array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 5 ),
8585 ),
8686 'combined' => array(
87 - array( 'src' => 'js/plugins.combined.js', 'version' => 389 ),
 87+ array( 'src' => 'js/plugins.combined.js', 'version' => 390 ),
8888 ),
8989 'minified' => array(
90 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 389 ),
 90+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 390 ),
9191 ),
9292 ),
9393 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.suggestions.js
@@ -175,7 +175,7 @@
176176 result = context.data.$container.find( '.suggestions-results div:last' )
177177 } else {
178178 result = selected.prev();
179 - if ( selected.size() == 0 ) {
 179+ if ( selected.length == 0 ) {
180180 // we are at the begginning, so lets jump to the last item
181181 if ( context.data.$container.find( '.suggestions-special' ).html() != "" ) {
182182 result = context.data.$container.find( '.suggestions-special' );
@@ -185,14 +185,21 @@
186186 }
187187 }
188188 } else if ( result == 'next' ) {
189 - if ( selected.size() == 0 )
 189+ if ( selected.length == 0 ) {
190190 // No item selected, go to the first one
191191 result = context.data.$container.find( '.suggestions-results div:first' );
192 - else {
 192+ if ( result.length == 0 && context.data.$container.find( '.suggestions-special' ).html() != "" ) {
 193+ // No suggestion exists, use the
 194+ result = context.data.$container.find( '.suggestions-special' );
 195+ }
 196+ } else {
193197 result = selected.next();
194198 if ( selected.is( '.suggestions-special' ) ) {
195199 result = $( [] );
196 - } else if ( result.size() == 0 && context.data.$container.find( '.suggestions-special' ).html() != "" ) {
 200+ } else if (
 201+ result.length == 0 &&
 202+ context.data.$container.find( '.suggestions-special' ).html() != ""
 203+ ) {
197204 // We were at the last item, jump to the specials!
198205 result = context.data.$container.find( '.suggestions-special' );
199206 }
@@ -202,7 +209,7 @@
203210 result.addClass( 'suggestions-result-current' );
204211 }
205212 if ( updateTextbox ) {
206 - if ( result.size() == 0 ) {
 213+ if ( result.length == 0 ) {
207214 $.suggestions.restore( context );
208215 } else {
209216 context.data.$textbox.val( result.data( 'text' ) );
@@ -428,7 +435,7 @@
429436 .blur( function() {
430437 // When losing focus because of a mousedown
431438 // on a suggestion, don't hide the suggestions
432 - if ( context.data.mouseDownOn.size() > 0 ) {
 439+ if ( context.data.mouseDownOn.length > 0 ) {
433440 return;
434441 }
435442 context.data.$container.hide();
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -5926,7 +5926,7 @@
59275927 result = context.data.$container.find( '.suggestions-results div:last' )
59285928 } else {
59295929 result = selected.prev();
5930 - if ( selected.size() == 0 ) {
 5930+ if ( selected.length == 0 ) {
59315931 // we are at the begginning, so lets jump to the last item
59325932 if ( context.data.$container.find( '.suggestions-special' ).html() != "" ) {
59335933 result = context.data.$container.find( '.suggestions-special' );
@@ -5936,14 +5936,21 @@
59375937 }
59385938 }
59395939 } else if ( result == 'next' ) {
5940 - if ( selected.size() == 0 )
 5940+ if ( selected.length == 0 ) {
59415941 // No item selected, go to the first one
59425942 result = context.data.$container.find( '.suggestions-results div:first' );
5943 - else {
 5943+ if ( result.length == 0 && context.data.$container.find( '.suggestions-special' ).html() != "" ) {
 5944+ // No suggestion exists, use the
 5945+ result = context.data.$container.find( '.suggestions-special' );
 5946+ }
 5947+ } else {
59445948 result = selected.next();
59455949 if ( selected.is( '.suggestions-special' ) ) {
59465950 result = $( [] );
5947 - } else if ( result.size() == 0 && context.data.$container.find( '.suggestions-special' ).html() != "" ) {
 5951+ } else if (
 5952+ result.length == 0 &&
 5953+ context.data.$container.find( '.suggestions-special' ).html() != ""
 5954+ ) {
59485955 // We were at the last item, jump to the specials!
59495956 result = context.data.$container.find( '.suggestions-special' );
59505957 }
@@ -5953,7 +5960,7 @@
59545961 result.addClass( 'suggestions-result-current' );
59555962 }
59565963 if ( updateTextbox ) {
5957 - if ( result.size() == 0 ) {
 5964+ if ( result.length == 0 ) {
59585965 $.suggestions.restore( context );
59595966 } else {
59605967 context.data.$textbox.val( result.data( 'text' ) );
@@ -6179,7 +6186,7 @@
61806187 .blur( function() {
61816188 // When losing focus because of a mousedown
61826189 // on a suggestion, don't hide the suggestions
6183 - if ( context.data.mouseDownOn.size() > 0 ) {
 6190+ if ( context.data.mouseDownOn.length > 0 ) {
61846191 return;
61856192 }
61866193 context.data.$container.hide();
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -395,10 +395,9 @@
396396 if(context.data.timerID!=null){clearTimeout(context.data.timerID);}
397397 if(delayed){context.data.timerID=setTimeout(maybeFetch,context.config.delay);}else{maybeFetch();}
398398 $.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();for(var i=0;i<context.config.suggestions.length;i++){$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.text(context.config.suggestions[i]).autoEllipsis();}}}}
399 -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'submitOnClick':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.size()==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.size()==0)
400 -result=context.data.$container.find('.suggestions-results div:first');else{result=selected.next();if(selected.is('.suggestions-special')){result=$([]);}else if(result.size()==0&&context.data.$container.find('.suggestions-special').html()!=""){result=context.data.$container.find('.suggestions-special');}}}
 399+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'submitOnClick':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');}}}
401400 selected.removeClass('suggestions-result-current');result.addClass('suggestions-result-current');}
402 -if(updateTextbox){if(result.size()==0){$.suggestions.restore(context);}else{context.data.$textbox.val(result.data('text'));context.data.$textbox.change();}
 401+if(updateTextbox){if(result.length==0){$.suggestions.restore(context);}else{context.data.$textbox.val(result.data('text'));context.data.$textbox.change();}
403402 context.data.$textbox.trigger('change');}
404403 $.suggestions.special(context);},keypress:function(e,context,key){var wasVisible=context.data.$container.is(':visible');var preventDefault=false;switch(key){case 40:if(wasVisible){$.suggestions.highlight(context,'next',false);}else{$.suggestions.update(context,false);}
405404 preventDefault=true;break;case 38:if(wasVisible){$.suggestions.highlight(context,'prev',false);}
@@ -411,7 +410,7 @@
412411 $.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);}
413412 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;}
414413 context.data.$container.hide();if(typeof context.config.special.select=='function'){context.config.special.select.call($special,context.data.$textbox);}
415 -context.data.$textbox.focus();}).mouseover(function(e){$.suggestions.highlight(context,$(e.target).closest('.suggestions-special'),false);})).appendTo($('body'));$(this).attr('autocomplete','off').keydown(function(e){context.data.keypressed=(e.keyCode==undefined)?e.which:e.keyCode;context.data.keypressedCount=0;switch(context.data.keypressed){case 40:e.preventDefault();e.stopImmediatePropagation();break;case 38:case 27:case 13:if(context.data.$container.is(':visible')){e.preventDefault();e.stopImmediatePropagation();}}}).keypress(function(e){context.data.keypressedCount++;$.suggestions.keypress(e,context,context.data.keypressed);}).keyup(function(e){if(context.data.keypressedCount==0){$.suggestions.keypress(e,context,context.data.keypressed);}}).blur(function(){if(context.data.mouseDownOn.size()>0){return;}
 414+context.data.$textbox.focus();}).mouseover(function(e){$.suggestions.highlight(context,$(e.target).closest('.suggestions-special'),false);})).appendTo($('body'));$(this).attr('autocomplete','off').keydown(function(e){context.data.keypressed=(e.keyCode==undefined)?e.which:e.keyCode;context.data.keypressedCount=0;switch(context.data.keypressed){case 40:e.preventDefault();e.stopImmediatePropagation();break;case 38:case 27:case 13:if(context.data.$container.is(':visible')){e.preventDefault();e.stopImmediatePropagation();}}}).keypress(function(e){context.data.keypressedCount++;$.suggestions.keypress(e,context,context.data.keypressed);}).keyup(function(e){if(context.data.keypressedCount==0){$.suggestions.keypress(e,context,context.data.keypressed);}}).blur(function(){if(context.data.mouseDownOn.length>0){return;}
416415 context.data.$container.hide();$.suggestions.cancel(context);});}
417416 $(this).data('suggestions-context',context);});return returnValue!==null?returnValue:$(this);};})(jQuery);(function($){$.fn.textSelection=function(command,options){var fn={getContents:function(){return this.val();},getSelection:function(){var e=this.get(0);var retval='';if($(e).is(':hidden')){}else if(document.selection&&document.selection.createRange){e.focus();var range=document.selection.createRange();retval=range.text;}else if(e.selectionStart||e.selectionStart=='0'){retval=e.value.substring(e.selectionStart,e.selectionEnd);}
418417 return retval;},encapsulateSelection:function(options){return this.each(function(){function checkSelectedText(){if(!selText){selText=options.peri;isSample=true;}else if(options.replace){selText=options.peri;}else if(selText.charAt(selText.length-1)==' '){selText=selText.substring(0,selText.length-1);options.post+=' ';}}

Comments

#Comment by Catrope (talk | contribs)   21:16, 10 May 2010
+						// No suggestion exists, use the
+						result = context.data.$container.find( '.suggestions-special' );

That comment is incomplete.

Status & tagging log