GlassDialogUtil.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. 'use strict';
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2014, 2019
  5. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  6. */
  7. define(['../../lib/@waca/core-client/js/core-client/ui/core/Class', 'underscore', 'doT', '../../lib/@waca/core-client/js/core-client/utils/ClassFactory'], function (Class, _, dot, ClassFactory) {
  8. /**
  9. * To show modal dialogs in glass, we need to supply the html & css
  10. * This utility provides a simple way to use consistent style in all dialogs & make it easier to maintain
  11. * All the css variables are maintained here and templates are populated using them (similar to variables in stylus)
  12. */
  13. // @class
  14. var GlassDialogUtil = Class.extend({
  15. cssVars: {
  16. font: '14px Roboto,Arial,Garuda,sans-serif',
  17. dialogTextLineHeight: 1,
  18. dialogHeaderColor: '#231f20',
  19. dialogHeaderFontSize: '18px',
  20. dialogInputColor: '#666666',
  21. dialogInputHeight: '18px',
  22. dialogHeaderPadding: '12px',
  23. dialogFooterPadding: '20px',
  24. primaryButtonBorder: '1px solid #D84E8D',
  25. primaryButtonColor: '#D84E8D', //pink (not ba blue) is used for authoring, '#319BD4' bablue
  26. primaryButtonHoverBackgroundColor: '#D84E8D',
  27. primaryButtonHoverColor: '#fff',
  28. secondaryButtonBorder: '1px solid #666666',
  29. secondaryButtonColor: '#666666', //grey_3
  30. secondaryButtonHoverBackgroundColor: '#666666',
  31. secondaryButtonHoverColor: '#fff',
  32. dialogButtonHeight: '32px',
  33. dialogButtonPadding: ' 0 20px 0 20px',
  34. dialogButtonLineHeight: '30px',
  35. dialogButtonFontFamily: 'Helvetica Neue Medium",Roboto,Helvetica,Arial,sans-serif'
  36. },
  37. generateMarkup: function generateMarkup(htmlTemplate, htmlParams, cssTemplate, cssParams) {
  38. var _this = this;
  39. var modules = ['text!dashboard-core/js/app/util/templates/' + htmlTemplate + '.html'];
  40. if (cssTemplate) {
  41. modules.push('text!dashboard-core/js/app/util/templates/' + cssTemplate + '.csstemplate');
  42. }
  43. return Promise.all(modules.map(function (module) {
  44. return ClassFactory.loadModule(module);
  45. })).then(function (Modules) {
  46. var htmlString = Modules[0];
  47. var cssString = Modules[1];
  48. var output = {};
  49. output.html = _this._generate(htmlString, htmlParams);
  50. if (cssString) {
  51. var _cssParams = _.extend({}, _this.cssVars, cssParams);
  52. output.css = _this._generate(cssString, _cssParams);
  53. }
  54. return output;
  55. });
  56. },
  57. _generate: function _generate(templateString, params) {
  58. var dotTemplate = dot.template(templateString || '');
  59. var output = dotTemplate(params);
  60. return output;
  61. }
  62. });
  63. // Singleton
  64. return new GlassDialogUtil();
  65. });
  66. //# sourceMappingURL=GlassDialogUtil.js.map