drag.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. /********************************************************************************************************************************
  2. * Licensed Materials - Property of IBM *
  3. * *
  4. * IBM Cognos Products: AGS *
  5. * *
  6. * (C) Copyright IBM Corp. 2005, 2008 *
  7. * *
  8. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *
  9. *********************************************************************************************************************************/
  10. var dragapproved=false;
  11. var dragToolTip;
  12. var oldDropZone;
  13. var dragData;
  14. var selTab;
  15. var dragItem;
  16. var nextZoneId;
  17. parent.doAction = doAction;
  18. function drag_move(evt){
  19. evt = (evt) ? evt : ((event) ? event : null);
  20. dragToolTip.style.display = "";
  21. if (dragapproved==true){
  22. dragToolTip.style.left = (evt.clientX+20) + "px";
  23. dragToolTip.style.top = evt.clientY + "px";
  24. return false;
  25. }
  26. }
  27. // select the tab
  28. function selectTab(tabId, type)
  29. {
  30. var cf = window.parent.getConfigFrame();
  31. if(cf.applicationActionManager.isBlocked()){
  32. return;
  33. }
  34. if(!cf.agsDialogTypes.VALIDATE.equals(cf.agsDialogTypes.getCurrentType())){
  35. cf.hideDialogFrame();
  36. }
  37. if(submitAndGo()){
  38. //block until page is reloaded
  39. cf.applicationActionManager.blockActions();
  40. // we're replacing the current selected tab - keep the old value
  41. selTab = document.getElementById('tabSelectedID');
  42. //guard clause, scheduling is not available
  43. if (typeof parent.userCanUseSched != 'undefined' && parent.userCanUseSched==false && type=='schedule') {
  44. return;
  45. }
  46. selTab.value = tabId;
  47. // and call submit on the form to proceed - explicitly setting variables as we go.
  48. document.pform.m.value='/ags/dialogAdapter.xts';
  49. document.pform.ps_nav_op.value='';
  50. //reset the undo state
  51. cf.getRedoUndoManager().resetTreeAction();
  52. //clear the tab as a delete candidate (will get set on load)
  53. cf.deletionCandidateManager.clearCandidate();
  54. // submit the form
  55. document.pform.submit();
  56. }
  57. }
  58. /*
  59. * Fired when the user clicks on a selected tab. In this case we set
  60. * the task as a valid deletion candidate
  61. */
  62. function selectCurrentTab(tabId, type)
  63. {
  64. var cf = window.parent.getConfigFrame();
  65. //set the tab as a delete candidate
  66. parent.deletionCandidateManager.setCandidate('tabSelectedID',cf.K_sControlCandidate);
  67. }
  68. // function used to create a task - so doAction is a bad name as it happens.
  69. // arguments:
  70. // taskType : the type of task that you want created. Either
  71. // "message", "report", "sql", "job", "agent" or "web"
  72. function doAction(taskType) {
  73. var cf = window.parent.getConfigFrame();
  74. if(cf.applicationActionManager.isBlocked()){
  75. return;
  76. }
  77. // hide save/save_as dialog
  78. if(cf.hideDialogFrame)cf.hideDialogFrame();
  79. if(submitAndGo()){
  80. // we're replacing the current tab - keep the old value
  81. document.pform.tabSelectedID.value=taskType;
  82. document.pform.newTaskType.value=taskType;
  83. // set agent state
  84. cf.agentHasChanged(true);
  85. //reset the undo state
  86. cf.getRedoUndoManager().resetTreeAction();
  87. // if sql task then pass in the default package name
  88. if(taskType=='sql'){
  89. var packRoot = document.createElement("input");
  90. packRoot.setAttribute('type', 'hidden');
  91. packRoot.setAttribute('name', 'packRoot');
  92. packRoot.value= decodeURIComponent(cf.cfgGet('PackageRoot'));
  93. document.pform.appendChild(packRoot);
  94. }
  95. //block until page is reloaded
  96. parent.applicationActionManager.blockActions();
  97. //
  98. document.pform.m.value='/ags/dialogAdapter.xts';
  99. document.pform.ps_nav_op.value='';
  100. document.pform.submit();
  101. }
  102. }
  103. /*
  104. The function leavingDialog should exist in the page if it has some extra info
  105. to be submitted, currently email options page does that.
  106. */
  107. function submitAndGo()
  108. {
  109. if(window.leavingDialog){
  110. //if we have any more info to operate
  111. leavingDialog();
  112. }
  113. return true;
  114. }
  115. // allows drop only if the item being dragged is different from drop area item
  116. function onDrop(evt, dropedOnItemName)
  117. {
  118. evt = (evt) ? evt : ((event) ? event : null);
  119. if(dragapproved && dropedOnItemName!=dragData)
  120. {
  121. dropOnItem = document.getElementById('itemNewLocation');
  122. if(dropOnItem != null) {
  123. dropOnItem.value = dropedOnItemName;
  124. }
  125. // item being dragged, we save its id so that we know what
  126. // requires to be shuffled upon reloading of the page
  127. draggedItem = document.getElementById('itemSelected');
  128. if(draggedItem != null) {
  129. draggedItem.value = dragData;
  130. }
  131. // now set the form action to shuffle
  132. setAgentItemOp('shuffle');
  133. //the task ordering has changed, so update the agent change state
  134. cf.agentHasChanged(true);
  135. // and call submit on the form to proceed
  136. document.pform.submit();
  137. }
  138. }
  139. // set the agent item operation - this should have values of
  140. // 'shuffle', 'move_up', 'move_way_up', 'move_down', 'move_way_down'
  141. function setAgentItemOp(operation)
  142. {
  143. agentOperation = document.getElementById('agentItemOp');
  144. agentOperation.value = operation;
  145. }
  146. function initdragie(evt, label, icon, dragInfo, nextItemId)
  147. {
  148. var cf = window.parent.getConfigFrame();
  149. // hide save/save_as dialog
  150. if(cf.hideDialogs)cf.hideDialogs();
  151. evt = (evt) ? evt : ((event) ? event : null);
  152. dragapproved=true;
  153. dragData = dragInfo;
  154. dragToolTip = document.getElementById('dragTip');
  155. // if we reach in this we might see flicker of scrollbars in browser
  156. if(dragToolTip == null){
  157. dragToolTip = document.createElement("div");
  158. dragToolTip.setAttribute("id", "dragTip");
  159. dragToolTip.setAttribute("style", "z-index:100");
  160. //dragToolTip.setAttribute("class", "tooltip");
  161. document.body.appendChild(dragToolTip);
  162. }
  163. nextZoneId = nextItemId;
  164. var it = "<table class=\"tooltip\" cellpadding=\"0\" cellspacing=\"1\"><tr> <td valign=\"middle\"> <img width=\"16\" height=\"16\" src=\"" + icon + "\"/> </td> <td id=\"taskActionName\" valign=\"middle\">&nbsp;</td></tr></table>";
  165. // we are ready with the dragtip but will show it when user moves the mouse
  166. //dragToolTip.style.visibility = "hidden";
  167. if (dragToolTip) {
  168. dragToolTip.innerHTML = it;
  169. var taskActionName = document.getElementById('taskActionName');
  170. taskActionName.firstChild.nodeValue=label;
  171. dragToolTip.style.zIndex = 100;
  172. dragToolTip.style.position = "absolute";
  173. dragToolTip.style.left = (evt.clientX+20) + "px";
  174. dragToolTip.style.top = evt.clientY + "px";
  175. dragToolTip.style.display = "inline";
  176. }
  177. tempx = dragToolTip.style.pixelLeft;
  178. tempy = dragToolTip.style.pixelTop;
  179. iex=evt.clientX;
  180. iey=evt.clientY;
  181. window.status = '';
  182. if (document.all) {
  183. document.attachEvent("onmousemove", drag_move);
  184. document.attachEvent("onmouseup", stopdrag);
  185. } else {
  186. document.addEventListener("mousemove", drag_move, false);
  187. document.addEventListener("mouseup", stopdrag, false);
  188. }
  189. }
  190. function dropZoneActive(evt, zoneID){
  191. evt = (evt) ? evt : ((event) ? event : null);
  192. var blinkCaret = "../ags/images/summary/drop_caret.gif";
  193. // allows drop only if the item being dragged is different from drop area item
  194. if(dragapproved && zoneID!=dragData && zoneID!=nextZoneId) {
  195. var external_dropZone = document.getElementById(zoneID+"_external");
  196. var internal_dropZone = document.getElementById(zoneID+"_internal");
  197. // make the external one visible
  198. external_dropZone.className='external_div';
  199. // set the image into the inner one
  200. internal_dropZone.src = blinkCaret;
  201. }
  202. // stop this going any further
  203. evt.cancelBubble=true;
  204. }
  205. function dropZoneInactive(evt, zoneID){
  206. evt = (evt) ? evt : ((event) ? event : null);
  207. var emptyCaret = "../ags/images/spacer.gif";
  208. var external_dropZone = document.getElementById(zoneID+"_external");
  209. var internal_dropZone = document.getElementById(zoneID+"_internal");
  210. // make the external one hidden again
  211. external_dropZone.className='external_div_hidden';
  212. // set the image into the inner one
  213. internal_dropZone.src = emptyCaret;
  214. // stop this going any further
  215. evt.cancelBubble=true;
  216. }
  217. function stopdrag(evt){
  218. evt = (evt) ? evt : ((event) ? event : null);
  219. dragapproved=false;
  220. dragToolTip.style.display = "none";
  221. dragToolTip.onmousemove=null;
  222. if (document.all) {
  223. document.detachEvent("onmousemove",drag_move);
  224. document.detachEvent("onmouseup",stopdrag);
  225. }
  226. else {
  227. document.removeEventListener("mousemove",drag_move, false);
  228. document.removeEventListener("mouseup", stopdrag, false);
  229. }
  230. }
  231. var resizeCount = 0;
  232. // set scrollbar div view width
  233. function setBarSize(event)
  234. {
  235. // get the size of the two button area's
  236. var flyOut = document.getElementById("flyout_td");
  237. if(!flyOut){
  238. //not finished page drawing
  239. setTimeout("setBarSize()", 100);
  240. return;
  241. }
  242. var left_button_size = flyOut.offsetWidth;
  243. var scrollTd = document.getElementById("scroll_td");
  244. var right_button_size = scrollTd.offsetWidth;
  245. // get the size for the both - and add an offset
  246. var size = left_button_size + right_button_size + 10;
  247. // alter the size of the body if we can
  248. if(document.body.offsetWidth > size){
  249. document.getElementById("SummaryBarScrollpane").style.width=document.body.offsetWidth-size + "px";
  250. document.getElementById("SummaryBarScrollpane2").style.width=document.body.offsetWidth-size + "px";
  251. }
  252. //Now adjust horizontal and vertical scroll bars of the IFrame so that they
  253. //are moved to the Div d2.
  254. var newHeight = document.body.offsetHeight-(document.getElementById("d1").offsetHeight+15);
  255. // this can be negative if window is too small or save as dialog is shown
  256. if(newHeight>0){
  257. document.getElementById("d2").style.height = newHeight;
  258. } else {
  259. document.getElementById("d2").style.height = 10;
  260. }
  261. var newWidth = document.body.offsetWidth - 15;
  262. if(newWidth>0){
  263. document.getElementById("d2").style.width = newWidth;
  264. } else{
  265. document.getElementById("d2").style.width = 10;
  266. }
  267. leftRightController();
  268. //COGCQ00242304 - Unable to attach multiple reports to an email in Event Studio using IE7
  269. //This should deal with email options attachment menu.
  270. //This is when Portal puts the code in.
  271. /*if (window.removeAttachmentMenuListener && window.showMenu) {
  272. if (window.attachmentMenu && window.attachmentMenu.isVisible()) {
  273. window.removeAttachmentMenuListener();
  274. //This will toggle it.
  275. window.showMenu();
  276. }
  277. }*/
  278. }
  279. /*
  280. This function finds out if the content of summary bar is out of view area
  281. if it so then enables or disables the left/right scroll buttons
  282. */
  283. function leftRightController(){
  284. var summaryBarScrollpane2 = document.getElementById("SummaryBarScrollpane2");
  285. var scrollLeft = document.getElementById("scroll_left");
  286. if( summaryBarScrollpane2.scrollLeft <= 0 ){
  287. scrollLeft.className = "button";
  288. scrollLeft.innerHTML = '<IMG alt="" src="../ags/images/summary/summary_scroll_left_dis.gif"/>' ;
  289. scrollLeft.onmousedown = null;
  290. }else{
  291. scrollLeft.innerHTML = '<IMG alt="" src="../ags/images/summary/summary_scroll_left.gif"/>' ;
  292. scrollLeft.onmousedown = scrollLeftDown;
  293. }
  294. var shoScrollRight = summaryBarScrollpane2.scrollWidth - (summaryBarScrollpane2.scrollLeft + summaryBarScrollpane2.clientWidth) ;
  295. var scrollRight = document.getElementById("scroll_right");
  296. if( shoScrollRight > 0){
  297. scrollRight.innerHTML = '<IMG alt="" src="../ags/images/summary/summary_scroll_right.gif"/>' ;
  298. scrollRight.onmousedown = scrollRightDown;
  299. }else{
  300. scrollRight.className = "button";
  301. scrollRight.innerHTML = '<IMG alt="" src="../ags/images/summary/summary_scroll_right_dis.gif"/>' ;
  302. scrollRight.onmousedown = null;
  303. }
  304. }
  305. // scroll left the view in the scrollbar div
  306. function goLeft(){
  307. for(var i=0; i < 20; i++){
  308. document.getElementById("SummaryBarScrollpane").scrollLeft -=2;
  309. document.getElementById("SummaryBarScrollpane2").scrollLeft -=2;
  310. }
  311. leftRightController();
  312. }
  313. // scroll right the view in the scrollbar div
  314. function goRight(){
  315. for(var i=0; i < 20; i++){
  316. document.getElementById("SummaryBarScrollpane").scrollLeft +=2;
  317. document.getElementById("SummaryBarScrollpane2").scrollLeft +=2;
  318. }
  319. leftRightController();
  320. }
  321. // scroll left down
  322. function scrollLeftDown(){
  323. document.getElementById('scroll_left').className='button_pressed';
  324. window.status='';
  325. goLeft();
  326. return true;
  327. }
  328. // scroll left down
  329. function scrollRightDown(){
  330. document.getElementById('scroll_right').className='button_pressed';
  331. window.status='';
  332. goRight();
  333. return true;
  334. }
  335. // move focus to the selected button
  336. function setFocusToSelectedTab(){
  337. // item_selected is the name of the selected tab so we find
  338. // its co-ordinates and set focus to it
  339. var myObj = document.getElementById('item_selected') ;
  340. if(null!=myObj){
  341. var summaryBarScrollpane = document.getElementById("SummaryBarScrollpane");
  342. var summaryBarScrollpane2 = document.getElementById("SummaryBarScrollpane2");
  343. var offx = myObj.offsetLeft ;
  344. if(offx > (summaryBarScrollpane.offsetWidth-myObj.offsetWidth-10)){
  345. summaryBarScrollpane.scrollLeft = offx-summaryBarScrollpane.offsetWidth+myObj.offsetWidth+10;
  346. summaryBarScrollpane2.scrollLeft = offx-summaryBarScrollpane.offsetWidth+myObj.offsetWidth+10;
  347. //moveInSteps(offx-summaryBarScrollpane.offsetWidth+myObj.offsetWidth+10);
  348. }
  349. }
  350. // set the item in task menu active
  351. highlightSelectedMenuItem();
  352. }
  353. function highlightSelectedMenuItem(){
  354. //get the id of the selected tab
  355. var selType = document.getElementById('tabSelectedID').value;
  356. if (selType.match('AgentTask-condition'))
  357. {
  358. selType = parent.K_sCondition;
  359. }
  360. parent.makeSelection(selType);
  361. }
  362. function moveInSteps(x){
  363. var summaryBarScrollpane = document.getElementById("SummaryBarScrollpane");
  364. var summaryBarScrollpane2 = document.getElementById("SummaryBarScrollpane2");
  365. var lx = x-60;
  366. summaryBarScrollpane.scrollLeft = lx;
  367. summaryBarScrollpane2.scrollLeft = lx;
  368. for(var i=0; i < 30; i++){
  369. summaryBarScrollpane.scrollLeft +=2;
  370. summaryBarScrollpane2.scrollLeft +=2;
  371. }
  372. }
  373. function openTask(idAndType)
  374. {
  375. // Remarks: if anypage id has this %% in its id this code can misbehave
  376. if (idAndType == "" || idAndType == null) return;
  377. var sepX = idAndType.indexOf('%%');
  378. if(sepX > -1){
  379. id = idAndType.substring(0, sepX);
  380. type = idAndType.substring(sepX+2);
  381. selectTab(id, type);
  382. }
  383. }
  384. function doSelectObject(mode, selectedObject){
  385. var cf = window.parent.getConfigFrame();
  386. cf.doSelectObject(mode, selectedObject);
  387. }