110 lines
3.6 KiB
JavaScript
110 lines
3.6 KiB
JavaScript
/* 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 = {
|
|
'sunrise': '',
|
|
'sun': '',
|
|
'moon': '',
|
|
'sun2': '',
|
|
'windy': '',
|
|
'wind': '',
|
|
'snowflake': '',
|
|
'cloudy': '',
|
|
'cloud': '',
|
|
'weather': '',
|
|
'weather2': '',
|
|
'weather3': '',
|
|
'lines': '',
|
|
'cloud2': '',
|
|
'lightning': '',
|
|
'lightning2': '',
|
|
'rainy': '',
|
|
'rainy2': '',
|
|
'windy2': '',
|
|
'windy3': '',
|
|
'snowy': '',
|
|
'snowy2': '',
|
|
'snowy3': '',
|
|
'weather4': '',
|
|
'cloudy2': '',
|
|
'cloud3': '',
|
|
'lightning3': '',
|
|
'sun3': '',
|
|
'moon2': '',
|
|
'cloudy3': '',
|
|
'cloud4': '',
|
|
'cloud5': '',
|
|
'lightning4': '',
|
|
'rainy3': '',
|
|
'rainy4': '',
|
|
'windy4': '',
|
|
'windy5': '',
|
|
'snowy4': '',
|
|
'snowy5': '',
|
|
'weather5': '',
|
|
'cloudy4': '',
|
|
'lightning5': '',
|
|
'thermometer': '',
|
|
'compass': '',
|
|
'none': '',
|
|
'celsius': '',
|
|
'fahrenheit': '',
|
|
'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 (/icomoon-liga/.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();
|
|
}
|
|
}());
|