From 17f2602ca263b9994bc6f6f44525a896f3db1d8c Mon Sep 17 00:00:00 2001 From: perploug Date: Wed, 2 Oct 2013 10:56:40 +0200 Subject: [PATCH] icon finder now loads .icon-* from all registered stylesheets --- .../src/common/services/util.service.js | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/services/util.service.js b/src/Umbraco.Web.UI.Client/src/common/services/util.service.js index cec4630f28..43520d8cca 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/util.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/util.service.js @@ -418,7 +418,7 @@ function iconHelper($q) { }, /** Return a list of icons, optionally filter them */ - /** It fetches them directly from the active stylesheet in the browser */ + /** It fetches them directly from the active stylesheets in the browser */ getIcons: function(filter){ var deferred = $q.defer(); @@ -426,22 +426,32 @@ function iconHelper($q) { deferred.resolve(collectedIcons); } - var classes = document.styleSheets[0].rules || document.styleSheets[0].cssRules; collectedIcons = []; var f = filter || ""; var c = ".icon-" + f; + for (var i = document.styleSheets.length - 1; i >= 0; i--) { + var classes = document.styleSheets[i].rules || document.styleSheets[i].cssRules; + + for(var x=0;x0){ + s = s.substring(0, hasSpace); + } + var hasPseudo = s.indexOf(":"); + if(hasPseudo>0){ + s = s.substring(0, hasPseudo); + } - for(var x=0;x 0 && cur.selectorText.indexOf(",") < 0) { - var s = cur.selectorText; - s = cur.selectorText.substring(1, s.indexOf(":")); - - if(collectedIcons.indexOf(s) < 0){ - collectedIcons.push(s); + if(collectedIcons.indexOf(s) < 0){ + collectedIcons.push(s); + } } } } + deferred.resolve(collectedIcons); return deferred.promise; },