r67741 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67740‎ | r67741 | r67742 >
Date:18:42, 9 June 2010
Author:catrope
Status:deferred
Tags:
Comment:
UsabilityInitiative: Temporarily revert r66658, r66662, r66690 so UsabilityInitiative trunk is deployable. Will put these revs back in in no less than 24 hours
Modified paths:
  • /trunk/extensions/UsabilityInitiative/Vector/Vector.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/css/combined.css (modified) (history)
  • /trunk/extensions/UsabilityInitiative/css/combined.min.css (modified) (history)
  • /trunk/extensions/UsabilityInitiative/css/suggestions.css (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.autoEllipsis.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.suggestions.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/css/suggestions.css
@@ -39,9 +39,8 @@
4040 margin: 0;
4141 width: 100%;
4242 }
43 -.suggestions-result div {
 43+.suggestions-result span {
4444 line-height: 1.5em;
45 - display: inline;
4645 padding: 0.25em 0.25em;
4746 }
4847 .suggestions-result-current {
Index: trunk/extensions/UsabilityInitiative/css/combined.css
@@ -39,9 +39,8 @@
4040 margin: 0;
4141 width: 100%;
4242 }
43 -.suggestions-result div {
 43+.suggestions-result span {
4444 line-height: 1.5em;
45 - display: inline;
4645 padding: 0.25em 0.25em;
4746 }
4847 .suggestions-result-current {
Index: trunk/extensions/UsabilityInitiative/css/combined.min.css
@@ -37,9 +37,8 @@
3838 margin:0;
3939 width:100%;
4040 }
41 -.suggestions-result div{
 41+.suggestions-result span{
4242 line-height:1.5em;
43 -display:inline;
4443 padding:0.25em 0.25em;
4544 }
4645 .suggestions-result-current{
Index: trunk/extensions/UsabilityInitiative/Vector/Vector.hooks.php
@@ -20,10 +20,10 @@
2121 array( 'src' => 'Modules/SimpleSearch/SimpleSearch.js', 'version' => 15 ),
2222 ),
2323 'combined' => array(
24 - array( 'src' => 'Vector.combined.js', 'version' => 46 ),
 24+ array( 'src' => 'Vector.combined.js', 'version' => 47 ),
2525 ),
2626 'minified' => array(
27 - array( 'src' => 'Vector.combined.min.js', 'version' => 46 ),
 27+ array( 'src' => 'Vector.combined.min.js', 'version' => 47 ),
2828 ),
2929 );
3030 static $modules = array(
Index: trunk/extensions/UsabilityInitiative/WikiEditor/WikiEditor.hooks.php
@@ -22,10 +22,10 @@
2323 array( 'src' => 'Modules/AddMediaWizard/AddMediaWizard.js', 'version' => 6 ),
2424 ),
2525 'combined' => array(
26 - array( 'src' => 'WikiEditor.combined.js', 'version' => 98 ),
 26+ array( 'src' => 'WikiEditor.combined.js', 'version' => 99 ),
2727 ),
2828 'minified' => array(
29 - array( 'src' => 'WikiEditor.combined.min.js', 'version' => 98 ),
 29+ array( 'src' => 'WikiEditor.combined.min.js', 'version' => 99 ),
3030 ),
3131 );
3232 static $messages = array(
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.suggestions.js
@@ -38,8 +38,6 @@
3939 * Type: Number, Range: 1 - infinity, Default: 3
4040 * positionFromLeft: Whether to position the suggestion box with the left attribute or the right
4141 * Type: Boolean, Default: true
42 - * highlightInput: Highlights the matched text in the suggestions
43 - * Type: Boolean, Default: true
4442 */
4543 ( function( $ ) {
4644
@@ -148,7 +146,6 @@
149147 var expWidth = -1;
150148 var $autoEllipseMe = $( [] );
151149 for ( var i = 0; i < context.config.suggestions.length; i++ ) {
152 - var text = context.config.suggestions[i];
153150 var $result = $( '<div />' )
154151 .addClass( 'suggestions-result' )
155152 .attr( 'rel', i )
@@ -162,27 +159,17 @@
163160
164161 // Allow custom rendering
165162 if ( typeof context.config.result.render == 'function' ) {
166 - context.config.result.render.call( $result, text );
 163+ context.config.result.render.call( $result, context.config.suggestions[i] );
167164 } else {
168165 // Add <span> with text
169 - if( context.config.highlightInput ) {
170 - var matchedText = text.substr( 0, context.data.prevText.length );
171 - text = text.substr( context.data.prevText.length, text.length );
172 - $result.append( $( '<div />' )
173 - .css( 'whiteSpace', 'nowrap' )
174 - .text( text )
175 - .prepend( $( '<strong />' ).text( matchedText ) )
176 - );
177 - } else {
178 - $result.append( $( '<div />' )
179 - .css( 'whiteSpace', 'nowrap' )
180 - .text( text )
181 - );
182 - }
 166+ $result.append( $( '<span />' )
 167+ .css( 'whiteSpace', 'nowrap' )
 168+ .text( context.config.suggestions[i] )
 169+ );
183170
184171 // Widen results box if needed
185172 // New width is only calculated here, applied later
186 - var $span = $result.children( 'div' );
 173+ var $span = $result.children( 'span' );
187174 if ( $span.outerWidth() > $result.width() && $span.outerWidth() > expWidth ) {
188175 expWidth = $span.outerWidth();
189176 }
@@ -195,7 +182,7 @@
196183 context.data.$container.width( Math.min( expWidth, maxWidth ) );
197184 }
198185 // autoEllipse the results. Has to be done after changing the width
199 - $autoEllipseMe.autoEllipsis( { hasSpan: true, tooltip: true, selector: 'div' } );
 186+ $autoEllipseMe.autoEllipsis( { hasSpan: true, tooltip: true } );
200187 }
201188 }
202189 break;
@@ -210,7 +197,6 @@
211198 break;
212199 case 'submitOnClick':
213200 case 'positionFromLeft':
214 - case 'highlightInput':
215201 context.config[property] = value ? true : false;
216202 break;
217203 }
@@ -362,8 +348,7 @@
363349 'delay': 120,
364350 'submitOnClick': false,
365351 'maxExpandFactor': 3,
366 - 'positionFromLeft': true,
367 - 'highlightInput': true
 352+ 'positionFromLeft': true
368353 }
369354 };
370355 }
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.autoEllipsis.js
@@ -10,7 +10,6 @@
1111 options = $.extend( {
1212 'position': 'center',
1313 'tooltip': false,
14 - 'selector': 'span',
1514 'restoreText': false,
1615 'hasSpan': false
1716 }, options );
@@ -27,7 +26,7 @@
2827 var w = $this.width();
2928 var $text;
3029 if ( options.hasSpan ) {
31 - $text = $this.children( options.selector );
 30+ $text = $this.children( 'span' );
3231 } else {
3332 $text = $( '<span />' ).css( 'whiteSpace', 'nowrap' );
3433 $this.empty().append( $text );
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -5182,7 +5182,6 @@
51835183 options = $.extend( {
51845184 'position': 'center',
51855185 'tooltip': false,
5186 - 'selector': 'span',
51875186 'restoreText': false,
51885187 'hasSpan': false
51895188 }, options );
@@ -5199,7 +5198,7 @@
52005199 var w = $this.width();
52015200 var $text;
52025201 if ( options.hasSpan ) {
5203 - $text = $this.children( options.selector );
 5202+ $text = $this.children( 'span' );
52045203 } else {
52055204 $text = $( '<span />' ).css( 'whiteSpace', 'nowrap' );
52065205 $this.empty().append( $text );
@@ -5926,8 +5925,6 @@
59275926 * Type: Number, Range: 1 - infinity, Default: 3
59285927 * positionFromLeft: Whether to position the suggestion box with the left attribute or the right
59295928 * Type: Boolean, Default: true
5930 - * highlightInput: Highlights the matched text in the suggestions
5931 - * Type: Boolean, Default: true
59325929 */
59335930 ( function( $ ) {
59345931
@@ -6036,7 +6033,6 @@
60376034 var expWidth = -1;
60386035 var $autoEllipseMe = $( [] );
60396036 for ( var i = 0; i < context.config.suggestions.length; i++ ) {
6040 - var text = context.config.suggestions[i];
60416037 var $result = $( '<div />' )
60426038 .addClass( 'suggestions-result' )
60436039 .attr( 'rel', i )
@@ -6050,27 +6046,17 @@
60516047
60526048 // Allow custom rendering
60536049 if ( typeof context.config.result.render == 'function' ) {
6054 - context.config.result.render.call( $result, text );
 6050+ context.config.result.render.call( $result, context.config.suggestions[i] );
60556051 } else {
60566052 // Add <span> with text
6057 - if( context.config.highlightInput ) {
6058 - var matchedText = text.substr( 0, context.data.prevText.length );
6059 - text = text.substr( context.data.prevText.length, text.length );
6060 - $result.append( $( '<div />' )
6061 - .css( 'whiteSpace', 'nowrap' )
6062 - .text( text )
6063 - .prepend( $( '<strong />' ).text( matchedText ) )
6064 - );
6065 - } else {
6066 - $result.append( $( '<div />' )
6067 - .css( 'whiteSpace', 'nowrap' )
6068 - .text( text )
6069 - );
6070 - }
 6053+ $result.append( $( '<span />' )
 6054+ .css( 'whiteSpace', 'nowrap' )
 6055+ .text( context.config.suggestions[i] )
 6056+ );
60716057
60726058 // Widen results box if needed
60736059 // New width is only calculated here, applied later
6074 - var $span = $result.children( 'div' );
 6060+ var $span = $result.children( 'span' );
60756061 if ( $span.outerWidth() > $result.width() && $span.outerWidth() > expWidth ) {
60766062 expWidth = $span.outerWidth();
60776063 }
@@ -6083,7 +6069,7 @@
60846070 context.data.$container.width( Math.min( expWidth, maxWidth ) );
60856071 }
60866072 // autoEllipse the results. Has to be done after changing the width
6087 - $autoEllipseMe.autoEllipsis( { hasSpan: true, tooltip: true, selector: 'div' } );
 6073+ $autoEllipseMe.autoEllipsis( { hasSpan: true, tooltip: true } );
60886074 }
60896075 }
60906076 break;
@@ -6098,7 +6084,6 @@
60996085 break;
61006086 case 'submitOnClick':
61016087 case 'positionFromLeft':
6102 - case 'highlightInput':
61036088 context.config[property] = value ? true : false;
61046089 break;
61056090 }
@@ -6250,8 +6235,7 @@
62516236 'delay': 120,
62526237 'submitOnClick': false,
62536238 'maxExpandFactor': 3,
6254 - 'positionFromLeft': true,
6255 - 'highlightInput': true
 6239+ 'positionFromLeft': true
62566240 }
62576241 };
62586242 }
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -359,8 +359,8 @@
360360 {var i=0,l=array.length,loop=opts.loop||function(){};$.whileAsync($.extend(opts,{test:function(){return i<l;},loop:function()
361361 {var val=array[i];return loop.call(val,i++,val);}}));}
362362 $.fn.eachAsync=function(opts)
363 -{$.eachAsync(this,opts);return this;}})(jQuery);(function($){var cache={};$.fn.autoEllipsis=function(options){options=$.extend({'position':'center','tooltip':false,'selector':'span','restoreText':false,'hasSpan':false},options);$(this).each(function(){var $this=$(this);if(options.restoreText){if(!$this.data('autoEllipsis.originalText')){$this.data('autoEllipsis.originalText',$this.text());}else{$this.text($this.data('autoEllipsis.originalText'));}}
364 -var text=$this.text();var w=$this.width();var $text;if(options.hasSpan){$text=$this.children(options.selector);}else{$text=$('<span />').css('whiteSpace','nowrap');$this.empty().append($text);}
 363+{$.eachAsync(this,opts);return this;}})(jQuery);(function($){var cache={};$.fn.autoEllipsis=function(options){options=$.extend({'position':'center','tooltip':false,'restoreText':false,'hasSpan':false},options);$(this).each(function(){var $this=$(this);if(options.restoreText){if(!$this.data('autoEllipsis.originalText')){$this.data('autoEllipsis.originalText',$this.text());}else{$this.text($this.data('autoEllipsis.originalText'));}}
 364+var text=$this.text();var w=$this.width();var $text;if(options.hasSpan){$text=$this.children('span');}else{$text=$('<span />').css('whiteSpace','nowrap');$this.empty().append($text);}
365365 if(!(text in cache)){cache[text]={};}
366366 if(w in cache[text]){$text.text(cache[text][w]);if(options.tooltip)
367367 $text.attr('title',text);return;}
@@ -400,12 +400,11 @@
401401 if(delayed){context.data.timerID=setTimeout(maybeFetch,context.config.delay);}else{maybeFetch();}
402402 $.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'}
403403 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());}
404 -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 text=context.config.suggestions[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,text);}else{if(context.config.highlightInput){var matchedText=text.substr(0,context.data.prevText.length);text=text.substr(context.data.prevText.length,text.length);$result.append($('<div />').css('whiteSpace','nowrap').text(text).prepend($('<strong />').text(matchedText)));}else{$result.append($('<div />').css('whiteSpace','nowrap').text(text));}
405 -var $span=$result.children('div');if($span.outerWidth()>$result.width()&&$span.outerWidth()>expWidth){expWidth=$span.outerWidth();}
 404+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.outerWidth()>$result.width()&&$span.outerWidth()>expWidth){expWidth=$span.outerWidth();}
406405 $autoEllipseMe=$autoEllipseMe.add($result);}}
407406 if(expWidth>context.data.$container.width()){var maxWidth=context.config.maxExpandFactor*context.data.$textbox.width();context.data.$container.width(Math.min(expWidth,maxWidth));}
408 -$autoEllipseMe.autoEllipsis({hasSpan:true,tooltip:true,selector:'div'});}}
409 -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)){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');}}}
 407+$autoEllipseMe.autoEllipsis({hasSpan:true,tooltip:true});}}
 408+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');}}}
410409 selected.removeClass('suggestions-result-current');result.addClass('suggestions-result-current');}
411410 if(updateTextbox){if(result.length==0){$.suggestions.restore(context);}else{context.data.$textbox.val(result.data('text'));context.data.$textbox.change();}
412411 context.data.$textbox.trigger('change');}
@@ -413,7 +412,7 @@
414413 preventDefault=true;break;case 38:if(wasVisible){$.suggestions.highlight(context,'prev',false);}
415414 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);}}
416415 break;default:$.suggestions.update(context,true);break;}
417 -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':3,'positionFromLeft':true,'highlightInput':true}};}
 416+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':3,'positionFromLeft':true}};}
418417 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]]);}}}
419418 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'}
420419 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());}

Follow-up revisions

RevisionCommit summaryAuthorDate
r677461.16wmf4: Update UsabilityInitiative to r67741 and merge r67743catrope19:16, 9 June 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r66658Adding match highlighting to the suggestions pluginadam21:18, 19 May 2010
r66662Follow up to r66658. Not sure if this fixes everything but i can not figure o...adam22:23, 19 May 2010
r66690Adding a selector option to autoEllipsis to allow it to work with elements ot...adam13:23, 20 May 2010

Status & tagging log