X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=resources%2Fsrc%2Fjquery%2Fjquery.autoEllipsis.js;h=e1115d6504c4ea7919142643dfe73f8efe814809;hb=ee734d0d3c7533bd9a690dbd71f5151da55c32ad;hp=9a196b5dbc51c65a0a04cdaa4e7634be7702f318;hpb=27eafef2947051a2d5d2ee024e0c23f518b786be;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/jquery/jquery.autoEllipsis.js b/resources/src/jquery/jquery.autoEllipsis.js index 9a196b5dbc..e1115d6504 100644 --- a/resources/src/jquery/jquery.autoEllipsis.js +++ b/resources/src/jquery/jquery.autoEllipsis.js @@ -69,16 +69,16 @@ $.fn.autoEllipsis = function ( options ) { // Try cache if ( options.matchText ) { if ( !( text in matchTextCache ) ) { - matchTextCache[text] = {}; + matchTextCache[ text ] = {}; } - if ( !( options.matchText in matchTextCache[text] ) ) { - matchTextCache[text][options.matchText] = {}; + if ( !( options.matchText in matchTextCache[ text ] ) ) { + matchTextCache[ text ][ options.matchText ] = {}; } - if ( !( w in matchTextCache[text][options.matchText] ) ) { - matchTextCache[text][options.matchText][w] = {}; + if ( !( w in matchTextCache[ text ][ options.matchText ] ) ) { + matchTextCache[ text ][ options.matchText ][ w ] = {}; } - if ( options.position in matchTextCache[text][options.matchText][w] ) { - $container.html( matchTextCache[text][options.matchText][w][options.position] ); + if ( options.position in matchTextCache[ text ][ options.matchText ][ w ] ) { + $container.html( matchTextCache[ text ][ options.matchText ][ w ][ options.position ] ); if ( options.tooltip ) { $container.attr( 'title', text ); } @@ -86,13 +86,13 @@ $.fn.autoEllipsis = function ( options ) { } } else { if ( !( text in cache ) ) { - cache[text] = {}; + cache[ text ] = {}; } - if ( !( w in cache[text] ) ) { - cache[text][w] = {}; + if ( !( w in cache[ text ] ) ) { + cache[ text ][ w ] = {}; } - if ( options.position in cache[text][w] ) { - $container.html( cache[text][w][options.position] ); + if ( options.position in cache[ text ][ w ] ) { + $container.html( cache[ text ][ w ][ options.position ] ); if ( options.tooltip ) { $container.attr( 'title', text ); } @@ -120,19 +120,19 @@ $.fn.autoEllipsis = function ( options ) { break; case 'center': // TODO: Use binary search like for 'right' - i = [Math.round( trimmableText.length / 2 ), Math.round( trimmableText.length / 2 )]; + i = [ Math.round( trimmableText.length / 2 ), Math.round( trimmableText.length / 2 ) ]; // Begin with making the end shorter side = 1; - while ( $trimmableText.outerWidth() + pw > w && i[0] > 0 ) { - $trimmableText.text( trimmableText.slice( 0, i[0] ) + '...' + trimmableText.slice( i[1] ) ); + while ( $trimmableText.outerWidth() + pw > w && i[ 0 ] > 0 ) { + $trimmableText.text( trimmableText.slice( 0, i[ 0 ] ) + '...' + trimmableText.slice( i[ 1 ] ) ); // Alternate between trimming the end and begining if ( side === 0 ) { // Make the begining shorter - i[0]--; + i[ 0 ]--; side = 1; } else { // Make the end shorter - i[1]++; + i[ 1 ]++; side = 0; } } @@ -152,9 +152,9 @@ $.fn.autoEllipsis = function ( options ) { } if ( options.matchText ) { $container.highlightText( options.matchText ); - matchTextCache[text][options.matchText][w][options.position] = $container.html(); + matchTextCache[ text ][ options.matchText ][ w ][ options.position ] = $container.html(); } else { - cache[text][w][options.position] = $container.html(); + cache[ text ][ w ][ options.position ] = $container.html(); } } );