VisPropertiesCSSProxy.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. 'use strict';
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2013, 2017
  5. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  6. *
  7. */
  8. define(['jquery', 'underscore', '../lib/@waca/core-client/js/core-client/ui/core/Class'], function ($, _, Class) {
  9. /**
  10. * Creates a new VisPropertiesCSSProxy converter object.
  11. * VisPropertiesCSSProxy is used in conjunction with a VisProperty map to convert the
  12. * stored values to css values.
  13. * It is mostly used for colors and fonts but any property with a css name designation in the
  14. * VisDefinition, or even an id which matches a css property name and a css meaning can be used.
  15. * @param {Object}
  16. * attrs Property map to mix-in
  17. * @abstract
  18. * @class
  19. */
  20. var VisPropertiesCSSProxy = Class.extend({
  21. init: function init() {
  22. _.extend(this, arguments[0]);
  23. this.styleToValue = {
  24. 'font-weight': 'bold',
  25. 'font-style': 'italic',
  26. 'text-decoration': 'underline',
  27. 'word-break': 'break-all',
  28. 'white-space': 'initial'
  29. };
  30. this.cssPropertyMap = {
  31. 'Color': 'color',
  32. 'FontSize': 'font-size',
  33. 'FontFace': 'font-family',
  34. 'FontBold': 'font-weight',
  35. 'FontItalic': 'font-style',
  36. 'FontUnderline': 'text-decoration',
  37. 'FontAlign': 'text-align',
  38. 'TextWrap': ['word-break', 'white-space']
  39. };
  40. },
  41. /**
  42. * Get the corresponding css style for a given property ID and property style (as speciied in the vizdef).
  43. * (property styles can be one of Color, FontSize, FontFace, FontBold, FontItalice, FontUnerline, and FontAlign
  44. * @returns [string] mapped CSS style
  45. */
  46. getPropertyStyle: function getPropertyStyle(propName) {
  47. var prop = this.props ? this.props[propName] : undefined;
  48. if (prop && prop.style) {
  49. return this.cssPropertyMap[prop.style];
  50. }
  51. }
  52. });
  53. return VisPropertiesCSSProxy;
  54. });
  55. //# sourceMappingURL=VisPropertiesCSSProxy.js.map