edittitle.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. // Licensed Materials - Property of IBM
  2. //
  3. // IBM Cognos Products: pps
  4. //
  5. // (C) Copyright IBM Corp. 2005, 2017
  6. //
  7. // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  8. // This forms the javascript functions used for the edit title
  9. // action pane for PowerPlay Studio.
  10. // The functions handle any minor browser differences.
  11. var caretPos;
  12. function onOK() {
  13. topparent.clearActionPane();
  14. var userTitle = new String(getUserEditTitle());
  15. //remove any tabs
  16. var rExp = new RegExp("\t", "gi");
  17. userTitle = userTitle.replace(rExp, "	");
  18. userTitle = translateVariables(userTitle, true);
  19. var command = 'IP:"' + userTitle + '"';
  20. topparent.getXtabFrame().doit(command);
  21. }
  22. function translateVariables(titleText, toInternal) {
  23. var selectBox = document.getElementById("Variable_select");
  24. for (i=0;i<selectBox.options.length;i++)
  25. {
  26. var localizedVar = localizedVars[i];
  27. var internalVar = selectBox.options[i].value;
  28. if(toInternal){
  29. var rExp = new RegExp(localizedVar, "gi");
  30. titleText = titleText.replace(rExp,internalVar)
  31. }
  32. else{
  33. var rExp = new RegExp(internalVar, "gi");
  34. titleText = titleText.replace(rExp,localizedVar)
  35. }
  36. }
  37. return titleText;
  38. }
  39. //Tab delimited value string:
  40. //append PDF Title (1 = yes, 0 = no)
  41. //Use User Defined Title (1 = yes, 0 = no)( if yes then append :titleText)
  42. function getUserEditTitle() {
  43. var aptCheck, opt;
  44. if (document.getElementById("append_PDF_Title").checked) {
  45. aptCheck = "1";
  46. }
  47. else {
  48. aptCheck = "0";
  49. }
  50. if (document.getElementById("Title_radio").checked) {
  51. opt = "1" + aptCheck + document.getElementById("Title_textarea").value;
  52. }
  53. else {
  54. opt = "0" + aptCheck;
  55. }
  56. return opt;
  57. }
  58. function storeCaret() {
  59. var textArea = document.getElementById("Title_textarea");
  60. if (textArea.createTextRange) {
  61. textArea.caretPos = document.selection.createRange().duplicate();
  62. }
  63. }
  64. function insertVar() {
  65. var textArea = document.getElementById("Title_textarea");
  66. if (textArea.caretPos) {
  67. textArea.caretPos.select();
  68. }
  69. else {
  70. textArea.focus();
  71. storeCaret();
  72. }
  73. var selectBox = document.getElementById("Variable_select");
  74. var text = "";
  75. if (selectBox.selectedIndex >= 0) {
  76. text = localizedVars[selectBox.selectedIndex];
  77. }
  78. if (textArea.createTextRange && textArea.caretPos) {
  79. textArea.caretPos.text = text;
  80. }
  81. else {
  82. textArea.value = textArea.value + text;
  83. }
  84. if (textArea.caretPos) {
  85. textArea.caretPos.select();
  86. }
  87. textArea.focus();
  88. storeCaret();
  89. }
  90. function init() {
  91. if (window.name == "ActionPane")
  92. topparent.openActionPane();
  93. ContextMenu.initialize(true,false);
  94. // adjust the size of the action pane to accomodate the display option pane.
  95. if (topparent.getGlobal("nn7"))
  96. topparent.setActionPaneHeight("283");
  97. else
  98. topparent.setActionPaneHeight("270");
  99. if (parent.isXtabStillLoading())
  100. {
  101. setTimeout('initEditTitle()', 50);
  102. return;
  103. }
  104. var textArea = document.getElementById("Title_textarea");
  105. textArea.value = translateVariables(textArea.value, false);
  106. var selectBox = document.getElementById("Variable_select");
  107. if (document.getElementById("Title_radio").checked) {
  108. textArea.focus();
  109. storeCaret();
  110. }
  111. else {
  112. selectBox.focus();
  113. }
  114. selectBox.options[0].selected = true;
  115. }
  116. function updateRadioButtons() {
  117. document.getElementById("Title_radio").checked = true;
  118. }
  119. function editTitleArrowMouseOver(table) {
  120. document.getElementById("insertVarArrowImg").className = "customSubsetsArrowButtonRollover";
  121. document.getElementById("insertVarArrowLink").className = "editTitleLinksRollover";
  122. }
  123. function editTitleArrowMouseOut(table) {
  124. document.getElementById("insertVarArrowImg").className = "customSubsetsArrowButton";
  125. document.getElementById("insertVarArrowLink").className = "editTitleLinks";
  126. }
  127. function editTitleArrowMouseDown(table) {
  128. document.getElementById("insertVarArrowImg").className = "customSubsetsArrowButtonPressed";
  129. document.getElementById("insertVarArrowLink").className = "editTitleLinksRollover";
  130. }
  131. function editTitleArrowMouseUp(table) {
  132. document.getElementById("insertVarArrowImg").className = "customSubsetsArrowButtonRollover";
  133. document.getElementById("insertVarArrowLink").className = "editTitleLinksRollover";
  134. }