'use strict'; /** * Licensed Materials - Property of IBM * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2016, 2019 * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ define(['../../lib/@waca/dashboard-common/dist/core/Model', '../../util/ColorUtils', 'jquery'], function (Model, ColorUtils, $) { 'use strict'; /** * Model which represents a single color in a conditional format */ var ConditionalStyle = Model.extend({ whitelistAttrs: ['value'], init: function init() /* options */{ ConditionalStyle.inherited('init', this, arguments); }, getValue: function getValue() { return this.value; }, setValue: function setValue(value, options) { this.set({ value: value }, options); }, getColor: function getColor() { return this.color; }, setColor: function setColor(color) { this.color = color; if (!this.color && this.bgcolor) { this.color = ColorUtils.invertColor(this.bgcolor); } }, getBackgroundColor: function getBackgroundColor() { return this.bgcolor; }, setBackgroundColor: function setBackgroundColor(bgcolor) { this.bgcolor = bgcolor; }, getPattern: function getPattern() { return this.pattern; }, setPattern: function setPattern(pattern) { if (pattern && pattern.indexOf(',') > -1) { var parts = pattern.split(', '); this.pattern = parts[0]; this.patternSize = parts[1]; } else { this.pattern = pattern; } }, applyStyle: function applyStyle(element) { $(element).css('color', this.color); if (this.pattern) { $(element).css('background-image', 'url(dashboard-core/images/patterns/' + this.pattern + '.svg)'); $(element).css('background-repeat', 'repeat'); $(element).css('text-shadow', '2px 2px 2px ' + this.bgcolor + ', 2px -2px 2px' + this.bgcolor + ', 2px 0px 2px' + this.bgcolor + ',-2px 2px 2px' + this.bgcolor + ',-2px -2px 2px' + this.bgcolor + ',-2px 0px 2px' + this.bgcolor + ', 0px 2px 2px' + this.bgcolor + ', 0px -2px 2px' + this.bgcolor + ', 0px 0px 2px' + this.bgcolor); if (this.patternSize) { $(element).css('background-size', this.patternSize); } } else { $(element).css('background-color', this.bgcolor); } }, //TODO: once the new grid is on, we should remove the applyStyle function getStyle: function getStyle() { var style = { 'color': this.color }; if (this.pattern) { style['background-image'] = 'url(dashboard-core/images/patterns/' + this.pattern + '.svg)'; style['background-repeat'] = 'repeat'; style['text-shadow'] = '2px 2px 2px ' + this.bgcolor + ', 2px -2px 2px' + this.bgcolor + ', 2px 0px 2px' + this.bgcolor + ',-2px 2px 2px' + this.bgcolor + ',-2px -2px 2px' + this.bgcolor + ',-2px 0px 2px' + this.bgcolor + ', 0px 2px 2px' + this.bgcolor + ', 0px -2px 2px' + this.bgcolor + ', 0px 0px 2px' + this.bgcolor; if (this.patternSize) { style['background-size'] = this.patternSize; } } else { style['background-color'] = this.bgcolor; } return style; }, clearStyle: function clearStyle() { this.setBackgroundColor(''); this.setPattern(''); this.setColor(''); } }); ConditionalStyle.clearStyleFromElement = function (element) { $(element).css({ 'background-color': '', 'background-image': '', 'background-repeat': '', 'background-size': '', 'color': '', 'text-shadow': '' }); }; return ConditionalStyle; }); //# sourceMappingURL=ConditionalStyle.js.map