-
Notifications
You must be signed in to change notification settings - Fork 2
/
liga.js
100 lines (99 loc) · 3.24 KB
/
liga.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/* A polyfill for browsers that don't support ligatures. */
/* The script tag referring to this file must be placed before the ending body tag. */
/* To provide support for elements dynamically added, this script adds
method 'icomoonLiga' to the window object. You can pass element references to this method.
*/
(function () {
'use strict';
function supportsProperty(p) {
var prefixes = ['Webkit', 'Moz', 'O', 'ms'],
i,
div = document.createElement('div'),
ret = p in div.style;
if (!ret) {
p = p.charAt(0).toUpperCase() + p.substr(1);
for (i = 0; i < prefixes.length; i += 1) {
ret = prefixes[i] + p in div.style;
if (ret) {
break;
}
}
}
return ret;
}
var icons;
if (!supportsProperty('fontFeatureSettings')) {
icons = {
'hash': '',
'number': '',
'diff': '',
'watch': '',
'single-window': '',
'dual-window': '',
'cross-team-search': '',
'presentation': '',
'clipboard': '',
'ellipsis': '',
'copy': '',
'medicine': '',
'piyo': '',
'lgtm': '',
'egg': '',
'wip': '',
'esa': '',
'tori': '',
'toriatama': '',
'torihome': '',
'nena': '',
'kusonemi': '',
'suya': '',
'fish': '',
'sakana': '',
'iwashi': '',
'fishbone': '',
'shachihoko': '',
'shrimp': '',
'ebi': '',
'hone': '',
'bone': '',
'mola': '',
'footprint': '',
'inu': '',
'niku': '',
'meat': '',
'pplog': '',
'0': 0
};
delete icons['0'];
window.icomoonLiga = function (els) {
var classes,
el,
i,
innerHTML,
key;
els = els || document.getElementsByTagName('*');
if (!els.length) {
els = [els];
}
for (i = 0; ; i += 1) {
el = els[i];
if (!el) {
break;
}
classes = el.className;
if (/icon-/.test(classes)) {
innerHTML = el.innerHTML;
if (innerHTML && innerHTML.length > 1) {
for (key in icons) {
if (icons.hasOwnProperty(key)) {
innerHTML = innerHTML.replace(new RegExp(key, 'g'), icons[key]);
}
}
el.innerHTML = innerHTML;
}
}
}
};
window.icomoonLiga();
}
}());