defineIcon method
This commit is contained in:
@@ -31,7 +31,7 @@ function iconHelper($http, $q, $sce, $timeout, umbRequestHelper) {
|
||||
{ oldIcon: ".sprToPublish", newIcon: "mail-forward" },
|
||||
{ oldIcon: ".sprTranslate", newIcon: "comments" },
|
||||
{ oldIcon: ".sprUpdate", newIcon: "save" },
|
||||
|
||||
|
||||
{ oldIcon: ".sprTreeSettingDomain", newIcon: "icon-home" },
|
||||
{ oldIcon: ".sprTreeDoc", newIcon: "icon-document" },
|
||||
{ oldIcon: ".sprTreeDoc2", newIcon: "icon-diploma-alt" },
|
||||
@@ -39,21 +39,21 @@ function iconHelper($http, $q, $sce, $timeout, umbRequestHelper) {
|
||||
{ oldIcon: ".sprTreeDoc4", newIcon: "icon-newspaper-alt" },
|
||||
{ oldIcon: ".sprTreeDoc5", newIcon: "icon-notepad-alt" },
|
||||
|
||||
{ oldIcon: ".sprTreeDocPic", newIcon: "icon-picture" },
|
||||
{ oldIcon: ".sprTreeDocPic", newIcon: "icon-picture" },
|
||||
{ oldIcon: ".sprTreeFolder", newIcon: "icon-folder" },
|
||||
{ oldIcon: ".sprTreeFolder_o", newIcon: "icon-folder" },
|
||||
{ oldIcon: ".sprTreeMediaFile", newIcon: "icon-music" },
|
||||
{ oldIcon: ".sprTreeMediaMovie", newIcon: "icon-movie" },
|
||||
{ oldIcon: ".sprTreeMediaPhoto", newIcon: "icon-picture" },
|
||||
|
||||
|
||||
{ oldIcon: ".sprTreeMember", newIcon: "icon-user" },
|
||||
{ oldIcon: ".sprTreeMemberGroup", newIcon: "icon-users" },
|
||||
{ oldIcon: ".sprTreeMemberType", newIcon: "icon-users" },
|
||||
|
||||
|
||||
{ oldIcon: ".sprTreeNewsletter", newIcon: "icon-file-text-alt" },
|
||||
{ oldIcon: ".sprTreePackage", newIcon: "icon-box" },
|
||||
{ oldIcon: ".sprTreeRepository", newIcon: "icon-server-alt" },
|
||||
|
||||
|
||||
{ oldIcon: ".sprTreeSettingDataType", newIcon: "icon-autofill" },
|
||||
|
||||
// TODO: Something needs to be done with the old tree icons that are commented out.
|
||||
@@ -61,7 +61,7 @@ function iconHelper($http, $q, $sce, $timeout, umbRequestHelper) {
|
||||
{ oldIcon: ".sprTreeSettingAgent", newIcon: "" },
|
||||
{ oldIcon: ".sprTreeSettingCss", newIcon: "" },
|
||||
{ oldIcon: ".sprTreeSettingCssItem", newIcon: "" },
|
||||
|
||||
|
||||
{ oldIcon: ".sprTreeSettingDataTypeChild", newIcon: "" },
|
||||
{ oldIcon: ".sprTreeSettingDomain", newIcon: "" },
|
||||
{ oldIcon: ".sprTreeSettingLanguage", newIcon: "" },
|
||||
@@ -94,9 +94,9 @@ function iconHelper($http, $q, $sce, $timeout, umbRequestHelper) {
|
||||
var iconCache = [];
|
||||
var liveRequests = [];
|
||||
var allIconsRequested = false;
|
||||
|
||||
|
||||
return {
|
||||
|
||||
|
||||
/** Used by the create dialogs for content/media types to format the data so that the thumbnails are styled properly */
|
||||
formatContentTypeThumbnails: function (contentTypes) {
|
||||
for (var i = 0; i < contentTypes.length; i++) {
|
||||
@@ -209,15 +209,11 @@ function iconHelper($http, $q, $sce, $timeout, umbRequestHelper) {
|
||||
,'Failed to retrieve icon: ' + iconName)
|
||||
.then(icon => {
|
||||
if(icon) {
|
||||
var trustedIcon = {
|
||||
name: icon.Name,
|
||||
svgString: $sce.trustAsHtml(icon.SvgString)
|
||||
};
|
||||
this._cacheIcon(trustedIcon);
|
||||
var trustedIcon = this.defineIcon(icon.name, icon.SvgString);
|
||||
|
||||
liveRequests = _.filter(liveRequests, iconRequestPath);
|
||||
liveRequests = _.filter(liveRequests, iconRequestPath);
|
||||
|
||||
resolve(trustedIcon);
|
||||
resolve(trustedIcon);
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
@@ -240,15 +236,10 @@ function iconHelper($http, $q, $sce, $timeout, umbRequestHelper) {
|
||||
,'Failed to retrieve icons')
|
||||
.then(icons => {
|
||||
icons.forEach(icon => {
|
||||
var trustedIcon = {
|
||||
name: icon.Name,
|
||||
svgString: $sce.trustAsHtml(icon.SvgString)
|
||||
};
|
||||
|
||||
this._cacheIcon(trustedIcon);
|
||||
this.defineIcon(icon.Name, icon.SvgString);
|
||||
});
|
||||
|
||||
resolve(iconCache);
|
||||
resolve(iconCache);
|
||||
})
|
||||
.catch(err => {
|
||||
console.warn(err);
|
||||
@@ -278,7 +269,7 @@ function iconHelper($http, $q, $sce, $timeout, umbRequestHelper) {
|
||||
console.warn("Can't read the css rules of: " + document.styleSheets[i].href, e);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (classes !== null) {
|
||||
for(var x=0;x<classes.length;x++) {
|
||||
var cur = classes[x];
|
||||
@@ -312,11 +303,17 @@ function iconHelper($http, $q, $sce, $timeout, umbRequestHelper) {
|
||||
return deferred.promise;
|
||||
},
|
||||
|
||||
/** A simple cache to ensure that the icon is only requested from the server if is isn't already in memory */
|
||||
_cacheIcon: function(icon) {
|
||||
if(_.find(iconCache, {name: icon.name}) === undefined) {
|
||||
iconCache = _.union(iconCache, [icon]);
|
||||
}
|
||||
/** Creates a icon object, and caches it in a runtime cache */
|
||||
defineIcon: function(name, svg) {
|
||||
var icon = iconCache.find(x => x.name === name);
|
||||
if(icon === undefined) {
|
||||
icon = {
|
||||
name: name,
|
||||
svgString: $sce.trustAsHtml(svg)
|
||||
};
|
||||
iconCache.push(icon);
|
||||
}
|
||||
return icon;
|
||||
},
|
||||
|
||||
/** Returns the cached icon or undefined */
|
||||
|
||||
Reference in New Issue
Block a user