PageSourceSearch

https://softtennis-navi.com/softtennis-navi/wp-content/themes/gens…/jquery.textOverflowEllipsis.js?ver=2.1.6

js softtennis-navi.com collected 2026-09-24 12:50:10 UTC 2,412 bytes, 93 lines download raw bytes

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.