Files
Umbraco-CMS/src/Umbraco.Web.UI.Client/src/common/directives/components/application/sectionicon.directive.js
2016-02-28 17:40:58 +01:00

30 lines
1.1 KiB
JavaScript

angular.module("umbraco.directives")
.directive('sectionIcon', function ($compile, iconHelper) {
return {
restrict: 'E',
replace: true,
link: function (scope, element, attrs) {
var icon = attrs.icon;
if (iconHelper.isLegacyIcon(icon)) {
//its a known legacy icon, convert to a new one
element.html("<i class='" + iconHelper.convertFromLegacyIcon(icon) + "'></i>");
}
else if (iconHelper.isFileBasedIcon(icon)) {
var convert = iconHelper.convertFromLegacyImage(icon);
if(convert){
element.html("<i class='icon-section " + convert + "'></i>");
}else{
element.html("<img class='icon-section' src='images/tray/" + icon + "'>");
}
//it's a file, normally legacy so look in the icon tray images
}
else {
//it's normal
element.html("<i class='icon-section " + icon + "'></i>");
}
}
};
});