uicommon.js 95 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480
  1. // Licensed Materials - Property of IBM
  2. //
  3. // IBM Cognos Products: cpscrn
  4. //
  5. // (C) Copyright IBM Corp. 2005, 2021
  6. //
  7. // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  8. //
  9. //
  10. // Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  11. // Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  12. if (window.dojo) {
  13. dojo.require("dijit.dijit");
  14. }
  15. var maximizeBVToAvailableHeight = true;
  16. /**
  17. * ui_templates
  18. * Singleton to hold the current html templates.
  19. */
  20. var ui_templates = {
  21. contentTemplate:
  22. '<div id="^CONTENTID^" class="^CONTENTCLASS^" style="width:100%; height:100%;">' +
  23. '<table removeonerror="true" cellspacing="0" cellpadding="0" border="0" width="100%">' +
  24. '<tr>' +
  25. '<td style="text-align:center">' +
  26. '<br><br><br>' +
  27. '<div>' +
  28. '<img src="$WEB$/fragments/common/images/progress.gif" border="0">' +
  29. '<br>' +
  30. '<span>' +
  31. PFM.JS.IDS_JS_TAB_WAIT +
  32. '</span>' +
  33. '</div>' +
  34. '<br><br><br>' +
  35. '</td>' +
  36. '</tr>' +
  37. '</table>' +
  38. '</div>',
  39. /**
  40. * get usage:
  41. * using param names in message string:
  42. * get(template, "name1", "value1", "name2", "value2", ...)
  43. * using indexes in message string:
  44. * get(msg, ["value1", "value2", ...])
  45. */
  46. get: function(sourceString) {
  47. var result = sourceString;
  48. var i, l=arguments.length;
  49. if (l == 2 && typeof arguments[1] == "object" && arguments[1].length > 0) {
  50. // second argument is an array of values
  51. args = arguments[1];
  52. l = args.length;
  53. for (i = 0; i < l; i++) {
  54. result = result.replace(new RegExp("\\^" + i + "\\^"), args[i]);
  55. }
  56. } else {
  57. for (i = 1; (i + 1) < l; i += 2) {
  58. result = result.replace(new RegExp("\\^" + arguments[i] + "\\^"), arguments[i + 1]);
  59. }
  60. }
  61. return _F_Config.expandMacros(result);
  62. },
  63. preload: function() {
  64. new Image().src = _F_Config.expandMacros("$WEB$/fragments/common/images/progress.gif");
  65. }
  66. };
  67. /**
  68. * ui_htabs
  69. * @param obj containing: "frag" a fragment object, "id" unique identifier,
  70. * "activeTabID" current active tab identifier and "tabs" array of ui_htab objects.
  71. */
  72. function ui_htabs(obj, height) {
  73. this.parent = null;
  74. this.tabs = { };
  75. for (var o in obj) {
  76. this[o] = obj[o];
  77. }
  78. if (this.activeTabID === undefined) {
  79. for (var t in this.tabs) {
  80. this.activeTabID = t;
  81. break;
  82. }
  83. }
  84. this.pos = 0;
  85. this.scrollTimer = null;
  86. this.tableID = this.uniqueID() + "table";
  87. this.tabCellID = this.uniqueID() + "tabscell";
  88. this.buttons = {
  89. left: new ui_tabbutton({ id: this.frag.id + this.id + "leftbutton", type: "left" }),
  90. right: new ui_tabbutton({ id: this.frag.id + this.id + "rightbutton", type: "right" })
  91. };
  92. this.buttonsEnabled = false;
  93. }
  94. ui_htabs.prototype = {
  95. uniqueID: function() {
  96. return this.frag.id + this.id;
  97. },
  98. attach: function(parent) {
  99. this.parent = parent;
  100. for (var t in this.tabs) {
  101. this.tabs[t].attach(this);
  102. }
  103. this.buttons.left.attach(this);
  104. this.buttons.right.attach(this);
  105. },
  106. add: function(tab) {
  107. this.tabs[tab.id] = tab;
  108. tab.attach(this);
  109. },
  110. remove: function(id) {
  111. if (this.tabs[id] != null) {
  112. if (this.active() == id) {
  113. for (var x in this.tabs) {
  114. if (x != id) {
  115. this.select(x);
  116. break;
  117. }
  118. }
  119. }
  120. delete this.tabs[id];
  121. }
  122. },
  123. select: function(id) {
  124. if (this.tabs[id] != null) {
  125. var cur = this.active();
  126. if (cur != "") {
  127. this.tabs[cur].deselect();
  128. }
  129. this.activeTabID = id;
  130. this.tabs[id].select();
  131. }
  132. },
  133. getTab: function(posIdx) {
  134. var x = 0;
  135. for (var tabId in this.tabs) {
  136. if (x++==posIdx) {
  137. return this.tabs[tabId];
  138. }
  139. }
  140. },
  141. active: function() {
  142. return this.activeTabID;
  143. },
  144. getRoot: function() {
  145. var p = this;
  146. while (p.parent != null) {
  147. p = p.parent;
  148. }
  149. return p;
  150. },
  151. isFixed: function() {
  152. return this.getRoot().fixed == true;
  153. },
  154. onresize: function() { //ui_htabs
  155. var _self = this;
  156. window.setTimeout(function() { _self.adjustLayout(); }, 1);
  157. if (this.active() != "") {
  158. this.tabs[this.active()].onresize();
  159. }
  160. },
  161. scroll: function(dir) {
  162. if (!this.buttonsEnabled) {
  163. return;
  164. }
  165. var pos = this.pos + ((dir == "left") ? 5 : -5);
  166. this.setScrollPosition(pos);
  167. },
  168. setScrollPosition: function(pos){
  169. this.pos = pos;
  170. var table = $(this.tableID);
  171. if (this.pos >= 0) {
  172. this.pos = 0;
  173. } else {
  174. var td = xParent(xParent(table, true), true);
  175. var maxX = (xPageX(table) + xWidth(table)) - (xPageX(td) + xWidth(td)) - 5;
  176. if (maxX < 0) {
  177. this.pos -= maxX;
  178. }
  179. }
  180. table.style.marginLeft = this.pos + "px";
  181. },
  182. scrollTo: function(tab){
  183. var node = $(tab.tabID)
  184. var tabPosition = xLeft(node);
  185. var tabWidth = xWidth(node);
  186. var clientWidth = xClientWidth();
  187. if ((tabPosition + this.pos) > clientWidth) {
  188. this.setScrollPosition(clientWidth - tabPosition - tabWidth - 30);
  189. }
  190. },
  191. startScroll: function(dir) {
  192. if (!this.buttonsEnabled) {
  193. return;
  194. }
  195. // If there is already an active timer, it should be stopped first to avoid it from being lost (i.e.: running) forever
  196. if (this.scrollTimer != null) {
  197. window.clearInterval(this.scrollTimer);
  198. this.scrollTimer = null;
  199. }
  200. var _self = this;
  201. this.scrollTimer = window.setInterval(function() { _self.scroll(dir); }, 10);
  202. },
  203. stopScroll: function() {
  204. if (!this.buttonsEnabled) {
  205. return;
  206. }
  207. if (this.scrollTimer != null) {
  208. window.clearInterval(this.scrollTimer);
  209. this.scrollTimer = null;
  210. }
  211. },
  212. adjustLayout: function() {
  213. var table = $(this.tableID);
  214. var tabsCell = $(this.tabCellID);
  215. if (table == null) {
  216. return;
  217. }
  218. if (tabsCell) {
  219. //Reflow the tabs cell, as the width can become confused if it is hidden and re-shown in IE
  220. tabsCell.style.width="0";
  221. tabsCell.style.width="";
  222. }
  223. var td = xParent(xParent(table, true), true);
  224. // test of a firefox bug
  225. if (xWidth(td) == 0) {
  226. xWidth(td, xWidth(table));
  227. }
  228. var tabX = xPageX(td) + xWidth(td);
  229. if (this.pos < 0) {
  230. var maxX = (xPageX(table) + xWidth(table)) - tabX;
  231. if (maxX < 0) {
  232. this.pos -= maxX;
  233. }
  234. if (this.pos > 0) {
  235. this.pos = 0;
  236. }
  237. table.style.marginLeft = this.pos + "px";
  238. }
  239. this.buttonsEnabled = (xPageX(table) + xWidth(table)) >= tabX;
  240. this.buttons.left.setEnable(this.buttonsEnabled);
  241. this.buttons.right.setEnable(this.buttonsEnabled);
  242. }
  243. };
  244. /**
  245. * ui_htab
  246. * @param obj
  247. */
  248. function ui_htab(obj) {
  249. this.id = null;
  250. this.parent = null;
  251. this.loaded = false;
  252. this.refreshRequired = false;
  253. this.href = null;
  254. this.subtabs = null;
  255. this.width = -1;
  256. this.height = -1;
  257. this.customProperties = null;
  258. for (var o in obj) {
  259. this[o] = obj[o];
  260. }
  261. }
  262. ui_htab.prototype = {
  263. uniqueID: function() {
  264. if (this.parent != null) {
  265. return this.parent.uniqueID() + this.id;
  266. }
  267. return this.id;
  268. },
  269. attach: function(parent) {
  270. this.parent = parent;
  271. var uniqueID = this.parent.uniqueID() + this.id;
  272. if (this.tabID == null) {
  273. this.tabID = uniqueID + "tab";
  274. }
  275. if (this.pageID == null) {
  276. this.pageID = uniqueID + "page";
  277. }
  278. if (this.contentID == null) {
  279. this.contentID = uniqueID + "content";
  280. }
  281. if (this.subtabs != null) {
  282. this.subtabs.attach(this);
  283. }
  284. var elem = $(this.tabID);
  285. if (elem != null) {
  286. xAddEventListener(elem, "click", _F_Document.associate(elem, this, "onclick"));
  287. xAddEventListener(elem, "keypress", _F_Document.associate(elem, this, "onkeypress"));
  288. }
  289. },
  290. createPage: function() {
  291. var tabContainer = $(this.parent.frag.id + "bvContainer");
  292. var pageDiv = document.createElement("DIV");
  293. pageDiv.id = this.pageID;
  294. pageDiv.style.display="none";
  295. pageDiv.style.width="100%";
  296. pageDiv.style.height="100%";
  297. pageDiv.setAttribute("role", "tabpanel");
  298. var tabAnchorId = this.tabID + "_anchor";
  299. pageDiv.setAttribute("aria-labelledby", tabAnchorId);
  300. var tabEl = $(tabAnchorId);
  301. if (tabEl != null){
  302. tabEl.setAttribute("aria-controls", this.pageID);
  303. }
  304. var contentDiv = ui_templates.get(
  305. ui_templates.contentTemplate,
  306. 'CONTENTID', this.contentID,
  307. 'CONTENTCLASS', (this.parent.isFixed() ? "cogstyle-htabs-page-content-fixed" : "cogstyle-htabs-page-content")
  308. );
  309. pageDiv.innerHTML = contentDiv;
  310. tabContainer.appendChild(pageDiv);
  311. },
  312. isLoaded: function() {
  313. return this.loaded;
  314. },
  315. select: function() {
  316. if (!this.isLoaded()) {
  317. if ($(this.pageID)) {
  318. this.loaded = true;
  319. this.refreshRequired = true;
  320. } else {
  321. this.createPage();
  322. }
  323. }
  324. var frag = fragments[this.uniqueID()];
  325. if (frag) {
  326. frag.lockUpdates(false);
  327. frag.raiseEvent("fragment.visibility.change",{"setVisibility":"visible"}, "params", false, false);
  328. }
  329. //RTC 200661 not using the 'alt' for now
  330. //var alt = (this.parent.parent != null) ? "-alt" : "";
  331. var alt = "";
  332. var td = $(this.tabID);
  333. var div = xFirstChild(td, "DIV");
  334. div.className = "cogstyle-htabs" + alt + "-active-left-edge";
  335. div = xFirstChild(div, "DIV");
  336. div.className = "cogstyle-htabs" + alt + "-active-right-edge";
  337. div = xFirstChild(div, "DIV");
  338. div.className = "cogstyle-htabs" + alt + "-active";
  339. if (this.subtabs != null) {
  340. $(this.pageID).style.display = "block";
  341. this.subtabs.tabs[this.subtabs.active()].select();
  342. } else {
  343. $(this.pageID).style.display = "block";
  344. }
  345. // Get the tab title, which is the first anchor in the tab
  346. var label = xFirstChild(div, "A");
  347. // Set the tabindex to 0 so it shows up in the tab order
  348. label.tabIndex=0;
  349. // Set the focus to the tab title
  350. label.focus();
  351. label.setAttribute("aria-selected","true");
  352. this.refresh();
  353. this.parent.scrollTo(this);
  354. },
  355. deselect: function() {
  356. var frag = fragments[this.uniqueID()];
  357. if (frag) {
  358. frag.lockUpdates(true);
  359. frag.raiseEvent("fragment.visibility.change", {"setVisibility":"hidden"}, "params", false, false);
  360. }
  361. //var alt = (this.parent.parent != null) ? "-alt" : "";
  362. var alt = "";
  363. var td = $(this.tabID);
  364. var div = xFirstChild(td, "DIV");
  365. div.className = "cogstyle-htabs" + alt + "-left-edge";
  366. div = xFirstChild(div, "DIV");
  367. div.className = "cogstyle-htabs" + alt + "-right-edge";
  368. div = xFirstChild(div, "DIV");
  369. div.className = "cogstyle-htabs" + alt;
  370. if (this.subtabs != null) {
  371. $(this.pageID).style.display = "none";
  372. this.subtabs.tabs[this.subtabs.active()].deselect();
  373. } else {
  374. var pageDIV = $(this.pageID);
  375. if (pageDIV != null) {
  376. pageDIV.style.display = "none";
  377. }
  378. }
  379. var label = xFirstChild(div, "A");
  380. label.setAttribute("aria-selected","false");
  381. },
  382. refresh: function(force) {
  383. if (this.href != null) {
  384. if (!this.isLoaded()) {
  385. this.loaded = true;
  386. var frag = new fragment(this.href, this.uniqueID());
  387. frag.customProperties = this.customProperties;
  388. frag.retrieve();
  389. }
  390. else if (force || this.refreshRequired) {
  391. this.refreshRequired = false;
  392. fragments[this.uniqueID()].raiseEvent("fragment.refresh",null,null,false,true);
  393. }
  394. } else if (this.subtabs != null) {
  395. this.subtabs.select(this.subtabs.active());
  396. }
  397. var topLevel = this;
  398. while (topLevel.parent != null) {
  399. topLevel = topLevel.parent;
  400. }
  401. topLevel.onresize();
  402. },
  403. onclick: function(e, tag) {
  404. this.parent.select(this.id);
  405. },
  406. onkeypress: function(evt) {
  407. evt = evt != null ? evt : window.event;
  408. var e = evt.srcElement ? evt.srcElement : evt.target;
  409. var activeTab;
  410. // Left or Up Arrow
  411. if (evt.keyCode == 37 || evt.keyCode == 38) {
  412. activeTab = $(this.parent.uniqueID() + this.parent.activeTabID + "tab");
  413. // Get the previous tab
  414. var prevTab = activeTab.previousSibling;
  415. if (prevTab == null) {
  416. // or last child if you are on the first child.
  417. prevTab = activeTab.parentNode.lastChild;
  418. }
  419. // Extract the relevant part of the tab id
  420. var prevId = prevTab.id.substring(this.parent.uniqueID().length, prevTab.id.length-3);
  421. // Select the tab
  422. this.parent.select(prevId);
  423. }
  424. // Right or Down arrow
  425. else if (evt.keyCode == 39 || evt.keyCode == 40) {
  426. activeTab = $(this.parent.uniqueID() + this.parent.activeTabID + "tab");
  427. // Get the next tab
  428. var nextTab = activeTab.nextSibling;
  429. if (nextTab == null) {
  430. // or first child if you are on the last child.
  431. nextTab = activeTab.parentNode.firstChild;
  432. }
  433. // Extract the relevant part of the tab id
  434. var nextId = nextTab.id.substring(this.parent.uniqueID().length, nextTab.id.length-3);
  435. // Select the tab
  436. this.parent.select(nextId);
  437. }
  438. xStopPropagation(evt);
  439. },
  440. onresize: function() { //ui_htab
  441. if (!this.parent.isFixed())
  442. {
  443. //When we aren't in fixed mode, don't do any resizing to the booklet viewer, but propogate the resize event downward
  444. if (this.subtabs != null) {
  445. this.subtabs.onresize();
  446. } else {
  447. var objectType = this.target.targetType ? this.target.targetType : this.target.type;
  448. ui_resizeHelper.adjustHeightForFragmentContent(fragments[this.uniqueID()], $(this.contentID), objectType, this.height);
  449. var list = _F_descendants(this.uniqueID(), null, true);
  450. _F_resize(list);
  451. }
  452. return;
  453. }
  454. var parentTab = this.parent.parent;
  455. // check if top level or sub-level?
  456. if (parentTab == null) {
  457. var page = $(this.pageID);
  458. this.height = xClientHeight() - ui_calcAvailableHeight(page, document.body,true);
  459. this.width = xClientWidth() - ui_calcAvailableWidth(page, document.body);
  460. if (maximizeBVToAvailableHeight) {
  461. this.height = ui_calcMaximumHeight(page, document.body, true);
  462. readjustParentHeight(this.contentID);
  463. }
  464. } else {
  465. this.height = parentTab.height - xHeight(this.parent.tableID) - 1;
  466. this.width = parentTab.width;
  467. }
  468. if (this.subtabs != null) {
  469. this.subtabs.onresize();
  470. } else {
  471. var content = $(this.contentID);
  472. xHeight(content, this.height);
  473. // resize the fragments (and children)
  474. var dlist = _F_descendants(this.uniqueID(), null, true);
  475. _F_resize(dlist);
  476. }
  477. },
  478. getVTabs: function() {
  479. return fragments[this.uniqueID()];
  480. }
  481. };
  482. /**
  483. * ui_tabbutton
  484. * @param obj
  485. */
  486. function ui_tabbutton(obj) {
  487. this.id = null;
  488. this.parent = null;
  489. this.enabled = false;
  490. this.hovered = false;
  491. this.mouseUpHandler = null;
  492. this.selectStartHandler = function(e) {xPreventDefault(e);return false;};
  493. for (var o in obj) {
  494. this[o] = obj[o];
  495. }
  496. }
  497. ui_tabbutton.prototype = {
  498. attach: function(parent) {
  499. this.parent = parent;
  500. var elem = $(this.id);
  501. if (elem != null) {
  502. xAddEventListener(elem, "mousedown", _F_Document.associate(elem, this, "onmousedown"));
  503. xAddEventListener(elem, "mouseover", _F_Document.associate(elem, this, "onmouseover"));
  504. xAddEventListener(elem, "mouseout", _F_Document.associate(elem, this, "onmouseout"));
  505. xAddEventListener(elem, "keydown", _F_Document.associate(elem, this, "onkeydown"));
  506. xAddEventListener(elem, "touchstart", _F_Document.associate(elem, this, "ontouchstart"));
  507. xAddEventListener(elem, "touchend", _F_Document.associate(elem, this, "ontouchend"));
  508. }
  509. },
  510. setEnable: function(enable) {
  511. if (this.enabled != enable) {
  512. this.enabled = enable;
  513. this.updateStyles();
  514. }
  515. },
  516. updateStyles: function() {
  517. var style = "cogstyle-htabs-scroll-button";
  518. if (!this.enabled) {
  519. style += "-disabled";
  520. } else if (this.hovered) {
  521. style += "-hover";
  522. }
  523. style += " cogstyle-htabs-scroll-button-" + this.type;
  524. if (!this.enabled) {
  525. style += "-disabled";
  526. }
  527. $(this.id).className = style;
  528. var scrollImg = $(this.id + "img");
  529. if (this.enabled) {
  530. scrollImg.className = "";
  531. } else {
  532. scrollImg.className = "cogstyle-img-faded";
  533. }
  534. },
  535. onkeydown: function(e, tag){
  536. if (e.keyCode == 13 || e.keyCode == 32 || e.charCode==32){
  537. this.parent.scroll(this.type);
  538. }
  539. },
  540. onclick: function(e, tag) {
  541. this.parent.scroll(this.type);
  542. },
  543. onmousedown: function(e, tag) {
  544. xPreventDefault(e);
  545. this.mouseUpHandler = _F_Document.associate(document, this, "onmouseup");
  546. xAddEventListener(document, "mouseup", this.mouseUpHandler);
  547. xAddEventListener(document, "selectstart", this.selectStartHandler);
  548. xAddEventListener(document, "dragstart", this.selectStartHandler);
  549. this.parent.startScroll(this.type);
  550. },
  551. onmouseup: function(e, tag) {
  552. xRemoveEventListener(document, "mouseup", this.mouseUpHandler);
  553. xRemoveEventListener(document, "selectstart", this.selectStartHandler);
  554. xRemoveEventListener(document, "dragstart", this.selectStartHandler);
  555. this.mouseUpHandler = null;
  556. this.parent.stopScroll();
  557. },
  558. ontouchstart: function(e, tag) {
  559. xPreventDefault(e);
  560. this.touchEndHandler = _F_Document.associate(document, this, "ontouchend");
  561. xAddEventListener(document, "touchend", this.touchEndHandler);
  562. this.parent.startScroll(this.type);
  563. },
  564. ontouchend: function(e, tag) {
  565. xRemoveEventListener(document, "touchend", this.touchEndHandler);
  566. this.touchEndHandler = null;
  567. this.parent.stopScroll();
  568. },
  569. onmouseover: function(e, tag) {
  570. if (this.enabled) {
  571. this.hovered = true;
  572. this.updateStyles();
  573. if (this.mouseUpHandler != null) {
  574. this.parent.startScroll(this.type);
  575. }
  576. }
  577. },
  578. onmouseout: function(e, tag) {
  579. if (this.enabled) {
  580. this.parent.stopScroll();
  581. this.hovered = false;
  582. this.updateStyles();
  583. }
  584. }
  585. };
  586. /**
  587. * ui_vtabs
  588. * @param obj containing: "frag" the fragment object, "id" unique identifier,
  589. * "activeTabID" current active tab identifier and "tabs" array of ui_vtab objects.
  590. */
  591. function ui_vtabs(obj) {
  592. this.parent = null;
  593. this.tabs = { };
  594. for (var o in obj) {
  595. this[o] = obj[o];
  596. }
  597. if (this.activeTabID === undefined) {
  598. for (var t in this.tabs) {
  599. this.activeTabID = t;
  600. break;
  601. }
  602. }
  603. }
  604. ui_vtabs.prototype = {
  605. uniqueID: function() {
  606. return this.frag.id + this.id;
  607. },
  608. attach: function(parent) {
  609. this.parent = parent;
  610. this.bookletViewerContainerID = this.frag.id + "bvContainer";
  611. if (parent == null) {
  612. this.toplevel = countLevels(this.frag.parent) == 1;
  613. this.tabsmainID = this.frag.id + "tabs_main";
  614. this.tabsareaID = this.frag.id + "tabs_area";
  615. this.tabsareadivID = this.frag.id + "tabs_area_div";
  616. this.vtabsMinWidth = 0;
  617. }
  618. for (var t in this.tabs) {
  619. this.tabs[t].attach(this);
  620. }
  621. function countLevels(f) {
  622. var count = 0;
  623. while (f != null) {
  624. count++;
  625. f = f.parent;
  626. }
  627. return count;
  628. }
  629. },
  630. select: function(id) {
  631. if (this.tabs[id] != null) {
  632. var cur = this.active();
  633. if (cur != "") {
  634. this.tabs[cur].deselect();
  635. }
  636. this.activeTabID = id;
  637. this.tabs[id].select();
  638. }
  639. },
  640. active: function() {
  641. return this.activeTabID;
  642. },
  643. getTab: function(posIdx) {
  644. var x = 0;
  645. for (var tabId in this.tabs) {
  646. if (x++==posIdx) {
  647. return this.tabs[tabId];
  648. }
  649. }
  650. },
  651. getRoot: function() {
  652. var p = this;
  653. while (p.parent != null) {
  654. p = p.parent;
  655. }
  656. return p;
  657. },
  658. isFixed: function() {
  659. return this.getRoot().fixed == true;
  660. },
  661. getVTabsAreaWidth: function() {
  662. return this.getRoot().vtabsWidth;
  663. },
  664. getVTabsAreaHeight: function() {
  665. return this.getRoot().vtabsHeight;
  666. },
  667. setVTabsAreaWidth: function(vtabsWidth) {
  668. var o = this.getRoot();
  669. if (o.vtabsWidth != vtabsWidth) {
  670. if (vtabsWidth < o.vtabsMinWidth) {
  671. o.vtabsWidth = o.vtabsMinWidth;
  672. } else {
  673. o.vtabsWidth = vtabsWidth;
  674. }
  675. o.onresize();
  676. }
  677. },
  678. onresize: function() { //ui_vtabs
  679. var tabsArea = $(this.tabsareaID);
  680. if (tabsArea != null) {
  681. if (this.parent == null) {
  682. var tabsAreaDiv = $(this.tabsareadivID);
  683. var tabsListDiv = tabsAreaDiv.childNodes[0];
  684. var tabsFilterDiv = tabsAreaDiv.childNodes[1];
  685. var tabsMainTable = $(this.tabsmainID);
  686. // check if top level or embeded in another htabs/vtabs?
  687. if (this.toplevel) {
  688. this.vtabsHeight = xClientHeight() - ui_calcAvailableHeight(tabsArea, document.body, true);
  689. } else {
  690. var div = $(this.frag.div);
  691. this.vtabsHeight = xHeight(div) - ui_calcAvailableHeight(tabsArea, div, true);
  692. }
  693. if (maximizeBVToAvailableHeight) {
  694. if (this.isFixed()) {
  695. this.vtabsHeight = ui_calcMaximumHeight(tabsArea, document.body, true);
  696. }
  697. }
  698. if (this.isFixed() || _F_Config.application.toLowerCase() == "/cogadmin") {
  699. if (tabsMainTable.style.height != "100%") {
  700. tabsMainTable.style.height = "100%";
  701. }
  702. }
  703. xWidth(tabsFilterDiv, this.vtabsWidth);
  704. xWidth(tabsArea, this.vtabsWidth);
  705. if (!(xIE4Up)) {
  706. tabsListDiv.style.width = "auto";
  707. }
  708. }
  709. }
  710. if (this.active() != "") {
  711. this.tabs[this.active()].onresize();
  712. }
  713. }
  714. };
  715. /**
  716. * ui_vtab
  717. * @param obj
  718. */
  719. function ui_vtab(obj) {
  720. this.id = null;
  721. this.parent = null;
  722. this.loaded = false;
  723. this.refreshRequired = false;
  724. this.href = null;
  725. this.subtabs = null;
  726. this.width = -1;
  727. this.height = -1;
  728. this.customProperties = null;
  729. for (var o in obj) {
  730. this[o] = obj[o];
  731. }
  732. }
  733. ui_vtab.prototype = {
  734. uniqueID: function() {
  735. if (this.parent != null) {
  736. return this.parent.uniqueID() + this.id;
  737. }
  738. return this.id;
  739. },
  740. attach: function(parent) {
  741. this.parent = parent;
  742. var uniqueID = this.parent.uniqueID() + this.id;
  743. if (this.tabID == null) {
  744. this.tabID = uniqueID + "tab";
  745. }
  746. if (this.pageID == null) {
  747. this.pageID = uniqueID + "page";
  748. }
  749. if (this.filterID == null) {
  750. this.filterID = uniqueID + "filter";
  751. }
  752. if (this.contentID == null) {
  753. this.contentID = uniqueID + "content";
  754. }
  755. if (this.subtabs != null) {
  756. this.subtabs.attach(this);
  757. this.subtabsID = uniqueID + "subtabs";
  758. }
  759. var elem = $(this.tabID);
  760. if (elem != null) {
  761. xAddEventListener(elem, "click", _F_Document.associate(elem, this, "onclick"));
  762. xAddEventListener(elem, "mouseover", _F_Document.associate(elem, this, "onmouseover"));
  763. xAddEventListener(elem, "mouseout", _F_Document.associate(elem, this, "onmouseout"));
  764. xAddEventListener(elem, "keypress", _F_Document.associate(elem, this, "onkeypress"));
  765. }
  766. },
  767. createPage: function() {
  768. var tabContainer = $(this.parent.frag.id + "tabs_container");
  769. var pageDiv = document.createElement("DIV");
  770. pageDiv.id = this.pageID;
  771. pageDiv.style.width="100%";
  772. pageDiv.style.height="100%";
  773. pageDiv.style.display="none";
  774. pageDiv.setAttribute("role", "tabpanel");
  775. var tabAnchorId = this.tabID + "_anchor";
  776. pageDiv.setAttribute("aria-labelledby", tabAnchorId);
  777. var tabEl = $(tabAnchorId);
  778. if (tabEl != null){
  779. tabEl.setAttribute("aria-controls", this.pageID);
  780. }
  781. var contentDiv = ui_templates.get(
  782. ui_templates.contentTemplate,
  783. 'CONTENTID', this.contentID,
  784. 'CONTENTCLASS', (this.parent.isFixed() ? "cogstyle-vtabs-page-content-fixed" : "cogstyle-vtabs-page-content")
  785. );
  786. pageDiv.innerHTML = contentDiv;
  787. tabContainer.appendChild(pageDiv);
  788. },
  789. createFilter: function() {
  790. var filterContainer = $(this.parent.frag.id + "filter_container");
  791. var filterDiv = document.createElement("DIV");
  792. filterDiv.id = this.filterID;
  793. filterDiv.style.display="none";
  794. filterDiv.className = "cogstyle-filter";
  795. filterContainer.appendChild(filterDiv);
  796. },
  797. isLoaded: function() {
  798. return this.loaded;
  799. },
  800. select: function() {
  801. if (!this.isLoaded()) {
  802. if ($(this.pageID)) {
  803. this.loaded = true;
  804. this.refreshRequired = true;
  805. } else {
  806. this.createPage();
  807. this.createFilter();
  808. }
  809. }
  810. var frag = fragments[this.uniqueID()];
  811. if (frag) {
  812. frag.lockUpdates(false);
  813. frag.raiseEvent("fragment.visibility.change",
  814. {
  815. "setVisibility":"visible"
  816. }, "params", false, false);
  817. }
  818. var more = (this.parent.parent != null) ? "-alt" : "";
  819. more += (this.subtabs) ? "-opened" : "";
  820. var div = $(this.tabID);
  821. div.className = "cogstyle-vtabs-active-border";
  822. div = xFirstChild(div, "DIV");
  823. div.className = "cogstyle-vtabs" + more + "-active-left-edge";
  824. div = xFirstChild(div, "DIV");
  825. div.className = "cogstyle-vtabs" + more + "-active-right-edge";
  826. div = xFirstChild(div, "DIV");
  827. div.className = "cogstyle-vtabs" + more + "-active";
  828. if (this.subtabs != null) {
  829. $(this.subtabsID).style.display = "block";
  830. this.subtabs.tabs[this.subtabs.active()].select();
  831. } else {
  832. $(this.pageID).style.display = "block";
  833. var filterDIV = $(this.filterID);
  834. if (filterDIV != null && filterDIV.firstChild != null) {
  835. filterDIV.style.display = "block";
  836. }
  837. }
  838. // Get the tab title, which is the first anchor in the tab
  839. var label = xFirstChild(div, "A");
  840. // when you set the tabindex in IE, it shifts focus to the text inside it
  841. // if the tabsArea is smaller than the length of the text, it shifts over and hides the icon
  842. // setting the width of the label fixes this
  843. xWidth(label, xWidth(div));
  844. // Set the tabindex to 0 so it shows up in the tab order
  845. label.tabIndex=0;
  846. // Set the focus to the tab title
  847. label.focus();
  848. label.setAttribute("aria-selected","true");
  849. this.refresh();
  850. },
  851. deselect: function() {
  852. var frag = fragments[this.uniqueID()];
  853. if (frag) {
  854. frag.lockUpdates(true);
  855. frag.raiseEvent("fragment.visibility.change",
  856. {
  857. "setVisibility":"hidden"
  858. }, "params", false, false);
  859. }
  860. var more = (this.parent.parent != null) ? "-alt" : "";
  861. more += (this.subtabs) ? "-opened" : "";
  862. var div = $(this.tabID);
  863. div.className = "";
  864. div = xFirstChild(div, "DIV");
  865. div.className = "cogstyle-vtabs" + more + "-left-edge";
  866. div = xFirstChild(div, "DIV");
  867. div.className = "cogstyle-vtabs" + more + "-right-edge";
  868. div = xFirstChild(div, "DIV");
  869. div.className = "cogstyle-vtabs" + more;
  870. if (this.subtabs != null) {
  871. $(this.subtabsID).style.display = "none";
  872. this.subtabs.tabs[this.subtabs.active()].deselect();
  873. } else {
  874. var pageDIV = $(this.pageID);
  875. if (pageDIV != null)
  876. {
  877. pageDIV.style.display = "none";
  878. }
  879. var filterDIV = $(this.filterID);
  880. if (filterDIV != null) {
  881. filterDIV.style.display = "none";
  882. }
  883. }
  884. // Get the tab title, which is the first anchor in the tab
  885. var label = xFirstChild(div, "A");
  886. label.setAttribute("aria-selected","false");
  887. },
  888. refresh: function(force) {
  889. if (this.href != null) {
  890. if (!this.isLoaded()) {
  891. this.loaded = true;
  892. var frag = new fragment(this.href, this.uniqueID());
  893. frag.customProperties = this.customProperties;
  894. frag.retrieve();
  895. }
  896. else if (force || this.refreshRequired) {
  897. this.refreshRequired = false;
  898. fragments[this.uniqueID()].raiseEvent("fragment.refresh",null,null,false,true);
  899. }
  900. } else if (this.subtabs != null) {
  901. this.subtabs.select(this.subtabs.active());
  902. }
  903. var topLevel = this;
  904. while (topLevel.parent != null) {
  905. topLevel = topLevel.parent;
  906. }
  907. topLevel.onresize();
  908. },
  909. onclick: function(e, tag) {
  910. this.parent.select(this.id);
  911. },
  912. onkeypress: function(evt) {
  913. evt = evt != null ? evt : window.event;
  914. var e = evt.srcElement ? evt.srcElement : evt.target;
  915. var activeTab;
  916. // Left or Up Arrow
  917. if (evt.keyCode == 37 || evt.keyCode == 38) {
  918. activeTab = $(this.parent.uniqueID() + this.parent.activeTabID + "tab");
  919. // Get the previous tab
  920. var prevTab = activeTab.previousSibling;
  921. if (prevTab == null) {
  922. // or last child if you are on the first child.
  923. prevTab = activeTab.parentNode.lastChild;
  924. }
  925. // Extract the relevant part of the tab id
  926. var prevId = prevTab.id.substring(this.parent.uniqueID().length, prevTab.id.length-3);
  927. // Select the tab
  928. this.parent.select(prevId);
  929. }
  930. // Right or Down arrow
  931. else if (evt.keyCode == 39 || evt.keyCode == 40) {
  932. activeTab = $(this.parent.uniqueID() + this.parent.activeTabID + "tab");
  933. // Get the next tab
  934. var nextTab = activeTab.nextSibling;
  935. if (nextTab == null) {
  936. // or first child if you are on the last child.
  937. nextTab = activeTab.parentNode.firstChild;
  938. }
  939. // Extract the relevant part of the tab id
  940. var nextId = nextTab.id.substring(this.parent.uniqueID().length, nextTab.id.length-3);
  941. // Select the tab
  942. this.parent.select(nextId);
  943. }
  944. },
  945. onmouseover: function(e, tag) {
  946. var div = $(this.tabID);
  947. div = xFirstChild(div, "DIV");
  948. var cur = div.className;
  949. if (cur.indexOf('-hover') == -1) {
  950. div.className = cur + "-hover";
  951. }
  952. },
  953. onmouseout: function(e, tag) {
  954. var div = $(this.tabID);
  955. div = xFirstChild(div, "DIV");
  956. var cur = div.className;
  957. var i;
  958. if ((i = cur.indexOf('-hover')) != -1) {
  959. div.className = cur.substring(0, i);
  960. }
  961. },
  962. onresize: function() { //ui_vtab
  963. if (!this.parent.isFixed()) {
  964. //When we aren't in fixed mode, don't do any resizing to the booklet viewer, but propogate the resize event downward
  965. if (this.subtabs != null) {
  966. this.subtabs.onresize();
  967. } else {
  968. var objectType = this.target.targetType ? this.target.targetType : this.target.type;
  969. ui_resizeHelper.adjustHeightForFragmentContent(fragments[this.uniqueID()], $(this.contentID), objectType, this.height);
  970. var list = _F_descendants(this.uniqueID(), null, true);
  971. _F_resize(list);
  972. }
  973. return;
  974. }
  975. // check if top level or sub-level?
  976. var parentTab = this.parent.parent;
  977. if (parentTab == null) {
  978. this.height = this.parent.getRoot().vtabsHeight;
  979. if (maximizeBVToAvailableHeight) {
  980. readjustParentHeight(this.contentID);
  981. }
  982. } else {
  983. // propagate down the size for all tabs
  984. this.height = parentTab.height;
  985. }
  986. if (this.subtabs != null) {
  987. this.subtabs.onresize();
  988. } else {
  989. xHeight(this.contentID, this.height);
  990. xHeight(this.pageID, this.height);
  991. //keeps scrollbar from appearing off the side of the page in ie.
  992. // resize the fragments (and children)
  993. var dlist = _F_descendants(this.uniqueID(), null, true);
  994. _F_resize(dlist);
  995. }
  996. }
  997. };
  998. /**
  999. * ui_splitter
  1000. * @param obj
  1001. */
  1002. function ui_splitter(obj) {
  1003. this.id = null;
  1004. this.splitterBar = null;
  1005. this.startX = -1;
  1006. for (var o in obj) {
  1007. this[o] = obj[o];
  1008. }
  1009. xAddEventListener($(this.id), "mousedown", _F_Document.associate(window, this, "start"));
  1010. }
  1011. ui_splitter.prototype = {
  1012. start: function(e, tag) {
  1013. var evt = new xEvent(e);
  1014. xPreventDefault(e);
  1015. var bar = $(this.id);
  1016. var div = document.createElement('DIV');
  1017. div.appendChild(document.createElement('BR'));
  1018. div.className="cogstyle-splitter-bar";
  1019. this.mousemove = _F_Document.associate(window, this, "move");
  1020. xAddEventListener(document, "mousemove", this.mousemove, true);
  1021. this.mouseup = _F_Document.associate(window, this, "stop");
  1022. xAddEventListener(document, "mouseup", this.mouseup, true);
  1023. this.width = xWidth(bar);
  1024. xLeft(div, xPageX(bar));
  1025. xTop(div, xPageY(bar));
  1026. xWidth(div, this.width);
  1027. xHeight(div, xHeight(bar));
  1028. xAppendChild(document.body, div);
  1029. div.style.display = "";
  1030. this.splitterBar = div;
  1031. this.startX = evt.pageX;
  1032. var locker = ui_locker.get();
  1033. locker.show(true);
  1034. },
  1035. move: function(e, tag) {
  1036. if (this.startX > 0) {
  1037. var evt = new xEvent(e);
  1038. xPreventDefault(e);
  1039. xLeft(this.splitterBar, evt.pageX - (this.width / 2));
  1040. }
  1041. },
  1042. stop: function(e, tag) {
  1043. if (this.startX > 0) {
  1044. var evt = new xEvent(e);
  1045. xPreventDefault(e);
  1046. xHide(this.splitterBar);
  1047. document.body.removeChild(this.splitterBar);
  1048. this.splitterBar = null;
  1049. xRemoveEventListener(document, "mousemove", this.mousemove, true);
  1050. xRemoveEventListener(document, "mouseup", this.mouseup, true);
  1051. this.resizing.setVTabsAreaWidth(this.resizing.getVTabsAreaWidth() + (evt.pageX - this.startX));
  1052. this.startX = -1;
  1053. }
  1054. var locker = ui_locker.get();
  1055. locker.hide();
  1056. }
  1057. };
  1058. /**
  1059. * ui_error
  1060. * @param fragID the fragment unique identifier
  1061. * @param contentID the identifier of the "content" div receiving the error bar.
  1062. */
  1063. function ui_error(fragID, contentID) {
  1064. this.fragID = fragID;
  1065. this.contentID = contentID;
  1066. this.code = null;
  1067. this.message = null;
  1068. this.details = null;
  1069. }
  1070. ui_error.prototype = {
  1071. template: "<div id=\"_THIS_errormsg\"></div>",
  1072. setCode: function(code) {
  1073. this.code = code;
  1074. },
  1075. setMessage: function(msg) {
  1076. this.message = msg||"";
  1077. var div = $(this.fragID + "errormsg");
  1078. if (div != null) {
  1079. div.innerHTML = _F_Strings.htmlEncode(this.message);
  1080. }
  1081. },
  1082. setDetails: function(details) {
  1083. this.details = details;
  1084. },
  1085. show: function() {
  1086. var div = $(this.fragID + "error");
  1087. if (div == null) {
  1088. var content = $(this.contentID);
  1089. div = document.createElement("DIV");
  1090. div.className = "cogstyle-portlet-error-frame";
  1091. div.id = this.fragID + "error";
  1092. div.innerHTML = this.template.replace(/_THIS_/g, this.fragID);
  1093. content.parentNode.insertBefore(div, content);
  1094. var anchor = $(this.fragID + "error_showdetails");
  1095. if (anchor != null) {
  1096. xAddEventListener(anchor, "click", _F_Document.associate(anchor, this, "showDetails"));
  1097. anchor.href = "javascript:noop()";
  1098. }
  1099. anchor = $(this.fragID + "error_retry");
  1100. if (anchor != null) {
  1101. xAddEventListener(anchor, "click", _F_Document.associate(anchor, this, "retry"));
  1102. anchor.href = "javascript:noop()";
  1103. }
  1104. anchor = $(this.fragID + "error_hide");
  1105. if (anchor != null) {
  1106. xAddEventListener(anchor, "click", _F_Document.associate(anchor, this, "hide"));
  1107. anchor.href = "javascript:noop()";
  1108. }
  1109. }
  1110. $(this.fragID + "errormsg").innerHTML = _F_Strings.htmlEncode(this.message);
  1111. div.style.display = "";
  1112. setTimeout(function(){div.setAttribute("role","alert");},1)
  1113. this.hideLoading();
  1114. },
  1115. hide: function() {
  1116. var div = $(this.fragID + "error");
  1117. if (div != null) {
  1118. div.style.display = "none";
  1119. }
  1120. return false;
  1121. },
  1122. hideLoading: function() {
  1123. // get div, get firstchild, check for removeonerror attribute, if there clear div content
  1124. var viewport = $(this.contentID);
  1125. if (viewport) {
  1126. var ele = xFirstChild(viewport);
  1127. if (ele) {
  1128. if (ele.getAttribute("removeonerror") == "true") {
  1129. viewport.innerHTML = "";
  1130. }
  1131. }
  1132. }
  1133. },
  1134. showDetails: function() {
  1135. var dlg = new ui_dialog(this.fragID + "errordetails", PFM.JS.IDS_JS_DETAILS,
  1136. ui_dialog.style.ALERT | ui_dialog.style.BTN_CLOSE | ui_dialog.style.CENTER | ui_dialog.style.RESIZABLE, -1, -1, 500, 300, this.contentID);
  1137. dlg.processCommand = function(cmd) {
  1138. this.destroy();
  1139. return true;
  1140. };
  1141. if (this.details != null) {
  1142. var markup = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"4\">";
  1143. if (this.code != null) {
  1144. markup += "<tr><td colspan=\"2\" class=\"portlet-form-label\">" + this.code + "</td></tr>";
  1145. }
  1146. markup +=
  1147. "<tr>" +
  1148. "<td valign=\"top\">" +
  1149. "<img src=\"" + _F_Config.webContent + "/fragments/common/images/msg_error.gif\" style=\"width:32px;height:32px\">" +
  1150. "</td>" +
  1151. "<td class=\"portlet-font\" valign=\"top\">" +
  1152. _F_Strings.htmlEncode(this.message) +
  1153. "</td>" +
  1154. "</tr>" +
  1155. "</table>";
  1156. markup += "<pre>" + _F_Strings.htmlEncode(this.details) + "</pre>";
  1157. dlg.attachContent(markup);
  1158. }
  1159. dlg.show();
  1160. return false;
  1161. },
  1162. retry: function() {
  1163. this.hide();
  1164. // TODO: should call a retry instead of retrieve here
  1165. fragments[this.fragID].retrieve();
  1166. return false;
  1167. }
  1168. };
  1169. function ui_fragment_help(frag) {
  1170. if (frag) {
  1171. var sURL = frag.baseURI();
  1172. // replace the macros
  1173. sURL = _F_Config.expandMacros(sURL);
  1174. sURL += ((sURL.indexOf('?') >= 0) ? "&" : "?") + "frag-mode=help";
  1175. var windowHelp = window.open(sURL, "cps_help",
  1176. "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=500");
  1177. if (windowHelp != null) {
  1178. windowHelp.focus();
  1179. }
  1180. }
  1181. }
  1182. /**
  1183. * ui_dialog
  1184. * @param id unique identifier of dialog
  1185. * @param caption text
  1186. * @param styles bit field of STYLES_*
  1187. * @param dx width
  1188. * @param dy height
  1189. * @param contentId Optional unique identifier of the content div for the invoking fragment. Used to set the proper font size.
  1190. * @param srcHref Optional parameter, if passed the dialog system will use this as a url and create an iframe for it.
  1191. */
  1192. function ui_dialog(id, caption, styles, x, y, dx, dy, contentId, srcHref) {
  1193. this.id = id;
  1194. this.caption = caption;
  1195. this.styles = styles;
  1196. this.x = x;
  1197. this.y = y;
  1198. this.dx = dx;
  1199. this.dy = dy;
  1200. this.dlg = null;
  1201. this.backing = null;
  1202. this.content = "";
  1203. this.results = null;
  1204. this.contentId = contentId;
  1205. this.srcHref = (srcHref !== undefined)? srcHref:null;
  1206. this.minDialogWidth = 200;
  1207. this.iframeName = (srcHref !== undefined)? "MODAL_IFRAME" + ( new Date() ).getTime():null;
  1208. this.fragment = null;
  1209. this.eventHandlers = [];
  1210. this.triggerElement = document.activeElement;
  1211. }
  1212. ui_dialog.chain = [];
  1213. ui_dialog.nextX = 0;
  1214. ui_dialog.nextY = 0;
  1215. ui_dialog.style = {};
  1216. ui_dialog.style.BTN_OK = 0;
  1217. ui_dialog.style.BTN_OKCANCEL = 1;
  1218. ui_dialog.style.BTN_OKCANCELAPPLY = 2;
  1219. ui_dialog.style.BTN_CLOSE = 3;
  1220. ui_dialog.style.BTN_CANCEL = 4;
  1221. ui_dialog.style.BTN_YESNO = 5;
  1222. ui_dialog.style.BTN_YESNOCANCEL = 6;
  1223. ui_dialog.style.BTN_NOBUTTONS = 8;
  1224. ui_dialog.style.RESIZABLE = 16;
  1225. ui_dialog.style.MODELESS = 32;
  1226. ui_dialog.style.CENTER = 64;
  1227. ui_dialog.style.IFRAME = 128;
  1228. ui_dialog.style.READONLY = 256;
  1229. ui_dialog.style.ALERT = 512;
  1230. ui_dialog.button = {};
  1231. ui_dialog.button.OK = "ok";
  1232. ui_dialog.button.CANCEL = "cancel";
  1233. ui_dialog.button.APPLY = "apply";
  1234. ui_dialog.button.YES = "yes";
  1235. ui_dialog.button.NO = "no";
  1236. ui_dialog.button.CLOSE = "close";
  1237. ui_dialog.button.CLOSEBOX = "closebox";
  1238. ui_dialog.button.HELPBOX = "helpbox";
  1239. ui_dialog.button._styles_ = [
  1240. [ui_dialog.button.OK],
  1241. [ui_dialog.button.OK, ui_dialog.button.CANCEL],
  1242. [ui_dialog.button.OK, ui_dialog.button.CANCEL, ui_dialog.button.APPLY],
  1243. [ui_dialog.button.CLOSE],
  1244. [ui_dialog.button.CANCEL],
  1245. [ui_dialog.button.YES, ui_dialog.button.NO],
  1246. [ui_dialog.button.YES, ui_dialog.button.NO, ui_dialog.button.CANCEL],
  1247. null,
  1248. []
  1249. ];
  1250. ui_dialog.prototype = {
  1251. create: function() {
  1252. var iframe = null;
  1253. if (xIE4Up) {
  1254. iframe = document.createElement("iframe");
  1255. iframe.id = this.id + "iframe";
  1256. iframe.style.display="none";
  1257. iframe.style.border="0px";
  1258. iframe.style.position="absolute";
  1259. iframe.src = _F_Config.webContent + "/fragments/common/images/space.gif";
  1260. this.backing = iframe;
  1261. document.body.appendChild(iframe);
  1262. }
  1263. var div = document.createElement("DIV");
  1264. div.className = "cogstyle-dialog";
  1265. div.id = this.id;
  1266. div.style.display = "none";
  1267. if ((this.styles & ui_dialog.style.ALERT) == ui_dialog.style.ALERT) {
  1268. div.setAttribute("role", "alert");
  1269. }
  1270. var markup =
  1271. "<table role=\"dialog\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" aria-labelledby=\"" + this.id + "captiontext\">" +
  1272. "<tr>" +
  1273. "<td id=\"" + this.id + "caption\" class=\"cogstyle-dialog-caption\">" +
  1274. "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"width:100%\" role=\"presentation\">" +
  1275. "<tr>" +
  1276. "<td id=\"" + this.id + "captiontext\" >" + _F_Strings.htmlEncode(this.caption) + "</td>";
  1277. if (this.fragment != null && _F_Array.indexOf(this.fragment.modes, "help") > -1) {
  1278. markup += "<td style=\"width:16px\">" +
  1279. "<a id=\"" + this.id + "btnhelpbox\" href=\"#\">" + PFM.JS.IDS_JS_HELP_URL + "</a>" +
  1280. "</td>";
  1281. }
  1282. markup += "<td style=\"width:16px\">" +
  1283. "<input id=\"" + this.id + "btnclosebox\" type=\"image\" src=\"" + _F_Config.webContent + "/fragments/common/images/dialog_close.gif\" style=\"width:16px; height:16px\" role=\"button\" title=\""+PFM.JS.IDS_JS_BUTTON_CLOSE+"\" alt=\""+PFM.JS.IDS_JS_BUTTON_CLOSE+"\"/>" +
  1284. "</td>" +
  1285. "</tr>" +
  1286. "</table>" +
  1287. "</td>" +
  1288. "</tr>" +
  1289. "<tr>" +
  1290. "<td class=\"cogstyle-dialog-body\">";
  1291. var tempMarkup = " id=\"" + this.id + "content\" class=\"cogstyle-dialog-content\" style=\"width:" + this.dx + "px;height:" + this.dy + "px";
  1292. if ((this.styles & ui_dialog.style.IFRAME) != ui_dialog.style.IFRAME) {
  1293. markup += "<div" + tempMarkup + "\"></div>";
  1294. } else {
  1295. markup += "<iframe src=\""+_F_Config.webContent+"/fragments/common/images/space.gif\" name=\"" + this.iframeName + "\"" + tempMarkup + " ;margin:0px;padding:0px;border:0px;\"></iframe>";
  1296. }
  1297. markup += "<div class=\"cogstyle-dialog-commandbar\">" +
  1298. "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"width:100%\" role=\"presentation\"><tr><td>" ;
  1299. var buttons = ui_dialog.button._styles_[this.styles & 15];
  1300. var i, l = buttons.length;
  1301. if (l > 0) {
  1302. for (i=0; i<l; i++) {
  1303. markup +=
  1304. "<input id=\"" + this.id + "btn" + buttons[i] +
  1305. "\" class=\"cogstyle-dialog-button\" type=\"button\" value=\"" +
  1306. PFM.JS["IDS_JS_BUTTON_" + buttons[i].toUpperCase()] + "\" tabIndex=\"0\"/>";
  1307. }
  1308. markup+="</td>";
  1309. } else {
  1310. markup += "<br>";
  1311. }
  1312. if (((this.styles & ui_dialog.style.RESIZABLE) == ui_dialog.style.RESIZABLE) && ((this.styles & ui_dialog.style.IFRAME) != ui_dialog.style.IFRAME)) {
  1313. markup += "<td valign=\"bottom\" style=\"width:12px\">" +
  1314. "<img id=\"" + this.id + "resizebox\" src=\"" + _F_Config.webContent + "/fragments/common/images/dialog_resize.gif\" border=\"0\" style=\"width:12px;height:12px;cursor:nw-resize\" alt=\"\">" +
  1315. "</td>";
  1316. }
  1317. markup += "</tr>" +
  1318. "</table>" +
  1319. "</div>" +
  1320. "</td>" +
  1321. "</tr>" +
  1322. "</table>";
  1323. div.innerHTML = markup;
  1324. document.body.appendChild(div);
  1325. this.attachContent(this.content);
  1326. for (var b in ui_dialog.button) {
  1327. var btn = $(this.id + "btn" + ui_dialog.button[b]);
  1328. if (btn != null) {
  1329. xAddEventListener(btn, "click", _F_Document.associate(btn, this, "oncommand"));
  1330. }
  1331. }
  1332. var capDiv = $(this.id + "caption");
  1333. capDiv.xdlg = this;
  1334. xAddEventListener(div, "mousedown", _F_Document.associate(div, this, "onactivate"));
  1335. xEnableDrag(capDiv, this.onstartmove, this.onmove, null);
  1336. if ((this.styles & ui_dialog.style.RESIZABLE) == ui_dialog.style.RESIZABLE) {
  1337. var resizeBox = $(this.id + "resizebox");
  1338. resizeBox.xdlg = this;
  1339. xEnableDrag(resizeBox, this.onstartresize, this.onresize, null);
  1340. }
  1341. if ((this.styles & ui_dialog.style.IFRAME) == ui_dialog.style.IFRAME) {
  1342. if ((this.styles & ui_dialog.style.RESIZABLE) == ui_dialog.style.RESIZABLE) {
  1343. _F_log("I", "Resize not currently available for dialogs displaying iframes.");
  1344. }
  1345. this.showLoadingIndicator();
  1346. this.postForm(this.srcHref);
  1347. }
  1348. return div;
  1349. },
  1350. showLoadingIndicator: function () {
  1351. // BUSY DIV
  1352. var progressDiv = null;
  1353. var dialogIframe;
  1354. progressDiv = $(this.id + "progressDiv");
  1355. if (progressDiv == null) {
  1356. progressDiv = xCreateElement("div");
  1357. progressDiv.id = this.id + "progressDiv";
  1358. var progressMarkup= ui_templates.get(ui_templates.contentTemplate, 'CONTENTID', progressDiv.id + "content");
  1359. dialogIframe = $(this.id + "content");
  1360. progressDiv.innerHTML = progressMarkup;
  1361. progressDiv.style.height = this.dy;
  1362. progressDiv.style.width = this.dx;
  1363. dialogIframe.parentNode.insertBefore(progressDiv, dialogIframe);
  1364. _F_Document.addEventListener(dialogIframe,"load", _F_Document.associate(dialogIframe.id,this,"onContentLoaded"));
  1365. }
  1366. dialogIframe.style.display = "none";
  1367. },
  1368. onContentLoaded : function(event) {
  1369. var dialogIframe = $(this.id + "content");
  1370. var progressDiv = $(this.id + "progressDiv");
  1371. if ((dialogIframe) && (dialogIframe.style.display == "none"))
  1372. {
  1373. progressDiv.style.display = "none";
  1374. dialogIframe.style.display = "";
  1375. }
  1376. },
  1377. postForm: function(url) {
  1378. var iframe = $(this.id + "content");
  1379. var formElement = document.createElement("form");
  1380. formElement.setAttribute("name","_THIS_dlg_window_form");
  1381. formElement.setAttribute("method","POST");
  1382. formElement.setAttribute("target", iframe.name);
  1383. var qm_index = url.indexOf("?");
  1384. var action = (qm_index==-1) ? url : url.substring(0, qm_index);
  1385. formElement.setAttribute("action", action);
  1386. if (qm_index != -1) {
  1387. var paramString = url.substring(qm_index+1);
  1388. var params = paramString.split("&");
  1389. var i;
  1390. for (i=0; i < params.length; ++i) {
  1391. if (params[i].length>0) {
  1392. var hiddenElement = document.createElement("input");
  1393. hiddenElement.setAttribute("type","hidden");
  1394. var eq_index = params[i].indexOf("=");
  1395. if (eq_index != -1) {
  1396. hiddenElement.setAttribute("name",unescape(params[i].substring(0,eq_index)));
  1397. hiddenElement.setAttribute("value",unescape(params[i].substring(eq_index+1)));
  1398. } else {
  1399. hiddenElement.setAttribute("name",unescape(params[i]));
  1400. hiddenElement.setAttribute("value","");
  1401. }
  1402. formElement.appendChild(hiddenElement);
  1403. }
  1404. }
  1405. }
  1406. document.body.appendChild(formElement);
  1407. formElement.submit();
  1408. document.body.removeChild(formElement);
  1409. formElement = null;
  1410. },
  1411. destroy: function() {
  1412. this.hide();
  1413. if (xIE4Up) {
  1414. if ($(this.id + "caption")) {
  1415. xDisableDrag(this.id + "caption");
  1416. }
  1417. if ($(this.id + "resizebox")) {
  1418. xDisableDrag(this.id + "resizebox");
  1419. }
  1420. if ((this.styles & ui_dialog.style.IFRAME) == ui_dialog.style.IFRAME) {
  1421. var iFrameObj = $(this.id + "content");
  1422. iFrameObj.parentNode.removeChild(iFrameObj);
  1423. }
  1424. }
  1425. this.dlg.parentNode.removeChild(this.dlg);
  1426. this.dlg = null;
  1427. if (this.backing) {
  1428. this.backing.parentNode.removeChild(this.backing);
  1429. this.backing = null;
  1430. }
  1431. },
  1432. show: function() {
  1433. if (this.dlg == null) {
  1434. this.dlg = this.create();
  1435. }
  1436. ui_dialog.chain.push(this);
  1437. this.center(this.x, this.y, this.dx, this.dy);
  1438. this.onactivate();
  1439. if (this.fragment) {
  1440. this.fragment.raiseEvent("cognos.ui.dialog.show", null, null);
  1441. }
  1442. this.initTabStops();
  1443. },
  1444. initTabStops: function(skipFocus) {
  1445. for (var i=0; i< this.eventHandlers.length;i++) {
  1446. dojo.disconnect(this.eventHandlers[i]);
  1447. }
  1448. if ((this.styles & ui_dialog.style.MODELESS) == 0) {
  1449. var buttons = ui_dialog.button._styles_[this.styles & 15];
  1450. var firstBtn = document.getElementById(this.id + "btn" + buttons[0]);
  1451. var lastBtn = document.getElementById(this.id + "btn" + buttons[buttons.length-1]);
  1452. var dialogContainer = document.getElementById(this.id + "content");
  1453. tabStops = [];
  1454. if ((this.styles & ui_dialog.style.READONLY) == 0) {
  1455. tabStops = ui_getNavigableElements(dialogContainer);
  1456. this.eventHandlers[this.eventHandlers.length] = dojo.connect(dialogContainer, "onmouseup", function(e){
  1457. for (var i=0;i<tabStops.length;i++) {
  1458. if (tabStops[i]==e.target) {
  1459. tabIdx = i;
  1460. setTimeout(function(){tabStops[tabIdx].focus()},1);
  1461. }
  1462. }
  1463. });
  1464. } else {
  1465. this.eventHandlers[this.eventHandlers.length] = dojo.connect(dialogContainer, "onmousedown", function(e){
  1466. dojo.stopEvent(e);
  1467. });
  1468. if (tabStops.length > 0) {
  1469. this.eventHandlers[this.eventHandlers.length] = dojo.connect(dialogContainer, "onmouseup", function(e){
  1470. dojo.stopEvent(e);
  1471. setTimeout(function(){tabStops[tabIdx].focus()},1);
  1472. });
  1473. }
  1474. }
  1475. for (var i=0; i < buttons.length;i++) {
  1476. tabStops[tabStops.length] = document.getElementById(this.id + "btn" + buttons[i]);
  1477. }
  1478. for (var i=0; i < tabStops.length;i++) {
  1479. tabStops[i].tabIndex=i+1;
  1480. }
  1481. if (tabStops.length > 0) {
  1482. tabIdx = 0;
  1483. var self = this;
  1484. this.eventHandlers[this.eventHandlers.length] = dojo.connect(dojo.body(), "onkeypress", function(e){
  1485. if (e.charOrCode == dojo.keys.TAB) {
  1486. if (e.shiftKey) {
  1487. if (--tabIdx == -1) {
  1488. dojo.stopEvent(e);
  1489. tabIdx = tabStops.length-1;
  1490. }
  1491. } else if (++tabIdx == tabStops.length) {
  1492. dojo.stopEvent(e);
  1493. tabIdx = 0;
  1494. }
  1495. setTimeout(function(){tabStops[tabIdx].focus()},1);
  1496. } else if (e.charOrCode == dojo.keys.ESCAPE){
  1497. dojo.stopEvent(e);
  1498. self.processCommand(ui_dialog.button.CANCEL);
  1499. }
  1500. });
  1501. if (!skipFocus) {
  1502. tabStops[0].focus();
  1503. }
  1504. }
  1505. }
  1506. },
  1507. center: function(dialogX, dialogY, dialogW, dialogH) {
  1508. if ((this.styles & ui_dialog.style.CENTER) != 0) {
  1509. dialogX = ((xClientWidth() - dialogW ) / 2);
  1510. if (dialogX < 0) {dialogX = 0;}
  1511. dialogY = ((xClientHeight() - dialogH) / 2);
  1512. if (dialogY < 0) {dialogY = 0;}
  1513. } else {
  1514. if (dialogX == -1) {
  1515. ui_dialog.nextX += 20;
  1516. if (ui_dialog.nextX > 200) {ui_dialog.nextX = 0;}
  1517. dialogX = ui_dialog.nextX;
  1518. }
  1519. if (dialogY == -1) {
  1520. ui_dialog.nextY += 20;
  1521. if (ui_dialog.nextY > 200) {ui_dialog.nextY = 0;}
  1522. dialogY = ui_dialog.nextY;
  1523. }
  1524. }
  1525. if ((this.styles & ui_dialog.style.MODELESS) == 0) {
  1526. var locker = ui_locker.get();
  1527. locker.show();
  1528. }
  1529. if (this.contentId != null) {
  1530. var content = $(this.contentId);
  1531. this.dlg.style.fontSize = xGetComputedStyle(content, "font-size");
  1532. this.dlg.style.fontFamily = xGetComputedStyle(content, "font-family");
  1533. }
  1534. this.dlg.style.left = dialogX + "px";
  1535. this.dlg.style.top = dialogY + "px";
  1536. this.dlg.style.display = "";
  1537. if (this.backing) {
  1538. this.backing.style.left = dialogX + "px";
  1539. this.backing.style.top = dialogY + "px";
  1540. this.backing.style.display = "";
  1541. xResizeTo(this.backing, xWidth(this.dlg), xHeight(this.dlg));
  1542. }
  1543. },
  1544. hide: function() {
  1545. for (var i=0; i< this.eventHandlers.length;i++) {
  1546. dojo.disconnect(this.eventHandlers[i]);
  1547. }
  1548. if (this.dlg != null) {
  1549. this.dlg.style.display="none";
  1550. }
  1551. if (this.backing) {
  1552. this.backing.style.display="none";
  1553. }
  1554. if (_F_Array.remove(ui_dialog.chain, this) != null) {
  1555. var locker = ui_locker.get();
  1556. if ((this.styles & ui_dialog.style.MODELESS) == 0) {
  1557. locker.hide();
  1558. }
  1559. }
  1560. var currentElement = document.activeElement;
  1561. if (!ui_isTabNavigable(currentElement)) {
  1562. if (this.triggerElement != null) {
  1563. var self = this;
  1564. setTimeout(function(){self.triggerElement.focus();},500);
  1565. }
  1566. }
  1567. },
  1568. onactivate: function(e, tag) {
  1569. // move this dialog to the end of the chain
  1570. _F_Array.remove(ui_dialog.chain, this);
  1571. ui_dialog.chain.push(this);
  1572. // change Z order
  1573. var i, l=ui_dialog.chain.length;
  1574. for (i = 0; i < l; i++) {
  1575. if (ui_dialog.chain[i].dlg != null) {
  1576. $(ui_dialog.chain[i].id + "caption").className = "cogstyle-dialog-caption" + ((i < (l - 1)) ? "-inactive" : "");
  1577. ui_dialog.chain[i].dlg.style.zIndex = 9999 + (2*i);
  1578. if (this.backing) {
  1579. ui_dialog.chain[i].backing.style.zIndex = 9999 + ((2*i)-1);
  1580. }
  1581. }
  1582. }
  1583. },
  1584. onstartmove: function(e, dx, dy) {
  1585. if (e.xdlg != null) {
  1586. var _self = e.xdlg;
  1587. if (_self != null) {
  1588. var elm = _self.dlg;
  1589. _self.startX = xPageX(elm);
  1590. _self.startY = xPageY(elm);
  1591. _self.lastX = e.xDPX;
  1592. _self.lastY = e.xDPY;
  1593. }
  1594. }
  1595. },
  1596. onmove: function(e, dx, dy) {
  1597. if (e.xdlg != null) {
  1598. var _self = e.xdlg;
  1599. if (_self != null) {
  1600. var elm = _self.dlg;
  1601. var nx = _self.startX + (e.xDPX - _self.lastX);
  1602. var ny = _self.startY + (e.xDPY - _self.lastY);
  1603. var cx = xClientWidth();
  1604. if (cx < document.body.scrollWidth) {cx = document.body.scrollWidth;}
  1605. var cy = xClientHeight();
  1606. if (cy < document.body.scrollHeight) {cy = document.body.scrollHeight;}
  1607. var w = xWidth(elm);
  1608. var h = xHeight(elm);
  1609. if (nx < 0) {nx = 0;}
  1610. if (ny < 0) {ny = 0;}
  1611. if ((nx + w) > cx) {nx = cx - w;}
  1612. if ((ny + h) > cy) {ny = cy - h;}
  1613. _self.x = nx;
  1614. _self.y = ny;
  1615. xMoveTo(elm, nx, ny);
  1616. if (_self.backing) {
  1617. xMoveTo(_self.backing, nx, ny);
  1618. }
  1619. }
  1620. }
  1621. },
  1622. onstartresize: function(e, dx, dy) {
  1623. if (e.xdlg != null) {
  1624. var _self = e.xdlg;
  1625. if (_self != null) {
  1626. var elm = _self.dlg;
  1627. }
  1628. }
  1629. },
  1630. onresize: function(e, dx, dy) {
  1631. if (e.xdlg != null) {
  1632. var _self = e.xdlg;
  1633. if (_self != null) {
  1634. var elm = $(_self.id + "content");
  1635. if ((xWidth(elm) + dx) > _self.minDialogWidth) {
  1636. xResizeTo(elm, xWidth(elm) + dx, xHeight(elm) + dy);
  1637. if (_self.backing) {
  1638. xResizeTo(_self.backing, xWidth(_self.dlg), xHeight(_self.dlg));
  1639. }
  1640. }
  1641. }
  1642. }
  1643. },
  1644. onclose: function() {
  1645. this.hide();
  1646. },
  1647. oncommand: function(e, tag) {
  1648. try {
  1649. if (false == this.processCommand(tag.id.substring((this.id + "btn").length))) {
  1650. return;
  1651. }
  1652. }
  1653. catch (err) {
  1654. _F_log("E", err);
  1655. }
  1656. if (this.content && this.contentNativeParent) {
  1657. //Detach the content node from the dialog and re-attach to the native parent
  1658. this.content.parentNode.removeChild(this.content);
  1659. this.contentNativeParent.appendChild(this.content);
  1660. }
  1661. this.hide();
  1662. },
  1663. processCommand: function(action) {
  1664. if (this.fragment) {
  1665. if ((action == ui_dialog.button.OK) ||
  1666. (action == ui_dialog.button.APPLY) ||
  1667. (action == ui_dialog.button.YES))
  1668. {
  1669. return this.fragment.raiseEvent("cognos.ui.dialog.ok", null, null);
  1670. }
  1671. else if ((action == ui_dialog.button.CANCEL) ||
  1672. (action == ui_dialog.button.CLOSEBOX) ||
  1673. (action == ui_dialog.button.CLOSE) ||
  1674. (action == ui_dialog.button.NO))
  1675. {
  1676. return this.fragment.raiseEvent("cognos.ui.dialog.cancel", null, null);
  1677. }
  1678. else if ((action == ui_dialog.button.HELPBOX))
  1679. {
  1680. ui_fragment_help(this.fragment);
  1681. return false;
  1682. }
  1683. else
  1684. {
  1685. _F_log("E", "Event " + evt.name + " not handled");
  1686. return false;
  1687. }
  1688. }
  1689. return true;
  1690. },
  1691. setCaption: function(text) {
  1692. if (this.dlg != null) {
  1693. $(this.id + "captiontext").innerHTML = _F_Strings.htmlEncode(text);
  1694. } else {
  1695. this.caption = text;
  1696. }
  1697. },
  1698. setContent: function(content) {
  1699. this.content = content;
  1700. if (this.dlg != null) {
  1701. this.attachContent(content);
  1702. }
  1703. },
  1704. attachContent: function(content) {
  1705. this.content = content;
  1706. var contentParentDiv = $(this.id + "content");
  1707. if (contentParentDiv) {
  1708. if (typeof content == "string") {
  1709. var tempEl = document.createElement("div");
  1710. tempEl.innerHTML = content;
  1711. contentParentDiv.appendChild(tempEl);
  1712. } else {
  1713. this.contentNativeParent = content.parentNode;
  1714. if (this.contentNativeParent) {
  1715. this.contentNativeParent.removeChild(content);
  1716. }
  1717. contentParentDiv.appendChild(content);
  1718. content.style.display='';
  1719. }
  1720. }
  1721. },
  1722. getResults: function() {
  1723. return this.results;
  1724. }
  1725. };
  1726. /**
  1727. * ui_locker - creates a full screen DIV to lock events
  1728. */
  1729. function ui_locker() {
  1730. this.divID = "ui_locker";
  1731. this.backingID = "ui_lockerBacking";
  1732. var backing = $(this.backingID);
  1733. if (backing == null) {
  1734. backing = document.createElement("iframe");
  1735. backing.id = this.backingID;
  1736. backing.name = this.backingID;
  1737. backing.style.display= "none";
  1738. backing.style.position="absolute";
  1739. backing.style.backgroundColor="#dddddd";
  1740. backing.style.filter="alpha(opacity=0)";
  1741. backing.style.opacity="0.0";
  1742. backing.style.MozOpacity="0.0";
  1743. backing.src = _F_Config.webContent + "/fragments/common/images/space.gif";
  1744. backing.setAttribute("role","presentation");
  1745. document.body.appendChild(backing);
  1746. }
  1747. var div = $(this.divID);
  1748. if (div == null) {
  1749. div = document.createElement("DIV");
  1750. div.id = this.divID;
  1751. div.style.display= "none";
  1752. div.style.position="absolute";
  1753. div.style.backgroundColor="#dddddd";
  1754. document.body.appendChild(div);
  1755. }
  1756. this.count = 0;
  1757. }
  1758. ui_locker.singleton = null;
  1759. ui_locker.get = function() {
  1760. if (ui_locker.singleton == null) {
  1761. ui_locker.singleton = new ui_locker();
  1762. }
  1763. return this.singleton;
  1764. };
  1765. ui_locker.prototype = {
  1766. show: function(bHidden) {
  1767. var div = $(this.divID);
  1768. var backing = $(this.backingID);
  1769. if ((++this.count) == 1) {
  1770. div.style.width = "0px";
  1771. div.style.height = "0px";
  1772. div.style.top = "0px";
  1773. div.style.left ="0px";
  1774. div.style.display = "";
  1775. backing.style.width = "0px";
  1776. backing.style.height = "0px";
  1777. backing.style.top = "0px";
  1778. backing.style.left ="0px";
  1779. backing.style.display = "";
  1780. if (bHidden && bHidden == true) {
  1781. div.style.filter="alpha(opacity=0)";
  1782. div.style.opacity="0.0";
  1783. div.style.MozOpacity="0.0";
  1784. } else {
  1785. div.style.filter="alpha(opacity=50)";
  1786. div.style.opacity="0.5";
  1787. div.style.MozOpacity="0.5";
  1788. }
  1789. this.onresize();
  1790. }
  1791. if (ui_dialog.chain != null && ui_dialog.chain.length > 0) {
  1792. // move the glass before this dialog window
  1793. var w = ui_dialog.chain[ui_dialog.chain.length - 1];
  1794. if (w.dlg != null) {
  1795. w.dlg.parentNode.insertBefore(backing, w.dlg);
  1796. w.dlg.parentNode.insertBefore(div, w.dlg);
  1797. }
  1798. }
  1799. },
  1800. hide: function() {
  1801. var div = $(this.divID);
  1802. var backing = $(this.backingID);
  1803. if (ui_dialog.chain != null && ui_dialog.chain.length > 0) {
  1804. // move the glass before this dialog window
  1805. var w = ui_dialog.chain[ui_dialog.chain.length - 1];
  1806. if (w.dlg != null) {
  1807. w.dlg.parentNode.insertBefore(backing, w.dlg);
  1808. w.dlg.parentNode.insertBefore(div, w.dlg);
  1809. }
  1810. }
  1811. if ((--this.count) == 0) {
  1812. xDisplay(this.divID, "none");
  1813. xDisplay(this.backingID, "none");
  1814. }
  1815. },
  1816. isVisible: function() {
  1817. return (ui_locker.singleton != null) && ("none" != xDisplay(this.divID));
  1818. },
  1819. onresize: function() {
  1820. var div = $(this.divID);
  1821. var backing = $(this.backingID);
  1822. var cx = xClientWidth();
  1823. if (cx < document.body.scrollWidth) {cx = document.body.scrollWidth;}
  1824. var cy = xClientHeight();
  1825. if (cy < document.body.scrollHeight) {cy = document.body.scrollHeight;}
  1826. xResizeTo(div, cx, cy);
  1827. xResizeTo(backing, cx, cy);
  1828. }
  1829. };
  1830. /**
  1831. * toolbarButtonMouseOver
  1832. * @deprecated
  1833. */
  1834. function toolbarButtonMouseOver(e) {
  1835. e.className = "cogstyle-btn-over";
  1836. }
  1837. /**
  1838. * toolbarButtonMouseOut
  1839. * @deprecated
  1840. */
  1841. function toolbarButtonMouseOut(e) {
  1842. e.className = "cogstyle-btn-normal";
  1843. }
  1844. var ui_curmenu = null;
  1845. var ui_menuevt = false;
  1846. /**
  1847. * ui_menuShow
  1848. * @param evt
  1849. * @param menu
  1850. */
  1851. function ui_menuShow(evt, menu) {
  1852. ui_menuHide();
  1853. menu.show(evt);
  1854. }
  1855. /**
  1856. * ui_menuUpdate
  1857. * @param menu
  1858. */
  1859. function ui_menuUpdate(menu) {
  1860. menu.rebuild = true;
  1861. }
  1862. /**
  1863. * ui_menuHide
  1864. */
  1865. function ui_menuHide(menu) {
  1866. if (!menu && ui_curmenu) {
  1867. menu = ui_curmenu;
  1868. if (menu.enabled) {
  1869. menu.enabled = false;
  1870. var currentElement = document.activeElement;
  1871. if (!ui_isTabNavigable(currentElement)) {
  1872. if (menu.originalControlElement != null) {
  1873. menu.originalControlElement.focus();
  1874. }
  1875. }
  1876. }
  1877. }
  1878. if (menu != null) {
  1879. if (menu.child) {
  1880. for (var i in menu.child) {
  1881. menu.child[i].enabled = false;
  1882. ui_menuHide(menu.child[i]);
  1883. }
  1884. ui_curmenu = null;
  1885. }
  1886. if (menu.hide) {
  1887. menu.hide();
  1888. }
  1889. }
  1890. }
  1891. /**
  1892. * ui_menuHideHook
  1893. * @param evt
  1894. */
  1895. function ui_menuHideHook(evt) {
  1896. ui_menuHide();
  1897. }
  1898. /**
  1899. * ui_menuMouseOver
  1900. * @param evt
  1901. */
  1902. function ui_menuMouseOver(evt, menu) {
  1903. evt = evt != null ? evt : window.event;
  1904. var e = evt.srcElement ? evt.srcElement : evt.target;
  1905. if (e.tagName == "TD") {
  1906. e = e.parentNode; //get the TR rather than the TD
  1907. }
  1908. if (menu.menudef.items[menu.curitem] && menu.menudef.items[menu.curitem].items != null) {
  1909. menu.child[menu.curitem].enabled = false;
  1910. ui_menuHide(menu.child[menu.curitem]);
  1911. }
  1912. if (menu != null && menu.curitem !=null) {
  1913. document.getElementById(menu.menudef.id + "TR" + menu.curitem).className = "cogstyle-menu-item";
  1914. menu.curitem = e.id.substring(e.id.lastIndexOf("TR")+2);
  1915. }
  1916. e.className = "cogstyle-menu-item-hilite";
  1917. e.focus();
  1918. }
  1919. /**
  1920. * ui_menuMouseOut
  1921. */
  1922. function ui_menuMouseOut(evt) {
  1923. evt = evt != null ? evt : window.event;
  1924. var e = evt.srcElement ? evt.srcElement : evt.target;
  1925. if (e.tagName == "TD") {
  1926. e = e.parentNode; //get the TR rather than the TD
  1927. }
  1928. e.className = "cogstyle-menu-item";
  1929. }
  1930. /**
  1931. * ui_menu
  1932. * @param menudef
  1933. */
  1934. function ui_menu(menudef) {
  1935. this.menu = null;
  1936. this.backing = null;
  1937. this.menudef = menudef;
  1938. this.rebuild = true;
  1939. this.child = null;
  1940. this.enabled = false;
  1941. this.fragment = null;
  1942. this.curitem = null;
  1943. this.selectedItem = null;
  1944. this.originalControlElement = null;
  1945. }
  1946. ui_menu.prototype = {
  1947. build: function() {
  1948. // Remove the old menu if it already exists and is not this menu
  1949. // This menu is taken care of later.
  1950. var oldDiv = $(this.menudef.id + "mainDiv");
  1951. if (oldDiv && oldDiv != this.menu) {
  1952. document.body.removeChild(oldDiv);
  1953. }
  1954. var oldBacking = $(this.menudef.id + "backing");
  1955. if (oldBacking && oldBacking != this.backing) {
  1956. document.body.removeChild(oldBacking);
  1957. }
  1958. if (ui_menuevt == false) {
  1959. //Attach global events used by ui_menus.
  1960. ui_menuevt = true;
  1961. _F_Document.addEventListener(document.body, "mouseup", ui_menuHideHook);
  1962. _F_Document.addEventListener(window, "blur", ui_menuHideHook);
  1963. }
  1964. if (this.menu != null) {
  1965. document.body.removeChild(this.menu);
  1966. this.menu = null;
  1967. }
  1968. if (this.backing != null) {
  1969. document.body.removeChild(this.backing);
  1970. this.backing = null;
  1971. }
  1972. var pad = false;
  1973. var selected = false;
  1974. for (var i=0; i<this.menudef.items.length; i++) {
  1975. if (this.menudef.items[i].image != null) {
  1976. pad = true;
  1977. if (selected) {break;}
  1978. }
  1979. if (this.menudef.items[i].selected) {
  1980. selected = true;
  1981. if (pad) {break;}
  1982. }
  1983. }
  1984. var div = document.createElement('div');
  1985. div.id = this.menudef.id + "mainDiv";
  1986. div.style.display="none";
  1987. div.className="cogstyle-menu-popup";
  1988. // The tab index is required for keyboard events to be processed for the div in FireFox
  1989. div.tabIndex="-1";
  1990. div.setAttribute("aria-label", this.menudef.title || PFM.JS.IDS_JS_ACTION);
  1991. xAddEventListener(div, "keyup", _F_Document.associate(window, this, "onkeypress"));
  1992. xAddEventListener(div, "keypress", _F_Document.associate(window, this, "handleTab"));
  1993. var table = document.createElement('table');
  1994. table.cellSpacing="0";
  1995. table.cellPadding="0";
  1996. table.border="0";
  1997. table.setAttribute("role","menu");
  1998. table.setAttribute("aria-label", this.menudef.title || PFM.JS.IDS_JS_ACTION);
  1999. tbody = document.createElement('tbody');
  2000. table.appendChild(tbody);
  2001. for (i=0; i<this.menudef.items.length; i++) {
  2002. if (this.menudef.items[i].getItemState && this.menudef.items[i].getItemState(this.menudef, i) == 'hide') {
  2003. continue;
  2004. }
  2005. if (this.menudef.items[i].separatorBefore) {
  2006. var tr_separator = document.createElement('tr');
  2007. var td_separator = document.createElement('td');
  2008. var separator = document.createElement('div');
  2009. separator.className="cogstyle-menu-item-separator";
  2010. td_separator.appendChild(separator);
  2011. tr_separator.appendChild(td_separator);
  2012. tbody.appendChild(tr_separator);
  2013. }
  2014. var tr = document.createElement('tr');
  2015. tr.setAttribute("role","menuitem");
  2016. tr.setAttribute("aria-haspopup", this.menudef.items[i].haspopup && (this.menudef.items[i].haspopup == true) ? "true" : "false");
  2017. tr.setAttribute("tabindex","-1");
  2018. tr.id = this.menudef.id + "TR" + i;
  2019. if (selected) {
  2020. var tdSelected = document.createElement('td');
  2021. tdSelected.className="cogstyle-menu-item";
  2022. tdSelected.width="4px";
  2023. if (this.menudef.items[i].selected) {
  2024. this.curitem = this.selectedItem = i; //Use this index as reference for the current and selected item.
  2025. tdSelected.className="cogstyle-menu-item-selected";
  2026. }
  2027. tr.appendChild(tdSelected);
  2028. }
  2029. var td = document.createElement('td');
  2030. if (this.menudef.items[i].image != null) {
  2031. td.style.backgroundImage="url("+ ((this.menudef.items[i].image.indexOf("http") == 0) ? this.menudef.items[i].image : _F_Config.webContent+this.menudef.items[i].image)+")";
  2032. td.style.backgroundRepeat="no-repeat";
  2033. td.style.backgroundPosition="6px center";
  2034. }
  2035. if (pad) {
  2036. td.style.paddingLeft="32px";
  2037. }
  2038. if (this.menudef.items[i].action) {
  2039. tr.className="cogstyle-menu-item";
  2040. td.className="cogstyle-menu-item";
  2041. var self = this;
  2042. function menuAction(context) {
  2043. function menuActionFunction(evt) {
  2044. var menuDef = context.menuDef;
  2045. var selectedIdx = context.selectedIdx;
  2046. ui_curmenu.selectMenuItem(menuDef.items[selectedIdx].id);
  2047. ui_menuHide(evt);
  2048. if (self.fragment) {
  2049. self.fragment.raiseEvent("cognos.ui.menu.select", context);
  2050. }
  2051. setTimeout(menuDef.items[selectedIdx].action, 1);
  2052. }
  2053. return menuActionFunction;
  2054. }
  2055. var mouseDownFunction = menuAction({"menuDef":this.menudef,"selectedIdx":i});
  2056. td.className="cogstyle-menu-item";
  2057. EventUtils.addEventListener(tr, "mousedown", mouseDownFunction);
  2058. EventUtils.addEventListener(tr, "mouseout", ui_menuMouseOut);
  2059. EventUtils.addEventListener(tr, "mouseover", _F_Document.associate(tr, this, "onmouseover"));
  2060. } else if (this.menudef.items[i].items) { //this menu item has childen
  2061. tr.key=i;
  2062. td.className="cogstyle-menu-item";
  2063. td.style.backgroundImage="url("+_F_Config.webContent+"/fragments/common/images/right.gif)";
  2064. td.style.backgroundRepeat="no-repeat";
  2065. td.style.backgroundPosition="right";
  2066. td.style.paddingRight="10px";
  2067. if (!this.child) {
  2068. this.child = [];
  2069. }
  2070. this.child[i] = new ui_menu ({id: "child", parent: this, items: this.menudef.items[i].items});
  2071. _F_Document.addEventListener(tr, "mouseout", ui_menuMouseOut);
  2072. _F_Document.addEventListener(tr, "mouseout", _F_Document.associate(tr, this, "onmouseout"));
  2073. tr.onmouseover = _F_Document.associate(tr, this, "onmouseoverParent");
  2074. } else {
  2075. td.className="cogstyle-menu-item-disabled";
  2076. }
  2077. td.appendChild(document.createTextNode(this.menudef.items[i].title));
  2078. tr.appendChild(td);
  2079. tbody.appendChild(tr);
  2080. if (this.menudef.items[i].items) {
  2081. var image=document.defaultView ? document.defaultView.getComputedStyle(td,null).backgroundImage : td.currentStyle.backgroundImage;
  2082. if (image.indexOf('right.gif') < 0) {
  2083. //High Contrast Mode detected. Background images are lost so enable checkMark image via applicable CSS class
  2084. td.className="cogstyle-menu-item-parent";
  2085. }
  2086. }
  2087. }
  2088. div.appendChild(table);
  2089. var iframe = document.createElement("iframe");
  2090. iframe.id = this.menudef.id + "backing";
  2091. iframe.style.display = "none";
  2092. iframe.style.border = "0px";
  2093. iframe.style.position = "absolute";
  2094. iframe.src = _F_Config.webContent + "/fragments/common/images/space.gif";
  2095. document.body.appendChild(iframe);
  2096. document.body.appendChild(div);
  2097. this.backing = iframe;
  2098. this.menu = div;
  2099. this.rebuild = false;
  2100. },
  2101. show: function(evt) {
  2102. if (this.menu == null || this.rebuild) {
  2103. this.build();
  2104. } else {
  2105. // set the current item to the current selected item
  2106. this.curitem = this.selectedItem;
  2107. }
  2108. var e=this.findObject(evt);
  2109. this.originalControlElement = e;
  2110. var x=getAbsolutePosX(e) - getScrollPosX(e) + xWidth(e) - (this.menudef.parent ? 0 : xWidth(e)) + 2;
  2111. var y=getAbsolutePosY(e) - getScrollPosY(e) + e.offsetHeight - (this.menudef.parent ? 16 : 0);
  2112. this.menu.style.left = "-1000px"; // make it off screen
  2113. this.menu.style.display = "block";
  2114. var dropDownHeight = xHeight(this.menu);
  2115. if ((y + dropDownHeight) > xClientHeight()) {
  2116. y = y - dropDownHeight - e.offsetHeight;
  2117. }
  2118. // Add the body scroll position to the calculation
  2119. y = y + getBodyScrollPosY();
  2120. x = x + getBodyScrollPosX();
  2121. if (y < 0) {
  2122. y = 0;
  2123. }
  2124. this.menu.style.top = y + "px";
  2125. if ((x + this.menu.offsetWidth) > document.body.offsetWidth) {
  2126. x += e.offsetWidth - this.menu.offsetWidth;
  2127. }
  2128. this.menu.style.left = x + "px";
  2129. this.backing.style.top = y + "px";
  2130. this.backing.style.height = xHeight(this.menu);
  2131. this.backing.style.left = x + "px";
  2132. this.backing.style.width = xWidth(this.menu);
  2133. this.backing.style.display = "block";
  2134. if (!this.menudef.parent) {
  2135. ui_curmenu = this;
  2136. this.menu.focus();
  2137. }
  2138. if (this.curitem == null) {
  2139. this.curitem = 0;
  2140. }
  2141. var newElem = document.getElementById(this.menudef.id + "TR" + this.curitem);
  2142. newElem.className = "cogstyle-menu-item-hilite";
  2143. newElem.focus();
  2144. /* find iframes in page and hide menu when they are focused. IE does not trigger the window.onmouseup event when you click on an iframe */
  2145. for (var iframes = document.getElementsByTagName("iframe"), i = iframes.length; i--;) {
  2146. if (iframes[i].getAttribute("menu-focus") == null) {
  2147. _F_Document.addEventListener(iframes[i], "focus", ui_menuHideHook);
  2148. iframes[i].setAttribute("menu-focus", "set");
  2149. }
  2150. if (iframes[i].getAttribute("title") == null) {
  2151. iframes[i].setAttribute("role", "presentation");
  2152. }
  2153. }
  2154. evt.cancelBubble = true;
  2155. if (evt.stopPropagation) {
  2156. evt.stopPropagation();
  2157. }
  2158. this.enabled = true;
  2159. },
  2160. hide: function() {
  2161. if ((!this.enabled) && (this.menu != null)) {
  2162. this.backing.style.display="none";
  2163. this.menu.style.display="none";
  2164. if (this.curitem != null) {
  2165. document.getElementById(this.menudef.id + "TR" + this.curitem).className = "cogstyle-menu-item";
  2166. this.curitem = null;
  2167. }
  2168. }
  2169. },
  2170. hideFocusOnControlElement: function(restoreTriggerFocus) {
  2171. if (this.originalControlElement != null) {
  2172. if (restoreTriggerFocus) {
  2173. this.originalControlElement.focus();
  2174. }
  2175. this.currentControlElement = null;
  2176. }
  2177. ui_menuHide();
  2178. },
  2179. findObject: function(evt) {
  2180. var e=evt.srcElement ? evt.srcElement : evt.target;
  2181. while (e != null) {
  2182. if (typeof e.onclick !== "undefined" || typeof e.onmouseover !== "undefined") {
  2183. return e;
  2184. }
  2185. e = e.parentNode;
  2186. }
  2187. return e;
  2188. },
  2189. handleTab: function(evt){
  2190. this.keyIsUp = true;
  2191. evt = evt != null ? evt : window.event;
  2192. if (evt.keyCode == 9){
  2193. document.getElementById(this.menudef.id + "TR" + this.curitem).className = "cogstyle-menu-item";
  2194. this.curitem = null;
  2195. this.hideFocusOnControlElement(true);
  2196. }
  2197. },
  2198. onkeypress: function(evt) {
  2199. evt = evt != null ? evt : window.event;
  2200. var e = evt.srcElement ? evt.srcElement : evt.target;
  2201. // Enter: Act on the current menu
  2202. var newElem;
  2203. if (evt.keyCode == 13) {
  2204. if (this.keyIsUp) {
  2205. ui_curmenu.selectMenuItem(this.menudef.items[this.curitem].id);
  2206. ui_menuHide(evt);
  2207. if (this.fragment) {
  2208. this.fragment.raiseEvent("cognos.ui.menu.select", context);
  2209. }
  2210. if (this.menudef.items[this.curitem].action) {
  2211. setTimeout(this.menudef.items[this.curitem].action, 1);
  2212. }
  2213. if (this.menudef.items[this.curitem].items) {
  2214. this.child[this.curitem].show(evt);
  2215. document.getElementById(this.menudef.id + "TR" + this.curitem).className = "cogstyle-menu-item";
  2216. } else {
  2217. this.curitem = null;
  2218. this.hideFocusOnControlElement();
  2219. }
  2220. }
  2221. this.keyIsUp = false;
  2222. }
  2223. // Esc Key: Close menu
  2224. else if (evt.keyCode == 27) {
  2225. document.getElementById(this.menudef.id + "TR" + this.curitem).className = "cogstyle-menu-item";
  2226. this.curitem = null;
  2227. this.hideFocusOnControlElement(true);
  2228. this.keyIsUp = false;
  2229. }
  2230. // Up Arrow
  2231. else if (evt.keyCode == 38) {
  2232. if (this.curitem != null) {
  2233. document.getElementById(this.menudef.id + "TR" + this.curitem).className = "cogstyle-menu-item";
  2234. if (this.curitem > 0) {
  2235. this.curitem--;
  2236. }
  2237. newElem = document.getElementById(this.menudef.id + "TR" + this.curitem);
  2238. newElem.className = "cogstyle-menu-item-hilite";
  2239. newElem.focus();
  2240. }
  2241. }
  2242. // Down arrow
  2243. else if (evt.keyCode == 40) {
  2244. if (this.curitem != null) {
  2245. document.getElementById(this.menudef.id + "TR" + this.curitem).className = "cogstyle-menu-item";
  2246. if (this.menudef.items.length-1 > this.curitem) {
  2247. this.curitem++;
  2248. }
  2249. newElem = document.getElementById(this.menudef.id + "TR" + this.curitem);
  2250. newElem.className = "cogstyle-menu-item-hilite";
  2251. newElem.focus();
  2252. }
  2253. else {
  2254. this.curitem = 0;
  2255. newElem = document.getElementById(this.menudef.id + "TR" + this.curitem);
  2256. newElem.className = "cogstyle-menu-item-hilite";
  2257. newElem.focus();
  2258. }
  2259. }
  2260. //tab key
  2261. else if (evt.keyCode == 9) {
  2262. this.hideFocusOnControlElement(true);
  2263. }
  2264. xStopPropagation(evt);
  2265. },
  2266. onmouseover: function(e, tag) {
  2267. ui_menuMouseOver(e, this);
  2268. this.enabled = true;
  2269. },
  2270. onmouseoverParent: function(e, tag) {
  2271. ui_menuMouseOver(e, this);
  2272. this.child[tag.key].show(e != null ? e : window.event);
  2273. },
  2274. onmouseout: function(e, tag) {
  2275. this.child[tag.key].enabled = false;
  2276. var self = this;
  2277. window.setTimeout(function() { ui_menuHide(self.child[tag.key]); }, 100);
  2278. },
  2279. getRootMenuItems: function() {
  2280. return this.menudef.items;
  2281. },
  2282. getSubMenuItems: function(item) {
  2283. return item.items;
  2284. },
  2285. getMenuItemAndGroup: function(id, group) {
  2286. var itemAndGroup = null;
  2287. var menuItemList;
  2288. if (group) {
  2289. menuItemList = group;
  2290. } else {
  2291. menuItemList = this.menudef.items;
  2292. }
  2293. for (var i=0; i<menuItemList.length; i++) {
  2294. if (menuItemList[i].id != null && menuItemList[i].id == id) {
  2295. itemAndGroup = {};
  2296. itemAndGroup.group = menuItemList;
  2297. itemAndGroup.item = menuItemList[i];
  2298. return itemAndGroup;
  2299. }
  2300. if (menuItemList[i].items) {
  2301. itemAndGroup = this.getMenuItemAndGroup(id, menuItemList[i].items);
  2302. if (itemAndGroup) {return itemAndGroup;}
  2303. }
  2304. }
  2305. return null;
  2306. },
  2307. selectMenuItem: function(id) {
  2308. var itemAndGroup = this.getMenuItemAndGroup(id);
  2309. if (itemAndGroup) {
  2310. this.clearGroupSelection(itemAndGroup.group);
  2311. itemAndGroup.item.selected = true;
  2312. this.rebuild = true;
  2313. return true;
  2314. }
  2315. return false;
  2316. },
  2317. clearGroupSelection: function(group) {
  2318. for (var i=0; i<group.length; i++) {
  2319. if (group[i].selected) {
  2320. this.rebuild = true;
  2321. group[i].selected = false;
  2322. }
  2323. }
  2324. }
  2325. };
  2326. /**
  2327. * ui_dockpane
  2328. * @param obj
  2329. */
  2330. function ui_dockpane(obj) {
  2331. for (var o in obj) {
  2332. this[o] = obj[o];
  2333. }
  2334. if (this.width == null) {
  2335. this.width = 200;
  2336. }
  2337. this.anim_pos = 0;
  2338. this.sid = "";
  2339. }
  2340. ui_dockpane.prototype = {
  2341. show: function() {
  2342. this.anim_pos = -this.width;
  2343. this.div.style.left = this.anim_pos+"px";
  2344. this.div.style.top = "0px";
  2345. this.div.style.width = this.width+"px";
  2346. this.div.style.height = "100%";
  2347. this.div.style.display = "block";
  2348. this.parent.style.marginLeft = "0px";
  2349. var self = this;
  2350. this.sid = window.setInterval(function() { self.animate(); }, 10);
  2351. },
  2352. hide: function() {
  2353. this.anim_pos = 0;
  2354. this.div.style.display = "none";
  2355. this.parent.style.marginLeft = "0px";
  2356. },
  2357. animate: function() {
  2358. if (this.anim_pos < 0) {
  2359. this.anim_pos += (this.width / 25);
  2360. this.div.style.left = this.anim_pos+"px";
  2361. } else {
  2362. window.clearInterval(this.sid);
  2363. this.div.style.left = "0px";
  2364. this.parent.style.marginLeft = this.width+"px";
  2365. }
  2366. }
  2367. };
  2368. /**
  2369. * ui_modal_dialog
  2370. * @deprecated
  2371. */
  2372. function ui_modal_dialog() {
  2373. throw 'RuntimeException: ui_modal_dialog is a static class and may not be instantiated';
  2374. }
  2375. var UI_MODAL_DIALOG_VISIBLE_DIALOG = true;
  2376. var UI_MODAL_DIALOG_TRIGGER_ELEMENT = null;
  2377. ui_modal_dialog.open = function (url, showHeader, visibleDialog, forceReload, usePost, contentId) {
  2378. UI_MODAL_DIALOG_TRIGGER_ELEMENT = document.activeElement;
  2379. //if someone has passed in the visible dialog then use it, otherwise default it to true
  2380. if (visibleDialog != null) {
  2381. UI_MODAL_DIALOG_VISIBLE_DIALOG = visibleDialog;
  2382. } else {
  2383. UI_MODAL_DIALOG_VISIBLE_DIALOG = true;
  2384. }
  2385. var modalForceReload = true;
  2386. if (forceReload != null) {
  2387. modalForceReload = forceReload;
  2388. }
  2389. var modalHideHeader = false;
  2390. if (showHeader != null && showHeader == true) {
  2391. modalHideHeader = true;
  2392. }
  2393. var pageBlurBacking = document.getElementById("UI_MODAL_DIALOG_PAGE_BLUR_BACKING");
  2394. if (pageBlurBacking == null) {
  2395. pageBlurBacking = document.createElement("iframe");
  2396. pageBlurBacking.id = "UI_MODAL_DIALOG_PAGE_BLUR_BACKING";
  2397. pageBlurBacking.name = "UI_MODAL_DIALOG_PAGE_BLUR_BACKING";
  2398. pageBlurBacking.style.display= "none";
  2399. pageBlurBacking.style.position="absolute";
  2400. pageBlurBacking.style.backgroundColor="#eeeeee";
  2401. pageBlurBacking.style.filter="alpha(opacity=0)";
  2402. pageBlurBacking.style.opacity="0.0";
  2403. pageBlurBacking.src = _F_Config.webContent + "/fragments/common/images/space.gif";
  2404. document.body.appendChild(pageBlurBacking);
  2405. }
  2406. var pageBlurDiv = document.getElementById("UI_MODAL_DIALOG_PAGE_BLUR");
  2407. if (pageBlurDiv == null) {
  2408. pageBlurDiv = document.createElement("div");
  2409. pageBlurDiv.id = "UI_MODAL_DIALOG_PAGE_BLUR";
  2410. pageBlurDiv.style.display= "none";
  2411. pageBlurDiv.style.position="absolute";
  2412. pageBlurDiv.style.backgroundColor="#eeeeee";
  2413. pageBlurDiv.style.filter="alpha(opacity=50)";
  2414. pageBlurDiv.style.opacity="0.3";
  2415. pageBlurDiv.style.zIndex="8999";
  2416. document.body.appendChild(pageBlurDiv);
  2417. }
  2418. var iFrameDiv = document.getElementById("UI_MODAL_DIALOG_IFRAME_DIV");
  2419. if (iFrameDiv == null) {
  2420. // BUSY DIV
  2421. var iFrameBusy = document.createElement("div");
  2422. iFrameBusy.id = "UI_MODAL_DIALOG_IFRAME_BUSY_DIV";
  2423. iFrameBusy.style.padding="10px";
  2424. iFrameBusy.style.position="absolute";
  2425. document.body.appendChild(iFrameBusy);
  2426. var nobr = document.createElement("div");
  2427. nobr.style.backgroundColor="#EFEFEF";
  2428. nobr.style.padding="10px";
  2429. nobr.style.border="solid 1px black";
  2430. nobr.style.textAlign="center";
  2431. nobr.id ="UI_MODAL_DIALOG_IFRAME_BUSY_IMG";
  2432. iFrameBusy.appendChild(nobr);
  2433. var busyProgressImg = document.createElement("img");
  2434. busyProgressImg.src = _F_Config.webContent + "/fragments/common/images/progress.gif";
  2435. busyProgressImg.align= "absmiddle";
  2436. nobr.appendChild(busyProgressImg);
  2437. var cancelLink = document.createElement("a");
  2438. cancelLink.href="javascript:ui_modal_dialog.close()";
  2439. nobr.appendChild(cancelLink);
  2440. cancelLink.appendChild(document.createTextNode(PFM.JS.IDS_JS_MODAL_CANCEL));
  2441. // IFRAME DIV
  2442. iFrameDiv = document.createElement("div");
  2443. iFrameDiv.id = "UI_MODAL_DIALOG_IFRAME_DIV";
  2444. iFrameDiv.style.padding="0px";
  2445. iFrameDiv.style.display= "none";
  2446. iFrameDiv.style.position="absolute";
  2447. iFrameDiv.style.zIndex="9001";
  2448. iFrameDiv.tabIndex="0";
  2449. iFrameDiv.setAttribute("role", "dialog");
  2450. document.body.appendChild(iFrameDiv);
  2451. // HEADER
  2452. var headerDiv = document.createElement("div");
  2453. headerDiv.id = "UI_MODAL_DIALOG_IFRAME_HEADER_DIV";
  2454. headerDiv.style.textAlign="right";
  2455. headerDiv.style.width = "100%";
  2456. headerDiv.style.paddingTop="3px";
  2457. headerDiv.style.paddingBottom="3px";
  2458. headerDiv.style.borderRight="solid 1px black";
  2459. headerDiv.style.borderLeft="solid 1px black";
  2460. headerDiv.style.borderTop="solid 1px black";
  2461. headerDiv.style.height="20px";
  2462. headerDiv.style.backgroundColor="#eeeeee";
  2463. cancelLink = document.createElement("a");
  2464. cancelLink.style.marginRight="3px";
  2465. cancelLink.href="javascript:ui_modal_dialog.close()";
  2466. var busyImg = document.createElement("img");
  2467. busyImg.id="UI_MODAL_DIALOG_IFRAME_HEADER_DIV_CLOSE";
  2468. busyImg.style.border="solid 1px #eeeeee";
  2469. busyImg.src = _F_Config.webContent + "/fragments/common/images/dialog_close.gif";
  2470. busyImg.border="0";
  2471. busyImg.align= "absmiddle";
  2472. _F_Document.addEventListener(busyImg,"mouseover", function(event) { document.getElementById("UI_MODAL_DIALOG_IFRAME_HEADER_DIV_CLOSE").style.border="solid 1px black";});
  2473. _F_Document.addEventListener(busyImg,"mouseout", function(event) { document.getElementById("UI_MODAL_DIALOG_IFRAME_HEADER_DIV_CLOSE").style.border="solid 1px #eeeeee";});
  2474. cancelLink.appendChild(busyImg);
  2475. headerDiv.appendChild(cancelLink);
  2476. iFrameDiv.appendChild(headerDiv);
  2477. // IFRAME
  2478. var iFrame = null;
  2479. if (xIE4Up) {
  2480. //Get around issue with posting to an iframe causing new window to be opened for IE in quirks mode
  2481. try {
  2482. iFrame = document.createElement('<iframe name="UI_MODAL_DIALOG_IFRAME"/>');
  2483. } catch (e) {
  2484. iFrame = null;
  2485. }
  2486. }
  2487. if (iFrame == null) {
  2488. iFrame = document.createElement("iframe");
  2489. }
  2490. iFrame.id = "UI_MODAL_DIALOG_IFRAME";
  2491. iFrame.name = "UI_MODAL_DIALOG_IFRAME";
  2492. iFrame.src = _F_Config.webContent + "/fragments/common/images/space.gif";
  2493. iFrame.style.width = "100%";
  2494. iFrame.style.height = "100%";
  2495. iFrame.style.zIndex="9000";
  2496. iFrame.style.backgroundColor="white";
  2497. iFrame.style.borderRight="solid 1px black";
  2498. iFrame.style.borderLeft="solid 1px black";
  2499. iFrame.style.borderBottom="solid 1px black";
  2500. iFrame.border ="0";
  2501. iFrame.style.margin="0px";
  2502. iFrame.fragClientWidth = document.body.clientWidth - 80;
  2503. iFrameDiv.appendChild(iFrame);
  2504. _F_Document.addEventListener(iFrame,"load", function(event) { ui_modal_dialog.loaded(event);});
  2505. _F_Document.addEventListener(window,"resize", function(event) { ui_modal_dialog.resize(event);});
  2506. //need to create a dummy element in here so that we can trap the last tab and move the focus back to the top of the dialog
  2507. var dummyEl2 = document.createElement("p");
  2508. dummyEl2.tabIndex = "-1";
  2509. dummyEl2.id="UI_MODAL_DIALOG_TABSTOP2";
  2510. dummyEl2.style.position="absolute";
  2511. iFrameDiv.appendChild(dummyEl2);
  2512. var dummyEl = document.createElement("p");
  2513. dummyEl.tabIndex = "0";
  2514. dummyEl.id="UI_MODAL_DIALOG_TABSTOP";
  2515. dummyEl.style.position="absolute";
  2516. xAddEventListener(dummyEl, "onfocus", this.cycleFocus);
  2517. iFrameDiv.appendChild(dummyEl);
  2518. //also need to make sure that you can't back tab out of the dialog
  2519. xAddEventListener(iFrameDiv, "keypress", this.cycleFocusBack);
  2520. }
  2521. //Show or hide the header.
  2522. var winHeader = document.getElementById("UI_MODAL_DIALOG_IFRAME_HEADER_DIV");
  2523. var content = null;
  2524. if (contentId != null) {
  2525. content = $(contentId);
  2526. winHeader.style.fontSize = xGetComputedStyle(content, "font-size");
  2527. }
  2528. if (modalHideHeader == true) {
  2529. //Display header
  2530. winHeader.style.display = "";
  2531. } else {
  2532. winHeader.style.display = "none";
  2533. }
  2534. // Blur page
  2535. pageBlurDiv.style.width = "100%";
  2536. pageBlurDiv.style.height = Math.max(document.body.scrollHeight, xClientHeight()) + "px";
  2537. pageBlurDiv.style.top = "0";
  2538. pageBlurDiv.style.left ="0";
  2539. pageBlurDiv.style.display = "";
  2540. pageBlurBacking.style.width = "100%";
  2541. pageBlurBacking.style.height = Math.max(document.body.scrollHeight, xClientHeight()) + "px";
  2542. pageBlurBacking.style.top = "0";
  2543. pageBlurBacking.style.left ="0";
  2544. pageBlurBacking.style.display = "";
  2545. // Show busy
  2546. var iFrameBusyDiv = document.getElementById("UI_MODAL_DIALOG_IFRAME_BUSY_DIV");
  2547. iFrameBusyDiv.style.top =((document.body.clientHeight - 80 )/ 2) + "px";
  2548. iFrameBusyDiv.style.left =((document.body.clientWidth - 80 )/ 2) + "px";
  2549. if (contentId != null) {
  2550. iFrameBusyDiv.style.fontSize = xGetComputedStyle(content, "font-size");
  2551. }
  2552. iFrameBusyDiv.style.display="";
  2553. // invoke url
  2554. var iFr = document.getElementById("UI_MODAL_DIALOG_IFRAME");
  2555. if (modalForceReload == true) {
  2556. //Add a timestamp to create a unique URL. This prevents the iFrame from using a cached version of the page.
  2557. url += (( url.indexOf('?') + 1 ) ? '&' : '?') + ( new Date() ).getTime();
  2558. }
  2559. if (usePost != null && usePost == true) {
  2560. this.postForm(url);
  2561. } else {
  2562. iFr.src = url;
  2563. }
  2564. };
  2565. ui_modal_dialog.cycleFocusBack = function(event) {
  2566. if (event.keyCode == 9 && event.shiftKey) {
  2567. document.getElementById("UI_MODAL_DIALOG_TABSTOP2").focus();
  2568. }
  2569. };
  2570. ui_modal_dialog.cycleFocus = function() {
  2571. document.getElementById("UI_MODAL_DIALOG_IFRAME_DIV").focus();
  2572. };
  2573. ui_modal_dialog.postForm = function(url) {
  2574. var formElement = document.createElement("form");
  2575. formElement.setAttribute("name","wsrp_rewrite_post_window_form");
  2576. formElement.setAttribute("method","POST");
  2577. formElement.setAttribute("target", "UI_MODAL_DIALOG_IFRAME");
  2578. var action =_F_config.gateway; //default
  2579. var qm_index = url.indexOf("?");
  2580. if (qm_index!=0) {
  2581. action = (qm_index==-1) ? url : url.substring(0, qm_index);
  2582. }
  2583. formElement.setAttribute("action", action);
  2584. if (qm_index != -1) {
  2585. var paramString = url.substring(qm_index+1);
  2586. var params = paramString.split("&");
  2587. var i;
  2588. for (i=0; i < params.length; ++i) {
  2589. if (params[i].length>0) {
  2590. var hiddenElement = document.createElement("input");
  2591. hiddenElement.setAttribute("type","hidden");
  2592. var eq_index = params[i].indexOf("=");
  2593. if (eq_index != -1) {
  2594. hiddenElement.setAttribute("name",unescape(params[i].substring(0,eq_index)));
  2595. hiddenElement.setAttribute("value",unescape(params[i].substring(eq_index+1)));
  2596. } else {
  2597. hiddenElement.setAttribute("name",unescape(params[i]));
  2598. hiddenElement.setAttribute("value","");
  2599. }
  2600. formElement.appendChild(hiddenElement);
  2601. }
  2602. }
  2603. }
  2604. document.body.appendChild(formElement);
  2605. formElement.submit();
  2606. document.body.removeChild(formElement);
  2607. formElement = null;
  2608. };
  2609. ui_modal_dialog.loaded = function(event) {
  2610. var pageBlurDiv = document.getElementById("UI_MODAL_DIALOG_PAGE_BLUR");
  2611. var pageBlurBacking = document.getElementById("UI_MODAL_DIALOG_PAGE_BLUR_BACKING");
  2612. var iFrameBusy = document.getElementById("UI_MODAL_DIALOG_IFRAME_BUSY_DIV");
  2613. var iFrameDiv = document.getElementById("UI_MODAL_DIALOG_IFRAME_DIV");
  2614. var iFrame = document.getElementById("UI_MODAL_DIALOG_IFRAME");
  2615. var dummyEl = document.getElementById("UI_MODAL_DIALOG_TABSTOP");
  2616. var dummyEl2 = document.getElementById("UI_MODAL_DIALOG_TABSTOP2");
  2617. if (iFrameDiv.style.display == "none" && iFrameBusy.style.display == "" && UI_MODAL_DIALOG_VISIBLE_DIALOG) {
  2618. iFrameBusy.style.display="none";
  2619. iFrameDiv.style.width = (xClientWidth() - 80) + "px";
  2620. iFrameDiv.style.height = (xClientHeight() - 80) + "px";
  2621. iFrameDiv.style.top = 30+ getScrollPosY(document.body) + "px";
  2622. iFrameDiv.style.left = "30px";
  2623. dummyEl.style.top = 30+ getScrollPosY(document.body) + 4 + "px";
  2624. dummyEl.style.left = "30px";
  2625. dummyEl2.style.top = 30+ getScrollPosY(document.body) + 4 + "px";
  2626. dummyEl2.style.left = "30px";
  2627. iFrameDiv.style.display = "";
  2628. iFrameDiv.focus();
  2629. return;
  2630. }
  2631. else if ((xIE4Up) && (UI_MODAL_DIALOG_VISIBLE_DIALOG))
  2632. {
  2633. //if the page in the modal dialog is reloaded need to reset the width
  2634. //for ie (it sometimes makes it a little teenie bit too small)
  2635. iFrameBusy.style.display="none";
  2636. iFrameDiv.style.padding = "1px";
  2637. iFrameDiv.style.width = (xClientWidth() - 80) + "px";
  2638. iFrameDiv.style.display = "";
  2639. iFrameDiv.focus();
  2640. return;
  2641. }
  2642. };
  2643. ui_modal_dialog.resize = function(event) {
  2644. var iFrameDiv = document.getElementById("UI_MODAL_DIALOG_IFRAME_DIV");
  2645. var iFrame = document.getElementById("UI_MODAL_DIALOG_IFRAME");
  2646. var dummyEl = document.getElementById("UI_MODAL_DIALOG_TABSTOP");
  2647. var dummyEl2 = document.getElementById("UI_MODAL_DIALOG_TABSTOP");
  2648. if ( (!xIE4Up) && UI_MODAL_DIALOG_VISIBLE_DIALOG)
  2649. {
  2650. iFrameDiv.style.width = (xClientWidth() - 80) + "px";
  2651. iFrameDiv.style.height = (xClientHeight() - 80) + "px";
  2652. iFrameDiv.style.top = 30+ getScrollPosY(document.body) + "px";
  2653. iFrameDiv.style.left = "30px";
  2654. dummyEl.style.top = 30+ getScrollPosY(document.body) + 4 + "px";
  2655. dummyEl.style.left = "30px";
  2656. dummyEl2.style.top = 30+ getScrollPosY(document.body) + 4 + "px";
  2657. dummyEl2.style.left = "30px";
  2658. iFrameDiv.style.display = "";
  2659. iFrameDiv.focus();
  2660. return;
  2661. }
  2662. else if ((xIE4Up) && (UI_MODAL_DIALOG_VISIBLE_DIALOG))
  2663. {
  2664. //if the page in the modal dialog is reloaded need to reset the width
  2665. //for ie (it sometimes makes it a little teenie bit too small)
  2666. iFrameDiv.style.padding = "1px";
  2667. iFrameDiv.style.width = (xClientWidth() - 80) + "px";
  2668. iFrameDiv.style.height = (xClientHeight() - 80) + "px";
  2669. dummyEl.style.top = 30+ getScrollPosY(document.body) + 4 + "px";
  2670. dummyEl.style.left = "30px";
  2671. iFrameDiv.style.display = "";
  2672. iFrameDiv.focus();
  2673. return;
  2674. }
  2675. };
  2676. ui_modal_dialog.close = function() {
  2677. UI_MODAL_DIALOG_VISIBLE_DIALOG = false; //Reset the visibility flag
  2678. var pageBlurDiv = document.getElementById("UI_MODAL_DIALOG_PAGE_BLUR");
  2679. var pageBlurBacking = document.getElementById("UI_MODAL_DIALOG_PAGE_BLUR_BACKING");
  2680. var iFrameBusy = document.getElementById("UI_MODAL_DIALOG_IFRAME_BUSY_DIV");
  2681. var iFrameDiv = document.getElementById("UI_MODAL_DIALOG_IFRAME_DIV");
  2682. pageBlurDiv.style.display="none";
  2683. pageBlurBacking.style.display="none";
  2684. iFrameDiv.style.display="none";
  2685. iFrameBusy.style.display = "none";
  2686. var currentElement = document.activeElement;
  2687. if (!ui_isTabNavigable(currentElement)) {
  2688. if (UI_MODAL_DIALOG_TRIGGER_ELEMENT != null) {
  2689. UI_MODAL_DIALOG_TRIGGER_ELEMENT.focus();
  2690. }
  2691. }
  2692. };
  2693. /**
  2694. * getAbsolutePosX
  2695. * @param e
  2696. */
  2697. function getAbsolutePosX(e) {
  2698. var xx=0 + e.offsetLeft;
  2699. var p=e.offsetParent;
  2700. while(p!=null) {
  2701. xx+=(0 + p.offsetLeft);
  2702. p=p.offsetParent;
  2703. }
  2704. return xx;
  2705. }
  2706. /**
  2707. * getScrollPosX
  2708. * @param e
  2709. */
  2710. function getScrollPosX(e) {
  2711. var xx = 0;
  2712. var p=e;
  2713. do {
  2714. xx += p.scrollLeft || 0;
  2715. p = p.parentNode;
  2716. } while (p!=null);
  2717. return xx;
  2718. }
  2719. /**
  2720. * getBodyScrollPosX
  2721. *
  2722. */
  2723. function getBodyScrollPosX() {
  2724. return document.body.scrollLeft;
  2725. }
  2726. /**
  2727. * getAbsolutePosY
  2728. * @param e
  2729. */
  2730. function getAbsolutePosY(e) {
  2731. var yy=0 + e.offsetTop;
  2732. var p=e.offsetParent;
  2733. while(p!=null) {
  2734. yy+=(0 + p.offsetTop);
  2735. p=p.offsetParent;
  2736. }
  2737. return yy;
  2738. }
  2739. /**
  2740. * getScrollPosY
  2741. * @param e
  2742. */
  2743. function getScrollPosY(e) {
  2744. var yy = 0;
  2745. var p=e;
  2746. do {
  2747. yy += p.scrollTop || 0;
  2748. p = p.parentNode;
  2749. } while (p!=null);
  2750. return yy;
  2751. }
  2752. /**
  2753. * getBodyScrollPosY
  2754. *
  2755. */
  2756. function getBodyScrollPosY() {
  2757. return document.body.scrollTop;
  2758. }
  2759. /**
  2760. * EventUtils
  2761. * @deprecated - use xAddEventListener
  2762. */
  2763. function EventUtils() {
  2764. throw 'RuntimeException: EventUtils is a static utility class and may not be instantiated';
  2765. }
  2766. /**
  2767. * addEventListener
  2768. * @param target
  2769. * @param type
  2770. * @param callback
  2771. * @param captures
  2772. * @deprecated - use xAddEventListener instead.
  2773. */
  2774. EventUtils.addEventListener = function (target, type, callback, capture) {
  2775. _F_Document.addEventListener(target, type, callback, capture);
  2776. };
  2777. /**
  2778. * @deprecated: use _F_Document.associate()
  2779. */
  2780. EventUtils.associate = function (target, obj, methodName) {
  2781. return function(e) {
  2782. e = e||window.event;
  2783. return obj[methodName](e, target);
  2784. };
  2785. };
  2786. /**
  2787. * ui_init - must be called on load of the page
  2788. */
  2789. function ui_init() {
  2790. _F_Document.addEventListener(window, "resize", ui_onresize, true);
  2791. fragment.prototype.onerror = function(msg, details, code) {
  2792. if (this.error===undefined) {
  2793. this.error = new ui_error(this.id, this.div);
  2794. }
  2795. this.error.setCode(code);
  2796. this.error.setMessage(msg);
  2797. this.error.setDetails(details);
  2798. this.error.show();
  2799. };
  2800. fragment.prototype.clearerror = function() {
  2801. if (this.error != null) {
  2802. this.error.hide();
  2803. }
  2804. };
  2805. if (window.pageInit) {
  2806. pageInit();
  2807. }
  2808. ui_templates.preload();
  2809. }
  2810. /**
  2811. * ui_onresize - handle the resizing event
  2812. */
  2813. function ui_onresize(evt) {
  2814. ui_menuHideHook(evt);
  2815. var locker = ui_locker.get();
  2816. if (locker.isVisible()) {
  2817. locker.onresize();
  2818. }
  2819. }
  2820. /**
  2821. * ui_calcAvailableHeight - calculate how much height an HTML element can take
  2822. * to maximize itself.
  2823. * @param e the HTML DOM element
  2824. */
  2825. function ui_calcAvailableHeight(e,p,n) {
  2826. var y = 0,
  2827. ey;
  2828. var l = e;
  2829. var ly = xHeight(l);
  2830. while (e) {
  2831. if (xDef(e.offsetHeight)) {
  2832. ey = xHeight(e);
  2833. y += (ey - ly);
  2834. ly = ey;
  2835. } else {
  2836. ly = 0;
  2837. }
  2838. l = e;
  2839. e = xParent(e, n);
  2840. if (e != null && e === p) {
  2841. if (document.body === p) {
  2842. y += xOffsetTop(l);
  2843. }
  2844. e = l = null;
  2845. }
  2846. }
  2847. y += xOffsetTop(l);
  2848. return y;
  2849. }
  2850. /**
  2851. * ui_calcMaximumHeight - calculates the height such that it takes up all browser height starting at 'e'
  2852. */
  2853. function ui_calcMaximumHeight(e, p, n) {
  2854. var y = 0;
  2855. while (e) {
  2856. y += xOffsetTop(e);
  2857. e = e.offsetParent;
  2858. if (e == p) {
  2859. break;
  2860. }
  2861. }
  2862. return xClientHeight() - y;
  2863. }
  2864. /**
  2865. * readjustParentHeight - readjusts the height of the parents to elinimate scrollbars
  2866. */
  2867. function readjustParentHeight(thisnodeid) {
  2868. var t = document.getElementById(thisnodeid);
  2869. while (t) {
  2870. var parent = t.parentNode;
  2871. if (parent) {
  2872. if (parent.className == "cogstyle-htabs-page-content-fixed" || parent.className == "cogstyle-vtabs-page-content-fixed") {
  2873. parent.style.height = "100%";
  2874. }
  2875. }
  2876. t = parent;
  2877. }
  2878. }
  2879. /**
  2880. * ui_calcAvailableWidth - calculate how much width an HTML element can take
  2881. * to maximize itself.
  2882. * @param e the HTML DOM element
  2883. */
  2884. function ui_calcAvailableWidth(e,p,n) {
  2885. var x = 0, ex;
  2886. var l = e;
  2887. var lx = xWidth(l);
  2888. while (e) {
  2889. if (xDef(e.offsetWidth)) {
  2890. ex = xWidth(e);
  2891. x += (ex - lx);
  2892. lx = ex;
  2893. } else {
  2894. lx = 0;
  2895. }
  2896. l = e;
  2897. e = xParent(e,n);
  2898. if (e != null && e === p) {
  2899. e = l = null;
  2900. }
  2901. }
  2902. x += xOffsetLeft(l);
  2903. return x;
  2904. }
  2905. // FIXME! Delete this
  2906. function noop() {
  2907. }
  2908. function handleLogon(href, frag) {
  2909. if (frag.mode == "edit") {
  2910. alert(PFM.JS.IDS_JS_TIMEOUT_SETTINGS_LOST);
  2911. }
  2912. var href = window.location.href;
  2913. var params = href.split("CAMNamespace=");
  2914. if (params.length > 1) {
  2915. var CAMNamespaceValue;
  2916. var index = params[1].indexOf("&");
  2917. if (index != -1) {
  2918. CAMNamespaceValue = params[1].substring(0, index);
  2919. } else {
  2920. CAMNamespaceValue = params[1];
  2921. }
  2922. window.location.href = _F_Config.gateway + "?CAMNamespace=" + CAMNamespaceValue + "&b_action=xts.run&m=portal/main.xts&m_reload=&m_redirect=" + encodeURIComponent(href);
  2923. } else {
  2924. window.location.href = _F_Config.gateway + "?b_action=xts.run&m=portal/main.xts&m_reload=&m_redirect=" + encodeURIComponent(href);
  2925. }
  2926. }
  2927. /**
  2928. * ui_throbbers
  2929. * @param id
  2930. */
  2931. function ui_throbbers(id, imgSrc) {
  2932. this.id = id;
  2933. this.throbberURI = imgSrc;
  2934. // preload image
  2935. new Image().src = imgSrc;
  2936. }
  2937. ui_throbbers.prototype = {
  2938. map: {},
  2939. getTabFragment: function(frag) {
  2940. while (frag && frag.parent.id != this.id) {
  2941. frag = frag.parent;
  2942. }
  2943. return frag;
  2944. },
  2945. throb: function(id, bStart) {
  2946. var img = $(id);
  2947. if (img) {
  2948. var item = this.map[id];
  2949. if (bStart) {
  2950. if (item && item.count > 0) {
  2951. item.count++;
  2952. } else {
  2953. this.map[id] =
  2954. {
  2955. count: 1,
  2956. src: img.src
  2957. };
  2958. img.src = this.throbberURI;
  2959. }
  2960. } else {
  2961. if (item && item.count > 0) {
  2962. item.count--;
  2963. if (item.count == 0) {
  2964. img.src = item.src;
  2965. delete this.map[id];
  2966. }
  2967. }
  2968. }
  2969. if (img.getAttribute("parent")) {
  2970. this.throb(img.getAttribute("parent"), bStart);
  2971. }
  2972. }
  2973. },
  2974. reset: function() {
  2975. for (var id in this.map) {
  2976. var item = this.map[id];
  2977. if (item) {
  2978. if (item.count > 0) {
  2979. var img = $(id);
  2980. if (img) {
  2981. img.src = item.src;
  2982. }
  2983. delete this.map[id];
  2984. }
  2985. }
  2986. }
  2987. },
  2988. handler: function(evt) {
  2989. var frag = this.getTabFragment(evt.target);
  2990. if (frag) {
  2991. this.throb(frag.id + "_throbber", evt.name == "fragment.retrieve.before");
  2992. }
  2993. }
  2994. };
  2995. // Helper methods used to determine the viewer height when displaying various Objects
  2996. var ui_resizeHelper = {
  2997. // Set a default height when the content uses an iframe with 100% height
  2998. adjustHeightForFragmentContent: function(fragment, container, objectType, height) {
  2999. if (container) {
  3000. if (ui_resizeHelper.isIFrameBasedContent(objectType)) {
  3001. var frame = ui_resizeHelper.getFirstVisibleIFrame(container);
  3002. if (frame && (frame.height == "100%" || frame.style.height == "100%")) {
  3003. var heightInPX = "365px";
  3004. if (height > 0)
  3005. {
  3006. heightInPX = height + "px";
  3007. }
  3008. window.setTimeout(function() {
  3009. container.originalHeight = container.style.height;
  3010. container.style.height = heightInPX;
  3011. }, 1);
  3012. return;
  3013. }
  3014. }
  3015. // Make sure to restore the original height, if any, when no resizing is required.
  3016. if (container.originalHeight !== undefined){
  3017. container.style.height = container.originalHeight ;
  3018. delete container.originalHeight;
  3019. }
  3020. }
  3021. },
  3022. //Returns the first visible iframe
  3023. getFirstVisibleIFrame: function(container) {
  3024. var frame = null;
  3025. if (container) {
  3026. var nodeList = container.getElementsByTagName("iframe");
  3027. for (var i = 0; i < nodeList.length; i++) {
  3028. if (nodeList[i].style.display != "none") {
  3029. frame = nodeList[i];
  3030. break;
  3031. }
  3032. }
  3033. }
  3034. return frame;
  3035. },
  3036. // Check if the type of the object that is being viewed might return an iframe based content.\
  3037. isIFrameBasedContent: function(type) {
  3038. var iFrameBasedContent = ['query', 'analysis', 'report', 'reportView', 'output', 'powerPlayReport', 'powerPlay8Report', 'powerPlay8ReportView', 'powerPlayCube', 'document', 'documentContent', 'URL', 'dashboard'];
  3039. return (_F_Array.indexOf(iFrameBasedContent, type) != -1);
  3040. }
  3041. };
  3042. /**
  3043. * ui_getNavigableElements - return an ordererd list of child tab stops for a given parent element
  3044. * @param containerElement
  3045. * @returns array of ordered tabstops
  3046. */
  3047. function ui_getNavigableElements(containerElement) {
  3048. var tabStops = [];
  3049. if (window.dojo) {
  3050. var zeroTabStops = [];
  3051. dojo.query("*", containerElement).forEach( function(ele) {
  3052. if (ui_isTabNavigable(ele)) {
  3053. if (ele.tabIndex == 0) {
  3054. zeroTabStops[zeroTabStops.length] = ele;
  3055. } else {
  3056. tabStops[tabStops.length] = ele;
  3057. }
  3058. }
  3059. });
  3060. tabStops.sort(function(obj1, obj2) {
  3061. return obj1.tabIndex - obj2.tabIndex;
  3062. });
  3063. tabStops = tabStops.concat(zeroTabStops);
  3064. }
  3065. return tabStops;
  3066. }
  3067. /**
  3068. * ui_setFocus - set focus to the 1st focusable child tab stop for a given parent element
  3069. * @param containerElement
  3070. * @returns element with focus or null
  3071. */
  3072. function ui_setFocus(containerElement) {
  3073. var tabStops = ui_getNavigableElements(containerElement);
  3074. for (var i=0; i < tabStops.length;i++) {
  3075. tabStops[i].focus();
  3076. if (document.activeElement == tabStops[i]) {
  3077. return tabStops[i];
  3078. }
  3079. }
  3080. return null;
  3081. }
  3082. function ui_isTabNavigable(ele) {
  3083. if (ele) {
  3084. try {
  3085. return (dijit.isTabNavigable(ele) && (!ele.disabled));
  3086. } catch (e) {
  3087. return false;
  3088. }
  3089. }
  3090. return false;
  3091. }