xtaboptions.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  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 display options
  9. // action pane for PowerPlay Studio.
  10. // The functions are Internet Explorer specific.
  11. var XTAB_OBJ_REGULAR_IDX = -1;
  12. var XTAB_OBJ_CALC_IDX = -1;
  13. var XTAB_OBJ_RANK_IDX = -1;
  14. var XTAB_OBJ_8020_IDX = -1;
  15. var XTAB_OBJ_SUM1_IDX = -1;
  16. var XTAB_OBJ_SUM2_IDX = -1;
  17. var XTAB_OBJ_HIGH_EXC_IDX = -1;
  18. var XTAB_OBJ_LOW_EXC_IDX = -1;
  19. var XTAB_OBJ_MEASURE_IDX = -1;
  20. var XTAB_POS_CELL = 0;
  21. var XTAB_POS_ROW = 1;
  22. var XTAB_POS_COL = 2;
  23. var XTAB_POS_ALL = 3;
  24. var overwriteall = false;
  25. var xtabOptionsComboBoxes = new Array();
  26. var xtabOptionComboBoxIds = new Array();
  27. var currentSelectedItem = "";
  28. function areFormatsEqual(format1,format2) {
  29. return ((format1.getAttribute("useDefaults") == format2.getAttribute("useDefaults")) &&
  30. (format1.getAttribute("fontSize") == format2.getAttribute("fontSize")) &&
  31. (format1.getAttribute("color") == format2.getAttribute("color")) &&
  32. (format1.getAttribute("backColor") == format2.getAttribute("backColor")) &&
  33. (format1.getAttribute("bold") == format2.getAttribute("bold")) &&
  34. (format1.getAttribute("italic") == format2.getAttribute("italic")) &&
  35. (format1.getAttribute("underline") == format2.getAttribute("underline")) &&
  36. (format1.getAttribute("textAlign") == format2.getAttribute("textAlign")));
  37. }
  38. function overwriteFormat(format1,format2) {
  39. format1.setAttribute("useDefaults",format2.getAttribute("useDefaults"));
  40. format1.setAttribute("fontSize",format2.getAttribute("fontSize"));
  41. format1.setAttribute("color",format2.getAttribute("color"));
  42. format1.setAttribute("backColor",format2.getAttribute("backColor"));
  43. format1.setAttribute("bold",format2.getAttribute("bold"));
  44. format1.setAttribute("italic",format2.getAttribute("italic"));
  45. format1.setAttribute("underline",format2.getAttribute("underline"));
  46. format1.setAttribute("textAlign",format2.getAttribute("textAlign"));
  47. }
  48. function init() {
  49. topparent.openActionPane();
  50. topparent.setActionPaneHeight("300");
  51. removeMessage();
  52. if (xtabType != 0 && xtabType != 9)
  53. displayCommonMessage(strErrorMessageNoXtab, MESSAGE_TYPE_INFO, ["OK"], [function() {topparent.closeActionPane();}]);
  54. ContextMenu.initialize(true,false);
  55. notifyColorChange = "paletteColorChanged();";
  56. initializeObjTypeSelect("objectTypeSelect","changeCurrentFormatItem();");
  57. initializeXtabPositionSelect("xtabPositionSelect","changeCurrentFormatItem();");
  58. initializeFontSizeSelect("xtabfontsizeselect","formatItemChanged();");
  59. storeOptionsUnderTag(document.body);
  60. initializeOptionValues();
  61. changeCurrentFormatItem();
  62. }
  63. function initializeObjTypeSelect(comboBoxId,action) {
  64. var currentSeriesSelect = document.getElementById(comboBoxId);
  65. if (currentSeriesSelect) {
  66. var currentComboBox = initComboBox(currentSeriesSelect);
  67. var ctr = 0;
  68. currentComboBox.addItem(new cbTextItem(strCrosstab, action, true));
  69. XTAB_OBJ_REGULAR_IDX = ctr++;
  70. currentComboBox.addItem(new cbTextItem(strCalculation, action, false));
  71. XTAB_OBJ_CALC_IDX = ctr++;
  72. currentComboBox.addItem(new cbTextItem(strRank, action, false));
  73. XTAB_OBJ_RANK_IDX = ctr++;
  74. currentComboBox.addItem(new cbTextItem(strSuppressed, action, false));
  75. XTAB_OBJ_8020_IDX = ctr++;
  76. currentComboBox.addItem(new cbTextItem(strSummary1, action, false));
  77. XTAB_OBJ_SUM1_IDX = ctr++;
  78. currentComboBox.addItem(new cbTextItem(strSummary2, action, false));
  79. XTAB_OBJ_SUM2_IDX = ctr++;
  80. if (enableHighException) {
  81. currentComboBox.addItem(new cbTextItem(strHighException, action, false));
  82. XTAB_OBJ_HIGH_EXC_IDX = ctr++;
  83. }
  84. if (enableLowException) {
  85. currentComboBox.addItem(new cbTextItem(strLowException, action, false));
  86. XTAB_OBJ_LOW_EXC_IDX = ctr++;
  87. }
  88. currentComboBox.addItem(new cbTextItem(strMeasure, action, false));
  89. XTAB_OBJ_MEASURE_IDX = ctr++;
  90. xtabOptionsComboBoxes[comboBoxId] = currentComboBox;
  91. xtabOptionComboBoxIds[xtabOptionComboBoxIds.length] = comboBoxId;
  92. }
  93. }
  94. function initializeXtabPositionSelect(comboBoxId,action) {
  95. var currentSeriesSelect = document.getElementById(comboBoxId);
  96. if (currentSeriesSelect) {
  97. var currentComboBox = initComboBox(currentSeriesSelect);
  98. currentComboBox.addItem(new cbTextItem(strDataCell, action, true));
  99. currentComboBox.addItem(new cbTextItem(strRowHeader, action, false));
  100. currentComboBox.addItem(new cbTextItem(strColHeader, action, false));
  101. currentComboBox.addItem(new cbTextItem(strAll, action, false));
  102. xtabOptionsComboBoxes[comboBoxId] = currentComboBox;
  103. xtabOptionComboBoxIds[xtabOptionComboBoxIds.length] = comboBoxId;
  104. }
  105. }
  106. function initializeFontSizeSelect(comboBoxId,action) {
  107. var currentFontSizeSelect = document.getElementById(comboBoxId);
  108. if (currentFontSizeSelect) {
  109. var currentComboBox = initComboBox(currentFontSizeSelect);
  110. currentComboBox.addItem(new cbTextItem(strDefault, action, false));
  111. currentComboBox.addItem(new cbTextItem("4", action, false));
  112. currentComboBox.addItem(new cbTextItem("6", action, false));
  113. currentComboBox.addItem(new cbTextItem("7", action, false));
  114. currentComboBox.addItem(new cbTextItem("8", action, false));
  115. currentComboBox.addItem(new cbTextItem("9", action, false));
  116. currentComboBox.addItem(new cbTextItem("10", action, true));
  117. currentComboBox.addItem(new cbTextItem("11", action, true));
  118. currentComboBox.addItem(new cbTextItem("12", action, false));
  119. currentComboBox.addItem(new cbTextItem("13", action, false));
  120. currentComboBox.addItem(new cbTextItem("14", action, false));
  121. currentComboBox.addItem(new cbTextItem("15", action, false));
  122. currentComboBox.addItem(new cbTextItem("16", action, false));
  123. currentComboBox.addItem(new cbTextItem("18", action, false));
  124. currentComboBox.addItem(new cbTextItem("20", action, false));
  125. xtabOptionsComboBoxes[comboBoxId] = currentComboBox;
  126. xtabOptionComboBoxIds[xtabOptionComboBoxIds.length] = comboBoxId;
  127. }
  128. }
  129. function fontButtonClicked(event) {
  130. var eventM = new eventManager(event);
  131. eventM.cancelBubble();
  132. var button = eventM.getSrc();
  133. toggleButton(button);
  134. formatItemChanged();
  135. }
  136. function toggleButton(button) {
  137. if (button.getAttribute("isdisabled") == "true")
  138. return;
  139. if (button.getAttribute("pressed") == "true") {
  140. setButtonState(button,false);
  141. } else {
  142. setButtonState(button,true);
  143. }
  144. }
  145. function setButtonState(button,pressed) {
  146. if (pressed) {
  147. button.className = "chartOptionsFontButtonPressed";
  148. button.setAttribute("pressed","true");
  149. } else {
  150. button.className = "chartOptionsFontButton";
  151. button.setAttribute("pressed","false");
  152. }
  153. }
  154. function alignButtonClicked(event) {
  155. var eventM = new eventManager(event);
  156. eventM.cancelBubble();
  157. var button = eventM.getSrc();
  158. setButtonState(document.getElementById("xtab_left"),false);
  159. setButtonState(document.getElementById("xtab_center"),false);
  160. setButtonState(document.getElementById("xtab_right"),false);
  161. setButtonState(button,true);
  162. formatItemChanged();
  163. }
  164. function changeCurrentFormatItem() {
  165. var crosstabLocationShow = true;
  166. currentSelectedItem = "XF_";
  167. if (xtabOptionsComboBoxes["objectTypeSelect"].getSelectedItem() == XTAB_OBJ_REGULAR_IDX) {
  168. currentSelectedItem += "R";
  169. } else if (xtabOptionsComboBoxes["objectTypeSelect"].getSelectedItem() == XTAB_OBJ_CALC_IDX) {
  170. currentSelectedItem += "C";
  171. } else if (xtabOptionsComboBoxes["objectTypeSelect"].getSelectedItem() == XTAB_OBJ_RANK_IDX) {
  172. currentSelectedItem += "RK";
  173. } else if (xtabOptionsComboBoxes["objectTypeSelect"].getSelectedItem() == XTAB_OBJ_8020_IDX) {
  174. currentSelectedItem += "O";
  175. } else if (xtabOptionsComboBoxes["objectTypeSelect"].getSelectedItem() == XTAB_OBJ_SUM1_IDX) {
  176. currentSelectedItem += "S1";
  177. } else if (xtabOptionsComboBoxes["objectTypeSelect"].getSelectedItem() == XTAB_OBJ_SUM2_IDX) {
  178. currentSelectedItem += "S2";
  179. } else if (xtabOptionsComboBoxes["objectTypeSelect"].getSelectedItem() == XTAB_OBJ_HIGH_EXC_IDX) {
  180. currentSelectedItem += "H";
  181. crosstabLocationShow = false;
  182. } else if (xtabOptionsComboBoxes["objectTypeSelect"].getSelectedItem() == XTAB_OBJ_LOW_EXC_IDX) {
  183. currentSelectedItem += "L";
  184. crosstabLocationShow = false;
  185. } else if (xtabOptionsComboBoxes["objectTypeSelect"].getSelectedItem() == XTAB_OBJ_MEASURE_IDX) {
  186. currentSelectedItem += "M";
  187. crosstabLocationShow = false;
  188. }
  189. overwriteall = false;
  190. if (crosstabLocationShow) {
  191. document.getElementById("xtabposspan").style.visibility = "visible";
  192. if (xtabOptionsComboBoxes["xtabPositionSelect"].getSelectedItem() == XTAB_POS_ROW)
  193. currentSelectedItem += "R";
  194. else if (xtabOptionsComboBoxes["xtabPositionSelect"].getSelectedItem() == XTAB_POS_COL)
  195. currentSelectedItem += "C";
  196. else if (xtabOptionsComboBoxes["xtabPositionSelect"].getSelectedItem() == XTAB_POS_ALL)
  197. overwriteall = true;
  198. } else {
  199. document.getElementById("xtabposspan").style.visibility = "hidden";
  200. }
  201. changeCurrentlySelectedFormatItem();
  202. }
  203. function paletteColorChanged() {
  204. formatItemChanged();
  205. }
  206. function writeFormatDataToOption(option) {
  207. option.setAttribute("useDefaults",(document.getElementById("xtabusedefaults").checked)? "true" : "false");
  208. if (document.getElementById("xtabusedefaults").checked) {
  209. document.getElementById("settingsTable").style.visibility = "hidden";
  210. } else {
  211. document.getElementById("settingsTable").style.visibility = "visible";
  212. }
  213. option.setAttribute("bold",document.getElementById("xtab_bold").getAttribute("pressed"));
  214. option.setAttribute("italic",document.getElementById("xtab_italic").getAttribute("pressed"));
  215. option.setAttribute("underline",document.getElementById("xtab_underlined").getAttribute("pressed"));
  216. var fontSizes = new Array(0,4,6,7,8,9,10,11,12,13,14,15,16,18,20);
  217. option.setAttribute("fontSize",fontSizes[xtabOptionsComboBoxes["xtabfontsizeselect"].getSelectedItem()]);
  218. option.setAttribute("color",getColorPickerColor("textColor"));
  219. option.setAttribute("backColor",getColorPickerColor("cellColor"));
  220. var textAlign = 0;
  221. if (document.getElementById("xtab_center").getAttribute("pressed") == "true")
  222. textAlign = 1;
  223. else if (document.getElementById("xtab_right").getAttribute("pressed") == "true")
  224. textAlign = 2;
  225. option.setAttribute("textAlign",textAlign);
  226. }
  227. function formatItemChanged() {
  228. var option;
  229. if (!overwriteall) {
  230. writeFormatDataToOption(document.getElementById("opt_" + currentSelectedItem));
  231. } else {
  232. writeFormatDataToOption(document.getElementById("opt_" + currentSelectedItem));
  233. writeFormatDataToOption(document.getElementById("opt_" + currentSelectedItem + "R"));
  234. writeFormatDataToOption(document.getElementById("opt_" + currentSelectedItem + "C"));
  235. }
  236. refreshPreview();
  237. }
  238. function selectCellPosition() {
  239. xtabOptionsComboBoxes["xtabPositionSelect"].setSelectedItem(0);
  240. }
  241. function forceAllPositionsToCellFormat() {
  242. overwriteFormat(document.getElementById("opt_" + currentSelectedItem + "R"), document.getElementById("opt_" + currentSelectedItem));
  243. overwriteFormat(document.getElementById("opt_" + currentSelectedItem + "C"), document.getElementById("opt_" + currentSelectedItem));
  244. }
  245. function changeCurrentlySelectedFormatItem() {
  246. if (overwriteall) {
  247. var option1 = document.getElementById("opt_" + currentSelectedItem);
  248. var option2 = document.getElementById("opt_" + currentSelectedItem + "R");
  249. var option3 = document.getElementById("opt_" + currentSelectedItem + "C");
  250. if (!(areFormatsEqual(option1,option2) && areFormatsEqual(option2,option3))) {
  251. displayCommonMessage(errAll, MESSAGE_TYPE_INFO, ["OK","Cancel"], [function() {forceAllPositionsToCellFormat();changeCurrentlySelectedFormatItem();removeMessage();},function() {selectCellPosition();removeMessage();}]);
  252. return;
  253. }
  254. }
  255. var option = document.getElementById("opt_" + currentSelectedItem);
  256. if (option.getAttribute("useDefaults") == "true") {
  257. document.getElementById("xtabusedefaults").checked = true;
  258. document.getElementById("settingsTable").style.visibility = "hidden";
  259. } else {
  260. document.getElementById("xtabusecustom").checked = true;
  261. document.getElementById("settingsTable").style.visibility = "visible";
  262. }
  263. setButtonState(document.getElementById("xtab_bold"),option.getAttribute("bold") == "true");
  264. setButtonState(document.getElementById("xtab_italic"),option.getAttribute("italic") == "true");
  265. setButtonState(document.getElementById("xtab_underlined"),option.getAttribute("underline") == "true");
  266. var fontSizeItem = 0;
  267. switch (option.getAttribute("fontSize")) {
  268. case 0: fontSizeItem = 0; break;
  269. case 4: fontSizeItem = 1; break;
  270. case 6: fontSizeItem = 2; break;
  271. case 7: fontSizeItem = 3; break;
  272. case 8: fontSizeItem = 4; break;
  273. case 9: fontSizeItem = 5; break;
  274. case 10: fontSizeItem = 6; break;
  275. case 11: fontSizeItem = 7; break;
  276. case 12: fontSizeItem = 8; break;
  277. case 13: fontSizeItem = 9; break;
  278. case 14: fontSizeItem = 10; break;
  279. case 15: fontSizeItem = 11; break;
  280. case 16: fontSizeItem = 12; break;
  281. case 18: fontSizeItem = 13; break;
  282. case 20: fontSizeItem = 14; break;
  283. }
  284. xtabOptionsComboBoxes["xtabfontsizeselect"].setSelectedItem(fontSizeItem);
  285. setColorPicker("textColor",option.getAttribute("color"));
  286. setColorPicker("cellColor",option.getAttribute("backColor"));
  287. var textAlign = parseInt(option.getAttribute("textAlign"));
  288. setButtonState(document.getElementById("xtab_left"),(textAlign == 0));
  289. setButtonState(document.getElementById("xtab_center"),(textAlign == 1));
  290. setButtonState(document.getElementById("xtab_right"),(textAlign == 2));
  291. refreshPreview();
  292. }
  293. function onOk() {
  294. applyOptions(true);
  295. }
  296. function onCancel() {
  297. topparent.clearActionPane();
  298. }
  299. function onApply() {
  300. applyOptions(false);
  301. }
  302. function applyOptions(closePane) {
  303. var cmd = createCommand();
  304. if (cmd != "") {
  305. cmd = "B:" + cmd;
  306. if (closePane)
  307. topparent.getXtabFrame().document.fhidden.ACTPANE.value = "0";
  308. topparent.getXtabFrame().doit(cmd);
  309. }
  310. if (closePane) {
  311. topparent.clearActionPane();
  312. }
  313. }
  314. function clearAllPopups() {
  315. for (var i = 0; i < xtabOptionComboBoxIds.length; i++) {
  316. xtabOptionsComboBoxes[xtabOptionComboBoxIds[i]].hideDropDown();
  317. }
  318. }
  319. function refreshPreview() {
  320. var preview = document.getElementById("xtabPreview");
  321. var option = document.getElementById("opt_" + currentSelectedItem);
  322. preview.style.color = "#" + option.getAttribute("color");
  323. preview.style.backgroundColor = "#" + option.getAttribute("backColor");
  324. (option.getAttribute("bold") == "true")? preview.style.fontWeight = "bold" : preview.style.fontWeight = "normal" ;
  325. (option.getAttribute("italic") == "true")? preview.style.fontStyle = "italic" : preview.style.fontStyle = "normal" ;
  326. (option.getAttribute("underline") == "true")? preview.style.textDecoration = "underline" : preview.style.textDecoration = "none" ;
  327. var textAlign = parseInt(option.getAttribute("textAlign"));
  328. if (textAlign == 0)
  329. preview.style.textAlign = "left";
  330. else if (textAlign == 1)
  331. preview.style.textAlign = "center";
  332. else
  333. preview.style.textAlign = "right";
  334. if (option.getAttribute("fontSize") != 0) {
  335. preview.style.fontSize = option.getAttribute("fontSize") + "pt";
  336. } else
  337. preview.style.fontSize = "9pt";
  338. }