PageSourceSearch

https://www.jun.co.jp/assets/js/jquery.kerning.js

js jun.co.jp collected 2026-09-25 23:53:58 UTC 5,389 bytes, 178 lines download raw bytes

1/*! kerning - v0.3.1 - 2014-12-13
2* http://karappoinc.github.io/jquery.kerning.js/
3* Copyright (c) 2014 Karappo Inc.; Licensed MIT */
4(function($) {
5  $(document).on('ready', function() {
6    return $(document).find('[data-kerning]').each(function() {
7      var opts, txt;
8      txt = $(this).data('kerning');
9      opts = null;
10      if (txt) {
11        if (0 <= txt.indexOf('{')) {
12          opts = $.kerning.parseJSON(txt);
13        } else {
14          opts = txt;
15        }
16        return $(this).kerning(opts, $(this).data('kerning-extend'));
17      } else {
18        return $(this).kerning();
19      }
20    });
21  });
22  $.kerning = {};
23  $.kerning.defaults = {
24    removeTags: false,
25    removeAnchorTags: false,
26    data: {
27      kerning: {
28        "、": [0, -0.4],
29        "。": [0, -0.4],
30        "(": [-0.4, 0],
31        ")": [0, -0.4],
32        "〔": [-0.4, 0],
33        "〕": [0, -0.4],
34        "ï¼»": [-0.4, 0],
35        "ï¼½": [0, -0.4],
36        "{": [-0.4, 0],
37        "}": [0, -0.4],
38        "〈": [-0.4, 0],
39        "〉": [0, -0.4],
40        "《": [-0.4, 0],
41        "》": [0, -0.4],
42        "「": [-0.4, 0],
43        "」": [0, -0.4],
44        "『": [-0.4, 0],
45        "』": [0, -0.4],
46        "【": [-0.4, 0],
47        "】": [0, -0.4],
48        "・": [-0.22, -0.22],
49        ":": [-0.22, -0.22],
50        ";": [-0.22, -0.22],
51        "|": [-0.22, -0.22]
52      }
53    }
54  };
55  $.kerning.parseJSON = function(text) {
56    var O_o, o_O, obj;
57    obj = null;
58    try {
59      obj = JSON.parse(text);
60      return obj;
61    } catch (_error) {
62      O_o = _error;
63      console.log("jquery.kerning : [WARN] As a result of JSON.parse, a trivial problem has occurred");
64    }
65    try {
66      obj = eval("(" + text + ")");
67    } catch (_error) {
68      o_O = _error;
69      console.error("jquery.kerning : [ERROR] JSON.parse failed");
70      return null;
71    }
72    return obj;
73  };
74  return $.fn.kerning = function(config, _extend) {
75    if (_extend == null) {
76      _extend = false;
77    }
78    return this.each(function() {
79      var container, content, destroy, kdata, kern, me, options, strArray;
80      me = $(this);
81      container = me;
82      strArray = me.html();
83      content = '';
84      options = kdata = null;
85      destroy = function() {
86        var _results;
87        _results = [];
88        while (me.find('[data-kerned]').length) {
89          me.find('[data-kerned]').replaceWith(function() {
90            return this.innerHTML;
91          });
92          _results.push(strArray = me.html());
93        }
94        return _results;
95      };
96      kern = function(_config) {
97        var L, R, delimiter, i, linebreak, str, _i, _ref;
98        if (me.find('[data-kerned]').length) {
99          destroy();
100        }
101        if (_extend) {
102          options = $.extend(true, {}, $.kerning.defaults, _config);
103        } else {
104          options = $.extend({}, $.kerning.defaults, _config);
105        }
106        kdata = options.data.kerning;
107        if (options.removeAnchorTags) {
108          if ((me.children('a').length)) {
109            container = me.children('a');
110            strArray = container.html().replace(/(<([^>]+)>)/ig, "").split('');
111          } else {
112            container = me;
113            strArray = me.html().replace(/(<([^>]+)>)/ig, "").split('');
114          }
115        } else if (options.removeTags) {
116          strArray = me.html().replace(/(<([^>]+)>)/ig, "").split('');
117        } else {
118          me.find('[data-kerned]').empty();
119        }
120        delimiter = me.data('delimiter');
121        linebreak = me.data('linebreak');
122        if (delimiter !== void 0) {
123          strArray = (delimiter + strArray.join(delimiter) + delimiter).split('');
124        }
125        for (i = _i = 0, _ref = strArray.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
126          str = strArray[i];
127          L = 0;
128          R = 0;
129          if (kdata[str]) {
130            L = kdata[str][0];
131            R = kdata[str][1];
132            if (linebreak !== void 0) {
133              content += '<span style="display:inline-block;">' + linebreak + '</span>';
134            }
135            if (L !== 0 || R !== 0) {
136              content += '<span data-kerned style="display:inline-block;margin-left:' + L + 'em;margin-right:' + R + 'em;">' + str + '</span>';
137            } else {
138              content += str;
139            }
140            if (linebreak !== void 0) {
141              content += '<span style="display:inline-block;">
141' + linebreak + '</span><br>';
142            }
143          } else {
144            content += str;
145          }
146        }
147        container.html(content);
148        container.find('[data-kerned]').each(function() {
149          var _el;
150          _el = $(this);
151          if (parseInt(_el.css('text-indent'), 10) !== 0) {
152            return _el.css('text-indent', 0);
153          }
154        });
155        return me;
156      };
157      if (typeof config === 'string') {
158        if (config === 'destroy') {
159          destroy();
160          return me;
161        } else if (0 <= config.indexOf('.json')) {
162          return $.getJSON(config, function(_data) {
163            return kern({
164              data: _data
165            });
166          });
167        } else {
168          console.error('jquery.kerning : [ERROR] Invalid configure');
169          return me;
170        }
171      } else {
172        return kern(config);
173      }
174    });
175  };
176})(jQuery);
177
178//# sourceMappingURL=jquery.kerning.js.map

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.