r58441 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58440‎ | r58441 | r58442 >
Date:20:46, 2 November 2009
Author:catrope
Status:ok
Tags:
Comment:
NaNavigableTOC: Fix autoellipse bugginess
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.autoEllipse.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -61,7 +61,7 @@
6262 'base_sets' => array(
6363 'raw' => array(
6464 array( 'src' => 'js/plugins/jquery.async.js', 'version' => 3 ),
65 - array( 'src' => 'js/plugins/jquery.autoEllipse.js', 'version' => 3 ),
 65+ array( 'src' => 'js/plugins/jquery.autoEllipse.js', 'version' => 4 ),
6666 array( 'src' => 'js/plugins/jquery.browser.js', 'version' => 3 ),
6767 array( 'src' => 'js/plugins/jquery.collapsibleTabs.js', 'version' => 5 ),
6868 array( 'src' => 'js/plugins/jquery.cookie.js', 'version' => 3 ),
@@ -75,10 +75,10 @@
7676 array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 25 ),
7777 ),
7878 'combined' => array(
79 - array( 'src' => 'js/plugins.combined.js', 'version' => 58 ),
 79+ array( 'src' => 'js/plugins.combined.js', 'version' => 59 ),
8080 ),
8181 'minified' => array(
82 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 58 ),
 82+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 59 ),
8383 ),
8484 ),
8585 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.autoEllipse.js
@@ -12,7 +12,7 @@
1313 var text = $(this).text();
1414 var $text = $( '<span />' ).text( text ).css( 'whiteSpace', 'nowrap' );
1515 $(this).empty().append( $text );
16 - if ( $text.outerWidth() > $(this).innerWidth() ) {
 16+ if ( $text.width() > $(this).width() ) {
1717 switch ( options.position ) {
1818 case 'right':
1919 // Use binary search-like technique for efficiency
@@ -20,13 +20,14 @@
2121 do {
2222 var m = Math.ceil( ( l + r ) / 2 );
2323 $text.text( text.substr( 0, m ) + '...' );
24 - if ( $text.outerWidth() > $(this).width() ) {
 24+ if ( $text.width() > $(this).width() ) {
2525 // Text is too long
2626 r = m - 1;
2727 } else {
2828 l = m;
2929 }
3030 } while ( l < r );
 31+ $text.text( text.substr( 0, l ) + '...' );
3132 break;
3233 case 'center':
3334 // TODO: Use binary search like for 'right'
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -90,7 +90,7 @@
9191 var text = $(this).text();
9292 var $text = $( '<span />' ).text( text ).css( 'whiteSpace', 'nowrap' );
9393 $(this).empty().append( $text );
94 - if ( $text.outerWidth() > $(this).innerWidth() ) {
 94+ if ( $text.width() > $(this).width() ) {
9595 switch ( options.position ) {
9696 case 'right':
9797 // Use binary search-like technique for efficiency
@@ -98,13 +98,14 @@
9999 do {
100100 var m = Math.ceil( ( l + r ) / 2 );
101101 $text.text( text.substr( 0, m ) + '...' );
102 - if ( $text.outerWidth() > $(this).width() ) {
 102+ if ( $text.width() > $(this).width() ) {
103103 // Text is too long
104104 r = m - 1;
105105 } else {
106106 l = m;
107107 }
108108 } while ( l < r );
 109+ $text.text( text.substr( 0, l ) + '...' );
109110 break;
110111 case 'center':
111112 // TODO: Use binary search like for 'right'
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -11,7 +11,7 @@
1212 {var i=0,l=array.length,loop=opts.loop||function(){};$.whileAsync($.extend(opts,{test:function(){return i<l;},loop:function()
1313 {var val=array[i];return loop.call(val,i++,val);}}));}
1414 $.fn.eachAsync=function(opts)
15 -{$.eachAsync(this,opts);return this;}})(jQuery);(function($){$.fn.autoEllipse=function(options){$(this).each(function(){options=$.extend({'position':'center','tooltip':false},options);var text=$(this).text();var $text=$('<span />').text(text).css('whiteSpace','nowrap');$(this).empty().append($text);if($text.outerWidth()>$(this).innerWidth()){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.outerWidth()>$(this).width()){r=m-1;}else{l=m;}}while(l<r);break;case'center':var i=[Math.round(text.length/2),Math.round(text.length/2)];var side=1;while($text.outerWidth()>($(this).width())&&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;}}
 15+{$.eachAsync(this,opts);return this;}})(jQuery);(function($){$.fn.autoEllipse=function(options){$(this).each(function(){options=$.extend({'position':'center','tooltip':false},options);var text=$(this).text();var $text=$('<span />').text(text).css('whiteSpace','nowrap');$(this).empty().append($text);if($text.width()>$(this).width()){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()>$(this).width()){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()>($(this).width())&&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;}}
1616 break;case'left':var r=0;while($text.outerWidth()>$(this).width()&&r<text.length){$text.text('...'+text.substr(r));r++;}
1717 break;}
1818 if(options.tooltip)

Follow-up revisions

RevisionCommit summaryAuthorDate
r59204wmf-deployment: Merging usability changes from trunk...catrope18:53, 18 November 2009

Status & tagging log