1/* 2http://dev.classmethod.jp/ria/string-replace-css-and-jquery/ 3ãã«ã¹ã¿ãã¤ãºå©ç¨ 4*/ 5 6(function($) { 7 $.fn.textOverflowEllipsis = function(config) { 8 var defaults = { 9 resize: true, 10 numOfCharactersToReduce : 1, 11 suffix: 'â¦' 12 }; 13 14 var options = $.extend(defaults, config); 15 16 var elems = this; 17 18 var TextOverflowEllipsis = { 19 init : function($target) { 20 if ($target.css('overflow') != 'hidden') { 21 $target.css('overflow', 'hidden'); 22 } 23 24 // ãªãªã¸ãã«ã®æç« ãåå¾ã»ä¿æãã 25 var html = $target.attr('data-original'); 26 if (! html) { 27 html = $target.html(); 28 $target.attr('data-original', html); 29 } 30 31 }, 32 execute : function($target) { 33 var html = $target.attr('data-original'); 34 35 // 対象ã®è¦ç´ ããé«ãã«autoãæå®ãé表示ã§è¤è£½ãã 36 var $clone = $target.clone(); 37 $clone 38 .html(html) 39 .css({ 40 display : 'none', 41 position : 'absolute', 42 overflow : 'visible', 43 maxHeight : 'none' 44 }) 45 .width($target.width()) 46 .height('auto'); 47 48 // è¤è£½ããè¦ç´ ã䏿¦è¿½å 49 $target.after($clone); 50 51 // æå®ããé«ãã«ãªãã¾ã§ã1æåãã¤æ¶å»ãã¦ãã 52 while((html.length > 0) && ($clone.height() > $target.height())) { 53 html = html.substr(0, html.length - options.numOfCharactersToReduce); 54 $clone.html(html + options.suffix); 55 } 56 57 // æç« ãå ¥ãæ¿ãã¦ãè¤è£½ããè¦ç´ ãåé¤ãã 58 $target.html($clone.html()); 59 $clone.remove(); 60 }, 61 }; 62 63 // ã¦ã£ã³ãã¦ãªãµã¤ãºã«è¿½å¾ãã 64 if (options.resize) { 65 var timerId = null; 66 var windowWidth = $(window).width(); 67 68 $(window).resize(function() { 69 if (timerId) { 70 clearTimeout(timerId); 71 } 72 73 if (windowWidth == $(window).width()) { 74 return; 75 } 76 77 timerId = setTimeout(function() { 78 elems.each(function(index) { 79 TextOverflowEllipsis.execute($(this)); 80 }); 81 }, 100); 82 }); 83 } 84 85 return this.each(function(index) { 86 var $target = $(this); 87 88 TextOverflowEllipsis.init($target); 89 90 TextOverflowEllipsis.execute($target); 91 }); 92 }; 93})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.