Index: trunk/extensions/UsabilityInitiative/SimpleSearch/SimpleSearch.js |
— | — | @@ -91,13 +91,16 @@ |
92 | 92 | .addClass( 'special-label' ) |
93 | 93 | .text( gM( 'simplesearch-containing' ) ) |
94 | 94 | .appendTo( $j(this) ); |
95 | | - $query = $j( '<span />' ) |
| 95 | + $query = $j( '<div />' ) |
96 | 96 | .addClass( 'special-query' ) |
97 | 97 | .text( query ) |
98 | 98 | .appendTo( $j(this) ); |
99 | 99 | $query.autoEllipse(); |
100 | 100 | } else { |
101 | | - $j(this).find( '.special-query' ).empty().text( query ).autoEllipse(); |
| 101 | + $j(this).find( '.special-query' ) |
| 102 | + .empty() |
| 103 | + .text( query ) |
| 104 | + .autoEllipse(); |
102 | 105 | } |
103 | 106 | } else { |
104 | 107 | $j(this).hide(); |
Index: trunk/extensions/UsabilityInitiative/css/suggestions.css |
— | — | @@ -36,11 +36,13 @@ |
37 | 37 | .suggestions-result { |
38 | 38 | color: black; |
39 | 39 | color: WindowText; |
40 | | - padding: 0.25em 0.25em; |
41 | | - line-height: 1.25em; |
42 | 40 | margin: 0; |
43 | 41 | width: 100%; |
44 | 42 | } |
| 43 | +.suggestions-result span { |
| 44 | + line-height: 1.5em; |
| 45 | + padding: 0.25em 0.25em; |
| 46 | +} |
45 | 47 | .suggestions-result-current { |
46 | 48 | background-color: #4C59A6; |
47 | 49 | background-color: Highlight; |
Index: trunk/extensions/UsabilityInitiative/css/combined.css |
— | — | @@ -36,11 +36,13 @@ |
37 | 37 | .suggestions-result { |
38 | 38 | color: black; |
39 | 39 | color: WindowText; |
40 | | - padding: 0.25em 0.25em; |
41 | | - line-height: 1.25em; |
42 | 40 | margin: 0; |
43 | 41 | width: 100%; |
44 | 42 | } |
| 43 | +.suggestions-result span { |
| 44 | + line-height: 1.5em; |
| 45 | + padding: 0.25em 0.25em; |
| 46 | +} |
45 | 47 | .suggestions-result-current { |
46 | 48 | background-color: #4C59A6; |
47 | 49 | background-color: Highlight; |
Index: trunk/extensions/UsabilityInitiative/css/combined.min.css |
— | — | @@ -34,11 +34,13 @@ |
35 | 35 | .suggestions-result{ |
36 | 36 | color:black; |
37 | 37 | color:WindowText; |
38 | | -padding:0.25em 0.25em; |
39 | | -line-height:1.25em; |
40 | 38 | margin:0; |
41 | 39 | width:100%; |
42 | 40 | } |
| 41 | +.suggestions-result span{ |
| 42 | +line-height:1.5em; |
| 43 | +padding:0.25em 0.25em; |
| 44 | +} |
43 | 45 | .suggestions-result-current{ |
44 | 46 | background-color:#4C59A6; |
45 | 47 | background-color:Highlight; |
— | — | @@ -446,4 +448,4 @@ |
447 | 449 | background-color:white; |
448 | 450 | text-decoration:none; |
449 | 451 | border-color:#a8d7f9; |
450 | | -} |
\ No newline at end of file |
| 452 | +} |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.autoEllipse.js |
— | — | @@ -3,16 +3,47 @@ |
4 | 4 | */ |
5 | 5 | ( function( $ ) { |
6 | 6 | |
7 | | -$.fn.autoEllipse = function() { |
| 7 | +$.fn.autoEllipse = function( options ) { |
8 | 8 | $(this).each( function() { |
| 9 | + options = $.extend( { |
| 10 | + 'position': 'center' |
| 11 | + }, options ); |
9 | 12 | var text = $(this).text(); |
10 | 13 | var $text = $( '<span />' ).text( text ).css( 'whiteSpace', 'nowrap' ); |
11 | 14 | $(this).empty().append( $text ); |
12 | | - if ( $text.outerWidth() > $(this).outerWidth() ) { |
13 | | - var i = text.length; |
14 | | - while ( $text.outerWidth() > $(this).outerWidth() && i > 0 ) { |
15 | | - $text.text( text.substr( 0, i ) + '...' ); |
16 | | - i--; |
| 15 | + if ( $text.outerWidth() > $(this).innerWidth() ) { |
| 16 | + switch ( options.position ) { |
| 17 | + case 'right': |
| 18 | + var l = text.length; |
| 19 | + while ( $text.outerWidth() > $(this).innerWidth() && l > 0 ) { |
| 20 | + $text.text( text.substr( 0, l ) + '...' ); |
| 21 | + l--; |
| 22 | + } |
| 23 | + break; |
| 24 | + case 'center': |
| 25 | + var i = [Math.round( text.length / 2 ), Math.round( text.length / 2 )]; |
| 26 | + var side = 1; // Begin with making the end shorter |
| 27 | + while ( $text.outerWidth() > ( $(this).innerWidth() ) && i[0] > 0 ) { |
| 28 | + $text.text( text.substr( 0, i[0] ) + '...' + text.substr( i[1] ) ); |
| 29 | + // Alternate between trimming the end and begining |
| 30 | + if ( side == 0 ) { |
| 31 | + // Make the begining shorter |
| 32 | + i[0]--; |
| 33 | + side = 1; |
| 34 | + } else { |
| 35 | + // Make the end shorter |
| 36 | + i[1]++; |
| 37 | + side = 0; |
| 38 | + } |
| 39 | + } |
| 40 | + break; |
| 41 | + case 'left': |
| 42 | + var r = 0; |
| 43 | + while ( $text.outerWidth() > $(this).innerWidth() && r < text.length ) { |
| 44 | + $text.text( '...' + text.substr( r ) ); |
| 45 | + r++; |
| 46 | + } |
| 47 | + break; |
17 | 48 | } |
18 | 49 | } |
19 | 50 | } ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.suggestions.js |
— | — | @@ -119,6 +119,15 @@ |
120 | 120 | } else { |
121 | 121 | // Rebuild the suggestions list |
122 | 122 | context.data.$container.show(); |
| 123 | + // Update the size and position of the list |
| 124 | + context.data.$container.css( { |
| 125 | + 'top': context.config.$region.offset().top + context.config.$region.outerHeight(), |
| 126 | + 'bottom': 'auto', |
| 127 | + 'width': context.config.$region.outerWidth(), |
| 128 | + 'height': 'auto', |
| 129 | + 'left': context.config.$region.offset().left, |
| 130 | + 'right': 'auto' |
| 131 | + } ); |
123 | 132 | var $results = context.data.$container.children( '.suggestions-results' ); |
124 | 133 | $results.empty(); |
125 | 134 | for ( var i = 0; i < context.config.suggestions.length; i++ ) { |
— | — | @@ -131,19 +140,9 @@ |
132 | 141 | if ( typeof context.config.result.render == 'function' ) { |
133 | 142 | context.config.result.render.call( $result, context.config.suggestions[i] ); |
134 | 143 | } else { |
135 | | - $result.text( context.config.suggestions[i] ); |
136 | | - $result.autoEllipse(); |
| 144 | + $result.text( context.config.suggestions[i] ).autoEllipse(); |
137 | 145 | } |
138 | 146 | } |
139 | | - // Update the size and position of the list |
140 | | - context.data.$container.css( { |
141 | | - 'top': context.config.$region.offset().top + context.config.$region.outerHeight(), |
142 | | - 'bottom': 'auto', |
143 | | - 'width': context.config.$region.outerWidth(), |
144 | | - 'height': 'auto', |
145 | | - 'left': context.config.$region.offset().left, |
146 | | - 'right': 'auto' |
147 | | - } ); |
148 | 147 | } |
149 | 148 | } |
150 | 149 | break; |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -81,16 +81,47 @@ |
82 | 82 | */ |
83 | 83 | ( function( $ ) { |
84 | 84 | |
85 | | -$.fn.autoEllipse = function() { |
| 85 | +$.fn.autoEllipse = function( options ) { |
86 | 86 | $(this).each( function() { |
| 87 | + options = $.extend( { |
| 88 | + 'position': 'center' |
| 89 | + }, options ); |
87 | 90 | var text = $(this).text(); |
88 | 91 | var $text = $( '<span />' ).text( text ).css( 'whiteSpace', 'nowrap' ); |
89 | 92 | $(this).empty().append( $text ); |
90 | | - if ( $text.outerWidth() > $(this).outerWidth() ) { |
91 | | - var i = text.length; |
92 | | - while ( $text.outerWidth() > $(this).outerWidth() && i > 0 ) { |
93 | | - $text.text( text.substr( 0, i ) + '...' ); |
94 | | - i--; |
| 93 | + if ( $text.outerWidth() > $(this).innerWidth() ) { |
| 94 | + switch ( options.position ) { |
| 95 | + case 'right': |
| 96 | + var l = text.length; |
| 97 | + while ( $text.outerWidth() > $(this).innerWidth() && l > 0 ) { |
| 98 | + $text.text( text.substr( 0, l ) + '...' ); |
| 99 | + l--; |
| 100 | + } |
| 101 | + break; |
| 102 | + case 'center': |
| 103 | + var i = [Math.round( text.length / 2 ), Math.round( text.length / 2 )]; |
| 104 | + var side = 1; // Begin with making the end shorter |
| 105 | + while ( $text.outerWidth() > ( $(this).innerWidth() ) && i[0] > 0 ) { |
| 106 | + $text.text( text.substr( 0, i[0] ) + '...' + text.substr( i[1] ) ); |
| 107 | + // Alternate between trimming the end and begining |
| 108 | + if ( side == 0 ) { |
| 109 | + // Make the begining shorter |
| 110 | + i[0]--; |
| 111 | + side = 1; |
| 112 | + } else { |
| 113 | + // Make the end shorter |
| 114 | + i[1]++; |
| 115 | + side = 0; |
| 116 | + } |
| 117 | + } |
| 118 | + break; |
| 119 | + case 'left': |
| 120 | + var r = 0; |
| 121 | + while ( $text.outerWidth() > $(this).innerWidth() && r < text.length ) { |
| 122 | + $text.text( '...' + text.substr( r ) ); |
| 123 | + r++; |
| 124 | + } |
| 125 | + break; |
95 | 126 | } |
96 | 127 | } |
97 | 128 | } ); |
— | — | @@ -484,6 +515,15 @@ |
485 | 516 | } else { |
486 | 517 | // Rebuild the suggestions list |
487 | 518 | context.data.$container.show(); |
| 519 | + // Update the size and position of the list |
| 520 | + context.data.$container.css( { |
| 521 | + 'top': context.config.$region.offset().top + context.config.$region.outerHeight(), |
| 522 | + 'bottom': 'auto', |
| 523 | + 'width': context.config.$region.outerWidth(), |
| 524 | + 'height': 'auto', |
| 525 | + 'left': context.config.$region.offset().left, |
| 526 | + 'right': 'auto' |
| 527 | + } ); |
488 | 528 | var $results = context.data.$container.children( '.suggestions-results' ); |
489 | 529 | $results.empty(); |
490 | 530 | for ( var i = 0; i < context.config.suggestions.length; i++ ) { |
— | — | @@ -496,19 +536,9 @@ |
497 | 537 | if ( typeof context.config.result.render == 'function' ) { |
498 | 538 | context.config.result.render.call( $result, context.config.suggestions[i] ); |
499 | 539 | } else { |
500 | | - $result.text( context.config.suggestions[i] ); |
501 | | - $result.autoEllipse(); |
| 540 | + $result.text( context.config.suggestions[i] ).autoEllipse(); |
502 | 541 | } |
503 | 542 | } |
504 | | - // Update the size and position of the list |
505 | | - context.data.$container.css( { |
506 | | - 'top': context.config.$region.offset().top + context.config.$region.outerHeight(), |
507 | | - 'bottom': 'auto', |
508 | | - 'width': context.config.$region.outerWidth(), |
509 | | - 'height': 'auto', |
510 | | - 'left': context.config.$region.offset().left, |
511 | | - 'right': 'auto' |
512 | | - } ); |
513 | 543 | } |
514 | 544 | } |
515 | 545 | break; |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -11,7 +11,10 @@ |
12 | 12 | {var i=0,l=array.length,loop=opts.loop||function(){};$.whileAsync($.extend(opts,{test:function(){return i<l;},loop:function() |
13 | 13 | {var val=array[i];return loop.call(val,i++,val);}}));} |
14 | 14 | $.fn.eachAsync=function(opts) |
15 | | -{$.eachAsync(this,opts);return this;}})(jQuery);(function($){$.fn.autoEllipse=function(){$(this).each(function(){var text=$(this).text();var $text=$('<span />').text(text).css('whiteSpace','nowrap');$(this).empty().append($text);if($text.outerWidth()>$(this).outerWidth()){var i=text.length;while($text.outerWidth()>$(this).outerWidth()&&i>0){$text.text(text.substr(0,i)+'...');i--;}}});};})(jQuery);(function($){$.browserTest=function(a,z){var u='unknown',x='X',m=function(r,h){for(var i=0;i<h.length;i=i+1){r=r.replace(h[i][0],h[i][1]);} |
| 15 | +{$.eachAsync(this,opts);return this;}})(jQuery);(function($){$.fn.autoEllipse=function(options){$(this).each(function(){options=$.extend({'position':'center'},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=text.length;while($text.outerWidth()>$(this).innerWidth()&&l>0){$text.text(text.substr(0,l)+'...');l--;} |
| 16 | +break;case'center':var i=[Math.round(text.length/2),Math.round(text.length/2)];var side=1;while($text.outerWidth()>($(this).innerWidth())&&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;}} |
| 17 | +break;case'left':var r=0;while($text.outerWidth()>$(this).innerWidth()&&r<text.length){$text.text('...'+text.substr(r));r++;} |
| 18 | +break;}}});};})(jQuery);(function($){$.browserTest=function(a,z){var u='unknown',x='X',m=function(r,h){for(var i=0;i<h.length;i=i+1){r=r.replace(h[i][0],h[i][1]);} |
16 | 19 | return r;},c=function(i,a,b,c){var r={name:m((a.exec(i)||[u,u])[1],b)};r[r.name]=true;r.version=(c.exec(i)||[x,x,x,x])[3];if(r.name.match(/safari/)&&r.version>400){r.version='2.0';} |
17 | 20 | if(r.name==='presto'){r.version=($.browser.version>9.27)?'futhark':'linear_b';} |
18 | 21 | r.versionNumber=parseFloat(r.version,10)||0;r.versionX=(r.version!==x)?(r.version+'').substr(0,1):x;r.className=r.name+r.versionX;return r;};a=(a.match(/Opera|Navigator|Minefield|KHTML|Chrome/)?m(a,[[/(Firefox|MSIE|KHTML,\slike\sGecko|Konqueror)/,''],['Chrome Safari','Chrome'],['KHTML','Konqueror'],['Minefield','Firefox'],['Navigator','Netscape']]):a).toLowerCase();$.browser=$.extend((!z)?$.browser:{},c(a,/(camino|chrome|firefox|netscape|konqueror|lynx|msie|opera|safari)/,[],/(camino|chrome|firefox|netscape|netscape6|opera|version|konqueror|lynx|msie|safari)(\/|\s)([a-z0-9\.\+]*?)(\;|dev|rel|\s|$)/));$.layout=c(a,/(gecko|konqueror|msie|opera|webkit)/,[['konqueror','khtml'],['msie','trident'],['opera','presto']],/(applewebkit|rv|konqueror|msie)(\:|\/|\s)([a-z0-9\.]*?)(\;|\)|\s)/);$.os={name:(/(win|mac|linux|sunos|solaris|iphone)/.exec(navigator.platform.toLowerCase())||[u])[0].replace('sunos','solaris')};if(!z){$('html').addClass([$.os.name,$.browser.name,$.browser.className,$.layout.name,$.layout.className].join(' '));}};$.browserTest(navigator.userAgent);})(jQuery);jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;} |
— | — | @@ -28,8 +31,7 @@ |
29 | 32 | 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());}}} |
30 | 33 | if(context.data.timerID!=null){clearTimeout(context.data.timerID);} |
31 | 34 | if(delayed){context.data.timerID=setTimeout(maybeFetch,context.config.delay);}else{maybeFetch();} |
32 | | -$.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.config.suggestions.length==0){context.data.$container.hide();}else{context.data.$container.show();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]).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]);$result.autoEllipse();}} |
33 | | -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'});}} |
| 35 | +$.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.config.suggestions.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]).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]).autoEllipse();}}}} |
34 | 36 | break;case'maxRows':context.config[property]=Math.max(1,Math.min(100,value));break;case'delay':context.config[property]=Math.max(0,Math.min(12000,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') |
35 | 37 | if(!result.get||selected.get(0)!=result.get(0)){if(result=='prev'){result=selected.prev();}else if(result=='next'){if(selected.size()==0) |
36 | 38 | result=context.data.$container.find('.suggestions-results div:first');else{result=selected.next();if(result.size()==0) |