Skip to content

Instantly share code, notes, and snippets.

@sarat246
Forked from Thibaut-B/font-ie.js
Created May 7, 2013 09:37
Show Gist options
  • Select an option

  • Save sarat246/5531442 to your computer and use it in GitHub Desktop.

Select an option

Save sarat246/5531442 to your computer and use it in GitHub Desktop.
window.onload = function() {
function addIcon(el, entity) {
var html = el.innerHTML;
el.innerHTML = '<span style="font-family: \'fontName\'">' + entity + '</span>' + html;
}
var icons = {
'icon-newspaper' : '&#xe000;',
'icon-play' : '&#xe001;',
'icon-film' : '&#xe002;'
},
els = document.getElementsByTagName('*'),
i, attr, html, c, el;
for (i = 0; ; i += 1) {
el = els[i];
if(!el) {
break;
}
attr = el.getAttribute('data-icon');
if (attr) {
addIcon(el, attr);
}
c = el.className;
c = c.match(/icon-[^\s'"]+/);
if (c && icons[c[0]]) {
addIcon(el, icons[c[0]]);
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment