TextPlaceholderView.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. 'use strict';
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Cognos Products: Storytelling (C) Copyright IBM Corp. 2018, 2019
  5. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  6. */
  7. define(['./PlaceholderView', 'text!./TextPlaceholder.html', '../../util/TextFitUtil', '../../../app/nls/StringResources'], function (BaseClass, Template, TextFitUtil, stringResources) {
  8. var TextPlaceholderView = null;
  9. TextPlaceholderView = BaseClass.extend({
  10. templateString: Template,
  11. init: function init() {
  12. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  13. TextPlaceholderView.inherited('init', this, arguments);
  14. this.text = options.text || stringResources.get('textPlaceHolder');
  15. },
  16. render: function render() {
  17. var sHtml = this.dotTemplate({
  18. placeholderText: this.text
  19. });
  20. this.$el.append(sHtml);
  21. },
  22. show: function show() {
  23. TextPlaceholderView.inherited('show', this, arguments);
  24. this.fillText();
  25. },
  26. fillText: function fillText() {
  27. var node = this.el.querySelector('.placeholder.text');
  28. if (!node || node.style.display === 'none') {
  29. return;
  30. }
  31. node.classList.add('textFillNoScroll');
  32. var options = {
  33. maxFontSize: Math.ceil(node.clientHeight),
  34. minFontSize: 1,
  35. multiLine: false,
  36. detectMultiLine: false
  37. };
  38. TextFitUtil.fillText(node, options);
  39. }
  40. });
  41. return TextPlaceholderView;
  42. });
  43. //# sourceMappingURL=TextPlaceholderView.js.map