r66690 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66689‎ | r66690 | r66691 >
Date:13:23, 20 May 2010
Author:adam
Status:deferred (Comments)
Tags:
Comment:
Adding a selector option to autoEllipsis to allow it to work with elements other than spans, adding the proper config options to the autoElipsis call in the suggestions code to restore autoElipsis functionality
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.autoEllipsis.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.suggestions.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -64,7 +64,7 @@
6565
6666 // Core functionality of extension scripts
6767 array( 'src' => 'js/plugins/jquery.async.js', 'version' => 3 ),
68 - array( 'src' => 'js/plugins/jquery.autoEllipsis.js', 'version' => 8 ),
 68+ array( 'src' => 'js/plugins/jquery.autoEllipsis.js', 'version' => 9 ),
6969 array( 'src' => 'js/plugins/jquery.browser.js', 'version' => 6 ),
7070 array( 'src' => 'js/plugins/jquery.collapsibleTabs.js', 'version' => 6 ),
7171 array( 'src' => 'js/plugins/jquery.color.js', 'version' => 1 ),
@@ -72,7 +72,7 @@
7373 array( 'src' => 'js/plugins/jquery.delayedBind.js', 'version' => 1 ),
7474 array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 18 ),
7575 array( 'src' => 'js/plugins/jquery.expandableField.js', 'version' => 15 ),
76 - array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 20 ),
 76+ array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 21 ),
7777 array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 33 ),
7878 array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 188 ),
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' => 405 ),
 89+ array( 'src' => 'js/plugins.combined.js', 'version' => 406 ),
9090 ),
9191 'minified' => array(
92 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 405 ),
 92+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 406 ),
9393 ),
9494 ),
9595 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.suggestions.js
@@ -195,7 +195,7 @@
196196 context.data.$container.width( Math.min( expWidth, maxWidth ) );
197197 }
198198 // autoEllipse the results. Has to be done after changing the width
199 - $autoEllipseMe.autoEllipsis( { hasSpan: true, tooltip: true } );
 199+ $autoEllipseMe.autoEllipsis( { hasSpan: true, tooltip: true, selector: 'div' } );
200200 }
201201 }
202202 break;
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.autoEllipsis.js
@@ -10,6 +10,7 @@
1111 options = $.extend( {
1212 'position': 'center',
1313 'tooltip': false,
 14+ 'selector': 'span',
1415 'restoreText': false,
1516 'hasSpan': false
1617 }, options );
@@ -26,7 +27,7 @@
2728 var w = $this.width();
2829 var $text;
2930 if ( options.hasSpan ) {
30 - $text = $this.children( 'span' );
 31+ $text = $this.children( options.selector );
3132 } else {
3233 $text = $( '<span />' ).css( 'whiteSpace', 'nowrap' );
3334 $this.empty().append( $text );
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -5182,6 +5182,7 @@
51835183 options = $.extend( {
51845184 'position': 'center',
51855185 'tooltip': false,
 5186+ 'selector': 'span',
51865187 'restoreText': false,
51875188 'hasSpan': false
51885189 }, options );
@@ -5198,7 +5199,7 @@
51995200 var w = $this.width();
52005201 var $text;
52015202 if ( options.hasSpan ) {
5202 - $text = $this.children( 'span' );
 5203+ $text = $this.children( options.selector );
52035204 } else {
52045205 $text = $( '<span />' ).css( 'whiteSpace', 'nowrap' );
52055206 $this.empty().append( $text );
@@ -5952,7 +5953,7 @@
59535954 context.data.$container.width( Math.min( expWidth, maxWidth ) );
59545955 }
59555956 // autoEllipse the results. Has to be done after changing the width
5956 - $autoEllipseMe.autoEllipsis( { hasSpan: true, tooltip: true } );
 5957+ $autoEllipseMe.autoEllipsis( { hasSpan: true, tooltip: true, selector: 'div' } );
59575958 }
59585959 }
59595960 break;
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,'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);}
 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);}
365365 if(!(text in cache)){cache[text]={};}
366366 if(w in cache[text]){$text.text(cache[text][w]);return;}
367367 $text.text(text);if($text.width()>w){switch(options.position){case'right':var l=0,r=text.length;do{var m=Math.ceil((l+r)/2);$text.text(text.substr(0,m)+'...');if($text.width()>w){r=m-1;}else{l=m;}}while(l<r);$text.text(text.substr(0,l)+'...');break;case'center':var i=[Math.round(text.length/2),Math.round(text.length/2)];var side=1;while($text.outerWidth()>w&&i[0]>0){$text.text(text.substr(0,i[0])+'...'+text.substr(i[1]));if(side==0){i[0]--;side=1;}else{i[1]++;side=0;}}
@@ -401,7 +401,7 @@
402402 var $span=$result.children('div');if($span.outerWidth()>$result.width()&&$span.outerWidth()>expWidth){expWidth=$span.outerWidth();}
403403 $autoEllipseMe=$autoEllipseMe.add($result);}}
404404 if(expWidth>context.data.$container.width()){var maxWidth=context.config.maxExpandFactor*context.data.$textbox.width();context.data.$container.width(Math.min(expWidth,maxWidth));}
405 -$autoEllipseMe.autoEllipsis({hasSpan:true,tooltip:true});}}
 405+$autoEllipseMe.autoEllipsis({hasSpan:true,tooltip:true,selector:'div'});}}
406406 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');}}}
407407 selected.removeClass('suggestions-result-current');result.addClass('suggestions-result-current');}
408408 if(updateTextbox){if(result.length==0){$.suggestions.restore(context);}else{context.data.$textbox.val(result.data('text'));context.data.$textbox.change();}

Follow-up revisions

RevisionCommit summaryAuthorDate
r67741UsabilityInitiative: Temporarily revert r66658, r66662, r66690 so UsabilityIn...catrope18:42, 9 June 2010

Comments

#Comment by Adammiller~mediawikiwiki (talk | contribs)   14:24, 20 May 2010

Lies. Still not working. The problem is that autoEllipsis uses text() for replacing the contents of whatever it's autoEllipsis. If I stick markup in there, and allow autoEllipsis to run, it removes the markup. It only dawned on me what was going on after committing this.

#Comment by Adammiller~mediawikiwiki (talk | contribs)   14:29, 20 July 2010

No longer a problem. Worked around it in later revisions.

Status & tagging log