layout.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. /********************************************************************************************************************************
  2. * Licensed Materials - Property of IBM *
  3. * *
  4. * IBM Cognos Products: AGS *
  5. * *
  6. * (C) Copyright IBM Corp. 2005, 2014 *
  7. * *
  8. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *
  9. *********************************************************************************************************************************/
  10. //
  11. // Those functions are used to reload frames or to change their aspect.
  12. //
  13. //Frame ids
  14. var DIALOG_FRAME_ID = "dialogIFrame";
  15. var MESSAGE_FRAME_ID = "messageIFrame";
  16. var DISPLAY_NONE = "none";
  17. // define some parameters for this sort of thing
  18. var WIZARD_MENU_ALIAS='wizard';
  19. var TASK_MENU_ALIAS='task2';
  20. // define some variable for the tabs
  21. var TAB_MODEL = 'Model';
  22. var TAB_DATAITEMS = 'DataItems';
  23. var TAB_FUNCTIONS = 'Functions';
  24. var TAB_PARAMETERS = 'Parameters';
  25. var TAB_HISTORY = 'History';
  26. var TAB_MEMBERS = 'MemberSearch';
  27. var flag = null;
  28. var itemType = "";
  29. var itemLabel= "";
  30. //var popWin1;
  31. /*
  32. * switch the task menu depending on whether the new agent wizard is active
  33. * alias Can be 'wizard' or 'task2'. When null the default alias is task2
  34. * taskCount The number of tasks in the summary bar
  35. */
  36. function changeTaskMenu(alias)
  37. {
  38. var lastMenuDiv = null;
  39. //set the default alias if necessary
  40. if (alias==null) {
  41. alias=TASK_MENU_ALIAS;
  42. }
  43. //get the last menu
  44. if (alias == WIZARD_MENU_ALIAS) {
  45. lastMenuDiv = document.getElementById('div_taskmenu_task2');
  46. }
  47. else if (alias == TASK_MENU_ALIAS) {
  48. lastMenuDiv = document.getElementById('div_taskmenu_wizard');
  49. }
  50. if (lastMenuDiv != null) {
  51. //hide the old menu
  52. lastMenuDiv.style.display="none";
  53. //get the new menu div
  54. var newMenuDiv = document.getElementById('div_taskmenu_'+alias);
  55. //show the correct menu
  56. if(newMenuDiv != null){
  57. if (browserCheck.isIE5Up()) {
  58. newMenuDiv.style.display="block";
  59. }
  60. else {
  61. newMenuDiv.style.display="table";
  62. }
  63. var taskCount = cfgGet("TaskCount");
  64. //set a default task count if it has not been set
  65. if (taskCount == undefined || taskCount == null) {
  66. taskCount = 0;
  67. }
  68. //alert('changeTaskMenu:alias='+alias+', task count:'+taskCount);
  69. // now do the setSubmissionMenu
  70. doSetSubmissionMenu(taskCount);
  71. }
  72. }
  73. }
  74. function doSetSubmissionMenu(taskCount) {
  75. var menuItem = menuItemMap['sequenceTasks'];
  76. // hide the set submission of tasks item if there's no sequencing to be done
  77. if (taskCount < 2) {
  78. // hide it
  79. document.getElementById('set_submit_spacer').style.display="none";
  80. document.getElementById('set_submit').style.display="none";
  81. menuItem.hide();
  82. }
  83. // show it.
  84. else{
  85. if (browserCheck.isIE5Up() && document.documentMode < 10) { // IE7, IE8, IE9 Standards mode
  86. document.getElementById('set_submit').style.display="block";
  87. document.getElementById('set_submit_spacer').style.display="block";
  88. } else { // IE 10 or upper IE browser and other browsers.
  89. document.getElementById('set_submit').style.display="table-row";
  90. document.getElementById('set_submit_spacer').style.display="table-row";
  91. }
  92. menuItem.show();
  93. }
  94. }
  95. function getConfigFrame() {
  96. if (this.id == 'CR1_AgentStudio_TopFrame')
  97. return this;
  98. else if (parent != null && parent.id == 'CR1_AgentStudio_TopFrame')
  99. return parent;
  100. else if (opener != null && opener.id == 'CR1_AgentStudio_TopFrame')
  101. return opener;
  102. else if (top.id == 'CR1_AgentStudio_TopFrame')
  103. return top;
  104. else
  105. return null;
  106. }
  107. function getMessageIFrame() {
  108. return getFrame('messageIFrame');
  109. }
  110. function getPopUpFrame() {
  111. return getFrame('popUpFrame');
  112. }
  113. function getDialogFrame(frameId) {
  114. if(!frameId){
  115. frameId = DIALOG_FRAME_ID;
  116. }
  117. return getFrame(frameId);
  118. }
  119. function getFrameDocument(frame)
  120. {
  121. return frame.document;
  122. }
  123. function getFrame(name) {
  124. var cf = getConfigFrame();
  125. var f = null;
  126. if (cf)
  127. f = cf.window.frames[name];
  128. return f;
  129. }
  130. function redrawLayers() {
  131. // always change the menu to a new agent
  132. changeMenu(TAB_MODEL);
  133. changeTaskMenu('task2');
  134. doSetSubmissionMenu(); // ?
  135. showDialogFrame(0);
  136. }
  137. function hideDialogFrame(){
  138. saveChangesToDialogFrame=false;
  139. //only hide if the dialog is showing
  140. if (isDialogFrameShowing()) {
  141. showDialogFrame(0);
  142. //Make the call to reset the Task Menu selection
  143. //so that it is the select tab in summary bar.
  144. //Only do this if summarybar is currently displayed.
  145. if (getMessageIFrame() && getMessageIFrame().highlightSelectedMenuItem) {
  146. getMessageIFrame().highlightSelectedMenuItem();
  147. getMessageIFrame().focus();
  148. }
  149. }
  150. }
  151. //only hide if we can match to the current type
  152. function hideDialogFrameForType(dialogType){
  153. var currentType = agsDialogTypes.getCurrentType();
  154. if(currentType && currentType.equals(dialogType)){
  155. showDialogFrame(0);
  156. }
  157. }
  158. function closeErrorPage(){
  159. var popUpform = getPopUpFrame().document.forms[0];
  160. var isLogonShowing = (popUpform.h_CAM_action && popUpform.h_CAM_action.value.indexOf(K_logon) == 0) ? true : false;
  161. if (isLogonShowing) {
  162. if (history.startIndex >= 0){
  163. history.back();
  164. history.startIndex--;
  165. return;
  166. } else {
  167. if(cfgGet("CAN_CANCEL_LOGON") && cfgGet("AGS_initialized")){
  168. //empty the command stack and return if ags is up and running
  169. getCommandStackManager().getCommandStack().clear();
  170. //display a message : OK to close event studio, Cancel to leave logon dialog showing
  171. }else if(confirm(closeAgsWarningMessage_string)){
  172. //canceling a logon means warn and then close ags
  173. closeAGS();
  174. }
  175. else {
  176. //do not close ags, leave the logon dialog showing
  177. return;
  178. }
  179. }
  180. }
  181. cfgRemove("CAN_CANCEL_LOGON")
  182. var dialog = parent.agsFormUtils.getElementFromFrame(parent,parent.DIALOG_FRAME_ID);
  183. if (popUpIsOpen()) {
  184. doClosePopUp();
  185. }
  186. else if (dialog && dialog.style.display=='') {
  187. hideDialogFrame();
  188. }
  189. }
  190. /*
  191. * Set the dialog frame height and border style
  192. * percentage The height of the dialog frame (integer)
  193. */
  194. function setDialogFrameHeight(percentage) {
  195. //height expressed as <n>px or <n>%
  196. //there is a firefox issue when using percentages. If the message frame is set
  197. //to 100% and the dialog frame is set to 0%, space will still be allocated to
  198. //the dialog frame. This is fixed by always specifying the dialog frame size in
  199. //pixels when hiding it, when showing it we can still use percentages
  200. var dlgFrameHeight='100%';
  201. var heightStr='0px';
  202. var borderTop='0px';
  203. var dlgDisplay="";
  204. //collect the message and dialog frames
  205. var aMessageFrame = agsFormUtils.getElementFromFrame(getConfigFrame(), MESSAGE_FRAME_ID);
  206. var messageTD = agsFormUtils.getElementFromFrame(getConfigFrame(), getFrameBorderId(MESSAGE_FRAME_ID));
  207. var aDialogFrame = agsFormUtils.getElementFromFrame(getConfigFrame(), DIALOG_FRAME_ID);
  208. var dialogTD = agsFormUtils.getElementFromFrame(getConfigFrame(), getFrameBorderId(DIALOG_FRAME_ID));
  209. var windowHeight = aMessageFrame.contentWindow.document.body.clientHeight + aDialogFrame.contentWindow.document.body.clientHeight;
  210. //hidden dialog, showing message frame
  211. if(percentage == 0){
  212. //uncomment when bugzilla bug 100533 is fixed (firefox 1.6)
  213. //see https://bugzilla.mozilla.org/show_bug.cgi?id=100533
  214. //dlgDisplay=DISPLAY_NONE;
  215. dlgFrameHeight='0px';
  216. getConfigFrame().getAgentItemsListener().frameHidden(DIALOG_FRAME_ID);
  217. //showing dialog, hidden message frame
  218. }else if(percentage == 100){
  219. heightStr = '100%';
  220. //showing dialog frame, showing message frame
  221. }else{
  222. borderTop = "1px solid #999999";
  223. heightStr = percentage + '%';
  224. }
  225. //set the height
  226. dialogTD.style.height = heightStr;
  227. aDialogFrame.style.height=dlgFrameHeight;
  228. //set the top border style
  229. aDialogFrame.style.borderTop = borderTop;
  230. //set the display style
  231. aDialogFrame.style.display = dlgDisplay;
  232. dialogTD.style.display = dlgDisplay;
  233. //alert('aDialogFrame.style.height:'+aDialogFrame.style.height);
  234. }
  235. //if the frame is going to 100% we dont show the top border
  236. function showDialogFrame(size) {
  237. //for good measure.... the wait pop up may be expecting to be closed from
  238. //a page being run in the dialog fram
  239. getConfigFrame().doClosePopUp();
  240. //collect the message and dialog frames
  241. var aMessageFrame = agsFormUtils.getElementFromFrame(getConfigFrame(), MESSAGE_FRAME_ID);
  242. var messageTD = agsFormUtils.getElementFromFrame(getConfigFrame(), getFrameBorderId(MESSAGE_FRAME_ID));
  243. if(!aMessageFrame.contentWindow.document.body){
  244. //were in page transition.. hold on
  245. setTimeout("showDialogFrame("+size+")", 100);
  246. return;
  247. }
  248. var aDialogFrame = agsFormUtils.getElementFromFrame(getConfigFrame(), DIALOG_FRAME_ID);
  249. var dialogTD = agsFormUtils.getElementFromFrame(getConfigFrame(), getFrameBorderId(DIALOG_FRAME_ID));
  250. //the whole kaboudle
  251. var windowHeight = aMessageFrame.contentWindow.document.body.clientHeight + aDialogFrame.contentWindow.document.body.clientHeight;
  252. var msgDisplay="";
  253. var newDialogSize=0;
  254. var newMessageSize;
  255. //parse it
  256. if (typeof size != SizeParser) {
  257. size = new SizeParser(size);
  258. }
  259. //express the size as a percentage always
  260. if(size.isPercent()){
  261. newDialogSize = size.number;
  262. newMessageSize = 100 - size.number;
  263. }else{
  264. newMessageSize = ((windowHeight - size.number) * 100) / windowHeight;
  265. if(newMessageSize > 100) newMessageSize = 100;
  266. if(newMessageSize < 0) newMessageSize = 0;
  267. newDialogSize = 100 - newMessageSize;
  268. }
  269. setDialogFrameHeight(newDialogSize);
  270. //adjust the size unit for firefox
  271. // KM this code had strange behaviour in IE so added a condition to avoid it in IE, was working ok in Firefox
  272. // although setting size to 0 or display prop to none should effectively do the same
  273. if (newMessageSize==0) {
  274. // msgDisplay = DISPLAY_NONE; // causes cq 261144 in IE
  275. msgDisplay = "";
  276. messageTD.style.height = '0%';
  277. }
  278. else {
  279. msgDisplay = "";
  280. messageTD.style.height = newMessageSize + '%';
  281. }
  282. messageTD.style.display = msgDisplay;
  283. aMessageFrame.style.display = msgDisplay;
  284. if(getMessageIFrame().setBarSize) {
  285. getMessageIFrame().setBarSize();
  286. }
  287. }
  288. function isDialogFrameShowing(){
  289. //var aDialogFrame = agsFormUtils.getElementFromFrame(self, DIALOG_FRAME_ID);
  290. //return aDialogFrame.style.display == "";
  291. var isShowing=false;
  292. var aDialogFrame = agsFormUtils.getElementFromFrame(getConfigFrame(), DIALOG_FRAME_ID);
  293. var size = new SizeParser(aDialogFrame.style.height);
  294. return isShowing = size.number > 0;
  295. }
  296. function getFrameBorderId(frameId){
  297. return frameId + "_td";
  298. }
  299. function collapseMenu(url) {
  300. document.getElementById("menuFrame").style.width = "0%";
  301. document.getElementById("messageFrame").style.width = "100%";
  302. document.getElementById('menuTabs_and_Props').style.display="none";
  303. //As these statement is used for Quirks mode to Standards mode, so there is no judgement which is set for Quirks mode.
  304. if (browserCheck.isIE5Up() && document.documentMode < 10) { //IE7, IE8, IE9 Standards mode
  305. document.getElementById('menuExpand_button').style.display="block";
  306. }else { //IE10 or upper IE Standards mode and other browser.
  307. document.getElementById('menuExpand_button').style.display="table";
  308. }
  309. }
  310. function expandMenu() {
  311. var size = cfgGet("MenuSize");
  312. if (size == null || isNaN(size)) {
  313. size = 200;
  314. cfgSet("MenuSize");
  315. }
  316. //document.getElementById("menuFrame").style.width = size + "px";
  317. //document.getElementById("messageFrame").style.width = "";
  318. updateMenuFrameWidth(size);
  319. document.getElementById('menuExpand_button').style.display="none";
  320. //As these statement is used for Quirks mode to Standards mode, so there is no judgement which is set for Quirks mode.
  321. if (browserCheck.isIE5Up() && document.documentMode < 10) { //IE7, IE8, IE9 Standards mode
  322. document.getElementById('menuTabs_and_Props').style.display="block";
  323. }else { //IE10 or upper IE Standards mode and other browser.
  324. document.getElementById('menuTabs_and_Props').style.display="table";
  325. }
  326. }
  327. function showAgsMenu(alias){
  328. if (alias==null)
  329. alias=TAB_MODEL;
  330. if (alias != 'closed')
  331. cfgSet("lastMenu", alias);
  332. document.getElementById('div_menu_' + TAB_MODEL).style.display="none";
  333. document.getElementById('div_menu_' + TAB_DATAITEMS).style.display="none";
  334. document.getElementById('div_menu_' + TAB_FUNCTIONS).style.display="none";
  335. document.getElementById('div_menu_' + TAB_PARAMETERS).style.display="none";
  336. document.getElementById('div_menu_' + TAB_HISTORY).style.display="none";
  337. document.getElementById('div_menu_' + TAB_MEMBERS).style.display="none";
  338. if(null != document.getElementById('div_menu_'+alias) ){
  339. if (browserCheck.isIE5Up() && document.documentMode < 10) { // IE7, IE8, IE9 Standards mode
  340. document.getElementById('div_menu_'+alias).style.display="block";
  341. } else { //IE10 or upper IE Standards mode and other browser.
  342. document.getElementById('div_menu_'+alias).style.display="table";
  343. }
  344. var cf = getConfigFrame();
  345. setInsertableObjectsTabContainerHeight();
  346. }
  347. }
  348. // DO NOT USE THIS METHOD OTHER THAN IN HERE - USE THE ABOVE UTIL FUNCTIONS
  349. function changeMenu(alias) {
  350. showAgsMenu(alias);
  351. if (alias == TAB_MODEL && metadataTree == null) {
  352. refreshMetaDataTree();
  353. }
  354. if (alias == TAB_FUNCTIONS && functionsTree == null) {
  355. refreshFunctionsTree();
  356. }
  357. }
  358. // for click and enter key press action
  359. function changeTabMenu(alias) {
  360. showAgsMenu(alias);
  361. if (AccessibilityHandler.isEnabled()) {
  362. AccessibilityHandler.setTabMenuFocus(alias);
  363. }
  364. }
  365. // not sure
  366. function enableResize(bEnable, widthOrHight) {
  367. cfgSet('RESIZING_MENU_PANE', bEnable);
  368. if(widthOrHight == "width" || widthOrHight == "height"){
  369. flag = widthOrHight;
  370. }else{
  371. flag = null;
  372. }
  373. }
  374. // utility function too
  375. /*
  376. Event handler
  377. onmousemove on menu frame's body or report frame's body
  378. This function
  379. resizes the menu pane when the user is dragging the expand icon.
  380. */
  381. function resizeMenuPane(evt, bEventInReportFrame) {
  382. var buttondown;
  383. if (document.documentMode < 10)
  384. buttondown = (evt.button!= null && evt.button == 1);
  385. else if (browserCheck.isNav6Up() || document.documentMode >= 10)
  386. buttondown = (evt.button!= null && evt.button == 0);
  387. if (buttondown && flag == "width") {
  388. var m = document.getElementById("menuFrame");
  389. if (!m)
  390. return;
  391. var size = parseInt(m.style.width);
  392. if (size == null || isNaN(size))
  393. size = 200;
  394. if(!bEventInReportFrame)
  395. size = 0;
  396. if (browserCheck.isIE5Up())
  397. size += evt.x;
  398. else
  399. size += evt.pageX;
  400. if (size < 100)
  401. size = 100;
  402. cfgSet("MenuSize", size);
  403. //m.style.width = size + "px";
  404. updateMenuFrameWidth(size);
  405. }
  406. }
  407. /*
  408. * The two columns that hold the menu frame and message frame are specified
  409. * in terms of a percentage. This function will take a new menu frame width given
  410. * in pixels, convert it into two percentages and set the style widths for both menu
  411. * frame and message frame.
  412. */
  413. function updateMenuFrameWidth(menuFrameWidth) {
  414. var perc;
  415. var menuFrame = document.getElementById('menuFrame');
  416. var parent = document.getElementById('container_float');
  417. var messageFrame = document.getElementById('messageFrame');
  418. var parentWidth=parent.offsetWidth;
  419. perc = Math.round((menuFrameWidth/parentWidth)*100);
  420. //20% is the minimum size for the menu frame
  421. if (perc<=20) {
  422. perc=20;
  423. }
  424. var messageFramePerc = 100-perc;
  425. //set the percentages
  426. menuFrame.style.width=perc+'%';
  427. messageFrame.style.width=messageFramePerc+'%';
  428. }
  429. function moveHorizPane(evt, bEventInReportFrame) {
  430. var buttondown;
  431. if (document.documentMode < 10)
  432. buttondown = (evt.button!= null && evt.button == 1);
  433. else if (browserCheck.isNav6Up() || document.documentMode >= 10)
  434. buttondown = (evt.button!= null && evt.button == 0);
  435. if (buttondown && flag == "height") {
  436. var m = document.getElementById("taskDiv");
  437. if (!m)
  438. return;
  439. var height = parseInt(m.style.height);
  440. if (height == null || isNaN(height))
  441. height = 100;
  442. if(!bEventInReportFrame)
  443. height = 0;
  444. if (browserCheck.isIE5Up())
  445. height = evt.y-100;
  446. else
  447. height += evt.pageY;
  448. if (height > 120)
  449. height = 120;
  450. if (height < 98)
  451. height = 98;
  452. //cfgSet("MenuSize", size);
  453. window.status= "";
  454. m.style.height = height + "px";
  455. m.style.zIndex = -10;
  456. }
  457. }
  458. function AgsDialogTypes(){
  459. this.DIALOG_TYPE_KEY = "AgsDialogType_key"
  460. this.SAVE_SAVEAS = new AgsDialogType("save-saveas");
  461. this.VALIDATE = new AgsDialogType("validate");
  462. this.SCHEDULE = new AgsDialogType("schedule");
  463. this.OPEN_FILE = new AgsDialogType("file-open");
  464. this.SUPPRESSION = new AgsDialogType("suppression");
  465. this.DATAITEMS = new AgsDialogType("dataitems");
  466. this.PARAMETER = new AgsDialogType("paramter");
  467. this.PROMPT = new AgsDialogType("prompt");
  468. this.SEQUENCE_AGENT_TASKS = new AgsDialogType("sequenceagenttasks");
  469. this.NOTIFICATION_LIST = new AgsDialogType("notificationlist");
  470. this.DEFAULT_TASKS_OPTIONS = new AgsDialogType("defaulttasksoptions");
  471. }
  472. AgsDialogTypes.prototype.setCurrentType = function(agsDialogType){
  473. if(agsDialogType && agsDialogType instanceof AgsDialogType){
  474. cfgSet(this.DIALOG_TYPE_KEY, agsDialogType);
  475. }
  476. }
  477. AgsDialogTypes.prototype.getCurrentType = function(agsDialogType){
  478. return cfgGet(this.DIALOG_TYPE_KEY);
  479. }
  480. AgsDialogTypes.prototype.isCurrentType = function(){
  481. if(agsDialogType && agsDialogType instanceof AgsDialogType){
  482. var currentType = cfgGet(this.DIALOG_TYPE_KEY);
  483. return agsDialogType.equals(currentType);
  484. }
  485. return false;
  486. }
  487. function AgsDialogType(type){
  488. this.equals = equals;
  489. this.agsDialogType = type;
  490. function equals(another){
  491. var isEqual = false;
  492. if(another instanceof AgsDialogType){
  493. isEqual = another.agsDialogType == this.agsDialogType;
  494. }
  495. return isEqual;
  496. }
  497. }
  498. //use this as a one off
  499. var agsDialogTypes = new AgsDialogTypes();