styleText.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /****************************************************************
  2. ** Licensed Materials - Property of IBM
  3. **
  4. ** BI and PM: qs
  5. **
  6. ** (C) Copyright IBM Corp. 2001, 2015
  7. **
  8. ** US Government Users Restricted Rights - Use, duplication or
  9. ** disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  10. *****************************************************************/
  11. // Copyright (C) 2008 Cognos ULC, an IBM Company. All Rights Reserved.
  12. // Cognos and the Cognos logo are trademarks of Cognos ULC (formerly Cognos Incorporated) in the United States and/or other countries. IBM and the IBM logo are trademarks of International Business Machines Corporation in the United States, or other countries, or both. Other company, product, or service names may be trademarks or service marks of others.
  13. function getCSSFromForm()
  14. {
  15. var cssString = "";
  16. var fontFamily = document.f.fontFamily[document.f.fontFamily.selectedIndex].value;
  17. if (fontFamily != "" && fontFamily != null)
  18. {
  19. cssString += "font-family:" + fontFamily;
  20. }
  21. var fontSize = document.f.fontSize[document.f.fontSize.selectedIndex].value;
  22. if (fontSize != "" && fontSize != null)
  23. {
  24. cssString = addSeparator(cssString);
  25. cssString += "font-size:" + fontSize;
  26. }
  27. var fontStyle = document.f.fontStyle[document.f.fontStyle.selectedIndex].value;
  28. if (fontStyle != "" && fontStyle != null)
  29. {
  30. cssString = addSeparator(cssString);
  31. cssString += "font-style:" + fontStyle;
  32. }
  33. var fontWeight = document.f.fontWeight[document.f.fontWeight.selectedIndex].value;
  34. if (fontWeight != "" && fontWeight != null)
  35. {
  36. cssString = addSeparator(cssString);
  37. cssString += "font-weight:" + fontWeight;
  38. }
  39. var bEffect = false;
  40. var cssEffectsString = "text-decoration:";
  41. if (document.f.chkUnderline.checked)
  42. {
  43. cssEffectsString += "underline";
  44. bEffect = true;
  45. }
  46. if (document.f.chkOverline.checked)
  47. {
  48. cssEffectsString += (bEffect ? " " : "") + "overline";
  49. bEffect = true;
  50. }
  51. if (document.f.chkStrikeThrough.checked)
  52. {
  53. cssEffectsString += (bEffect ? " " : "") + "line-through";
  54. bEffect = true;
  55. }
  56. if (bEffect == true)
  57. {
  58. cssString = addSeparator(cssString);
  59. cssString += cssEffectsString;
  60. }
  61. var color = document.f.ForeColor.value;
  62. if (color != "" && color != null)
  63. {
  64. cssString = addSeparator(cssString);
  65. cssString += "color:" + color;
  66. }
  67. var backgroundColor = document.f.BackColor.value;
  68. if (backgroundColor != "" && backgroundColor != null)
  69. {
  70. cssString = addSeparator(cssString);
  71. cssString += "background-color:" + backgroundColor;
  72. }
  73. var textAlignment = document.f.textAlignment.value;
  74. if (textAlignment != "" && textAlignment != null)
  75. {
  76. cssString = addSeparator(cssString);
  77. cssString += getConfigFrame().alignStyleToCSS(textAlignment);
  78. }
  79. return cssString;
  80. };
  81. function processCSSForSubmission(cssString)
  82. {
  83. var rColon = new RegExp (':', 'gi');
  84. cssString = cssString.replace(rColon ,"\:");
  85. return cssString;
  86. };
  87. function updateColor(s)
  88. {
  89. cp.updateSwatch(s);
  90. updatePreview();
  91. };
  92. function updateBackgroundColor(s)
  93. {
  94. bcp.updateSwatch(s);
  95. updatePreview();
  96. };
  97. function updateAlignment(s)
  98. {
  99. var oDiv = document.getElementById('selectAlignment');
  100. while (oDiv.hasChildNodes())
  101. {
  102. oDiv.removeChild(oDiv.firstChild);
  103. }
  104. var newText = document.createTextNode(alignments[s]);
  105. oDiv.appendChild(newText);
  106. document.f.textAlignment.value = s;
  107. alp.setActiveAlignment(s);
  108. updatePreview();
  109. };
  110. function updatePreview()
  111. {
  112. var oPreview = document.getElementById("preview");
  113. if (typeof oPreview != "undefined" && oPreview != null)
  114. {
  115. var sPreview = '<table border="0" cellpadding="0" cellspacing="0" style="height:100%;width:100%;border:1px solid #999999;'
  116. + '"><tr><td style="text-align:center;height:56px;width:100%;'
  117. + getCSSFromForm()
  118. + '">'
  119. + previewString
  120. + '</td></tr></table>';
  121. oPreview.innerHTML = sPreview;
  122. }
  123. };
  124. function hidePickers()
  125. {
  126. if (typeof cp != 'undefined')
  127. {
  128. cp.hide();
  129. }
  130. if (typeof bcp != 'undefined')
  131. {
  132. bcp.hide();
  133. }
  134. if (typeof alp != 'undefined')
  135. {
  136. alp.hide();
  137. }
  138. };