Skip to content
This repository has been archived by the owner on Nov 4, 2023. It is now read-only.

Commit

Permalink
fix: don't cache icon background (#471)
Browse files Browse the repository at this point in the history
fixes #425
  • Loading branch information
akloeckner authored Oct 12, 2020
1 parent f6a0911 commit f9ea1ef
Showing 1 changed file with 8 additions and 27 deletions.
35 changes: 8 additions & 27 deletions scripts/controllers/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,34 +440,15 @@ App.controller('Main', function ($scope, $timeout, $location, Api) {
};

$scope.itemBgStyles = function (item, entity) {
const obj = entity.attributes || entity;
const bg = getItemFieldValue('bg', item, entity);
const bgSuffix = getItemFieldValue('bgSuffix', item, entity);
const opacity = getItemFieldValue('bgOpacity', item, entity);

if (!obj.bgStyles) {
let bg;
const styles = {};

if ('bgOpacity' in item) {
styles.opacity = parseFieldValue(item.bgOpacity, item, entity);
}

if (item.bg) {
bg = parseFieldValue(item.bg, item, entity);

if (bg) {
styles.backgroundImage = 'url(' + bg + ')';
}
} else if (item.bgSuffix) {
bg = parseFieldValue(item.bgSuffix, item, entity);

if (bg) {
styles.backgroundImage = 'url("' + toAbsoluteServerURL(bg) + '")';
}
}

obj.bgStyles = styles;
}

return obj.bgStyles;
return {
opacity: opacity || null,
backgroundImage: bg ? `url("${bg}")`
: bgSuffix ? `url("${toAbsoluteServerURL(bgSuffix)}")` : null,
};
};

$scope.itemClasses = function (item) {
Expand Down

0 comments on commit f9ea1ef

Please sign in to comment.