cv.js 79 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| IBM Cognos Products: Viewer
  5. *| (C) Copyright IBM Corp. 2001, 2021
  6. *|
  7. *| US Government Users Restricted Rights - Use, duplication or
  8. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. *|
  10. *+------------------------------------------------------------------------+
  11. */
  12. var __excel_win = null;
  13. var __pdf_win = null;
  14. if (window.attachEvent)
  15. {
  16. window.attachEvent("onkeydown", viewerMainKeyPress);
  17. window.attachEvent("onresize", onResizeViewerEvent);
  18. }
  19. else if (window.addEventListener)
  20. {
  21. window.addEventListener("keydown", viewerMainKeyPress, false);
  22. window.addEventListener("resize", onResizeViewerEvent, false);
  23. }
  24. function attachLeavingRV() {
  25. if (window.attachEvent)
  26. {
  27. window.attachEvent("onbeforeunload", leavingRV);
  28. }
  29. else if (window.addEventListener)
  30. {
  31. window.addEventListener("beforeunload", leavingRV, false);
  32. }
  33. else
  34. {
  35. // We should not get here, but just in case for older browsers.
  36. try
  37. {
  38. var oUnload = window.onunload;
  39. // add leavingRV if not already in the onunload events
  40. if ( !(""+oUnload).match(/leavingRV/gi) )
  41. {
  42. window.oLeavingRV_onunload = window.onunload;
  43. window.onunload = function()
  44. {
  45. window.oLeavingRV_onunload();
  46. leavingRV();
  47. };
  48. }
  49. }
  50. catch (e)
  51. {
  52. // Can't set unload event.
  53. }
  54. }
  55. }
  56. function detachLeavingRV() {
  57. if (window.detachEvent)
  58. {
  59. window.detachEvent("onbeforeunload", leavingRV);
  60. }
  61. else
  62. {
  63. window.removeEventListener("beforeunload", leavingRV, false);
  64. }
  65. }
  66. window.attachLeavingRV();
  67. function CContextMenu(rvMainWnd) {
  68. if (rvMainWnd == null) {
  69. return;
  70. }
  71. /**
  72. A reference to CMainWnd associated with this context menu.
  73. @type CMainWnd
  74. */
  75. this.m_mainWnd = rvMainWnd;
  76. this.setCV(this.m_mainWnd.getCV());
  77. var sWebContentRoot = this.m_mainWnd.getCV().getWebContentRoot();
  78. var sSkin = this.m_mainWnd.getCV().getSkin();
  79. var sBlacklist = this.m_mainWnd.getUIHide();
  80. /**
  81. A reference to localized strings from CCognosViewer (used as shortcut).
  82. @type object
  83. */
  84. this.m_contextMenu = new CMenu('rvContextMenu' + this.getCVId(),gMenuStyle, sWebContentRoot);
  85. this.m_contextMenu.m_oCV = this.getCV();
  86. // Download chart menu item
  87. this.m_downloadChart = new CMenuItem(this.m_contextMenu, RV_RES.RV_DOWNLOAD_CHART, "if(typeof " + getCognosViewerSCObjectRefAsString(this.getCVId()) + " != \'undefined\') " + getCognosViewerSCObjectRefAsString(this.getCVId()) + ".downloadSelectedChartImage('" + this.getCVId() + "');", sWebContentRoot + '/rv/images/action_chart.gif', gMenuItemStyle, sWebContentRoot, sSkin);
  88. this.m_downloadChart.hide();
  89. // Context Menu Seperator
  90. this.m_downloadChartSeperator = new CSeperator('horizontal_line'+this.getCVId(), '1',gMenuSeperatorStyle, sWebContentRoot);
  91. this.m_downloadChartSeperator.hide();
  92. this.m_contextMenu.add(this.m_downloadChartSeperator);
  93. // drill down item
  94. var oDrillMgr = this.getCV().getDrillMgr();
  95. if(oDrillMgr)
  96. {
  97. if(typeof RV_RES.RV_DRILL_DOWN != "undefined")
  98. {
  99. this.m_drillDown = new CMenuItem(this.m_contextMenu, RV_RES.RV_DRILL_DOWN, this.getCVObjectRef() + ".getDrillMgr().rvDrillDown();", sWebContentRoot + '/rv/images/action_drill_down.gif', gMenuItemStyle, sWebContentRoot, sSkin);
  100. this.m_drillDown.disable();
  101. }
  102. // drill up
  103. if(typeof RV_RES.RV_DRILL_UP != "undefined")
  104. {
  105. this.m_drillUp = new CMenuItem(this.m_contextMenu, RV_RES.RV_DRILL_UP, this.getCVObjectRef() + ".getDrillMgr().rvDrillUp();", sWebContentRoot + '/rv/images/action_drill_up.gif', gMenuItemStyle, sWebContentRoot, sSkin);
  106. this.m_drillUp.disable();
  107. }
  108. if(this.getCV().isInteractiveViewer() && this.getCV().getAdvancedServerProperty("VIEWER_JS_ENABLE_EXPAND_COLLAPSE") == "true") {
  109. // Context Menu Separator
  110. this.m_contextMenu.add(gMenuSeperator);
  111. if(typeof RV_RES.IDS_JS_EXPAND_MEMBER != "undefined") {
  112. this.m_expand = new CMenuItem(this.m_contextMenu, RV_RES.IDS_JS_EXPAND_MEMBER, this.getCVObjectRef() + ".expand();", "", gMenuItemStyle, sWebContentRoot, sSkin);
  113. this.m_expand.disable();
  114. }
  115. if(typeof RV_RES.IDS_JS_COLLAPSE_MEMBER != "undefined") {
  116. this.m_collapse = new CMenuItem(this.m_contextMenu, RV_RES.IDS_JS_COLLAPSE_MEMBER, this.getCVObjectRef() + ".collapse();", "", gMenuItemStyle, sWebContentRoot, sSkin);
  117. this.m_collapse.disable();
  118. }
  119. }
  120. if ((!this.getCV().m_viewerFragment || this.getCV().envParams["ui.action"] != "view") && typeof RV_RES.IDS_JS_FREEZECOLUMNHEADINGS !== "undefined" && typeof RV_RES.IDS_JS_FREEZEROWHEADINGS !== "undefined") {
  121. this.m_freezeRowHeadings = new CMenuItem(this.m_contextMenu, RV_RES.IDS_JS_FREEZEROWHEADINGS, this.getCVObjectRef() + ".getPinFreezeManager().freezeSelectedRowHeadings();", sWebContentRoot + '/rv/images/action_freeze_row_heading.gif', gMenuItemStyle, sWebContentRoot, sSkin);
  122. this.m_unfreezeRowHeadings = new CMenuItem(this.m_contextMenu, RV_RES.IDS_JS_UNFREEZEROWHEADINGS, this.getCVObjectRef() + ".getPinFreezeManager().unfreezeSelectedRowHeadings();", sWebContentRoot + '/rv/images/action_freeze_row_heading.gif', gMenuItemStyle, sWebContentRoot, sSkin);
  123. this.m_freezeColumnHeadings = new CMenuItem(this.m_contextMenu, RV_RES.IDS_JS_FREEZECOLUMNHEADINGS, this.getCVObjectRef() + ".getPinFreezeManager().freezeSelectedColumnHeadings();", sWebContentRoot + '/rv/images/action_freeze_column_heading.gif', gMenuItemStyle, sWebContentRoot, sSkin);
  124. this.m_unfreezeColumnHeadings = new CMenuItem(this.m_contextMenu, RV_RES.IDS_JS_UNFREEZECOLUMNHEADINGS, this.getCVObjectRef() + ".getPinFreezeManager().unfreezeSelectedColumnHeadings();", sWebContentRoot + '/rv/images/action_freeze_column_heading.gif', gMenuItemStyle, sWebContentRoot, sSkin);
  125. this.m_freezeColumnHeadings.hide();
  126. this.m_unfreezeColumnHeadings.hide();
  127. this.m_freezeRowHeadings.hide();
  128. this.m_unfreezeRowHeadings.hide();
  129. }
  130. if(typeof RV_RES.RV_GO_TO != "undefined")
  131. {
  132. if(sBlacklist.indexOf(' RV_CONTEXT_MENU_GOTO ') == -1)
  133. {
  134. // seperator
  135. if (sBlacklist.indexOf(' RV_CONTEXT_MENU_DRILL_UP ') == -1 || !sBlacklist.indexOf(' RV_CONTEXT_MENU_DRILL_DOWN ') == -1) {
  136. this.m_contextMenu.add(gMenuSeperator);
  137. }
  138. }
  139. // go to
  140. this.m_goto = new CMenuItem(this.m_contextMenu, RV_RES.RV_GO_TO, this.getCVObjectRef() + ".getDrillMgr().launchGoToPage(null,true);", sWebContentRoot + "/rv/images/action_go_to.gif", gMenuItemStyle, sWebContentRoot, sSkin);
  141. var drillThroughMenu = this.m_goto.createCascadedMenu(gMenuStyle);
  142. drillThroughMenu.m_oCV = this.getCV();
  143. if (this.getCV().envParams["cv.containerApp"] == "AA")
  144. {
  145. drillThroughMenu.registerCallback(this.getCVObjectRef() + ".m_viewerFragment.raiseGotoContextMenuEvent()");
  146. }
  147. else
  148. {
  149. drillThroughMenu.registerCallback(this.getCVObjectRef() + ".getDrillMgr().getDrillThroughParameters()");
  150. }
  151. }
  152. }
  153. var subsMan = this.getCV().getSubscriptionManager();
  154. if (subsMan && this.getCV().bCanUseCognosViewerConditionalSubscriptions)
  155. {
  156. this.m_subscriptionSeperator = new CSeperator('horizontal_line', '1',gMenuSeperatorStyle, sWebContentRoot);
  157. this.m_subscriptionSeperator.hide();
  158. this.m_contextMenu.add(this.m_subscriptionSeperator);
  159. // custom subscriptions
  160. if(RV_RES.RV_NEW_WATCH_RULE)
  161. {
  162. this.m_subscription = new CMenuItem(this.m_contextMenu, RV_RES.RV_NEW_WATCH_RULE, this.getCVObjectRef() + ".getSubscriptionManager().NewSubscription();", sWebContentRoot + '/rv/images/action_new_subscription.gif', gMenuItemStyle, sWebContentRoot, sSkin);
  163. this.m_subscription.disable();
  164. }
  165. }
  166. var bGlossary = false;
  167. if(this.getCV().bCanUseGlossary && RV_RES.RV_GLOSSARY && sBlacklist.indexOf(' RV_CONTEXT_MENU_GLOSSARY ') == -1)
  168. {
  169. bGlossary = true;
  170. this.m_contextMenu.add(gMenuSeperator);
  171. this.m_glossaryItem = new CMenuItem(this.m_contextMenu, RV_RES.RV_GLOSSARY, this.getCVObjectRef() + ".executeAction('Glossary');", sWebContentRoot + '/rv/images/action_glossary.gif', gMenuItemStyle, sWebContentRoot, sSkin);
  172. this.m_glossaryItem.disable();
  173. }
  174. if (this.isLinegaeVisisble(sBlacklist))
  175. {
  176. if (!bGlossary)
  177. {
  178. this.m_contextMenu.add(gMenuSeperator);
  179. }
  180. this.m_lineageItem = new CMenuItem(this.m_contextMenu, RV_RES.RV_LINEAGE, this.getCVObjectRef() + ".executeAction('Lineage');", sWebContentRoot + '/rv/images/action_lineage.gif', gMenuItemStyle, sWebContentRoot, sSkin);
  181. this.m_lineageItem.disable();
  182. }
  183. }
  184. CContextMenu.prototype = new CViewerHelper();
  185. CContextMenu.prototype.isLinegaeVisisble = function(sBlacklist)
  186. {
  187. if(!isSafari() && this.getCV().bCanUseLineage && RV_RES.RV_LINEAGE && sBlacklist.indexOf(' RV_CONTEXT_MENU_LINEAGE ') == -1)
  188. {
  189. // don't allow lineage for reports ran from a studio if the lineage URI is getting redirected to another provider
  190. if (this.getCV().envParams["ui.object"] || (this.getCV().envParams["metadataInformationURI"] && this.getCV().envParams["metadataInformationURI"].indexOf("iis=") == -1))
  191. {
  192. return true;
  193. }
  194. }
  195. return false;
  196. };
  197. /**
  198. * Cleans up the menu since we never want the first visible menuItem to be a seperator.
  199. */
  200. CContextMenu.prototype.hideFirstSeperators = function()
  201. {
  202. var contextMenuLength = this.m_contextMenu.m_menuItems.length;
  203. for (var iIndex = 0; iIndex < contextMenuLength; iIndex++)
  204. {
  205. var menuItem = this.m_contextMenu.m_menuItems[iIndex];
  206. if (menuItem.isVisible() && typeof menuItem.m_toolbarSeperatorClass != "string")
  207. {
  208. break;
  209. }
  210. else if (typeof menuItem.m_toolbarSeperatorClass == "string")
  211. {
  212. menuItem.hide();
  213. }
  214. }
  215. };
  216. /**
  217. * update the freeze headings options
  218. */
  219. CContextMenu.prototype.updateFreezeHeadings = function()
  220. {
  221. if (this.getCV().m_viewerFragment || this.getCV().envParams["ui.action"] == "view") {
  222. return;
  223. }
  224. if (this.getCV().getPinFreezeManager()) {
  225. var oPinFreezeManager=this.getCV().getPinFreezeManager();
  226. if (this.m_freezeRowHeadings) {
  227. if (oPinFreezeManager.canFreezeSelectedRowHeadings()) {
  228. this.m_freezeRowHeadings.show();
  229. } else {
  230. this.m_freezeRowHeadings.hide();
  231. }
  232. }
  233. if (this.m_unfreezeRowHeadings) {
  234. if (oPinFreezeManager.canUnfreezeSelectedRowHeadings()) {
  235. this.m_unfreezeRowHeadings.show();
  236. } else {
  237. this.m_unfreezeRowHeadings.hide();
  238. }
  239. }
  240. if (this.m_freezeColumnHeadings) {
  241. if (oPinFreezeManager.canFreezeSelectedColumnHeadings()) {
  242. this.m_freezeColumnHeadings.show();
  243. } else {
  244. this.m_freezeColumnHeadings.hide();
  245. }
  246. }
  247. if (this.m_unfreezeColumnHeadings) {
  248. if (oPinFreezeManager.canUnfreezeSelectedColumnHeadings()) {
  249. this.m_unfreezeColumnHeadings.show();
  250. } else {
  251. this.m_unfreezeColumnHeadings.hide();
  252. }
  253. }
  254. }
  255. };
  256. function CContextMenu_draw(evt) {
  257. this.updateSubscriptionContextMenuItem();
  258. if (this.m_bFaultModalShown)
  259. {
  260. this.update(this.subject);
  261. this.m_bFaultModalShown = false;
  262. }
  263. this.hideFirstSeperators();
  264. this.m_contextMenu.remove(); // calling remove() to make sure all existing sub items are removed/updated correctly when this menu is updated
  265. this.m_contextMenu.setHTMLContainer(document.body);
  266. this.m_contextMenu.draw();
  267. // In IE, if we're showing the context menu from a keyboard event
  268. // we need to calculate the coords of the DOM element
  269. if (isIE() && evt.keyCode && evt.keyCode != 0) {
  270. var node = getCrossBrowserNode(evt);
  271. var coords = clientToScreenCoords(node, document.body);
  272. this.m_contextMenu.setXCoord(coords.leftCoord + node.scrollWidth);
  273. this.m_contextMenu.setYCoord(coords.topCoord);
  274. }
  275. else {
  276. this.m_contextMenu.setXCoord(evt.clientX);
  277. this.m_contextMenu.setYCoord(evt.clientY);
  278. }
  279. // We might be displaying a log on page, if we are, don't show the menu
  280. if (getCVWaitingOnFault() == null)
  281. {
  282. this.m_contextMenu.show();
  283. this.m_bFaultModalShown = false;
  284. }
  285. else
  286. {
  287. this.m_bFaultModalShown = true;
  288. }
  289. var lastMenuItem = this.m_contextMenu.get(this.m_contextMenu.getNumItems()-1);
  290. if(lastMenuItem && typeof lastMenuItem.getObservers == "function" && typeof lastMenuItem.getObservers() == "object")
  291. {
  292. lastMenuItem.getObservers().attach(this, this.closeMenuTabEvent, "CMenuItem_closeMenuTabEvent");
  293. }
  294. }
  295. function CContextMenu_getDrillUpMenuItem() {
  296. return this.m_drillUp;
  297. }
  298. function CContextMenu_getDrillDownMenuItem() {
  299. return this.m_drillDown;
  300. }
  301. function CContextMenu_getGoToMenuItem() {
  302. return this.m_goto;
  303. }
  304. /**
  305. * Called when the context menu gets closed because the user tabbed past the last item in the context menu.
  306. * Sets the focus back to the last selected cell
  307. */
  308. function CContextMenu_closeMenuTabEvent() {
  309. var oCV = this.m_mainWnd.getCV();
  310. var selectionController = oCV.getSelectionController();
  311. var selLength = selectionController.getAllSelectedObjects().length;
  312. if (selLength > 0) {
  313. // get the last selected cell
  314. var selection = selectionController.getAllSelectedObjects()[selLength - 1];
  315. var allChildren = selection.getCellRef().getElementsByTagName("span");
  316. if (allChildren.length > 0) {
  317. for (var i = 0; i < allChildren.length; i++) {
  318. var span = allChildren[i];
  319. if (span.getAttribute("tabindex") != null && span.style.visibility != "hidden") {
  320. span.focus();
  321. }
  322. }
  323. }
  324. }
  325. }
  326. function CContextMenu_hide() {
  327. this.m_contextMenu.remove();
  328. }
  329. function CContextMenu_hideDownloadChartMenuItem() {
  330. this.m_downloadChart.hide();
  331. this.m_downloadChartSeperator.hide();
  332. }
  333. function CContextMenu_showDownloadChartMenuItem() {
  334. this.m_downloadChart.show();
  335. this.m_downloadChartSeperator.show();
  336. }
  337. function CContextMenu_update(subject)
  338. {
  339. if(subject instanceof CSelectionController)
  340. {
  341. this.subject = subject;
  342. var sBlacklist = this.m_mainWnd.getUIHide();
  343. var oDrillMgr = this.getCV().getDrillMgr();
  344. if(oDrillMgr)
  345. {
  346. var oGotoMenuItem = this.getGoToMenuItem();
  347. var oMenu = oGotoMenuItem.getMenu();
  348. if(oMenu)
  349. {
  350. // when the selection changes clear out the cached report drill targets (if any)
  351. oMenu.clear();
  352. }
  353. if (!subject.getSelectionBasedFeaturesEnabled() || sBlacklist.indexOf(' RV_CONTEXT_MENU_GOTO ') != -1) {
  354. oGotoMenuItem.hide();
  355. }
  356. var oDrillDownMenuItem = this.getDrillDownMenuItem();
  357. if (sBlacklist.indexOf(' RV_CONTEXT_MENU_DRILL_DOWN ') != -1)
  358. {
  359. oDrillDownMenuItem.hide();
  360. }
  361. else if(oDrillMgr.canDrillDown())
  362. {
  363. this.updateDrillMenu(oDrillDownMenuItem, "DrillDown");
  364. oDrillDownMenuItem.enable();
  365. }
  366. else
  367. {
  368. if (!subject.getSelectionBasedFeaturesEnabled()) {
  369. oDrillDownMenuItem.hide();
  370. } else {
  371. oDrillDownMenuItem.disable();
  372. }
  373. }
  374. var oDrillUpMenuItem = this.getDrillUpMenuItem();
  375. if (sBlacklist.indexOf(' RV_CONTEXT_MENU_DRILL_UP ') != -1)
  376. {
  377. oDrillUpMenuItem.hide();
  378. }
  379. if(oDrillMgr.canDrillUp())
  380. {
  381. this.updateDrillMenu(oDrillUpMenuItem, "DrillUp");
  382. oDrillUpMenuItem.enable();
  383. }
  384. else
  385. {
  386. if (!subject.getSelectionBasedFeaturesEnabled()) {
  387. oDrillUpMenuItem.hide();
  388. gMenuSeperator.hide();
  389. } else {
  390. oDrillUpMenuItem.disable();
  391. }
  392. }
  393. if(this.m_expand) {
  394. this.getCV().canExpand() ? this.m_expand.enable() : this.m_expand.disable();
  395. }
  396. if(this.m_collapse) {
  397. this.getCV().canCollapse() ? this.m_collapse.enable() : this.m_collapse.disable();
  398. }
  399. if (sBlacklist.indexOf(' RV_CONTEXT_MENU_DOWNLOAD_CHART ') != -1)
  400. {
  401. this.hideDownloadChartMenuItem();
  402. }
  403. else
  404. {
  405. if(!subject.hasSelectedChartNodes())
  406. {
  407. if (!subject.getSelectionBasedFeaturesEnabled()) {
  408. this.hide();
  409. } else {
  410. this.hideDownloadChartMenuItem();
  411. }
  412. }
  413. else
  414. {
  415. this.showDownloadChartMenuItem();
  416. }
  417. }
  418. }
  419. var bContext = false;
  420. if(this.m_lineageItem || this.m_glossaryItem)
  421. {
  422. var selections = subject.getAllSelectedObjects();
  423. if(selections != null && selections.length > 0)
  424. {
  425. for (var i=0; i < selections.length; i++)
  426. {
  427. if (selections[i].hasContextInformation())
  428. {
  429. bContext = true;
  430. break;
  431. }
  432. }
  433. }
  434. }
  435. this.updateFreezeHeadings();
  436. if (this.m_glossaryItem && bContext && this.getCV().envParams["glossaryURI"] != null && this.getCV().envParams["glossaryURI"] != "")
  437. {
  438. this.m_glossaryItem.enable();
  439. }
  440. else if (this.m_glossaryItem)
  441. {
  442. this.m_glossaryItem.disable();
  443. }
  444. if (this.m_lineageItem && bContext)
  445. {
  446. this.m_lineageItem.enable();
  447. }
  448. else if (this.m_lineageItem)
  449. {
  450. this.m_lineageItem.disable();
  451. }
  452. }
  453. }
  454. /**
  455. * Uses the DrillContextMenuHelper to get the JSON for the drill sub menus and then uses the
  456. * information found in the JSON to create old school menus for the CC Viewer (CMenuItem).
  457. */
  458. CContextMenu.prototype.updateDrillMenu = function(oButton, sAction)
  459. {
  460. oButton.clearCascadedMenu();
  461. var tempJson = {};
  462. DrillContextMenuHelper.updateDrillMenuItems(tempJson, this.getCV(), sAction);
  463. if (tempJson.items) {
  464. var drillItems = tempJson.items;
  465. var drillMenu = oButton.createCascadedMenu(gMenuStyle);
  466. var sWebContentRoot = this.getCV().getWebContentRoot();
  467. var sSkin = this.m_mainWnd.getCV().getSkin();
  468. for (var i=0; i < drillItems.length; i++) {
  469. var drillItem = drillItems[i];
  470. if (drillItem.separator) {
  471. // make sure we don't end with a seperator
  472. if (i < (drillItems.length - 1)) {
  473. drillMenu.add(gMenuSeperator);
  474. }
  475. }
  476. else {
  477. // The only menus only accept a string for the action, so build up the correct payload string
  478. var userSelectedDrillItem = drillItem.action && drillItem.action.payload && drillItem.action.payload.userSelectedDrillItem ? drillItem.action.payload.userSelectedDrillItem : "";
  479. var payload = userSelectedDrillItem ? "{\"userSelectedDrillItem\" : \"" + userSelectedDrillItem + "\"}" : "{}";
  480. if (sAction == "DrillDown") {
  481. new CMenuItem(drillMenu, drillItem.label, this.getCVObjectRef() + ".getDrillMgr().rvDrillDown(" + payload + ");", "", gMenuItemStyle, sWebContentRoot, sSkin);
  482. }
  483. else {
  484. new CMenuItem(drillMenu, drillItem.label, this.getCVObjectRef() + ".getDrillMgr().rvDrillUp(" + payload + ");", "", gMenuItemStyle, sWebContentRoot, sSkin);
  485. }
  486. }
  487. }
  488. }
  489. };
  490. function CContextMenu_updateSubscriptionContextMenuItem()
  491. {
  492. var sBlacklist = this.m_mainWnd.getUIHide();
  493. var subsMan = this.getCV().getSubscriptionManager();
  494. if (sBlacklist.indexOf(' RV_CONTEXT_MENU_ALERT_USING_NEW_WATCH_RULE ') != -1 && this.m_subscription)
  495. {
  496. this.m_subscription.hide();
  497. }
  498. else if (subsMan && this.m_subscription && subsMan.CanCreateNewWatchRule())
  499. {
  500. this.m_subscriptionSeperator.show();
  501. this.m_subscription.show();
  502. if (subsMan.IsValidSelectionForNewRule())
  503. {
  504. this.m_subscription.enable();
  505. }
  506. else
  507. {
  508. this.m_subscription.disable();
  509. }
  510. }
  511. else if (this.m_subscription)
  512. {
  513. this.m_subscriptionSeperator.hide();
  514. this.m_subscription.hide();
  515. }
  516. }
  517. CContextMenu.prototype.draw = CContextMenu_draw;
  518. CContextMenu.prototype.hide = CContextMenu_hide;
  519. CContextMenu.prototype.closeMenuTabEvent = CContextMenu_closeMenuTabEvent;
  520. CContextMenu.prototype.getDrillUpMenuItem = CContextMenu_getDrillUpMenuItem;
  521. CContextMenu.prototype.getDrillDownMenuItem = CContextMenu_getDrillDownMenuItem;
  522. CContextMenu.prototype.getGoToMenuItem = CContextMenu_getGoToMenuItem;
  523. CContextMenu.prototype.hideDownloadChartMenuItem = CContextMenu_hideDownloadChartMenuItem;
  524. CContextMenu.prototype.showDownloadChartMenuItem = CContextMenu_showDownloadChartMenuItem;
  525. CContextMenu.prototype.update = CContextMenu_update;
  526. CContextMenu.prototype.updateSubscriptionContextMenuItem = CContextMenu_updateSubscriptionContextMenuItem;
  527. function CReportHistory(mainWnd, stack_idx, reportName, params)
  528. {
  529. this.m_mainWnd = mainWnd;
  530. this.m_stack_idx = stack_idx;
  531. this.m_reportName = "";
  532. if(typeof reportName == "undefined" || reportName == null || reportName.length == 0)
  533. {
  534. if(typeof mainWnd != "undefined" && mainWnd != null)
  535. {
  536. var previousReport = RV_RES.RV_PREVIOUS_REPORT;
  537. this.m_reportName = previousReport;
  538. }
  539. }
  540. else
  541. {
  542. this.m_reportName = reportName;
  543. }
  544. this.m_params = params;
  545. }
  546. CReportHistory.prototype.getDropDownMenuIcon = function()
  547. {
  548. var sIcon = "/ps/portal/images/";
  549. if(this.m_params["ui.action"] == "view")
  550. {
  551. sIcon += "icon_result_";
  552. if(this.m_params["ui.format"] == "PDF")
  553. {
  554. sIcon += "pdf.gif";
  555. }
  556. else
  557. {
  558. sIcon += "html.gif";
  559. }
  560. }
  561. else
  562. {
  563. sIcon += "action_run.gif";
  564. }
  565. return sIcon;
  566. };
  567. CReportHistory.prototype.addParamNode = function(previousReportNode, sName, sValue)
  568. {
  569. var paramNode = previousReportNode.ownerDocument.createElement("param");
  570. previousReportNode.appendChild(paramNode);
  571. paramNode.setAttribute("name", sName);
  572. paramNode.appendChild(previousReportNode.ownerDocument.createTextNode(sValue));
  573. };
  574. CReportHistory.prototype.saveAsXML = function(previousReportsNode)
  575. {
  576. var previousReportNode = previousReportsNode.ownerDocument.createElement("previousReport");
  577. previousReportsNode.appendChild(previousReportNode);
  578. for(var paramName in this.m_params)
  579. {
  580. this.addParamNode(previousReportNode, paramName, this.m_params[paramName]);
  581. }
  582. this.addParamNode(previousReportNode, "ui.name", this.getReportName());
  583. };
  584. CReportHistory.prototype.getIdx = function()
  585. {
  586. return this.m_stack_idx;
  587. };
  588. CReportHistory.prototype.getReportName = function()
  589. {
  590. return this.m_reportName;
  591. };
  592. CReportHistory.prototype.getParameters = function()
  593. {
  594. return this.m_params;
  595. };
  596. CReportHistory.prototype.createRequestForm = function()
  597. {
  598. var oCV = this.m_mainWnd.getCV();
  599. var formWarpRequest = document.getElementById("formWarpRequest" + oCV.getId());
  600. // build a form and submit it.
  601. var form = document.createElement("form");
  602. form.setAttribute("id", "previousReport");
  603. form.setAttribute("name", "previousReport");
  604. form.setAttribute("target", formWarpRequest.getAttribute("target") ? formWarpRequest.getAttribute("target") : "");
  605. form.setAttribute("method", "post");
  606. form.setAttribute("action", formWarpRequest.getAttribute("action"));
  607. form.style.display = "none";
  608. document.body.appendChild(form);
  609. for(var paramName in this.m_params)
  610. {
  611. if(paramName != "m_tracking")
  612. {
  613. form.appendChild(createHiddenFormField(paramName, this.m_params[paramName]));
  614. }
  615. }
  616. for(var cvParam in oCV.envParams)
  617. {
  618. if( cvParam.indexOf("cv.") == 0 && cvParam != "cv.previousReports" && cvParam != "m_tracking" && cvParam != "cv.actionState")
  619. {
  620. form.appendChild(createHiddenFormField(cvParam, oCV.envParams[cvParam]));
  621. }
  622. }
  623. if(this.getIdx() > 0)
  624. {
  625. this.m_mainWnd.m_reportHistoryList = this.m_mainWnd.m_reportHistoryList.slice(0, this.getIdx());
  626. form.appendChild(createHiddenFormField("cv.previousReports",this.m_mainWnd.saveReportHistoryAsXML()));
  627. }
  628. form.appendChild(createHiddenFormField("ui.name", this.getReportName()));
  629. form.appendChild(createHiddenFormField("b_action", "cognosViewer"));
  630. var formWarpRequestInputs = formWarpRequest.getElementsByTagName("INPUT");
  631. for (var index = 0; index < formWarpRequestInputs.length; ++index)
  632. {
  633. if(typeof form[formWarpRequestInputs[index].name] == "undefined" && formWarpRequestInputs[index].name != "cv.previousReports" && formWarpRequestInputs[index].name.length > 0)
  634. {
  635. form.appendChild(createHiddenFormField(formWarpRequestInputs[index].name, formWarpRequestInputs[index].value));
  636. }
  637. }
  638. return form;
  639. };
  640. CReportHistory.prototype.execute = function()
  641. {
  642. var oCV = this.m_mainWnd.getCV();
  643. if(typeof oCV.m_viewerFragment != "undefined")
  644. {
  645. var oRequest = new ViewerDispatcherEntry(oCV);
  646. oRequest.addFormField("ui.action", this.m_params["ui.action"]);
  647. for(var paramName in this.m_params)
  648. {
  649. if(paramName != "ui.action" && paramName != "m_tracking" && paramName != "cv.actionState")
  650. {
  651. oRequest.addFormField(paramName, this.m_params[paramName]);
  652. }
  653. }
  654. if(this.getIdx() > 0)
  655. {
  656. this.m_mainWnd.m_reportHistoryList = this.m_mainWnd.m_reportHistoryList.slice(0, this.getIdx());
  657. oRequest.addFormField("cv.previousReports",this.m_mainWnd.saveReportHistoryAsXML());
  658. }
  659. else
  660. {
  661. oRequest.removeFormField("cv.previousReports");
  662. }
  663. if (this.m_reportName && this.m_reportName.length > 0) {
  664. oRequest.addFormField("ui.name", this.m_reportName);
  665. }
  666. oRequest.addFormField("cv.responseFormat", "fragment");
  667. oRequest.addFormField("cv.ignoreState", "true");
  668. oRequest.addFormField("cv.id", "_THIS_");
  669. oRequest.addFormField("m_tracking", "");
  670. oCV.dispatchRequest(oRequest);
  671. }
  672. else
  673. {
  674. var form = this.createRequestForm();
  675. form.submit();
  676. }
  677. };
  678. /**
  679. Contains function specific to Cognos Viewer clients.
  680. @param CCognosViewer oCV reference to the CCognosViewer instance using this class.
  681. */
  682. function CViewerManager(oCV)
  683. {
  684. this.setCV(oCV);
  685. }
  686. CViewerManager.prototype = new CViewerHelper();
  687. CViewerManager.prototype.Print = function() {
  688. var savedOutputIframe = document.getElementById("CVIFrame" + this.getCVId());
  689. if (savedOutputIframe) {
  690. if(isIE()) {
  691. savedOutputIframe.contentWindow.document.execCommand("print", true, null);
  692. } else {
  693. savedOutputIframe.focus();
  694. savedOutputIframe.contentWindow.print();
  695. }
  696. }
  697. // reset focus back to the print toolbar button
  698. var cv = this.getCV();
  699. var mainWnd = cv.rvMainWnd;
  700. var toolbarCtrl = mainWnd.getToolbarControl();
  701. if (typeof toolbarCtrl != "undefined" && toolbarCtrl != null) {
  702. var printButton = toolbarCtrl.getItem("print");
  703. if (printButton) {
  704. printButton.setFocus();
  705. }
  706. }
  707. };
  708. CViewerManager.prototype.DownloadReport = function()
  709. {
  710. var theURL="";
  711. var f = document.forms["formWarpRequest" + this.getCVId()];
  712. theURL += 'b_action=xts.run&m=portal/download.xts&m_obj=';
  713. theURL += f["ui.object"].value;
  714. theURL += '&m_name=';
  715. theURL += f["ui.name"].value;
  716. if (f["ui.format"] && f["ui.format"].value)
  717. {
  718. theURL += '&format=';
  719. theURL += f["ui.format"].value;
  720. }
  721. theURL = constructGETRequestParamsString(theURL);
  722. theURL = f.action + '?' + theURL;
  723. location.href = theURL;
  724. };
  725. CViewerManager.prototype.SaveReport = function(bWaitPage)
  726. {
  727. var oCV = this.getCV();
  728. var oReq = new ViewerDispatcherEntry(oCV);
  729. // don't want to show a full working dialog
  730. oReq.setWorkingDialog(null);
  731. oReq.addFormField("ui.action", "save");
  732. if(!bWaitPage) {
  733. oReq.addFormField("run.continueConversation", "true");
  734. }
  735. else {
  736. this.getCV().closeActiveHTTPConnection();
  737. if (oCV.getWorkingDialog()) {
  738. oCV.getWorkingDialog().hide();
  739. }
  740. this.getCV().setKeepSessionAlive(true);
  741. oReq.addFormField("run.continueConversation", "false");
  742. var callback = GUtil.generateCallback(executeBackURL, [this.getCV().getId()], null);
  743. oReq.setCallbacks( {
  744. "complete" : {"method" : callback}
  745. });
  746. }
  747. oReq.addFormField("run.saveOutput", "true");
  748. this.getCV().dispatchRequest(oReq);
  749. };
  750. CViewerManager.prototype.SaveAsReportView = function(bWaitPage)
  751. {
  752. var formWarpRequest = document.getElementById("formWarpRequest" + this.getCVId());
  753. if(formWarpRequest)
  754. {
  755. var bContinueConversation = !bWaitPage;
  756. var formFields = {"m":"portal/viewer-saveAs.xts"};
  757. formFields["run.continueConversation"] = bContinueConversation;
  758. formFields["initializeSave"] = "true";
  759. formFields["ui.object"] = formWarpRequest["ui.object"].value;
  760. formFields["ui.backURL"] = formWarpRequest["ui.backURL"].value;
  761. formFields["ui.routingServerGroup"] = this.getRoutingServerGroup();
  762. cvLoadDialog(this.getCV(), formFields, 600, 425, RV_RES.IDS_JS_SAVE_AS_REPORT_VIEW_IFRAME_TITLE);
  763. }
  764. };
  765. CViewerManager.prototype.init = function(oProperties)
  766. {
  767. if (oProperties && typeof oProperties == "object")
  768. {
  769. for (var sProp in oProperties)
  770. {
  771. this[sProp] = oProperties[sProp];
  772. }
  773. }
  774. };
  775. CViewerManager.prototype.SendReport = function(bWaitPage)
  776. {
  777. var bContinueConversation = !bWaitPage;
  778. var formFields = {"m":"portal/viewer-email.xts"};
  779. formFields["run.continueConversation"] = bContinueConversation;
  780. formFields["ui.routingServerGroup"] = this.getRoutingServerGroup();
  781. cvLoadDialog(this.getCV(), formFields, 800, 550, RV_RES.IDS_JS_EMAIL_REPORT_IFRAME_TITLE);
  782. };
  783. CViewerManager.prototype.validatePromptControls = function()
  784. {
  785. // prompting validation (cleans up controls state)
  786. if(typeof this.getCV().preProcessControlArray != "undefined" && typeof preProcessForm != "undefined") {
  787. preProcessForm(this.getCV().preProcessControlArray);
  788. }
  789. };
  790. CViewerManager.prototype.RunReport = function()
  791. {
  792. this.validatePromptControls();
  793. var oReq = null;
  794. var sSearchPath = this.getCV().envParams["ui.object"];
  795. var sSpecification = this.getCV().envParams["ui.spec"];
  796. var sAction = this.getCV().envParams["ui.action"];
  797. var formWarpRequest = document.forms["formWarpRequest" + this.getCVId()];
  798. if(sSpecification != null && sSpecification != "")
  799. {
  800. oReq = new ViewerDispatcherEntry(this.getCV());
  801. oReq.addFormField("ui.action", "runSpecification");
  802. oReq.addFormField("ui.spec", sSpecification);
  803. var sSpecificationType = this.getCV().envParams["specificationType"];
  804. if(sSpecificationType != null)
  805. {
  806. oReq.addFormField("specificationType", sSpecificationType);
  807. }
  808. }
  809. else if(sSearchPath != null && sSearchPath != "")
  810. {
  811. if (this.getCV().isBux)
  812. {
  813. oReq = new ViewerDispatcherEntry(this.getCV());
  814. oReq.addFormField("ui.action", "bux");
  815. }
  816. else
  817. {
  818. oReq = new ViewerDispatcherEntry(this.getCV());
  819. oReq.addFormField("ui.action", "run");
  820. }
  821. // If we're doing a view, get the "re-run" search path.
  822. // The search path associated with a view is not a search path that we would use on a run ie (defaultOutput(...))
  823. if(sAction == "view")
  824. {
  825. if (this.getCV().envParams["ui.reRunObj"])
  826. {
  827. sSearchPath = this.getCV().envParams["ui.reRunObj"];
  828. }
  829. else if (typeof formWarpRequest["reRunObj"] != "undefined" && formWarpRequest["reRunObj"] != null)
  830. {
  831. sSearchPath = formWarpRequest["reRunObj"].value;
  832. }
  833. }
  834. oReq.addFormField("ui.object", sSearchPath);
  835. }
  836. oReq.addFormField("run.outputFormat", this.getCV().rvMainWnd.getCurrentFormat());
  837. oReq.addFormField("ui.primaryAction","");
  838. var promptOnRerun = this.getCV().envParams["promptOnRerun"];
  839. if (promptOnRerun != null)
  840. {
  841. oReq.addFormField("run.prompt", promptOnRerun);
  842. }
  843. else
  844. {
  845. oReq.addFormField("run.prompt", "true");
  846. }
  847. this.getCV().preparePromptValues(oReq);
  848. this.getCV().dispatchRequest(oReq);
  849. };
  850. CViewerManager.prototype.viewReport = function(format)
  851. {
  852. if(this.getCV().rvMainWnd.getCurrentFormat() == format)
  853. {
  854. return;
  855. }
  856. var f = document.forms["formWarpRequest" + this.getCVId()];
  857. if(f["ui.action"].value == 'view')
  858. {
  859. this.viewOutput(format);
  860. }
  861. else
  862. {
  863. var oReq = new ViewerDispatcherEntry(this.getCV());
  864. oReq.addFormField("ui.action", "render");
  865. oReq.addFormField("run.outputFormat", format);
  866. if( this.isExcelFormat(format))
  867. {
  868. this.viewInExcel(oReq);
  869. }
  870. else if (this.getCV().isAccessibleMode() && format == 'PDF')
  871. {
  872. this.viewPDFInNewWindow(oReq);
  873. }
  874. else if (isSafari() && format == 'PDF')
  875. {
  876. oReq.addFormField("ui.reuseWindow", "true");
  877. this.viewPDFInNewWindow(oReq);
  878. }
  879. else
  880. {
  881. this.getCV().deleteTabs();
  882. this.getCV().dispatchRequest(oReq);
  883. }
  884. }
  885. };
  886. CViewerManager.prototype.isExcelFormat = function(format)
  887. {
  888. if(format == 'xlsxData' || format == 'XLS' || format == 'CSV' || format == 'XLWA' || format == 'singleXLS' || format == 'spreadsheetML')
  889. {
  890. return true;
  891. }
  892. return false;
  893. };
  894. CViewerManager.prototype.viewOutput = function(format)
  895. {
  896. var oFWR = document.forms["formWarpRequest" + this.getCVId()];
  897. var oReq = new ViewerDispatcherEntry(this.getCV());
  898. oReq.addFormField("ui.action", "view");
  899. oReq.addFormField("cv.responseFormat", "view");
  900. oReq.addFormField("ui.format", format);
  901. var sObject = "";
  902. switch(format)
  903. {
  904. case "HTML":
  905. sObject = this.getCV().oOutputFormatPath.HTML;
  906. break;
  907. case "PDF":
  908. sObject = this.getCV().oOutputFormatPath.PDF;
  909. break;
  910. case "singleXLS":
  911. sObject = this.getCV().oOutputFormatPath.singleXLS;
  912. break;
  913. case "XLS":
  914. sObject = this.getCV().oOutputFormatPath.XLS;
  915. break;
  916. case "XLWA":
  917. sObject = this.getCV().oOutputFormatPath.XLWA;
  918. break;
  919. case "CSV":
  920. sObject = this.getCV().oOutputFormatPath.CSV;
  921. break;
  922. case "XML":
  923. sObject = this.getCV().oOutputFormatPath.XML;
  924. break;
  925. case "spreadsheetML":
  926. sObject = this.getCV().oOutputFormatPath.spreadsheetML;
  927. break;
  928. case "xlsxData":
  929. sObject = this.getCV().oOutputFormatPath.xlsxData;
  930. break;
  931. }
  932. if (sObject)
  933. {
  934. oReq.addFormField("ui.object", sObject);
  935. }
  936. oReq.addFormField("reRunObj", oFWR.reRunObj.value);
  937. oReq.addFormField("ui.format", format);
  938. oReq.addFormField("ui.name", oFWR["ui.name"].value);
  939. if( this.isExcelFormat(format))
  940. {
  941. this.viewInExcel(oReq);
  942. }
  943. else if (this.getCV().isAccessibleMode() && format == 'PDF')
  944. {
  945. this.viewPDFInNewWindow(oReq);
  946. }
  947. else if (isSafari() && format == 'PDF')
  948. {
  949. oReq.addFormField("ui.reuseWindow", "true");
  950. this.viewPDFInNewWindow(oReq);
  951. }
  952. else
  953. {
  954. this.getCV().dispatchRequest(oReq);
  955. }
  956. };
  957. CViewerManager.prototype.viewPDFInNewWindow = function(oReq)
  958. {
  959. this.viewInNewWindow(oReq, __pdf_win);
  960. };
  961. CViewerManager.prototype.viewInExcel = function(oReq)
  962. {
  963. this.viewInNewWindow(oReq, __excel_win);
  964. };
  965. CViewerManager.prototype.viewInNewWindow = function(oReq, browserHandle)
  966. {
  967. var oldUnload=window.onbeforeunload;
  968. window.onbeforeunload=null;
  969. if (browserHandle != null) {
  970. browserHandle.close();
  971. }
  972. var target = "winNAT_" + ( new Date() ).getTime();
  973. var sPath = this.getCV().getWebContentRoot() + "/" + "rv/blankNewWin.html?cv.id=" + this.getCVId();
  974. var sFormID = "viewForm" + this.getCVId();
  975. var oForm = document.getElementById(sFormID);
  976. if (oForm) {
  977. oForm.parentNode.removeChild(oForm);
  978. }
  979. oForm = document.createElement("form");
  980. oForm.setAttribute("method", "post");
  981. oForm.setAttribute("id", sFormID);
  982. oForm.setAttribute("action", this.getCV().getGateway());
  983. oForm.style.display = "inline";
  984. var oFWR = document["formWarpRequest" + this.getCVId()];
  985. if (oFWR && oFWR["run.outputFormat"]) {
  986. oReq.addFormField("previousFormat", oFWR["run.outputFormat"].value);
  987. }
  988. var formFieldNames = oReq.getFormFields().keys();
  989. for (var index = 0; index < formFieldNames.length; index++)
  990. {
  991. var name = formFieldNames[index];
  992. // we'll force the action and respons format later on so we don't indirectly send this request to the fragment server
  993. // since we're now doing a render, don't pass along the tracking. We still need to pass the
  994. // conversation since we want to reuse the parameters and options
  995. if(name != "cv.responseFormat" && name != "b_action" && name != "m_tracking")
  996. {
  997. oForm.appendChild(createHiddenFormField(name, oReq.getFormField(name)));
  998. }
  999. }
  1000. oForm.appendChild(createHiddenFormField("cv.responseFormat", "page"));
  1001. oForm.appendChild(createHiddenFormField("b_action", "cognosViewer"));
  1002. oForm.appendChild(createHiddenFormField("BIline1", RV_RES.RV_RUNNING));
  1003. oForm.appendChild(createHiddenFormField("BIline2", RV_RES.RV_PLEASE_WAIT));
  1004. if (this.getCV().envParams['ui.name']) {
  1005. oForm.appendChild(createHiddenFormField("ui.name", this.getCV().envParams['ui.name']));
  1006. }
  1007. document.body.appendChild(oForm);
  1008. oForm.target = target;
  1009. browserHandle = window.open(sPath, target, "rv");
  1010. window.onbeforeunload=oldUnload;
  1011. };
  1012. /* drill through functions */
  1013. CViewerManager.prototype.cancel = function()
  1014. {
  1015. var oCV = this.getCV();
  1016. oCV.cancel();
  1017. };
  1018. //take an input string and convert it into
  1019. //xml friendly entity references
  1020. CViewerManager.prototype.sXmlEncode = function(sInputString)
  1021. {
  1022. var sOutputString = "" + sInputString;
  1023. if ((sOutputString == '0') || ((sInputString != null) && (sInputString != false)))
  1024. {
  1025. //&amp;
  1026. sOutputString = sOutputString.replace(/&/g, "&amp;");
  1027. //&lt;
  1028. sOutputString = sOutputString.replace(/</g, "&lt;");
  1029. //&gt;
  1030. sOutputString = sOutputString.replace(/>/g, "&gt;");
  1031. //&quot;
  1032. sOutputString = sOutputString.replace(/"/g, "&quot;");
  1033. //&apos;
  1034. sOutputString = sOutputString.replace(/'/g, "&apos;");
  1035. }
  1036. else if (sInputString == null)
  1037. {
  1038. //return empty string if the value is null or false
  1039. sOutputString = "";
  1040. }
  1041. return sOutputString;
  1042. };
  1043. CViewerManager.prototype.exit = function(callback)
  1044. {
  1045. var form = document.getElementById("formWarpRequest" + this.getCVId());
  1046. var oCV = this.getCV();
  1047. // In the case of a view, and there are no previous reports opened, just execute the back URL.
  1048. if(form && form["ui.action"] && form["ui.action"].value == "view" && callback)
  1049. {
  1050. executeBackURL(this.getCVId());
  1051. }
  1052. else if(oCV.getKeepSessionAlive() == false)
  1053. {
  1054. oCV.exit(callback);
  1055. }
  1056. };
  1057. function executeBackURL(s_CVId)
  1058. {
  1059. var sCVId = "";
  1060. if (s_CVId) {
  1061. sCVId = s_CVId;
  1062. }
  1063. // we never want to execute a backURL if we're in BUX.
  1064. if (window["oCV" + sCVId] && window["oCV" + sCVId].isBux)
  1065. {
  1066. return false;
  1067. }
  1068. var form = document.getElementById("formWarpRequest" + sCVId);
  1069. if(form["ui.backURL"].value.length < 2048)
  1070. {
  1071. // if the back url is less than the 2kb limit imposed by IE, do a location.href
  1072. document.location.href = form["ui.backURL"].value;
  1073. return;
  1074. }
  1075. var backURL = decodeURIComponent(form["ui.backURL"].value);
  1076. var URLandParameters = backURL.split("?");
  1077. var backURLForm = document.createElement("form");
  1078. backURLForm.style.display = "none";
  1079. backURLForm.setAttribute("method", "post");
  1080. backURLForm.setAttribute("action", URLandParameters[0]);
  1081. backURLForm.setAttribute("target", "_self");
  1082. var parameterList = URLandParameters[1].split("&"); // must be ampersand symbol
  1083. for(var nextParameter = 0; nextParameter < parameterList.length; nextParameter++)
  1084. {
  1085. // We cannot use "split" here using "=" because there are "=" within the parameters
  1086. // that must be kept.
  1087. var equalsIndexPos = parameterList[nextParameter].indexOf("=");
  1088. var parameterName = parameterList[nextParameter].substr(0, equalsIndexPos);
  1089. var parameterValue = parameterList[nextParameter].substr(equalsIndexPos + 1);
  1090. var urlFormField = document.createElement("input");
  1091. urlFormField.setAttribute("type", "hidden");
  1092. urlFormField.setAttribute("name", decodeURIComponent(parameterName));
  1093. urlFormField.setAttribute("value", decodeURIComponent(parameterValue));
  1094. backURLForm.appendChild(urlFormField);
  1095. }
  1096. document.body.appendChild(backURLForm);
  1097. backURLForm.submit();
  1098. }
  1099. CViewerManager.prototype.getRoutingServerGroup = function()
  1100. {
  1101. var oCV = this.getCV();
  1102. if(oCV.envParams["ui.routingServerGroup"])
  1103. {
  1104. return oCV.envParams["ui.routingServerGroup"];
  1105. }
  1106. return "";
  1107. };
  1108. CViewerManager.prototype.launchQS = function()
  1109. {
  1110. var formWarpRequest = document.forms["formWarpRequest" + this.getCVId()];
  1111. // check to see if we're a fragment. If so, launch query studio in a new window
  1112. var oCV = this.getCV();
  1113. if(typeof oCV.m_viewerFragment != "undefined")
  1114. {
  1115. cognosLaunchInWindow("","menubar=no,toolbar=no,status=yes,location=no,resizable=yes,width=650,height=480",
  1116. "ui.gateway", formWarpRequest.action,
  1117. "ui.tool", "QueryStudio",
  1118. "ui.action", "edit",
  1119. "ui.object", formWarpRequest["ui.object"].value,
  1120. "ui.routingServerGroup", this.getRoutingServerGroup()); //TODO Support views
  1121. }
  1122. else
  1123. {
  1124. cognosLaunch("ui.gateway", formWarpRequest.action,
  1125. "ui.tool", "QueryStudio",
  1126. "ui.action", "edit",
  1127. "ui.object", formWarpRequest["ui.object"].value,
  1128. "ui.backURL", formWarpRequest["ui.backURL"].value,
  1129. "ui.routingServerGroup", this.getRoutingServerGroup());
  1130. }
  1131. };
  1132. CViewerManager.prototype.launchAS = function()
  1133. {
  1134. var formWarpRequest = document.forms["formWarpRequest" + this.getCVId()];
  1135. cognosLaunchInWindow("","menubar=no,toolbar=no,status=yes,location=no,resizable=yes,width=650,height=480",
  1136. "ui.gateway", formWarpRequest.action,
  1137. "ui.tool", "AnalysisStudio",
  1138. "ui.action", "edit",
  1139. "ui.object", formWarpRequest["ui.object"].value,
  1140. "ui.routingServerGroup", this.getRoutingServerGroup()); //TODO Support views
  1141. };
  1142. CViewerManager.prototype.launchRS = function()
  1143. {
  1144. var formWarpRequest = document.forms["formWarpRequest" + this.getCVId()];
  1145. cognosLaunchInWindow("_blank","menubar=no,toolbar=no,status=yes,location=no,resizable=yes,width=650,height=480",
  1146. "ui.gateway", formWarpRequest.action,
  1147. "ui.tool","ReportStudio",
  1148. "ui.action","edit",
  1149. "ui.profile", "Professional",
  1150. "ui.object",formWarpRequest["ui.object"].value,
  1151. "ui.routingServerGroup", this.getRoutingServerGroup());//TODO Support views
  1152. };
  1153. CViewerManager.prototype.returnHome = function(url)
  1154. {
  1155. var formWarpRequest = document.forms["formWarpRequest" + this.getCVId()];
  1156. formWarpRequest["ui.backURL"].value = url;
  1157. executeBackURL(this.getCVId());
  1158. };
  1159. CViewerManager.prototype.doPostBack = function()
  1160. {
  1161. var f = document.forms["formWarpRequest" + this.getCVId()];
  1162. f.appendChild(createHiddenFormField("b_action", "xts.run"));
  1163. f.appendChild(createHiddenFormField("m", f["ui.postBack"].value));
  1164. f.submit();
  1165. };
  1166. CViewerManager.prototype.hideAbout = function()
  1167. {
  1168. this.getCV().removeTransparentBackgroundLayer();
  1169. var cvId = this.getCV().getId();
  1170. if (document.getElementById("viewerAboutDiv" + cvId))
  1171. {
  1172. document.getElementById("viewerAboutDiv" + cvId).parentNode.removeChild(document.getElementById("viewerAboutDiv" + cvId));
  1173. }
  1174. if (document.getElementById("viewerAboutIframe" + cvId))
  1175. {
  1176. document.getElementById("viewerAboutIframe" + cvId).parentNode.removeChild(document.getElementById("viewerAboutIframe" + cvId));
  1177. }
  1178. };
  1179. function viewerAboutOnKeyDown(evt)
  1180. {
  1181. //get the event in a cross-browser fashion
  1182. evt = (evt) ? evt : ((event) ? event : null);
  1183. var srcNode = getCrossBrowserNode(evt);
  1184. if (evt.keyCode == "13" || evt.keyCode == "27" || evt.keyCode == "32") // enter, esc or space
  1185. {
  1186. var oCV = window["oCV" + srcNode.getAttribute("viewerId")];
  1187. oCV.m_oCVMgr.hideAbout();
  1188. return stopEventBubble(evt);
  1189. }
  1190. }
  1191. CViewerManager.prototype.fileExist = function( fileURL )
  1192. {
  1193. var http = null
  1194. if (window.XMLHttpRequest) {
  1195. http = new XMLHttpRequest();
  1196. }
  1197. else {
  1198. http = new ActiveXObject("Msxml2.XMLHTTP");
  1199. }
  1200. http.open( 'HEAD', fileURL, false);
  1201. http.send();
  1202. return ( http.status == 200 );
  1203. }
  1204. CViewerManager.prototype.getAboutBoxImageURL = function()
  1205. {
  1206. var aboutImgFileName = 'about_' + this.getCV().getProductLocale() + '.jpg';
  1207. var srcDirectory = this.getCV().getWebContentRoot() + '/rv/images/';
  1208. var fileURL = srcDirectory + aboutImgFileName;
  1209. if( !this.fileExist(fileURL) )
  1210. {
  1211. fileURL = srcDirectory + 'about_en.jpg' ;
  1212. }
  1213. return fileURL;
  1214. }
  1215. CViewerManager.prototype.about = function()
  1216. {
  1217. if (document.getElementById("viewerAbout" + this.getCV().getId()))
  1218. {
  1219. this.hideAbout();
  1220. }
  1221. this.getCV().createTransparentBackgroundLayer();
  1222. var iAboutWidth = 650;
  1223. var iAboutHeight = 522;
  1224. var iframe = document.createElement("iframe");
  1225. iframe.id = "viewerAboutIframe" + this.getCV().getId();
  1226. iframe.style.position = "absolute";
  1227. iframe.style.zIndex = 99;
  1228. iframe.style.width = iAboutWidth + "px";
  1229. iframe.style.height = iAboutHeight + "px";
  1230. iframe.setAttribute("src", this.getCV().getWebContentRoot() + '/common/blank.html');
  1231. iframe.setAttribute("scrolling",'no');
  1232. iframe.setAttribute("frameborder",'0');
  1233. iframe.setAttribute("title", RV_RES.IDS_JS_MODAL_BACK_IFRAME);
  1234. iframe.setAttribute("role", "presentation");
  1235. document.body.appendChild(iframe);
  1236. var id = this.getCV().getId();
  1237. // div to catch Shift-Tab and place the focus on the OK button
  1238. var divTabCatchBefore = document.createElement("div");
  1239. divTabCatchBefore.tabIndex = 0;
  1240. divTabCatchBefore.onfocus = function() {document.getElementById("viewerAboutOK" + id).focus();};
  1241. document.body.appendChild(divTabCatchBefore);
  1242. var div = document.createElement("div");
  1243. div.id = "viewerAboutDiv" + this.getCV().getId();
  1244. div.style.position = "absolute";
  1245. div.onkeydown = viewerAboutOnKeyDown;
  1246. div.style.zIndex = 100;
  1247. div.style.width = iAboutWidth + "px";
  1248. div.style.height = iAboutHeight + "px";
  1249. div.style.outline = "none";
  1250. div.setAttribute("role", "dialog");
  1251. div.setAttribute("aria-label", RV_RES.RV_ABOUT_DESCRIPTION);
  1252. var aboutImgURL = this.getAboutBoxImageURL();
  1253. var copyright = RV_RES.RV_ABOUT_DESCRIPTION.replace(/"/g, "&quot;") + RV_RES.IDS_PROP_LEGAL.replace(/"/g, "&quot;");
  1254. div.innerHTML = '<img role="img" id="viewerAbout' + this.getCV().getId() + '" tabIndex="0" alt="' + copyright + '" title="' + copyright + '" src="' + aboutImgURL + '" onclick="' + getCognosViewerObjectString(this.getCV().getId()) + '.m_oCVMgr.hideAbout()"></img>';
  1255. div.setAttribute("viewerId", this.getCV().getId());
  1256. document.body.appendChild(div);
  1257. this.createOKButton(div);
  1258. // div to catch tab and place the focus back on the about box
  1259. var divTabCatchAfter = document.createElement("div");
  1260. divTabCatchAfter.tabIndex = 0;
  1261. divTabCatchAfter.onfocus = function() {document.getElementById("viewerAbout" + id).focus();};
  1262. document.body.appendChild(divTabCatchAfter);
  1263. // position the about dialog in the middle of the report
  1264. var iBottom = 0;
  1265. var iLeft = 0;
  1266. if (typeof window.innerHeight != "undefined")
  1267. {
  1268. iBottom = Math.round((window.innerHeight/2) - (iAboutHeight/2));
  1269. iLeft = Math.round((window.innerWidth/2) - (iAboutWidth/2));
  1270. }
  1271. else
  1272. {
  1273. iBottom = Math.round((document.body.clientHeight/2) - (iAboutHeight/2));
  1274. iLeft = Math.round((document.body.clientWidth/2) - (iAboutWidth/2));
  1275. }
  1276. div.style.bottom = iframe.style.bottom = iBottom + "px";
  1277. div.style.left = iframe.style.left = iLeft + "px";
  1278. setTimeout("document.getElementById('viewerAbout" + id + "').focus();", 1);
  1279. };
  1280. CViewerManager.prototype.createOKButton = function(aboutDiv)
  1281. {
  1282. var aboutOK = document.createElement("div");
  1283. aboutOK.style.backgroundcolor="#FFFFFF";
  1284. aboutOK.id = "viewerAboutOK" + this.getCV().getId();
  1285. aboutOK.setAttribute("role", "button");
  1286. aboutOK.setAttribute("viewerId", this.getCV().getId());
  1287. aboutOK.setAttribute("tabIndex", "0");
  1288. var oCVMgr = this;
  1289. aboutOK.onclick = function() { oCVMgr.hideAbout(); };
  1290. aboutOK.onkeydown = viewerAboutOnKeyDown;
  1291. aboutOK.className = "aboutOkButton";
  1292. aboutDiv.appendChild(aboutOK);
  1293. var span = document.createElement("span");
  1294. span.style.padding = "7px 30px 7px 30px";
  1295. span.appendChild(document.createTextNode(RV_RES.IDS_JS_OK));
  1296. aboutOK.appendChild(span);
  1297. };
  1298. CViewerManager.prototype.updateUserName = function()
  1299. {
  1300. var request = new DataDispatcherEntry(this.getCV());
  1301. request.addFormField("ui.action", "CMRequest");
  1302. request.addFormField("CMRequest", "<CMRequest><searchPath>~</searchPath><properties><property>defaultName</property></properties></CMRequest>");
  1303. request.addFormField("cv.responseFormat", "CMRequest");
  1304. request.addFormField("cv.catchLogOnFault", "true");
  1305. request.addFormField("cv.id", this.getCVId());
  1306. request.setCallbacks( {
  1307. "complete" : {"object" : this, "method" : this.updateUserNameCallback}
  1308. });
  1309. request.setCanBeQueued(true);
  1310. this.getCV().dispatchRequest(request);
  1311. };
  1312. CViewerManager.prototype.updateUserNameCallback = function(response) {
  1313. var userName = this.getUserNameFromResponse(response);
  1314. if (userName != null)
  1315. {
  1316. var userNameId = "userNameTD" + this.getCVId();
  1317. var userNameTD = document.getElementById(userNameId);
  1318. if (userNameTD != null)
  1319. {
  1320. userNameTD.innerHTML = html_encode(userName);
  1321. }
  1322. var banner = this.getCV().rvMainWnd.getBannerToolbar();
  1323. if (banner)
  1324. {
  1325. for (var iIndex=0; iIndex < banner.getNumItems(); iIndex++)
  1326. {
  1327. if (typeof banner.get(iIndex).getId == "function" && banner.get(iIndex).getId() == userNameId)
  1328. {
  1329. banner.get(iIndex).setText(html_encode(userName));
  1330. break;
  1331. }
  1332. }
  1333. }
  1334. }
  1335. };
  1336. CViewerManager.prototype.getUserNameFromResponse = function(response)
  1337. {
  1338. if (response) {
  1339. var xmlParsedCMresponse = XMLBuilderLoadXMLFromString(response.getResult());
  1340. var defaultName = XMLHelper_FindChildByTagName(xmlParsedCMresponse, "defaultName", true);
  1341. if (defaultName != null)
  1342. {
  1343. var defaultNameValue = XMLHelper_FindChildByTagName(defaultName, "value", false);
  1344. if (defaultNameValue != null)
  1345. {
  1346. return XMLHelper_GetText(defaultNameValue);
  1347. }
  1348. }
  1349. }
  1350. return null;
  1351. };
  1352. CViewerManager.prototype.getAvailableOutput = function()
  1353. {
  1354. var oCV = this.getCV();
  1355. var formWarpRequest = document.getElementById("formWarpRequest" + this.getCVId());
  1356. var request = new JSONDispatcherEntry(this.getCV());
  1357. request.addFormField("ui.action", "getAvailableOutputs");
  1358. request.addFormField("cv.responseFormat", "getAvailableOutputs");
  1359. request.addFormField("ui.object", formWarpRequest["ui.object"].value);
  1360. request.addFormField("ui.reportVersion", formWarpRequest["ui.reportVersion"].value);
  1361. request.addFormField("reRunObj", formWarpRequest["reRunObj"].value);
  1362. request.addFormField("ui.outputLocale", formWarpRequest["ui.outputLocale"].value);
  1363. request.addFormField("ui.burstKey", formWarpRequest["ui.burstKey"].value);
  1364. request.addFormField("cv.id", this.getCVId());
  1365. request.setCallbacks({"complete":{"object":this, "method":this.getAvailableOutputResponseCallback}});
  1366. oCV.dispatchRequest(request);
  1367. };
  1368. CViewerManager.prototype.getAvailableOutputResponseCallback = function(response)
  1369. {
  1370. var oCV = this.getCV();
  1371. oCV.init(response.getJSONResponseObject());
  1372. oCV.rvMainWnd.renderAvailableOutputs();
  1373. };
  1374. /*
  1375. * Used to perform the log on and log off actions
  1376. */
  1377. CViewerManager.prototype.authenticate = function(action, url)
  1378. {
  1379. this.exit();
  1380. this.getCV().setKeepSessionAlive(true);
  1381. if (window.delCookie) {
  1382. delCookie('cc_state');
  1383. }
  1384. if (action == 'logon' || action == 'relogon') {
  1385. location.href = url + "&h_CAM_action=logon&m_reload=";
  1386. }
  1387. if (action == 'logoff') {
  1388. location.href = url + "&h_CAM_action=logoff";
  1389. }
  1390. };
  1391. /*
  1392. * Used to launch CC's new_general.xts
  1393. * @sNewClass - type of object to create
  1394. * @sNewSearchPath - default location to save the new object
  1395. */
  1396. CViewerManager.prototype.launchNewGeneral = function(sNewClass, sNewSearchPath)
  1397. {
  1398. var formWarpRequest = document.getElementById("formWarpRequest" + this.getCVId());
  1399. if(formWarpRequest)
  1400. {
  1401. var sSearchPath = "";
  1402. if (formWarpRequest["reRunObj"])
  1403. {
  1404. sSearchPath = formWarpRequest["reRunObj"].value;
  1405. }
  1406. else
  1407. {
  1408. sSearchPath = formWarpRequest["ui.object"].value;
  1409. }
  1410. var sBackURL = this.getCV().getGateway() + "?" + constructGETRequestParamsString("b_action=xts.run&m=portal/viewer-closeIframe.xts&cv.id=" + this.getCVId());
  1411. var formFields = {
  1412. "m":"portal/new_general.xts",
  1413. "m_new_class":sNewClass,
  1414. "so.searchPath":sNewSearchPath,
  1415. "m_name":this.getCV().envParams["ui.name"],
  1416. "m_obj_searchPath":sSearchPath,
  1417. "m_obj":sSearchPath};
  1418. formFields["ui.backURL"] = sBackURL;
  1419. cvLoadDialog(this.getCV(), formFields, 500, 425, RV_RES.IDS_JS_ADD_TO_MY_FOLDERS_IFRAME_TITLE);
  1420. }
  1421. };
  1422. /*
  1423. * Used to add to the user bookmarks. Only available in IE
  1424. */
  1425. CViewerManager.prototype.addToBookmarks = function()
  1426. {
  1427. var formWarpRequest = document.getElementById("formWarpRequest" + this.getCVId());
  1428. var envParams = this.getCV().envParams;
  1429. var sURLParams = "b_action=cognosViewer";
  1430. for(var envParam in envParams)
  1431. {
  1432. // get all the ui. params except a few
  1433. if (envParam.indexOf("ui.") == 0 && envParam != "ui.primaryAction" && envParam != "ui.backURL" && envParams != "ui.spec" && envParam != "ui.conversation" && envParam != "ui.cafcontextid")
  1434. {
  1435. sURLParams += "&" + envParam + "=";
  1436. if (envParam == "ui.action" && envParams["ui.primaryAction"] != "")
  1437. {
  1438. sURLParams += encodeURIComponent(envParams["ui.primaryAction"]);
  1439. }
  1440. else
  1441. {
  1442. sURLParams += encodeURIComponent(envParams[envParam]);
  1443. }
  1444. }
  1445. // all the run params
  1446. if (envParam.indexOf("run.") == 0)
  1447. {
  1448. sURLParams += "&" + envParam + "=" + encodeURIComponent(envParams[envParam]);
  1449. }
  1450. }
  1451. var sURL = this.getCV().sGateway + "?" + constructGETRequestParamsString(sURLParams);
  1452. var sBookmarkText = "";
  1453. if (formWarpRequest["ui.action"].value == 'view')
  1454. {
  1455. if (typeof envParams['versionName'] != "undefined" && envParams['versionName'] != "")
  1456. {
  1457. sBookmarkText = RV_RES.RV_VIEW_REPORT;
  1458. }
  1459. else
  1460. {
  1461. sBookmarkText = RV_RES.RV_VIEW_RECENT_REPORT;
  1462. }
  1463. }
  1464. if (formWarpRequest["ui.action"].value == 'run')
  1465. {
  1466. sBookmarkText = RV_RES.RV_RUN_REPORT;
  1467. }
  1468. if (sBookmarkText != "")
  1469. {
  1470. sBookmarkText += " - ";
  1471. }
  1472. sBookmarkText += envParams["ui.name"];
  1473. window.external.AddFavorite(sURL, sBookmarkText);
  1474. };
  1475. function leavingRV()
  1476. {
  1477. if (window.gaRV_INSTANCES && window.gaRV_INSTANCES.length)
  1478. {
  1479. for (var idxRV = 0; idxRV < window.gaRV_INSTANCES.length; idxRV++)
  1480. {
  1481. try
  1482. {
  1483. var oCV = window.gaRV_INSTANCES[idxRV];
  1484. if (oCV)
  1485. {
  1486. var oRV = oCV.getRV();
  1487. if (oRV)
  1488. {
  1489. oRV.exit();
  1490. }
  1491. }
  1492. }
  1493. catch (e)
  1494. {
  1495. }
  1496. }
  1497. }
  1498. }
  1499. function viewerMainKeyPress(evt)
  1500. {
  1501. //get the event in a cross-browser fashion
  1502. evt = (evt) ? evt : ((event) ? event : null);
  1503. if (window.gaRV_INSTANCES && window.gaRV_INSTANCES.length)
  1504. {
  1505. for (var idxRV = 0; idxRV < window.gaRV_INSTANCES.length; idxRV++)
  1506. {
  1507. try
  1508. {
  1509. var oCV = window.gaRV_INSTANCES[idxRV];
  1510. if (oCV && oCV.getId() == "_NS_")
  1511. {
  1512. // in firefox the keyCode will always be zero, so use the charCode if it's there. In IE, the charCode is undefined.
  1513. var keyPressed = evt.keyCode;
  1514. if (keyPressed == 0 && typeof evt.charCode != "undefined") {
  1515. keyPressed = evt.charCode;
  1516. }
  1517. // put focus on the report
  1518. if (!oCV.getViewerWidget() && (keyPressed == "64" || keyPressed == "50") && evt.shiftKey == true && evt.ctrlKey == true) { // Ctrl + Shift + 2
  1519. if (oCV.focusBackToMainContent)
  1520. {
  1521. oCV.focusBackToMainContent(evt);
  1522. return stopEventBubble(evt);
  1523. }
  1524. }
  1525. // put focus on the page navigation
  1526. else if (!oCV.getViewerWidget() && (keyPressed == "51" || keyPressed == "110") && evt.shiftKey == true && evt.ctrlKey == true) { // Ctrl + Shift + 3
  1527. var navLinks = document.getElementById("CVNavLinks" + oCV.getId());
  1528. if (navLinks) {
  1529. navLinks.setAttribute("tabIndex", "-1");
  1530. navLinks.focus();
  1531. return stopEventBubble(evt);
  1532. }
  1533. }
  1534. // put focus on the content
  1535. else if (!oCV.getViewerWidget() && keyPressed == "49" && evt.shiftKey == true && evt.ctrlKey == true)
  1536. { // Ctrl + Shift + 1
  1537. if (oCV.focusBackToContent)
  1538. {
  1539. oCV.focusBackToContent(evt)
  1540. return stopEventBubble(evt);
  1541. }
  1542. }
  1543. }
  1544. }
  1545. catch (e)
  1546. {
  1547. }
  1548. }
  1549. }
  1550. }
  1551. var g_ViewerResizeTimer = 0;
  1552. function onResizeViewerEvent(evt) {
  1553. // The resize event gets fired a lot when resizing the browser and we don't want to
  1554. // resize the pinned container on every resize event. Add a 200ms timeout, and if no other
  1555. // resize event is received in that 200 ms then go ahead and resize the pinned containers.
  1556. clearTimeout(g_ViewerResizeTimer);
  1557. g_ViewerResizeTimer = setTimeout(resizePinnedContainers, 200);
  1558. }
  1559. function constructGETRequestParamsString(urlParams)
  1560. {
  1561. if (typeof CAFXSSEncode == "function") {
  1562. // we should encode the part only AFTER ? symbol
  1563. if(urlParams.indexOf('?') >=0 ){
  1564. var aArray = urlParams.split('?');
  1565. //For URL like "?xxxx", aArray[0] is empty JS string
  1566. return aArray[0] + "?" + CAFXSSEncode(aArray[aArray.length-1]);
  1567. }
  1568. //Does not contain ?
  1569. return CAFXSSEncode(urlParams);
  1570. }
  1571. else {
  1572. return urlParams;
  1573. }
  1574. }
  1575. function sortReportHistoryStackDescending(a,b) {
  1576. return (b.getIdx() - a.getIdx());
  1577. }
  1578. function sortReportHistoryStackAscending(a,b) {
  1579. return (b.getIdx() - a.getIdx());
  1580. }
  1581. // Toolbar Styles
  1582. gToolbarButtonStyle = new CUIStyle('toolbarButton', 'toolbarButtonOver', 'toolbarButtonPressed', 'toolbarButtonOverPressed', 'toolbarButton');
  1583. gToolbarStyle = new CUIStyle('mainViewerHeader3', "", "", "", "");
  1584. gBannerButtonStyle = new CUIStyle('bannerToolbarButton', 'bannerToolbarButtonOver', "", "", "");
  1585. gBannerToolbarStyle = new CUIStyle('bannerButtonContainer', "", "", "", "");
  1586. // Menu Styles
  1587. gMenuItemStyle = new CUIStyle('menuItem_normal', 'menuItem_hover', "", "", 'menuItem_disabled');
  1588. gMenuStyle = new CUIStyle('clsMenu', "", "", "", "");
  1589. gMenuSeperatorStyle = new CUIStyle('menuHorizontalSeperator',"","","","");
  1590. // Banner link style
  1591. gBannerItemStyle = new CUIStyle('bannerMenuItem','bannerMenuItemOver',"","","");
  1592. // Static Text
  1593. gBannerStaticText = new CUIStyle('bannerText',"","","","");
  1594. // Link
  1595. gBannerLink = new CUIStyle('bannerLink','bannerLink',"","","");
  1596. // Context Menu Seperator
  1597. gMenuSeperator = new CSeperator('horizontal_line', '1',gMenuSeperatorStyle);
  1598. // Toolbar Seperator
  1599. gToolbarSeperator = new CSeperator("horizonal_blank", "5");
  1600. function CMainWnd(oCV)
  1601. {
  1602. this.setCV(oCV);
  1603. this.m_contextMenu = null;
  1604. this.m_reportHistoryList = [];
  1605. this.m_currentFormat = "";
  1606. this.m_toolbar = null;
  1607. this.m_bannerToolbar = null;
  1608. this.m_browserHistoryIndex = history.length;
  1609. this.m_showContextMenuOnClick = false;
  1610. if (oCV.getConfig && oCV.getConfig()) {
  1611. var eventsConfig = oCV.getConfig().getEventsConfig();
  1612. this.m_showContextMenuOnClick = eventsConfig ? eventsConfig.getShowContextMenuOnClick() : false;
  1613. }
  1614. }
  1615. CMainWnd.prototype = new CViewerHelper();
  1616. CMainWnd.prototype.setBannerToolbar = function(bannerToolbarSpecification)
  1617. {
  1618. this.m_bannerToolbar = new CViewerToolbar();
  1619. this.m_bannerToolbar.init(bannerToolbarSpecification);
  1620. };
  1621. CMainWnd.prototype.getBannerToolbar = function()
  1622. {
  1623. if (this.m_bannerToolbar)
  1624. {
  1625. return this.m_bannerToolbar.getCBar();
  1626. }
  1627. return null;
  1628. };
  1629. CMainWnd.prototype.closeContextMenuAndToolbarMenus = function() {
  1630. var toolbar = this.getToolbar();
  1631. if (toolbar) {
  1632. toolbar.closeMenus();
  1633. }
  1634. var cm = this.getContextMenu();
  1635. if (cm) {
  1636. cm.m_contextMenu.remove();
  1637. }
  1638. };
  1639. CMainWnd.prototype.setToolbar = function(toolbarSpecification)
  1640. {
  1641. this.m_toolbar = new CViewerToolbar();
  1642. this.m_toolbar.init(toolbarSpecification);
  1643. };
  1644. CMainWnd.prototype.getToolbar = function()
  1645. {
  1646. if (this.m_toolbar)
  1647. {
  1648. return this.m_toolbar.getCBar();
  1649. }
  1650. return null;
  1651. };
  1652. CMainWnd.prototype.getToolbarControl = function()
  1653. {
  1654. return this.m_toolbar;
  1655. };
  1656. CMainWnd.prototype.setCurrentFormat = function(sFormat)
  1657. {
  1658. this.m_currentFormat = sFormat;
  1659. };
  1660. CMainWnd.prototype.updateToolbar = function(sFormat)
  1661. {
  1662. this.updateCurrentFormat(sFormat, this.getCV().getWebContentRoot());
  1663. this.updateKeepThisVersion();
  1664. };
  1665. CMainWnd.prototype.updateKeepThisVersion = function()
  1666. {
  1667. if (this.getCV().getStatus() == 'complete')
  1668. {
  1669. var secondaryRequests = this.getCV().getSecondaryRequests();
  1670. var bSave = false;
  1671. var bSaveAs = false;
  1672. var bEmail = false;
  1673. if (secondaryRequests)
  1674. {
  1675. for (var iIndex=0; iIndex < secondaryRequests.length; iIndex++)
  1676. {
  1677. switch (secondaryRequests[iIndex])
  1678. {
  1679. case 'save':
  1680. bSave = true;
  1681. break;
  1682. case 'saveAs':
  1683. bSaveAs = true;
  1684. break;
  1685. case 'email':
  1686. bEmail = true;
  1687. break;
  1688. }
  1689. }
  1690. }
  1691. var toolbarControl = this.getToolbarControl();
  1692. if (toolbarControl)
  1693. {
  1694. var keepThisVersion = toolbarControl.getItem("keepThisVersion");
  1695. if (keepThisVersion)
  1696. {
  1697. if (!bSave && !bSaveAs && !bEmail) { keepThisVersion.hide(); } else { keepThisVersion.show(); }
  1698. var keepThisVersionMenu = keepThisVersion.getMenu();
  1699. if (bSave || bSaveAs || bEmail)
  1700. {
  1701. if (keepThisVersionMenu)
  1702. {
  1703. var saveMenuItem = keepThisVersionMenu.getItem("saveReport");
  1704. if (saveMenuItem)
  1705. {
  1706. if (bSave) { saveMenuItem.show(); } else { saveMenuItem.hide(); }
  1707. }
  1708. var saveAsMenuItem = keepThisVersionMenu.getItem("saveAsReportView");
  1709. if (saveAsMenuItem)
  1710. {
  1711. if (bSaveAs) { saveAsMenuItem.show(); } else { saveAsMenuItem.hide(); }
  1712. }
  1713. var emailMenuItem = keepThisVersionMenu.getItem("emailReport");
  1714. if (emailMenuItem)
  1715. {
  1716. if (bEmail) { emailMenuItem.show(); } else { emailMenuItem.hide(); }
  1717. }
  1718. }
  1719. }
  1720. }
  1721. }
  1722. }
  1723. };
  1724. function CMainWnd_updateCurrentFormat(sFormat, sWebContentRoot)
  1725. {
  1726. var sIcon = "";
  1727. var sTooltip = "";
  1728. switch(sFormat)
  1729. {
  1730. case 'HTML':
  1731. case 'HTMLFragment':
  1732. case 'XHTMLFRGMT':
  1733. sIcon = sWebContentRoot + "/rv/images/action_view_html.gif";
  1734. sTooltip = RV_RES.RV_VIEW_HTML;
  1735. break;
  1736. case 'PDF':
  1737. sIcon = sWebContentRoot + "/rv/images/action_view_pdf.gif";
  1738. sTooltip = RV_RES.RV_VIEW_PDF;
  1739. break;
  1740. case 'XML':
  1741. sIcon = sWebContentRoot + "/rv/images/action_view_xml.gif";
  1742. sTooltip = RV_RES.RV_VIEW_XML;
  1743. break;
  1744. }
  1745. if(sIcon != "" && sTooltip != "")
  1746. {
  1747. var toolbarControl = this.getToolbarControl();
  1748. if(toolbarControl)
  1749. {
  1750. var bIsUIActionView = this.getCV().envParams["ui.action"] == "view";
  1751. var formatButton = null;
  1752. if(bIsUIActionView)
  1753. {
  1754. formatButton = toolbarControl.getItem("viewIn");
  1755. }
  1756. else
  1757. {
  1758. formatButton = toolbarControl.getItem("runIn");
  1759. }
  1760. if(formatButton)
  1761. {
  1762. formatButton.setIcon(sIcon);
  1763. formatButton.setToolTip(sTooltip);
  1764. var sRV = this.getCVObjectRef() + ".getRV().";
  1765. formatButton.setAction("javascript:" + sRV + "viewReport('" + sFormat + "');");
  1766. }
  1767. }
  1768. }
  1769. this.setCurrentFormat(sFormat);
  1770. }
  1771. CMainWnd.prototype.getCurrentFormat = function()
  1772. {
  1773. return this.m_currentFormat;
  1774. };
  1775. function CMainWnd_getSelectionController()
  1776. {
  1777. var selectionController;
  1778. try
  1779. {
  1780. selectionController = getCognosViewerSCObjectRef(this.getCV().getId());
  1781. }
  1782. catch(e)
  1783. {
  1784. // ignore the exception and set the selection controller to null
  1785. selectionController = null;
  1786. }
  1787. return selectionController;
  1788. }
  1789. var g_oPressTimer = null;
  1790. var g_bLongPressDetected = false;
  1791. var g_oPreviousValues = {};
  1792. if (window.attachEvent)
  1793. {
  1794. window.attachEvent("onmouseout", f_cancelLongTouch);
  1795. window.attachEvent("ontouchstart", onTouchStart);
  1796. window.attachEvent("ontouchend", f_cancelLongTouch);
  1797. window.attachEvent("ontouchleave", f_cancelLongTouch);
  1798. window.attachEvent("ontouchcancel", f_cancelLongTouch);
  1799. }
  1800. else if (window.addEventListener)
  1801. {
  1802. window.addEventListener("mouseout", f_cancelLongTouch);
  1803. window.addEventListener("touchstart", onTouchStart);
  1804. window.addEventListener("touchend", f_cancelLongTouch);
  1805. window.addEventListener("touchleave", f_cancelLongTouch);
  1806. window.addEventListener("touchcancel", f_cancelLongTouch);
  1807. }
  1808. function f_cancelLongTouch (evt) {
  1809. if (isIOS())
  1810. {
  1811. if ( g_oPressTimer !== null) {
  1812. clearTimeout( g_oPressTimer );
  1813. g_oPressTimer = null;
  1814. }
  1815. }
  1816. }
  1817. function onTouchStart(evt)
  1818. {
  1819. if (isIOS())
  1820. {
  1821. g_bLongPressDetected = false;
  1822. g_oPressTimer = setTimeout(function() {
  1823. var node = getNodeFromEvent(evt);
  1824. // get the existing values so that they can be restored later
  1825. g_oPreviousValues.webkitTouchCallout = node.style.getPropertyValue("webkitTouchCallout");
  1826. g_oPreviousValues.webkitUserSelect = node.style.getPropertyValue("webkitUserSelect");
  1827. // set values to none
  1828. node.style.webkitTouchCallout = "None";
  1829. node.style.webkitUserSelect = "None";
  1830. g_bLongPressDetected = true;
  1831. }, 1500);
  1832. }
  1833. return false;
  1834. }
  1835. function CMainWnd_pageClicked(evt)
  1836. {
  1837. var oCV = this.getCV();
  1838. f_cancelLongTouch (evt);
  1839. if (this.m_showContextMenuOnClick || ( isIOS() && g_bLongPressDetected)) {
  1840. var node = getNodeFromEvent(evt);
  1841. // Only draw the context menu if the user clicked on a node that doesn't have a link
  1842. if (node && typeof node.onclick != "function" && (node.nodeName.toLowerCase() != "span" || typeof node.parentNode.onclick != "function")) {
  1843. oCV.dcm(evt, true);
  1844. if ( isIOS() && g_bLongPressDetected)
  1845. {
  1846. node.style.webkitTouchCallout = g_oPreviousValues.webkitTouchCallout;
  1847. node.style.webkitUserSelect = g_oPreviousValues.webkitUserSelect;
  1848. }
  1849. return stopEventBubble(evt);
  1850. }
  1851. }
  1852. this.hideOpenMenus();
  1853. if(oCV != null)
  1854. {
  1855. if (typeof oCV.sortColumn == "undefined" || !oCV.sortColumn(evt)) {
  1856. var oDrillMgr = oCV.getDrillMgr();
  1857. if (oDrillMgr)
  1858. {
  1859. var bDrilled = oDrillMgr.singleClickDrillEvent(evt, 'RV');
  1860. }
  1861. }
  1862. }
  1863. if (oCV.getViewerWidget())
  1864. {
  1865. oCV.getViewerWidget().updateToolbar();
  1866. }
  1867. setNodeFocus(evt);
  1868. if (bDrilled) {
  1869. return stopEventBubble(evt);
  1870. }
  1871. }
  1872. function CMainWnd_hideOpenMenus()
  1873. {
  1874. var cm = this.getContextMenu();
  1875. if (typeof cm != "undefined" && cm != null)
  1876. {
  1877. cm.hide();
  1878. }
  1879. var tb = this.getToolbar();
  1880. if (typeof tb != "undefined" && tb != null)
  1881. {
  1882. tb.closeMenus();
  1883. }
  1884. var banner = this.getBannerToolbar();
  1885. if (banner != "undefined" && banner != null)
  1886. {
  1887. banner.closeMenus();
  1888. }
  1889. }
  1890. function CMainWnd_draw()
  1891. {
  1892. var toolbar = this.getToolbar();
  1893. if (toolbar && this.m_uiBlackList.indexOf(' RV_TOOLBAR_BUTTONS '))
  1894. {
  1895. var sRunOutputFormat = "";
  1896. var f = document.forms['formWarpRequest' + this.getCVId()];
  1897. if (f["run.outputFormat"] && f["run.outputFormat"].value)
  1898. {
  1899. sRunOutputFormat = f["run.outputFormat"].value;
  1900. }
  1901. else if (f["ui.format"] && f["ui.format"].value)
  1902. {
  1903. sRunOutputFormat = f["ui.format"].value;
  1904. }
  1905. if(sRunOutputFormat != "")
  1906. {
  1907. this.updateCurrentFormat(sRunOutputFormat, this.getCV().getWebContentRoot());
  1908. }
  1909. toolbar.draw();
  1910. }
  1911. var bannerToolbar = this.getBannerToolbar();
  1912. if (bannerToolbar)
  1913. {
  1914. bannerToolbar.draw();
  1915. }
  1916. }
  1917. function CMainWnd_addToReportHistory(reportHistoryObj) {
  1918. this.m_reportHistoryList[this.m_reportHistoryList.length] = reportHistoryObj;
  1919. }
  1920. function CMainWnd_getReportHistory() {
  1921. return this.m_reportHistoryList;
  1922. }
  1923. function CMainWnd_getContextMenu() {
  1924. return this.m_contextMenu;
  1925. }
  1926. function CMainWnd_displayContextMenu(evt, selectNode)
  1927. {
  1928. if(!this.getCV().bEnableContextMenu)
  1929. {
  1930. return false;
  1931. }
  1932. //get the event in a cross-browser fashion
  1933. evt = (evt) ? evt : ((event) ? event : null);
  1934. var selectionController = this.getSelectionController();
  1935. if(selectionController != null)
  1936. {
  1937. var cm = this.getContextMenu();
  1938. if(selectNode && this.getCV().bCanUseCognosViewerSelection == true)
  1939. {
  1940. if (!selectionController.pageContextClicked(evt))
  1941. {
  1942. if (typeof cm != "undefined" && cm != null)
  1943. {
  1944. cm.m_contextMenu.remove();
  1945. }
  1946. return false;
  1947. }
  1948. }
  1949. cm = this.getContextMenu();
  1950. if (typeof cm != "undefined" && cm != null)
  1951. {
  1952. cm.draw(evt);
  1953. // need the cell node in firefox to reset the focus to the cell when the context menu closes
  1954. if (!isIE())
  1955. {
  1956. cm.m_contextMenu.m_focusCell = getNodeFromEvent(evt);
  1957. }
  1958. }
  1959. var tb = this.getToolbar();
  1960. if (typeof tb != "undefined" && tb != null)
  1961. {
  1962. tb.closeMenus();
  1963. }
  1964. var banner = this.getBannerToolbar();
  1965. if (banner != "undefined" && banner != null)
  1966. {
  1967. banner.closeMenus();
  1968. }
  1969. }
  1970. }
  1971. function CMainWnd_getReportHistoryLength() {
  1972. return this.m_reportHistoryList.length;
  1973. }
  1974. function CMainWnd_executePreviousReport(stackIdx)
  1975. {
  1976. // if the stack index is -1, the previous report button button was pressed, and this function was not called from the
  1977. // drop down menu. Set the stack index to the most recent report
  1978. if(stackIdx == -1) {
  1979. stackIdx = this.getReportHistoryLength() - 1;
  1980. }
  1981. for(var i = 0; i < this.getReportHistoryLength(); ++i)
  1982. {
  1983. var currentObj = this.m_reportHistoryList[i];
  1984. if(currentObj.getIdx() == stackIdx)
  1985. {
  1986. currentObj.execute();
  1987. return;
  1988. }
  1989. }
  1990. }
  1991. function CMainWnd_getReportHistoryConversations()
  1992. {
  1993. var reportHistoryConversations = [];
  1994. var reportHistoryList = this.getReportHistory();
  1995. for(var reportHistoryIdx = 0; reportHistoryIdx < reportHistoryList.length; ++reportHistoryIdx)
  1996. {
  1997. var reportHistory = reportHistoryList[reportHistoryIdx];
  1998. var tracking = reportHistory.getTrackingInfo();
  1999. if(tracking != "") {
  2000. reportHistoryConversations.push(tracking);
  2001. }
  2002. }
  2003. return reportHistoryConversations;
  2004. }
  2005. function CMainWnd_getUIHide()
  2006. {
  2007. return this.m_uiBlackList;
  2008. }
  2009. CMainWnd.prototype.loadPreviousReports = function()
  2010. {
  2011. // load any previous reports
  2012. var sPreviousReports = this.getCV().envParams["cv.previousReports"];
  2013. if(typeof sPreviousReports != "undefined" && sPreviousReports != null)
  2014. {
  2015. var xmlParsedCvPreviousReports = XMLBuilderLoadXMLFromString(sPreviousReports);
  2016. // get the root node
  2017. var rootNode = XMLHelper_GetFirstChildElement( xmlParsedCvPreviousReports );
  2018. if(XMLHelper_GetLocalName(rootNode) == "previousReports")
  2019. {
  2020. var previousReportEntries = rootNode.childNodes;
  2021. for(var index = 0; index < previousReportEntries.length; ++index)
  2022. {
  2023. var previousReportEntry = previousReportEntries[index];
  2024. var paramNodes = previousReportEntry.childNodes;
  2025. var reportName = "";
  2026. var params = {};
  2027. for(var paramNodeIndex = 0; paramNodeIndex < paramNodes.length; ++paramNodeIndex)
  2028. {
  2029. var sParamName = paramNodes[paramNodeIndex].getAttribute("name");
  2030. switch(sParamName)
  2031. {
  2032. case "ui.name":
  2033. reportName = XMLHelper_GetText(paramNodes[paramNodeIndex]);
  2034. break;
  2035. default:
  2036. params[sParamName] = XMLHelper_GetText(paramNodes[paramNodeIndex]);
  2037. break;
  2038. }
  2039. }
  2040. this.addToReportHistory(new CReportHistory(this, index, reportName, params));
  2041. }
  2042. }
  2043. }
  2044. };
  2045. CMainWnd.prototype.init = function()
  2046. {
  2047. this.m_uiBlackList = "";
  2048. if (typeof this.getCV().UIBlacklist == "string")
  2049. {
  2050. this.m_uiBlackList = this.getCV().UIBlacklist;
  2051. }
  2052. if ((typeof gCognosViewer != "undefined") && (gCognosViewer.envParams["isTitan"]) && (gCognosViewer.envParams["isTitan"] == true))
  2053. {
  2054. gMenuItemStyle = new CUIStyle('titanui menuItem_normal', 'titanui menuItem_hover', "", "", 'titanui menuItem_disabled');
  2055. }
  2056. // reset context menu and toolbar with new blacklist
  2057. this.m_contextMenu = null;
  2058. if(this.getCV().bEnableContextMenu && typeof CContextMenu != "undefined" && this.m_uiBlackList.indexOf(' RV_CONTEXT_MENU ') == -1) {
  2059. this.m_contextMenu = new CContextMenu(this);
  2060. }
  2061. this.loadPreviousReports();
  2062. // make sure the global seperators have the correct webContent root
  2063. gMenuSeperator.setWebContentRoot(this.getCV().getWebContentRoot());
  2064. gToolbarSeperator.setWebContentRoot(this.getCV().getWebContentRoot());
  2065. };
  2066. CMainWnd.prototype.renderPreviousReports = function()
  2067. {
  2068. var toolbar = this.getToolbarControl();
  2069. var previousReportButton = toolbar.getItem("previousReport");
  2070. var sWebContentRoot = this.getCV().getWebContentRoot();
  2071. var sSkin = this.getCV().getSkin();
  2072. if(previousReportButton)
  2073. {
  2074. var previousReportDropDownMenu = previousReportButton.getMenu();
  2075. var reportHistoryList = this.getReportHistory();
  2076. for(var index = 0; index < reportHistoryList.length; ++index)
  2077. {
  2078. var reportHistoryObject = reportHistoryList[index];
  2079. new CMenuItem(previousReportDropDownMenu, reportHistoryObject.getReportName(), "javascript:" + this.getCV().getObjectId() + ".rvMainWnd.executePreviousReport(" + index + ");", sWebContentRoot + reportHistoryObject.getDropDownMenuIcon(), gMenuItemStyle, sWebContentRoot, sSkin);
  2080. }
  2081. previousReportDropDownMenu.draw();
  2082. }
  2083. };
  2084. function CMainWnd_update(subject)
  2085. {
  2086. // validate the subject
  2087. if(typeof subject == "undefined" || subject === null) {
  2088. return;
  2089. }
  2090. // if we're being notified by the selection controller that selection has changed, notify the toolbar and context menu
  2091. if(subject instanceof CSelectionController)
  2092. {
  2093. var rvToolbar = this.getToolbarControl();
  2094. if(typeof rvToolbar != "undefined" && rvToolbar != null)
  2095. {
  2096. var oDrillMgr = this.getCV().getDrillMgr();
  2097. if(oDrillMgr)
  2098. {
  2099. var gotoToolbarButton = rvToolbar.getItem("goto");
  2100. if(gotoToolbarButton)
  2101. {
  2102. var menu = gotoToolbarButton.getMenu();
  2103. if(menu)
  2104. {
  2105. // when the selection changes clear out the cached report drill targets (if any)
  2106. menu.clear();
  2107. }
  2108. }
  2109. var drillDownToolbarButton = rvToolbar.getItem("drillDown");
  2110. if (drillDownToolbarButton)
  2111. {
  2112. if (oDrillMgr.canDrillDown()) { drillDownToolbarButton.enable(); } else { drillDownToolbarButton.disable(); }
  2113. }
  2114. var drillUpToolbarButton = rvToolbar.getItem("drillUp");
  2115. if (drillUpToolbarButton)
  2116. {
  2117. if (oDrillMgr.canDrillUp()) { drillUpToolbarButton.enable(); } else { drillUpToolbarButton.disable(); }
  2118. }
  2119. }
  2120. var lineageButton = rvToolbar.getItem("lineage");
  2121. if(lineageButton)
  2122. {
  2123. var selections = subject.getAllSelectedObjects();
  2124. if(selections != null && selections.length > 0)
  2125. {
  2126. lineageButton.enable();
  2127. }
  2128. else
  2129. {
  2130. lineageButton.disable();
  2131. }
  2132. }
  2133. }
  2134. var rvContextMenu = this.getContextMenu();
  2135. if(typeof rvContextMenu != "undefined" && rvContextMenu != null)
  2136. {
  2137. rvContextMenu.update(subject);
  2138. }
  2139. }
  2140. }
  2141. function CMainWnd_addDrillTargets(drillTargets) {
  2142. this.m_oCV.addDrillTargets(drillTargets);
  2143. }
  2144. function CMainWnd_getDrillTargets() {
  2145. return this.m_oCV.getDrillTargets();
  2146. }
  2147. function CMainWnd_getDrillTarget(idx)
  2148. {
  2149. return this.m_oCV.getDrillTarget(idx);
  2150. }
  2151. function CMainWnd_getNumberOfDrillTargets() {
  2152. return this.m_oCV.getNumberOfDrillTargets();
  2153. }
  2154. CMainWnd.prototype.renderAvailableOutputs = function()
  2155. {
  2156. var sObjectId = this.getCVObjectRef() + ".getRV().";
  2157. var oCV = this.getCV();
  2158. var toolbarCtrl = this.getToolbarControl();
  2159. var sBlacklist = this.getUIHide();
  2160. var sWebContentRoot = oCV.getWebContentRoot();
  2161. var sSkin = oCV.getSkin();
  2162. var viewInButton = null;
  2163. var oFormatDropDownMenu = null;
  2164. if (typeof toolbarCtrl != "undefined" && toolbarCtrl != null) {
  2165. viewInButton = toolbarCtrl.getItem("viewIn");
  2166. if (viewInButton)
  2167. {
  2168. oFormatDropDownMenu = viewInButton.getMenu();
  2169. }
  2170. }
  2171. if(oFormatDropDownMenu.getNumItems() == 0)
  2172. {
  2173. // view in html
  2174. if (sBlacklist.indexOf(' RV_TOOLBAR_BUTTONS_HTML ') == -1)
  2175. {
  2176. this.m_viewInHtmlButton = new CMenuItem(oFormatDropDownMenu, RV_RES.RV_VIEW_HTML, "javascript:" + sObjectId + "viewReport('HTML');", sWebContentRoot + '/rv/images/action_view_html.gif', gMenuItemStyle, sWebContentRoot, sSkin);
  2177. if(oCV.oOutputFormatPath.HTML == "")
  2178. {
  2179. this.m_viewInHtmlButton.disable();
  2180. }
  2181. }
  2182. // view in PDF
  2183. if (sBlacklist.indexOf(' RV_TOOLBAR_BUTTONS_PDF ') == -1)
  2184. {
  2185. this.m_viewInPDFButton = new CMenuItem(oFormatDropDownMenu, RV_RES.RV_VIEW_PDF, "javascript:" + sObjectId + "viewReport('PDF');", sWebContentRoot + '/rv/images/action_view_pdf.gif', gMenuItemStyle, sWebContentRoot, sSkin);
  2186. if(oCV.oOutputFormatPath.PDF == "")
  2187. {
  2188. this.m_viewInPDFButton.disable();
  2189. }
  2190. }
  2191. // view in XML
  2192. if (sBlacklist.indexOf(' RV_TOOLBAR_BUTTONS_XML ') == -1)
  2193. {
  2194. this.m_viewInXMLButton = new CMenuItem(oFormatDropDownMenu, RV_RES.RV_VIEW_XML, "javascript:" + sObjectId + "viewReport('XML');", sWebContentRoot + '/rv/images/action_view_xml.gif', gMenuItemStyle, sWebContentRoot, sSkin);
  2195. if(oCV.oOutputFormatPath.XML == "")
  2196. {
  2197. this.m_viewInXMLButton.disable();
  2198. }
  2199. }
  2200. // view in excel options
  2201. if (sBlacklist.indexOf(' RV_TOOLBAR_BUTTONS_XLS ') == -1)
  2202. {
  2203. this.m_viewInXLSButton = new CMenuItem(oFormatDropDownMenu, RV_RES.RV_VIEW_OPTIONS, "", sWebContentRoot + '/rv/images/action_view_excel_options.gif', gMenuItemStyle, sWebContentRoot, sSkin);
  2204. this.excelFormatCascadedMenu = this.m_viewInXLSButton.createCascadedMenu(gMenuStyle, RV_RES.RV_VIEW_OPTIONS);
  2205. if (sBlacklist.indexOf(' RV_TOOLBAR_BUTTONS_XLS_SPREADSHEETML_DATA ') == -1)
  2206. {
  2207. this.viewInSpreadsheetMLDataMenuItem = new CMenuItem(this.excelFormatCascadedMenu, RV_RES.RV_VIEW_SPREADSHEETML_DATA, "javascript:" + sObjectId + "viewReport('xlsxData');", sWebContentRoot + "/rv/images/action_view_excel_2007.gif", gMenuItemStyle, sWebContentRoot, sSkin);
  2208. if(oCV.oOutputFormatPath.xlsxData == "")
  2209. {
  2210. this.viewInSpreadsheetMLDataMenuItem.disable();
  2211. }
  2212. }
  2213. if (sBlacklist.indexOf(' RV_TOOLBAR_BUTTONS_XLS_SPREADSHEETML ') == -1)
  2214. {
  2215. this.viewInSpreadsheetMLMenuItem = new CMenuItem(this.excelFormatCascadedMenu, RV_RES.RV_VIEW_SPREADSHEETML, "javascript:" + sObjectId + "viewReport('spreadsheetML');", sWebContentRoot + "/rv/images/action_view_excel_2007.gif", gMenuItemStyle, sWebContentRoot, sSkin);
  2216. if(oCV.oOutputFormatPath.spreadsheetML == "")
  2217. {
  2218. this.viewInSpreadsheetMLMenuItem.disable();
  2219. }
  2220. }
  2221. if (sBlacklist.indexOf(' RV_TOOLBAR_BUTTONS_XLS_XLWA ') == -1)
  2222. {
  2223. this.viewInXLSWebArchiveMenuItem = new CMenuItem(this.excelFormatCascadedMenu , RV_RES.RV_VIEW_XLWA, "javascript:" + sObjectId + "viewReport('XLWA');", sWebContentRoot + "/rv/images/action_view_excel_2002.gif", gMenuItemStyle, sWebContentRoot, sSkin);
  2224. if(oCV.oOutputFormatPath.XLWA == "")
  2225. {
  2226. this.viewInXLSWebArchiveMenuItem.disable();
  2227. }
  2228. }
  2229. if (sBlacklist.indexOf(' RV_TOOLBAR_BUTTONS_XLS_SINGLEXLS ') == -1)
  2230. {
  2231. this.viewInSingleXLSMenuItem = new CMenuItem(this.excelFormatCascadedMenu , RV_RES.RV_VIEW_SINGLE_EXCEL, "javascript:" + sObjectId + "viewReport('singleXLS');", sWebContentRoot + "/rv/images/action_view_excel_options.gif", gMenuItemStyle, sWebContentRoot, sSkin);
  2232. if(oCV.oOutputFormatPath.singleXLS == "")
  2233. {
  2234. this.viewInSingleXLSMenuItem.disable();
  2235. }
  2236. }
  2237. if (sBlacklist.indexOf(' RV_TOOLBAR_BUTTONS_XLS_XLS ') == -1)
  2238. {
  2239. this.viewInSingleXLSMenuItem = new CMenuItem(this.excelFormatCascadedMenu , RV_RES.RV_VIEW_EXCEL, "javascript:" + sObjectId + "viewReport('XLS');", sWebContentRoot + "/rv/images/action_view_excel_2000.gif", gMenuItemStyle, sWebContentRoot, sSkin);
  2240. if(oCV.oOutputFormatPath.XLS == "")
  2241. {
  2242. this.viewInSingleXLSMenuItem.disable();
  2243. }
  2244. }
  2245. if (sBlacklist.indexOf(' RV_TOOLBAR_BUTTONS_XLS_CSV ') == -1)
  2246. {
  2247. var iconPath = "";
  2248. if (getViewerDirection() == "rtl") {
  2249. iconPath = "/rv/images/action_view_csv_rtl.gif";
  2250. }
  2251. else {
  2252. iconPath = "/rv/images/action_view_csv.gif";
  2253. }
  2254. this.viewInCSVMenuItem = new CMenuItem(this.excelFormatCascadedMenu , RV_RES.RV_VIEW_CSV, "javascript:" + sObjectId + "viewReport('CSV');", sWebContentRoot + iconPath, gMenuItemStyle, sWebContentRoot, sSkin);
  2255. if(oCV.oOutputFormatPath.CSV == "")
  2256. {
  2257. this.viewInCSVMenuItem.disable();
  2258. }
  2259. }
  2260. }
  2261. }
  2262. oFormatDropDownMenu.draw();
  2263. if (oFormatDropDownMenu.isVisible()) {
  2264. oFormatDropDownMenu.show();
  2265. }
  2266. };
  2267. CMainWnd.prototype.saveReportHistoryAsXML = function()
  2268. {
  2269. var sReportHistorySpecification = "";
  2270. var reportHistoryList = this.getReportHistory();
  2271. if(reportHistoryList.length > 0)
  2272. {
  2273. var previousReports = self.XMLBuilderCreateXMLDocument("previousReports");
  2274. var iStartingIndex = 0;
  2275. if (reportHistoryList.length > 20)
  2276. {
  2277. iStartingIndex = reportHistoryList.length - 20;
  2278. }
  2279. for(var index = iStartingIndex; index < reportHistoryList.length; ++index)
  2280. {
  2281. reportHistoryList[index].saveAsXML(previousReports.documentElement);
  2282. }
  2283. sReportHistorySpecification = XMLBuilderSerializeNode(previousReports);
  2284. }
  2285. return sReportHistorySpecification;
  2286. };
  2287. CMainWnd.prototype.addCurrentReportToReportHistory = function()
  2288. {
  2289. var oCV = this.getCV();
  2290. var params = {};
  2291. var reportName = oCV.envParams["ui.name"];
  2292. var sAction = oCV.envParams["ui.action"];
  2293. if(sAction == "view")
  2294. {
  2295. params["ui.action"] = "view";
  2296. params["ui.format"] = oCV.envParams["ui.format"];
  2297. }
  2298. else
  2299. {
  2300. params["ui.action"] = "currentPage";
  2301. params["ui.conversation"] = oCV.getConversation();
  2302. params["m_tracking"] = oCV.getTracking();
  2303. params["run.outputFormat"] = oCV.envParams["run.outputFormat"];
  2304. if (oCV.envParams["rapReportInfo"]) {
  2305. params["rapReportInfo"] = oCV.envParams["rapReportInfo"];
  2306. }
  2307. if (oCV.envParams.limitedInteractiveMode) {
  2308. params.limitedInteractiveMode = oCV.envParams.limitedInteractiveMode;
  2309. }
  2310. if (oCV.envParams["ui.spec"]) {
  2311. params["ui.spec"] = oCV.envParams["ui.spec"];
  2312. }
  2313. if (oCV.envParams.uiSpecAddedFromRun) {
  2314. params.uiSpecAddedFromRun = oCV.envParams.uiSpecAddedFromRun;
  2315. }
  2316. }
  2317. if(typeof oCV.envParams["ui.object"] != "undefined")
  2318. {
  2319. params["ui.object"] = oCV.envParams["ui.object"];
  2320. }
  2321. else
  2322. {
  2323. params["ui.spec"] = oCV.envParams["ui.spec"];
  2324. params["ui.object"] = "";
  2325. }
  2326. params["ui.primaryAction"] = oCV.envParams["ui.primaryAction"];
  2327. if(oCV.envParams["ui.routingServerGroup"])
  2328. {
  2329. params["ui.routingServerGroup"] = oCV.envParams["ui.routingServerGroup"];
  2330. }
  2331. this.addToReportHistory(new CReportHistory(this, this.m_reportHistoryList.length, reportName, params));
  2332. };
  2333. CMainWnd.prototype.draw = CMainWnd_draw;
  2334. CMainWnd.prototype.addDrillTargets = CMainWnd_addDrillTargets;
  2335. CMainWnd.prototype.getDrillTarget = CMainWnd_getDrillTarget;
  2336. CMainWnd.prototype.getDrillTargets = CMainWnd_getDrillTargets;
  2337. CMainWnd.prototype.getNumberOfDrillTargets = CMainWnd_getNumberOfDrillTargets;
  2338. CMainWnd.prototype.addToReportHistory = CMainWnd_addToReportHistory;
  2339. CMainWnd.prototype.getReportHistoryLength = CMainWnd_getReportHistoryLength;
  2340. CMainWnd.prototype.getReportHistory = CMainWnd_getReportHistory;
  2341. CMainWnd.prototype.executePreviousReport = CMainWnd_executePreviousReport;
  2342. CMainWnd.prototype.getContextMenu = CMainWnd_getContextMenu;
  2343. CMainWnd.prototype.displayContextMenu = CMainWnd_displayContextMenu;
  2344. CMainWnd.prototype.hideOpenMenus = CMainWnd_hideOpenMenus;
  2345. CMainWnd.prototype.pageClicked = CMainWnd_pageClicked;
  2346. CMainWnd.prototype.getUIHide = CMainWnd_getUIHide;
  2347. CMainWnd.prototype.update = CMainWnd_update;
  2348. CMainWnd.prototype.getSelectionController = CMainWnd_getSelectionController;
  2349. CMainWnd.prototype.getReportHistoryConversations = CMainWnd_getReportHistoryConversations;
  2350. CMainWnd.prototype.updateCurrentFormat = CMainWnd_updateCurrentFormat;
  2351. /**
  2352. * Function that will resize the iframe. This should only be called when we're viewing
  2353. * saved HTML output, we're standalone (i.e. not in QS or fragments) and we're in IE
  2354. */
  2355. function resizeIFrame(evt)
  2356. {
  2357. var oCV = window.gaRV_INSTANCES[0];
  2358. var oReportDiv = document.getElementById("CVReport" + oCV.getId());
  2359. var oReportIFrame = document.getElementById("CVIFrame" + oCV.getId());
  2360. if (typeof oReportDiv != "undefined" && oReportDiv != null && typeof oReportIFrame != "undefined" && oReportIFrame != null)
  2361. {
  2362. oCV.attachedOnResize = true;
  2363. oCV.setMaxContentSize();
  2364. oReportIFrame.style.height = "99%";
  2365. }
  2366. }