cvui.js 128 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| IBM Cognos Products: Viewer
  5. *| (C) Copyright IBM Corp. 2001, 2020
  6. *|
  7. *| US Government Users Restricted Rights - Use, duplication or
  8. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. *|
  10. *+------------------------------------------------------------------------+
  11. */
  12. /*-----------------------------------------------------------------------------------------------------
  13. Class : CStyle
  14. Description :
  15. -----------------------------------------------------------------------------------------------------*/
  16. function CUIStyle(normal, rollover, depressed, depressed_rollover, disabled) {
  17. this.m_active = normal;
  18. this.m_normal = normal;
  19. this.m_rollover = rollover;
  20. this.m_activeRollover = rollover;
  21. this.m_depressed = depressed;
  22. this.m_depressed_rollover = depressed_rollover;
  23. this.m_disabled = disabled;
  24. }
  25. function CUIStyle_getActiveState() {
  26. return this.m_active;
  27. }
  28. function CUIStyle_setActiveState(state) {
  29. switch(state) {
  30. case "normal":
  31. this.m_active = this.m_normal;
  32. break;
  33. case "depressed":
  34. this.m_active = this.m_depressed;
  35. break;
  36. case "disabled":
  37. this.m_active = this.m_disabled;
  38. break;
  39. default:
  40. this.m_active = this.m_normal;
  41. }
  42. }
  43. function CUIStyle_getActiveRolloverState() {
  44. return this.m_activeRollover;
  45. }
  46. function CUIStyle_setActiveRolloverState(state) {
  47. switch(state) {
  48. case "normal":
  49. this.m_activeRollover = this.m_rollover;
  50. break;
  51. case "depressed":
  52. this.m_activeRollover = this.m_depressed_rollover;
  53. break;
  54. case "disabled":
  55. this.m_activeRollover = this.m_disabled;
  56. break;
  57. default:
  58. this.m_activeRollover = this.m_rollover;
  59. }
  60. }
  61. function CUIStyle_getNormalState() {
  62. return this.m_normal;
  63. }
  64. function CUIStyle_getRolloverState() {
  65. return this.m_rollover;
  66. }
  67. function CUIStyle_getDepressedState() {
  68. return this.m_depressed;
  69. }
  70. function CUIStyle_getDepressedRolloverState() {
  71. return this.m_depressed_rollover;
  72. }
  73. function CUIStyle_getDisabledState() {
  74. return this.m_disabled;
  75. }
  76. function CUIStyle_setNormalState(state) {
  77. this.m_normal = state;
  78. }
  79. function CUIStyle_setRolloverState(state) {
  80. this.m_rollover = state;
  81. }
  82. function CUIStyle_setDepressedState(state) {
  83. this.m_depressed = state;
  84. }
  85. function CUIStyle_setDepressedRolloverState(state) {
  86. this.m_depressed_rollover = state;
  87. }
  88. function CUIStyle_setDisabledState(state) {
  89. this.m_disabled = state;
  90. }
  91. CUIStyle.prototype.getNormalState = CUIStyle_getNormalState;
  92. CUIStyle.prototype.getRolloverState = CUIStyle_getRolloverState;
  93. CUIStyle.prototype.getDepressedState = CUIStyle_getDepressedState;
  94. CUIStyle.prototype.getDepressedRolloverState = CUIStyle_getDepressedRolloverState;
  95. CUIStyle.prototype.getDisabledState = CUIStyle_getDisabledState;
  96. CUIStyle.prototype.setNormalState = CUIStyle_setNormalState;
  97. CUIStyle.prototype.setRolloverState = CUIStyle_setRolloverState;
  98. CUIStyle.prototype.setDepressedState = CUIStyle_setDepressedState;
  99. CUIStyle.prototype.setDepressedRolloverState = CUIStyle_setDepressedRolloverState;
  100. CUIStyle.prototype.setDisabledState = CUIStyle_setDisabledState;
  101. CUIStyle.prototype.setActiveState = CUIStyle_setActiveState;
  102. CUIStyle.prototype.getActiveState = CUIStyle_getActiveState;
  103. CUIStyle.prototype.getActiveRolloverState = CUIStyle_getActiveRolloverState;
  104. CUIStyle.prototype.setActiveRolloverState = CUIStyle_setActiveRolloverState;
  105. // Copyright (C) 2008 Cognos Incorporated. All rights reserved.
  106. // Cognos (R) is a trademark of Cognos Incorporated.
  107. /*-----------------------------------------------------------------------------------------------------
  108. Class : CToolbarSelect
  109. Description :
  110. -----------------------------------------------------------------------------------------------------*/
  111. function CToolbarSelect(parent, name, command, label, toolTip) {
  112. this.m_parent = parent;
  113. this.m_name = name;
  114. this.m_command = command;
  115. this.m_label = label;
  116. this.m_toolTip = toolTip;
  117. this.m_items = [];
  118. if(typeof this.m_parent == "object" && typeof this.m_parent.add == "function")
  119. {
  120. this.m_parent.add(this);
  121. }
  122. //add a defalt item
  123. if (label)
  124. {
  125. this.add("", label);
  126. }
  127. }
  128. function CToolbarSelect_draw() {
  129. var html = '<select id="' + this.m_name + '" name="' + this.m_name + '" onchange="' + this.m_command + '"';
  130. if (this.m_toolTip != "") {
  131. html += ' title="' + this.m_toolTip + '"';
  132. }
  133. html += '>';
  134. html += this.drawItems();
  135. html += '</select>';
  136. return html;
  137. }
  138. function CToolbarSelect_drawItems()
  139. {
  140. var html="";
  141. for (var i=0; i<this.m_items.length; i++)
  142. {
  143. html += '<option value="'+ this.m_items[i].getUse() +'">'+ this.m_items[i].getDisplay() +'</option>';
  144. }
  145. return html;
  146. }
  147. function CToolbarSelect_add(sUse, sDisplay)
  148. {
  149. var newItem = new CSelectItem(sUse, sDisplay);
  150. this.m_items = this.m_items.concat(newItem);
  151. }
  152. function CToolbarSelect_isVisible() {
  153. //return this.m_bVisible;
  154. return true;
  155. }
  156. CToolbarSelect.prototype.draw = CToolbarSelect_draw;
  157. CToolbarSelect.prototype.drawItems = CToolbarSelect_drawItems;
  158. CToolbarSelect.prototype.isVisible = CToolbarSelect_isVisible;
  159. CToolbarSelect.prototype.add = CToolbarSelect_add;
  160. function CSelectItem (sUse, sDisplay)
  161. {
  162. this.m_sUse = sUse;
  163. this.m_sDisplay = sDisplay;
  164. }
  165. function CSelectItem_getUse()
  166. {
  167. return this.m_sUse;
  168. }
  169. function CSelectItem_getDisplay()
  170. {
  171. return this.m_sDisplay;
  172. }
  173. CSelectItem.prototype.getUse = CSelectItem_getUse;
  174. CSelectItem.prototype.getDisplay = CSelectItem_getDisplay;
  175. // Copyright (C) 2008 Cognos Incorporated. All rights reserved.
  176. // Cognos (R) is a trademark of Cognos Incorporated.
  177. /*-----------------------------------------------------------------------------------------------------
  178. Class : CToolbarPicker
  179. Description : Toolbar Button wrapper for the CColorPicker and CAlignmentPicker prompt controls
  180. -----------------------------------------------------------------------------------------------------*/
  181. function CToolbarPicker(parent, sCommand, sPromptId, sRef, sType) {
  182. this.m_parent = parent;
  183. this.m_command = sCommand;
  184. this.m_oPicker = null;
  185. this.m_sPromptId = sPromptId;
  186. this.m_sRef = sRef;
  187. this.m_sType = sType;
  188. if(typeof this.m_parent == "object" && typeof this.m_parent.add == "function")
  189. {
  190. this.m_parent.add(this);
  191. }
  192. }
  193. function CToolbarPicker_draw() {
  194. var html = '<div id="' + this.m_sType + this.m_sPromptId + '" onclick="' + this.m_sRef + '.preventBubbling(event);"></div>';
  195. return html;
  196. }
  197. function CToolbarPicker_init()
  198. {
  199. this.m_oPicker = eval (this.m_command);
  200. g_pickerObservers = g_pickerObservers.concat(this.m_sRef);
  201. }
  202. function CToolbarPicker_isVisible() {
  203. //return this.m_bVisible;
  204. return true;
  205. }
  206. function CToolbarPicker_togglePicker()
  207. {
  208. this.m_oPicker.togglePicker();
  209. }
  210. function CToolbarPicker_setActiveColor(s)
  211. {
  212. this.m_oPicker.setActiveColor(s);
  213. }
  214. function CToolbarPicker_setColor(s)
  215. {
  216. this.m_oPicker.setColor(s);
  217. }
  218. function CToolbarPicker_setAlignment(s)
  219. {
  220. this.m_oPicker.setAlignment(s);
  221. }
  222. function CToolbarPicker_setActiveAlignment(s)
  223. {
  224. this.m_oPicker.setActiveAlignment(s);
  225. }
  226. function CToolbarPicker_setPalette(s)
  227. {
  228. this.m_oPicker.setPalette(s);
  229. }
  230. function CToolbarPicker_applyCustomStyle()
  231. {
  232. this.m_oPicker.applyCustomStyle();
  233. }
  234. function CToolbarPicker_updateCustomStyle()
  235. {
  236. this.m_oPicker.updateCustomStyle();
  237. }
  238. function CToolbarPicker_hide()
  239. {
  240. this.m_oPicker.hide();
  241. }
  242. function CToolbarPicker_preventBubbling(e)
  243. {
  244. this.m_oPicker.preventBubbling(e);
  245. }
  246. function CToolbarPicker_buttonMouseHandler(button, action)
  247. {
  248. this.m_oPicker.buttonMouseHandler(button, action);
  249. }
  250. CToolbarPicker.prototype.draw = CToolbarPicker_draw;
  251. CToolbarPicker.prototype.isVisible = CToolbarPicker_isVisible;
  252. CToolbarPicker.prototype.init = CToolbarPicker_init;
  253. CToolbarPicker.prototype.togglePicker = CToolbarPicker_togglePicker;
  254. CToolbarPicker.prototype.setColor = CToolbarPicker_setColor;
  255. CToolbarPicker.prototype.setAlignment = CToolbarPicker_setAlignment;
  256. CToolbarPicker.prototype.setActiveAlignment = CToolbarPicker_setActiveAlignment;
  257. CToolbarPicker.prototype.setActiveColor = CToolbarPicker_setActiveColor;
  258. CToolbarPicker.prototype.setPalette = CToolbarPicker_setPalette;
  259. CToolbarPicker.prototype.applyCustomStyle = CToolbarPicker_applyCustomStyle;
  260. CToolbarPicker.prototype.updateCustomStyle = CToolbarPicker_updateCustomStyle;
  261. CToolbarPicker.prototype.hide = CToolbarPicker_hide;
  262. CToolbarPicker.prototype.preventBubbling = CToolbarPicker_preventBubbling;
  263. CToolbarPicker.prototype.buttonMouseHandler = CToolbarPicker_buttonMouseHandler;
  264. // Copyright (C) 2008 Cognos Incorporated. All rights reserved.
  265. // Cognos (R) is a trademark of Cognos Incorporated.
  266. /*-----------------------------------------------------------------------------------------------------
  267. Class : CToolbarButton
  268. Description :
  269. -----------------------------------------------------------------------------------------------------*/
  270. var tbUniqueId = 0;
  271. function makeId() {
  272. return tbUniqueId++;
  273. }
  274. gDropDownButtonStyle = new CUIStyle('dropDownArrow','dropDownArrowOver',"","","");
  275. gHeaderDropDownButtonStyle = new CUIStyle('bannerDropDownArrow','bannerDropDownArrowOver',"","","");
  276. function CToolbarButton(parent, action, iconPath, toolTip, style, bHideDropDown, label, dropDownToolTip, webContentRoot) {
  277. this.m_id = 'tbbutton'+makeId();
  278. this.m_bVisible = true;
  279. this.m_action = action;
  280. this.m_toolTip = toolTip;
  281. if (typeof webContentRoot != "undefined" && webContentRoot != "")
  282. {
  283. this.m_webContentRoot = webContentRoot;
  284. }
  285. else
  286. {
  287. this.m_webContentRoot = "..";
  288. }
  289. this.m_icon = (iconPath) ? new CIcon(iconPath, toolTip, this.webContentRoot) : null;
  290. this.m_parent = parent;
  291. this.m_menu = null;
  292. if (typeof bHideDropDown == "boolean") {
  293. this.m_bHideDropDown = bHideDropDown;
  294. }
  295. else {
  296. this.m_bHideDropDown = false;
  297. }
  298. this.m_style = new CUIStyle(style.getNormalState(),style.getRolloverState(),style.getDepressedState(),style.getDepressedRolloverState(),style.getDisabledState());
  299. this.m_observers = new CObserver(this);
  300. if(typeof this.m_parent == "object" && typeof this.m_parent.add == "function") {
  301. this.m_parent.add(this);
  302. }
  303. this.m_label = (label) ? label : null;
  304. this.m_dropDownToolTip = (dropDownToolTip) ? dropDownToolTip : this.m_toolTip;
  305. this.m_dropDownStyle = gDropDownButtonStyle;
  306. }
  307. function CToolbarButton_getId() {
  308. return this.m_id;
  309. }
  310. function CToolbarButton_draw() {
  311. var html="";
  312. html += '<div style="margin-right:3px;"><button type="button" id="';
  313. html += this.m_id;
  314. html += '"';
  315. if(typeof this.getStyle() == "object")
  316. {
  317. html += ' class="' + this.getStyle().getActiveState() + '"';
  318. if (this.getStyle().getActiveState() != this.getStyle().getDisabledState())
  319. {
  320. if (this.isEnabled())
  321. {
  322. html += ' tabIndex="1"';
  323. }
  324. html += ' hideFocus="true"';
  325. }
  326. }
  327. if (this.m_toolTip != "")
  328. {
  329. html += ' title="' + this.m_toolTip + '"';
  330. }
  331. html += '>';
  332. if (this.m_icon != null)
  333. {
  334. html += this.m_icon.draw();
  335. }
  336. if (this.m_label != null)
  337. {
  338. html += this.m_label;
  339. }
  340. html += '</button>';
  341. if(this.m_menu != null && !this.m_bHideDropDown)
  342. {
  343. html += '<button type="button" id="';
  344. html += ('menu' + this.getId());
  345. html += '"';
  346. if(typeof this.getStyle() == "object")
  347. {
  348. html += ' class="'+this.getDropDownStyle().getActiveState() + '"';
  349. if (this.getStyle().getActiveState() != this.getStyle().getDisabledState())
  350. {
  351. if (this.isEnabled())
  352. {
  353. html += ' tabIndex="1"';
  354. }
  355. html += ' hideFocus="true"';
  356. }
  357. }
  358. if (this.m_dropDownToolTip != "")
  359. {
  360. html += ' title="' + this.m_dropDownToolTip + '"';
  361. }
  362. html += '><img style="vertical-align:middle;" border="0" src="' + this.m_webContentRoot + '/common/images/toolbar_drop_arrow.gif"';
  363. if (this.m_dropDownToolTip != "")
  364. {
  365. html += ' alt="' + this.m_dropDownToolTip + '"';
  366. html += ' title="' + this.m_dropDownToolTip + '"';
  367. }
  368. else
  369. {
  370. html += ' alt=""';
  371. }
  372. html += ' width="7" height="16"/></button>';
  373. }
  374. html += '</div>';
  375. return html;
  376. }
  377. function CToolbarButton_attachEvents() {
  378. if(typeof this.getParent().getHTMLContainer != "function") {
  379. return; // this method must be implemented by the parent
  380. }
  381. var htmlContainer = this.getParent().getHTMLContainer();
  382. if(htmlContainer == null) {
  383. return;
  384. }
  385. var hTbItem = eval(htmlContainer.document ? htmlContainer.document.getElementById(this.m_id) : htmlContainer.ownerDocument.getElementById(this.m_id));
  386. if(hTbItem == null) {
  387. return; // just to be safe
  388. }
  389. hTbItem.onmouseover = this.onmouseover;
  390. hTbItem.onmouseout = this.onmouseout;
  391. hTbItem.onclick = this.onclick;
  392. hTbItem.onkeypress = this.onkeypress;
  393. hTbItem.onfocus = this.onfocus;
  394. hTbItem.onblur = this.onblur;
  395. hTbItem.tbItem = eval(this);
  396. // attach the drop down arrow event handlers to the toolbar button as well
  397. if(this.m_menu != null && !this.m_bHideDropDown)
  398. {
  399. var hmenu = eval(htmlContainer.document ? htmlContainer.document.getElementById('menu'+this.getId()) : htmlContainer.ownerDocument.getElementById('menu'+this.getId()));
  400. hmenu.onmouseover = this.onmouseover;
  401. hmenu.onmouseout = this.onmouseout;
  402. hmenu.onclick = this.onclick;
  403. hmenu.onkeypress = this.onkeypress;
  404. hmenu.onfocus = this.onfocus;
  405. hmenu.onblur = this.onblur;
  406. hmenu.tbItem = eval(this);
  407. }
  408. }
  409. function CToolbarButton_createDropDownMenu(menuStyle, dropDownToolTip) {
  410. this.m_dropDownToolTip = (dropDownToolTip) ? dropDownToolTip : this.m_toolTip;
  411. this.m_menu = new CMenu('dropDown'+this.getId(),menuStyle, this.m_webContentRoot);
  412. this.m_menu.setParent(this);
  413. return this.m_menu;
  414. }
  415. function CToolbarButton_addOwnerDrawControl(control) {
  416. this.m_menu = control;
  417. if(typeof control.setParent != "undefined") {
  418. this.m_menu.setParent(this);
  419. }
  420. }
  421. function CToolbarButton_getParent() {
  422. return this.m_parent;
  423. }
  424. function CToolbarButton_setParent(parent) {
  425. this.m_parent = parent;
  426. }
  427. function CToolbarButton_getAction() {
  428. return this.m_action;
  429. }
  430. function CToolbarButton_setAction(action) {
  431. this.m_action = action;
  432. }
  433. function CToolbarButton_getToolTip() {
  434. return this.m_toolTip;
  435. }
  436. function CToolbarButton_setToolTip(tooltip) {
  437. this.m_toolTip = tooltip;
  438. }
  439. function CToolbarButton_getDropDownToolTip() {
  440. return this.m_dropDownToolTip;
  441. }
  442. function CToolbarButton_setDropDownToolTip(tooltip) {
  443. this.m_dropDownToolTip = tooltip;
  444. }
  445. function CToolbarButton_getIcon() {
  446. return this.m_icon;
  447. }
  448. function CToolbarButton_setIcon(iconPath) {
  449. this.m_icon.setPath(iconPath);
  450. }
  451. function CToolbarButton_onmouseover(evt)
  452. {
  453. var toolbarButton = this.tbItem;
  454. if(typeof toolbarButton == "object")
  455. {
  456. if(!toolbarButton.isEnabled()) {
  457. return;
  458. }
  459. if(toolbarButton.getMenu() != null && !toolbarButton.m_bHideDropDown && ('menu'+toolbarButton.getId()) == this.id) {
  460. this.className = toolbarButton.getDropDownStyle().getActiveRolloverState();
  461. }
  462. else
  463. {
  464. if(typeof toolbarButton.getStyle() == "object") {
  465. this.className = toolbarButton.getStyle().getActiveRolloverState();
  466. }
  467. if(toolbarButton.getMenu() != null && !toolbarButton.m_bHideDropDown)
  468. {
  469. var dropDownArrow = this.document ? this.document.getElementById('menu'+toolbarButton.getId()) : this.ownerDocument.getElementById('menu'+toolbarButton.getId());
  470. if(typeof dropDownArrow == "object") {
  471. dropDownArrow.className = toolbarButton.getDropDownStyle().getActiveRolloverState();
  472. }
  473. }
  474. }
  475. // send the message up to our parent
  476. if(toolbarButton.getParent() != null && typeof toolbarButton.getParent().onmouseover == "function") {
  477. toolbarButton.getParent().onmouseover(evt);
  478. }
  479. // notify our observers of this event
  480. toolbarButton.getObservers().notify(CToolbarButton_onmouseover);
  481. }
  482. }
  483. function CToolbarButton_onmouseout(evt) {
  484. var toolbarButton = this.tbItem;
  485. if(typeof toolbarButton == "object")
  486. {
  487. if(!toolbarButton.isEnabled()) {
  488. return;
  489. }
  490. if(toolbarButton.getMenu() != null && !toolbarButton.m_bHideDropDown && ('menu'+toolbarButton.getId()) == this.id) {
  491. this.className = toolbarButton.getDropDownStyle().getActiveState();
  492. }
  493. else
  494. {
  495. if(typeof toolbarButton.getStyle() == "object") {
  496. this.className = toolbarButton.getStyle().getActiveState();
  497. }
  498. if(toolbarButton.getMenu() != null && !toolbarButton.m_bHideDropDown)
  499. {
  500. var dropDownArrow = this.document ? this.document.getElementById('menu'+toolbarButton.getId()) : this.ownerDocument.getElementById('menu'+toolbarButton.getId());
  501. if(typeof dropDownArrow == "object") {
  502. dropDownArrow.className = toolbarButton.getDropDownStyle().getActiveState();
  503. }
  504. }
  505. }
  506. // send the message up to our parent
  507. if(toolbarButton.getParent() != null && typeof toolbarButton.getParent().onmouseout == "function") {
  508. toolbarButton.getParent().onmouseout(evt);
  509. }
  510. // notify our observers of this event
  511. toolbarButton.getObservers().notify(CToolbarButton_onmouseout);
  512. }
  513. }
  514. function CToolbarButton_onclick(evt) {
  515. //get the event in a cross-browser fashion
  516. evt = (evt) ? evt : ((event) ? event : null);
  517. // get the toolbar button from the html element
  518. var toolbarButton = this.tbItem;
  519. if(toolbarButton != null) {
  520. if(!toolbarButton.isEnabled()) {
  521. return;
  522. }
  523. var menu = toolbarButton.getMenu();
  524. if(menu != null && ((this.id == ('menu'+toolbarButton.getId())) || (toolbarButton.m_bHideDropDown && this.id == toolbarButton.getId()))) {
  525. if(menu.isVisible()) {
  526. menu.remove();
  527. } else {
  528. // the user clicked the drop down arrow
  529. if(typeof menu.setHTMLContainer != "undefined") {
  530. menu.setHTMLContainer(this.document ? this.document.body : this.ownerDocument.body);
  531. }
  532. //Close all the other dropdown menus first
  533. if(typeof toolbarButton.m_parent.closeMenus == "function") {
  534. toolbarButton.m_parent.closeMenus();
  535. }
  536. menu.draw();
  537. menu.show();
  538. }
  539. } else {
  540. eval(this.tbItem.m_action);
  541. }
  542. // send the message up to our parent
  543. if(toolbarButton.getParent() != null && typeof toolbarButton.getParent().onclick == "function") {
  544. toolbarButton.getParent().onclick(evt);
  545. }
  546. // notify our observers of this event
  547. toolbarButton.getObservers().notify(CToolbarButton_onclick);
  548. }
  549. if (this.blur) {
  550. this.blur();
  551. }
  552. evt.cancelBubble = true;
  553. return false;
  554. }
  555. function CToolbarButton_onkeypress(evt) {
  556. //get the event in a cross-browser fashion
  557. evt = (evt) ? evt : ((event) ? event : null);
  558. //check for the Enter or Space key
  559. if (evt.keyCode == 13 || evt.keyCode == 0) {
  560. // get the toolbar button from the html element
  561. var toolbarButton = this.tbItem;
  562. if(toolbarButton != null) {
  563. if(!toolbarButton.isEnabled()) {
  564. return;
  565. }
  566. var menu = toolbarButton.getMenu();
  567. if(menu != null && ((this.id == ('menu'+toolbarButton.getId())) || (toolbarButton.m_bHideDropDown && this.id == toolbarButton.getId()))) {
  568. if(menu.isVisible()) {
  569. menu.remove();
  570. } else {
  571. // the user clicked the drop down arrow
  572. if(typeof menu.setHTMLContainer != "undefined") {
  573. menu.setHTMLContainer(this.document ? this.document.body : this.ownerDocument.body);
  574. }
  575. menu.draw();
  576. menu.show();
  577. }
  578. } else {
  579. eval(this.tbItem.m_action);
  580. }
  581. // send the message up to our parent
  582. if(toolbarButton.getParent() != null && typeof toolbarButton.getParent().onkeypress == "function") {
  583. toolbarButton.getParent().onkeypress(evt);
  584. }
  585. // notify our observers of this event
  586. toolbarButton.getObservers().notify(CToolbarButton_onkeypress);
  587. }
  588. return false;
  589. }
  590. evt.cancelBubble = true;
  591. return true;
  592. }
  593. function CToolbarButton_getMenu() {
  594. return this.m_menu;
  595. }
  596. function CToolbarButton_getMenuType() {
  597. // current toolbar buttons only support drop down menus
  598. return 'dropDown';
  599. }
  600. function CToolbarButton_setStyle(style) {
  601. this.m_style = style;
  602. }
  603. function CToolbarButton_getStyle() {
  604. return this.m_style;
  605. }
  606. function CToolbarButton_getDropDownStyle() {
  607. return this.m_dropDownStyle;
  608. }
  609. function CToolbarButton_setDropDownStyle(style) {
  610. this.m_dropDownStyle = style;
  611. }
  612. function CToolbarButton_isVisible() {
  613. return this.m_bVisible;
  614. }
  615. function CToolbarButton_hide() {
  616. this.m_bVisible = false;
  617. }
  618. function CToolbarButton_show() {
  619. this.m_bVisible = true;
  620. }
  621. function CToolbarButton_enable() {
  622. this.getStyle().setActiveState('normal');
  623. this.getStyle().setActiveRolloverState('normal');
  624. if (this.getIcon())
  625. {
  626. this.getIcon().enable();
  627. }
  628. this.updateHTML();
  629. }
  630. function CToolbarButton_disable() {
  631. this.getStyle().setActiveState('disabled');
  632. this.getStyle().setActiveRolloverState('disabled');
  633. if (this.getIcon())
  634. {
  635. this.getIcon().disable();
  636. }
  637. this.updateHTML();
  638. }
  639. function CToolbarButton_isEnabled() {
  640. if (this.getIcon())
  641. {
  642. return this.getIcon().isEnabled();
  643. }
  644. else
  645. {
  646. return true;
  647. }
  648. }
  649. function CToolbarButton_pressed() {
  650. this.getStyle().setActiveState('depressed');
  651. this.getStyle().setActiveRolloverState('depressed');
  652. this.updateHTML();
  653. }
  654. function CToolbarButton_reset() {
  655. this.getStyle().setActiveState('normal');
  656. this.getStyle().setActiveRolloverState('normal');
  657. this.updateHTML();
  658. }
  659. function CToolbarButton_updateHTML() {
  660. if(typeof this.getStyle() == "object")
  661. {
  662. if(typeof this.getParent().getHTMLContainer == "function")
  663. {
  664. var htmlContainer = this.getParent().getHTMLContainer();
  665. if(htmlContainer != null)
  666. {
  667. var htmlElement = htmlContainer.document ? htmlContainer.document.getElementById(this.getId()) : htmlContainer.ownerDocument.getElementById(this.getId());
  668. if(htmlElement != null)
  669. {
  670. var toolbarImage = htmlElement.getElementsByTagName("img");
  671. if(typeof toolbarImage != "undefined" && toolbarImage instanceof Array && toolbarImage.length > 0)
  672. {
  673. if (this.getIcon())
  674. {
  675. if(this.getIcon().isEnabled())
  676. {
  677. toolbarImage[0].src = this.getIcon().getPath();
  678. }
  679. else
  680. {
  681. toolbarImage[0].src = this.getIcon().getDisabledImagePath();
  682. }
  683. }
  684. if(this.getToolTip())
  685. {
  686. htmlElement.title = this.getToolTip();
  687. toolbarImage[0].title = this.getToolTip();
  688. }
  689. }
  690. var dropDownIcon;
  691. if(this.getStyle().getActiveState() != this.getStyle().getDisabledState())
  692. {
  693. htmlElement.tabIndex = 1;
  694. if (this.getMenu() != null && !this.m_bHideDropDown)
  695. {
  696. htmlElement.nextSibling.tabIndex = 1;
  697. htmlElement.nextSibling.title = this.getToolTip();
  698. dropDownIcon = htmlElement.nextSibling.getElementsByTagName("img");
  699. if(dropDownIcon != null)
  700. {
  701. dropDownIcon[0].title = this.getToolTip();
  702. }
  703. }
  704. }
  705. else
  706. {
  707. if (htmlElement.tabIndex != "undefined")
  708. {
  709. htmlElement.removeAttribute("tabIndex");
  710. if (this.getMenu() != null)
  711. {
  712. htmlElement.nextSibling.removeAttribute("tabIndex");
  713. htmlElement.nextSibling.title = this.getToolTip();
  714. dropDownIcon = htmlElement.nextSibling.getElementsByTagName("img");
  715. if(dropDownIcon != null)
  716. {
  717. dropDownIcon[0].title = this.getToolTip();
  718. }
  719. }
  720. }
  721. }
  722. htmlElement.className = this.getStyle().getActiveState();
  723. }
  724. }
  725. }
  726. }
  727. }
  728. function CToolbarButton_getObservers() {
  729. return this.m_observers;
  730. }
  731. function CToolbarButton_setFocus() {
  732. if (this.m_menu != null && !this.m_bHideDropDown) {
  733. document.getElementById(this.m_id).nextSibling.focus();
  734. }
  735. else {
  736. document.getElementById(this.m_id).focus();
  737. }
  738. }
  739. CToolbarButton.prototype.draw = CToolbarButton_draw;
  740. CToolbarButton.prototype.attachEvents = CToolbarButton_attachEvents;
  741. CToolbarButton.prototype.onblur = CToolbarButton_onmouseout;
  742. CToolbarButton.prototype.onfocus = CToolbarButton_onmouseover;
  743. CToolbarButton.prototype.onkeypress = CToolbarButton_onkeypress;
  744. CToolbarButton.prototype.onmouseover = CToolbarButton_onmouseover;
  745. CToolbarButton.prototype.onmouseout = CToolbarButton_onmouseout;
  746. CToolbarButton.prototype.onclick = CToolbarButton_onclick;
  747. CToolbarButton.prototype.setParent = CToolbarButton_setParent;
  748. CToolbarButton.prototype.getParent = CToolbarButton_getParent;
  749. CToolbarButton.prototype.getAction = CToolbarButton_getAction;
  750. CToolbarButton.prototype.setAction = CToolbarButton_setAction;
  751. CToolbarButton.prototype.getToolTip = CToolbarButton_getToolTip;
  752. CToolbarButton.prototype.setToolTip = CToolbarButton_setToolTip;
  753. CToolbarButton.prototype.getDropDownToolTip = CToolbarButton_getDropDownToolTip;
  754. CToolbarButton.prototype.setDropDownToolTip = CToolbarButton_setDropDownToolTip;
  755. CToolbarButton.prototype.getIcon = CToolbarButton_getIcon;
  756. CToolbarButton.prototype.setIcon = CToolbarButton_setIcon;
  757. CToolbarButton.prototype.getMenu = CToolbarButton_getMenu;
  758. CToolbarButton.prototype.getMenuType = CToolbarButton_getMenuType;
  759. CToolbarButton.prototype.getId = CToolbarButton_getId;
  760. CToolbarButton.prototype.setStyle = CToolbarButton_setStyle;
  761. CToolbarButton.prototype.getStyle = CToolbarButton_getStyle;
  762. CToolbarButton.prototype.getDropDownStyle = CToolbarButton_getDropDownStyle;
  763. CToolbarButton.prototype.setDropDownStyle = CToolbarButton_setDropDownStyle;
  764. CToolbarButton.prototype.createDropDownMenu = CToolbarButton_createDropDownMenu;
  765. CToolbarButton.prototype.addOwnerDrawControl = CToolbarButton_addOwnerDrawControl;
  766. CToolbarButton.prototype.getObservers = CToolbarButton_getObservers;
  767. CToolbarButton.prototype.update = new Function("return true");
  768. CToolbarButton.prototype.isVisible = CToolbarButton_isVisible;
  769. CToolbarButton.prototype.hide = CToolbarButton_hide;
  770. CToolbarButton.prototype.show = CToolbarButton_show;
  771. CToolbarButton.prototype.isEnabled = CToolbarButton_isEnabled;
  772. CToolbarButton.prototype.enable = CToolbarButton_enable;
  773. CToolbarButton.prototype.disable = CToolbarButton_disable;
  774. CToolbarButton.prototype.pressed = CToolbarButton_pressed;
  775. CToolbarButton.prototype.reset = CToolbarButton_reset;
  776. CToolbarButton.prototype.setFocus = CToolbarButton_setFocus;
  777. CToolbarButton.prototype.updateHTML = CToolbarButton_updateHTML;
  778. // Copyright (C) 2008 Cognos Incorporated. All rights reserved.
  779. // Cognos (R) is a trademark of Cognos Incorporated.
  780. /**
  781. Class: CModal
  782. Description:
  783. @param title String to show in the header. [Mandatory]
  784. @param sCloseToolTip String to use as tooltip for close button. [Madatory]
  785. @param parent The container of this dialog. [Optional]
  786. @param t Top coordinate. [Optional] By Default the dialog is centered.
  787. @param l Left coordinate. [Optional] By Default the dialog is centered.
  788. @param h Height of the dialog. [Optional] By Default the dialog is centered.
  789. @param w Width of the dialog. [Optional] By Default the dialog is centered.
  790. */
  791. /* Constants */
  792. var CMODAL_ID = 'CMODAL_FRAME';
  793. var CMODAL_BLUR = 'CMODAL_BLUR';
  794. var CMODAL_CONTENT_ID = 'CMODAL_CONTENT';
  795. var CMODAL_HEADER = 'CMODAL_HEADER';
  796. var CMODAL_BACKGROUND_LAYER_ID = 'CMODAL_BK';
  797. var CMODAL_BACK_IFRAME_ID = 'CMODAL_BK_IFRAME';
  798. var CMODAL_ZINDEX = 111;
  799. /* Global variables */
  800. var CMODAL_dragEnabled = false;
  801. var CMODAL_resizeDirection = null;
  802. var CMODAL_startLeft = null;
  803. var CMODAL_startTop = null;
  804. var CMODAL_startWidth = null;
  805. var CMODAL_startHeight = null;
  806. var CMODAL_deltaX = null;
  807. var CMODAL_deltaY = null;
  808. function CModal(title, sCloseToolTip, parent, t, l, h, w, hideButtonBar, hideHeader, dynamicSize, blurBackground, webContentRoot)
  809. {
  810. this.m_hideButtonBar = false;
  811. if(typeof hideButtonBar != "undefined")
  812. {
  813. this.m_hideButtonBar = hideButtonBar;
  814. }
  815. this.m_hideHeader = false;
  816. if(typeof hideHeader != "undefined")
  817. {
  818. this.m_hideHeader= hideHeader;
  819. }
  820. this.m_title = title;
  821. this.m_sCloseToolTip = sCloseToolTip;
  822. if (parent) {
  823. this.m_parent = parent;
  824. } else {
  825. this.m_parent = (document.body ? document.body : document.documentElement);
  826. }
  827. var oBL = document.getElementById(CMODAL_BACKGROUND_LAYER_ID);
  828. if(oBL)
  829. {
  830. oBL.parentNode.removeChild(oBL);
  831. }
  832. if (typeof webContentRoot != "undefined" && webContentRoot != "")
  833. {
  834. this.m_webContentRoot = webContentRoot;
  835. }
  836. else
  837. {
  838. this.m_webContentRoot = "..";
  839. }
  840. oBL = document.createElement("div");
  841. oBL.id = CMODAL_BACKGROUND_LAYER_ID;
  842. oBL.style.display = "none";
  843. oBL.style.position = "absolute";
  844. oBL.style.top = "0px";
  845. oBL.style.left = "0px";
  846. oBL.style.zIndex = (CMODAL_ZINDEX - 2);
  847. oBL.style.width = "100%";
  848. oBL.style.height = "100%";
  849. if(typeof blurBackground != "undefined" && blurBackground)
  850. {
  851. oBL.style.backgroundColor = 'rgb(238, 238, 238)';
  852. oBL.style.opacity = '0.6';
  853. oBL.style.filter = 'alpha(opacity:60)';
  854. }
  855. oBL.innerHTML = '<table width="100%" height="100%" role="presentation"><tr><td role="presentation" onmousemove="CModalEvent_mousemoving(event)" onmouseup="CModalEvent_disableDrag(event)"></td></tr></table>';
  856. this.m_parent.appendChild(oBL);
  857. this.m_backLayer = oBL;
  858. this.m_top = (t == null ? 0 : t);
  859. this.m_left = (l == null ? 0 : l);
  860. this.m_height = (h == null ? 0 : h);
  861. this.m_width = (w == null ? 0 : w);
  862. if(typeof dynamicSize != "undefined" && dynamicSize == true)
  863. {
  864. this.m_height = CModal_dynamicHeight();
  865. this.m_width = CModal_dynamicWidth();
  866. }
  867. if (window.attachEvent)
  868. {
  869. window.attachEvent("onresize", CModalEvent_onWindowResize);
  870. window.attachEvent("onscroll", CModalEvent_onWindowResize);
  871. }
  872. else
  873. {
  874. window.addEventListener("resize", CModalEvent_onWindowResize, false);
  875. window.addEventListener("scroll", CModalEvent_onWindowResize, false);
  876. }
  877. var f = document.getElementById(CMODAL_ID);
  878. if(f)
  879. {
  880. f.parentNode.removeChild(f);
  881. }
  882. f = document.createElement("span");
  883. f.id = CMODAL_ID;
  884. f.CModal = this;
  885. f.className = 'CModal_frame';
  886. f.style.zIndex = CMODAL_ZINDEX;
  887. f.style.border = "#99aacc 1px solid";
  888. var div = this.createHiddenDiv("CMODAL_TAB_LOOP_BEFORE", 0);
  889. div.onfocus = function() {document.getElementById("CMODAL_AFTER_PLACEHOLDER").focus();};
  890. this.m_parent.appendChild(f);
  891. div = this.createHiddenDiv("CMODAL_AFTER_PLACEHOLDER", -1);
  892. div = this.createHiddenDiv("CMODAL_TAB_LOOP_AFTER", 0);
  893. div.onfocus = function() {document.getElementById(CMODAL_CONTENT_ID).contentWindow.focus();};
  894. this.m_back_iframe = document.getElementById(CMODAL_BACK_IFRAME_ID);
  895. if(this.m_back_iframe)
  896. {
  897. this.m_back_iframe.parentNode.removeChild(this.m_back_iframe);
  898. }
  899. this.m_back_iframe = document.createElement("iframe");
  900. this.m_back_iframe.id = CMODAL_BACK_IFRAME_ID;
  901. this.m_back_iframe.frameBorder = 0;
  902. this.m_back_iframe.src = this.m_webContentRoot + "/common/blank.html";
  903. this.m_back_iframe.style.position = "absolute";
  904. this.m_back_iframe.style.zIndex = CMODAL_ZINDEX - 1;
  905. this.m_back_iframe.onfocus = function() {document.getElementById(CMODAL_BACKGROUND_LAYER_ID).focus();};
  906. this.m_back_iframe.tabIndex = 1;
  907. this.m_back_iframe.title = "Empty frame";
  908. this.m_back_iframe.role = "presentation";
  909. this.m_parent.appendChild(this.m_back_iframe);
  910. // render framework of the modal dialog
  911. f.innerHTML = this.renderDialogFrame();
  912. this.m_frame = f;
  913. }
  914. function CModal_createHiddenDiv(divId, tabIndex) {
  915. var div = document.getElementById(divId);
  916. if (div)
  917. {
  918. div.parentNode.removeChild(div);
  919. }
  920. div = document.createElement("div");
  921. div.id = divId;
  922. div.tabIndex = tabIndex;
  923. div.style.position = "absolute";
  924. div.style.overflow = "hidden";
  925. div.style.width = "0px";
  926. div.style.height = "0px";
  927. this.m_parent.appendChild(div);
  928. return div;
  929. }
  930. function CModal_hide() {
  931. this.m_top = parseInt(this.m_frame.offsetTop,10);
  932. this.m_left = parseInt(this.m_frame.offsetLeft,10);
  933. this.m_height = parseInt(this.m_frame.offsetHeight,10);
  934. this.m_width = parseInt(this.m_frame.offsetWidth,10);
  935. this.m_backLayer.style.display = "none";
  936. this.m_frame.style.display = "none";
  937. if (this.m_back_iframe) {
  938. this.m_back_iframe.style.display = "none";
  939. }
  940. }
  941. function CModal_reCenter() {
  942. this.m_left = (document.getElementById(CMODAL_BACKGROUND_LAYER_ID).clientWidth - this.m_width)/2;
  943. this.m_top = (document.getElementById(CMODAL_BACKGROUND_LAYER_ID).clientHeight - this.m_height)/2;
  944. }
  945. function CModal_renderDialogFrame() {
  946. var sTableAttrs = 'summary="" cellpadding="0" cellspacing="0" border="0" role="presentation"';
  947. var out =
  948. '<table role="presentation" style="width:100%; height:99%; padding-top:2px;" ' + sTableAttrs + ' onmouseup="CModalEvent_disableDrag(event)" onmousemove="CModalEvent_mousemoving(event)">';
  949. if(!this.m_hideHeader)
  950. {
  951. out += '' +
  952. '<tr>' +
  953. '<td role="presentation" onmousedown="CModalEvent_enableDrag(event);">' +
  954. '<table class="dialogHeader" width="100%" ' + sTableAttrs + '>' +
  955. '<tr>' +
  956. '<td id="' + CMODAL_HEADER + '" valign="top" class="dialogHeaderTitle" width="100%" nowrap="nowrap">' +
  957. getConfigFrame().htmlencode(this.m_title) +
  958. '</td><td align="right" valign="middle">' +
  959. '<a onclick="hideCModal()" style="cursor:pointer;">' +
  960. '<img height="16" width="16" vspace="2" border="0" class="dialogClose" onmouseover="this.className = \'dialogCloseOver\'" onmouseout="this.className = \'dialogClose\'" onmouseup="this.className = \'dialogClose\'" src="' + p_sSkinFolder + '/portal/images/close.gif" alt="' + getConfigFrame().htmlencode(this.m_sCloseToolTip) + '" title="' + getConfigFrame().htmlencode(this.m_sCloseToolTip) + '">' +
  961. '</a>' +
  962. '</td>' +
  963. '</tr>' +
  964. '</table>' +
  965. '</td>' +
  966. '</tr>';
  967. }
  968. out += '<tr><td role="presentation" width="100%" height="100%" class="body_dialog_modal" onmousemove="CModalEvent_mousemoving(event)" onmouseup="CModalEvent_disableDrag(event)">' +
  969. '<iframe title="modal dialog" id="' + CMODAL_CONTENT_ID + '" name="' + CMODAL_CONTENT_ID + '" class="body_dialog_modal" src="' + this.m_webContentRoot + '/' + "qs" + '/blankNewWin.html" style="padding:0px;margin:0px;width:100%;height:100%;" frameborder="0">no iframe support?</iframe>' +
  970. '</td></tr>';
  971. if(!this.m_hideButtonBar)
  972. {
  973. out += '<tr><td>' +
  974. '<table ' + sTableAttrs + ' class="dialogButtonBar" style="padding:0px">' +
  975. '<tr>' +
  976. '<td width="2" valign="middle"><img width="2" alt="" src="' + this.m_webContentRoot + '/ps/images/space.gif"></td>' +
  977. '<td valign="middle"><table border="0" cellpadding="1" cellspacing="0" role="presentation">' +
  978. '<tr>' +
  979. '<td><img height="1" width="8" alt="" src="' + this.m_webContentRoot + '/ps/images/space.gif"></td>' +
  980. '<td>' + CModal_renderButton(msgQS['OK'], 'okCModal()') + '</td>' +
  981. '<td><img height="1" width="8" alt="" src="' + this.m_webContentRoot + '/ps/images/space.gif"></td>' +
  982. '<td>' + CModal_renderButton(msgQS['CANCEL'], 'cancelCModal()') + '</td>' +
  983. '<td><img height="1" width="8" alt="" src="' + this.m_webContentRoot + '/ps/images/space.gif"></td>' +
  984. '</tr></table>' +
  985. '</td><td width="100%">&nbsp;</td>' +
  986. '<td style="padding:3px;" valign="bottom" class="CModal_sideSE" onmousedown="CModalEvent_enableResize(event)">' +
  987. '<img role="presentation" class="CModal_sideSE" style="cursor:se-resize;" alt="" height="12" width="12" border="0" src="' + this.m_webContentRoot + '/common/images/dialog_resize.gif" onmousedown="CModalEvent_enableResize(event);return false;" onmouseup="CModalEvent_disableDrag(event);return false;" onmousemove="CModalEvent_mousemoving(event);return false;">' +
  988. '</td>' +
  989. '</tr></table></td></tr>';
  990. }
  991. out += '</table>';
  992. return out;
  993. }
  994. function CModal_renderButton(label, jsFct) {
  995. var out = '<table cellpadding="0" cellspacing="0" style="padding: 2px 10px 3px;" class="commandButton" onmouseover="this.className=\'commandButtonOver\'"' +
  996. ' onmouseout="this.className = \'commandButton\'" onmousedown="this.className=\'commandButtonDown\'">' +
  997. '<tr>' +
  998. '<td style="cursor:pointer;" valign="middle" align="center" nowrap id="btnAnchor" onclick="' + jsFct + '">' + ' <img height="1" width="60" alt="" src="' + this.m_webContentRoot + '/ps/images/space.gif"><br>' +
  999. label + '</td></tr></table>';
  1000. return out;
  1001. }
  1002. function CModal_show() {
  1003. this.m_backLayer.style.display = "";
  1004. this.reCenter();
  1005. var position = CMenu_getScrollingPosition();
  1006. this.m_frame.style.top = (position.y + this.m_top) + "px";
  1007. this.m_frame.style.left = (position.x + this.m_left) + "px";
  1008. this.m_frame.style.height = this.m_height + "px";
  1009. this.m_frame.style.width = this.m_width + "px";
  1010. this.m_frame.style.display = 'inline';
  1011. this.m_frame.focus();
  1012. if (this.m_back_iframe) {
  1013. this.m_back_iframe.style.top = this.m_frame.offsetTop + "px";
  1014. this.m_back_iframe.style.left = this.m_frame.offsetLeft + "px";
  1015. this.m_back_iframe.style.height = this.m_frame.offsetHeight + "px";
  1016. this.m_back_iframe.style.width = this.m_frame.offsetWidth + "px";
  1017. this.m_back_iframe.style.display = "block";
  1018. }
  1019. }
  1020. CModal.prototype.hide = CModal_hide;
  1021. CModal.prototype.createHiddenDiv = CModal_createHiddenDiv;
  1022. CModal.prototype.reCenter = CModal_reCenter;
  1023. CModal.prototype.renderDialogFrame = CModal_renderDialogFrame;
  1024. CModal.prototype.show = CModal_show;
  1025. /* Event handlers for CModal (global functions) */
  1026. function hideCModal() {
  1027. var cdlg = document.getElementById(CMODAL_ID);
  1028. if (cdlg && cdlg.CModal) {
  1029. cdlg.CModal.hide();
  1030. }
  1031. }
  1032. function destroyCModal() {
  1033. var oBL = document.getElementById(CMODAL_BACKGROUND_LAYER_ID);
  1034. if(oBL)
  1035. {
  1036. oBL.style.display = "none";
  1037. }
  1038. var modelContent = document.getElementById(CMODAL_ID);
  1039. if(modelContent)
  1040. {
  1041. modelContent.style.display = "none";
  1042. }
  1043. var back_iframe = document.getElementById(CMODAL_BACK_IFRAME_ID);
  1044. if(back_iframe)
  1045. {
  1046. back_iframe.style.display = "none";
  1047. }
  1048. if (window.detachEvent)
  1049. {
  1050. window.detachEvent("onresize", CModalEvent_onWindowResize);
  1051. window.detachEvent("onscroll", CModalEvent_onWindowResize);
  1052. }
  1053. else
  1054. {
  1055. window.removeEventListener("resize", CModalEvent_onWindowResize, false);
  1056. window.removeEventListener("scroll", CModalEvent_onWindowResize, false);
  1057. }
  1058. }
  1059. function cancelCModal() {
  1060. var iframe = document.getElementById(CMODAL_CONTENT_ID);
  1061. if (iframe && iframe.contentWindow && typeof iframe.contentWindow.cancelDialog == "function") {
  1062. iframe.contentWindow.cancelDialog();
  1063. }
  1064. else {
  1065. hideCModal();
  1066. }
  1067. }
  1068. function okCModal() {
  1069. var iframe = document.getElementById(CMODAL_CONTENT_ID);
  1070. if (iframe && iframe.contentWindow && typeof iframe.contentWindow.execute == "function") {
  1071. iframe.contentWindow.execute();
  1072. }
  1073. else {
  1074. hideCModal();
  1075. }
  1076. }
  1077. function CModal_dynamicWidth()
  1078. {
  1079. return (window.innerWidth != null ? window.innerWidth: document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth:document.body != null? document.body.clientWidth:null)-150;
  1080. }
  1081. function CModal_dynamicHeight()
  1082. {
  1083. return (window.innerHeight != null? window.innerHeight: document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight:document.body != null? document.body.clientHeight:null)-150;
  1084. }
  1085. function CModal_setModalHeight(modalDialog)
  1086. {
  1087. var storedHeight = modalDialog.getAttribute("storedHeight");
  1088. if(modalDialog.offsetHeight > document.getElementById(CMODAL_BACKGROUND_LAYER_ID).clientHeight)
  1089. {
  1090. if(storedHeight == null)
  1091. {
  1092. modalDialog.setAttribute("storedHeight", modalDialog.offsetHeight);
  1093. }
  1094. modalDialog.style.height = document.getElementById(CMODAL_BACKGROUND_LAYER_ID).clientHeight + "px";
  1095. }
  1096. else if(storedHeight != null)
  1097. {
  1098. if(storedHeight < document.getElementById(CMODAL_BACKGROUND_LAYER_ID).clientHeight)
  1099. {
  1100. modalDialog.style.height = storedHeight + "px";
  1101. }
  1102. else
  1103. {
  1104. modalDialog.style.height = document.getElementById(CMODAL_BACKGROUND_LAYER_ID).clientHeight + "px";
  1105. }
  1106. }
  1107. }
  1108. function CModal_setModalWidth(modalDialog)
  1109. {
  1110. var storedWidth = modalDialog.getAttribute("storedWidth");
  1111. if(modalDialog.offsetWidth > document.getElementById(CMODAL_BACKGROUND_LAYER_ID).clientWidth)
  1112. {
  1113. if(storedWidth == null)
  1114. {
  1115. modalDialog.setAttribute("storedWidth", modalDialog.offsetWidth);
  1116. }
  1117. modalDialog.style.width = document.getElementById(CMODAL_BACKGROUND_LAYER_ID).clientWidth + "px";
  1118. }
  1119. else if(storedWidth != null)
  1120. {
  1121. if(storedWidth < document.getElementById(CMODAL_BACKGROUND_LAYER_ID).clientWidth)
  1122. {
  1123. modalDialog.removeAttribute("storedWidth");
  1124. modalDialog.style.width = storedWidth + "px";
  1125. }
  1126. else
  1127. {
  1128. modalDialog.style.width = document.getElementById(CMODAL_BACKGROUND_LAYER_ID).clientWidth + "px";
  1129. }
  1130. }
  1131. }
  1132. function CModalEvent_onWindowResize(e){
  1133. var modalDialog = document.getElementById(CMODAL_ID);
  1134. var backLayer = document.getElementById(CMODAL_BACKGROUND_LAYER_ID);
  1135. var back_iframe = document.getElementById(CMODAL_BACK_IFRAME_ID);
  1136. if(modalDialog && backLayer && back_iframe)
  1137. {
  1138. CModal_setModalWidth(modalDialog);
  1139. CModal_setModalHeight(modalDialog);
  1140. var position = CMenu_getScrollingPosition();
  1141. var topCoord = (position.y + ((backLayer.clientHeight - modalDialog.offsetHeight)/2));
  1142. var leftCoord = (position.x + ((backLayer.clientWidth - modalDialog.offsetWidth)/2));
  1143. modalDialog.style.top = topCoord + "px";
  1144. modalDialog.style.left = leftCoord + "px";
  1145. back_iframe.style.top = topCoord + "px";
  1146. back_iframe.style.width = modalDialog.style.width;
  1147. back_iframe.style.height = modalDialog.style.height;
  1148. back_iframe.style.left = leftCoord + "px";
  1149. }
  1150. }
  1151. function CModalEvent_mousemoving(e) {
  1152. var oDlg = null;
  1153. var oIFrame = null;
  1154. if (CMODAL_dragEnabled) {
  1155. if (e == null && (typeof event == "object") && event.clientX != null) {
  1156. e = event;
  1157. }
  1158. oDlg = document.getElementById(CMODAL_ID);
  1159. if (CMODAL_startLeft == null) {
  1160. CMODAL_startLeft = parseInt(oDlg.style.left,10) - e.clientX;
  1161. CMODAL_startTop = parseInt(oDlg.style.top,10) - e.clientY;
  1162. }
  1163. oDlg.style.left = CMODAL_startLeft + e.clientX;
  1164. oDlg.style.top = CMODAL_startTop + e.clientY;
  1165. oIFrame = document.getElementById(CMODAL_BACK_IFRAME_ID);
  1166. if (oIFrame) {
  1167. oIFrame.style.left = oDlg.style.left;
  1168. oIFrame.style.top = oDlg.style.top;
  1169. }
  1170. }
  1171. if (CMODAL_resizeDirection) {
  1172. if (e == null && (typeof event == "object") && event.clientX != null) {
  1173. e = event;
  1174. }
  1175. oDlg = document.getElementById(CMODAL_ID);
  1176. if (CMODAL_startLeft == null) {
  1177. CMODAL_startLeft = parseInt(oDlg.style.left,10);
  1178. CMODAL_startTop = parseInt(oDlg.style.top,10);
  1179. CMODAL_startHeight = parseInt(oDlg.style.height,10);
  1180. CMODAL_startWidth = parseInt(oDlg.style.width,10);
  1181. }
  1182. var h = 0, w = 0;
  1183. switch (CMODAL_resizeDirection) {
  1184. case 'NE':
  1185. case 'E':
  1186. case 'SE':
  1187. w = (e.clientX - CMODAL_startLeft + CMODAL_deltaX);
  1188. if (w < 100) {
  1189. w = 100;
  1190. }
  1191. oDlg.style.width = w + "px";
  1192. }
  1193. switch (CMODAL_resizeDirection) {
  1194. case 'SW':
  1195. case 'S':
  1196. case 'SE':
  1197. h = (e.clientY - CMODAL_startTop + CMODAL_deltaY);
  1198. if (h < 100) {
  1199. h = 100;
  1200. }
  1201. oDlg.style.height = h + "px";
  1202. }
  1203. switch (CMODAL_resizeDirection) {
  1204. case 'NW':
  1205. case 'N':
  1206. case 'NE':
  1207. oDlg.style.top = e.clientY;
  1208. h = (CMODAL_startHeight + (CMODAL_startTop - e.clientY) + CMODAL_deltaY);
  1209. if (h < 100) {
  1210. h = 100;
  1211. }
  1212. oDlg.style.height = h + "px";
  1213. }
  1214. switch (CMODAL_resizeDirection) {
  1215. case 'NW':
  1216. case 'W':
  1217. case 'SW':
  1218. oDlg.style.left = e.clientX;
  1219. w = (CMODAL_startWidth + (CMODAL_startLeft - e.clientX) + CMODAL_deltaX);
  1220. if (w < 100) {
  1221. w = 100;
  1222. }
  1223. oDlg.style.width = w + "px";
  1224. }
  1225. oIFrame = document.getElementById(CMODAL_BACK_IFRAME_ID);
  1226. if (oIFrame) {
  1227. oIFrame.style.left = oDlg.offsetLeft;
  1228. oIFrame.style.top = oDlg.offsetTop;
  1229. oIFrame.style.height = oDlg.offsetHeight;
  1230. oIFrame.style.width = oDlg.offsetWidth;
  1231. }
  1232. }
  1233. if (e.returnValue) { e.returnValue = false; }
  1234. else if (e.preventDefault) { e.preventDefault(); }
  1235. else { return false; }
  1236. }
  1237. function CModalEvent_disableDrag(e) {
  1238. CMODAL_dragEnabled = false;
  1239. CMODAL_resizeDirection = null;
  1240. CMODAL_startLeft = null;
  1241. CMODAL_startTop = null;
  1242. CMODAL_deltaX = 0;
  1243. CMODAL_deltaY = 0;
  1244. // remove dragging style
  1245. var cn = document.getElementById(CMODAL_ID).className;
  1246. var modelHeader = document.getElementById(CMODAL_HEADER);
  1247. if(modelHeader != null)
  1248. {
  1249. modelHeader.style.cursor = 'default';
  1250. }
  1251. document.getElementById(CMODAL_ID).className = cn.replace(/\s*\bCModal_dragging\b/g, "");
  1252. // show content frame
  1253. document.getElementById(CMODAL_CONTENT_ID).style.visibility = "visible";
  1254. if (typeof document.getElementById(CMODAL_CONTENT_ID).contentWindow.refreshContent == "function") {
  1255. document.getElementById(CMODAL_CONTENT_ID).contentWindow.refreshContent();
  1256. }
  1257. if (e.returnValue) { e.returnValue = false; }
  1258. else if (e.preventDefault) { e.preventDefault(); }
  1259. else { return false; }
  1260. }
  1261. function CModalEvent_enableDrag(e) {
  1262. CMODAL_dragEnabled = true;
  1263. CMODAL_startLeft = null;
  1264. CMODAL_startTop = null;
  1265. if (e == null && (typeof event == "object") && event.clientX != null) {
  1266. e = event;
  1267. }
  1268. // apply dragging style to frame
  1269. document.getElementById(CMODAL_ID).className += " CModal_dragging";
  1270. document.getElementById(CMODAL_HEADER).style.cursor = 'move';
  1271. // hide content frame
  1272. document.getElementById(CMODAL_CONTENT_ID).style.visibility = "hidden";
  1273. if (e.returnValue) { e.returnValue = false; }
  1274. else if (e.preventDefault) { e.preventDefault(); }
  1275. else { return false; }
  1276. }
  1277. function CModalEvent_enableResize(e) {
  1278. CMODAL_startLeft = null;
  1279. CMODAL_startTop = null;
  1280. CMODAL_startWidth = null;
  1281. CMODAL_startHeight = null;
  1282. CMODAL_deltaX = 0;
  1283. CMODAL_deltaY = 0;
  1284. if (e == null && (typeof event == "object") && event.clientX != null) {
  1285. e = event;
  1286. }
  1287. var oDlg = document.getElementById(CMODAL_ID);
  1288. CMODAL_startLeft = parseInt(oDlg.style.left,10);
  1289. CMODAL_startTop = parseInt(oDlg.style.top,10);
  1290. CMODAL_startHeight = parseInt(oDlg.style.height,10);
  1291. CMODAL_startWidth = parseInt(oDlg.style.width,10);
  1292. CMODAL_deltaX = (CMODAL_startLeft + CMODAL_startWidth - e.clientX);
  1293. CMODAL_deltaY = (CMODAL_startTop + CMODAL_startHeight - e.clientY);
  1294. var src = (e.srcElement ? e.srcElement : e.target);
  1295. if ( (/\bCModal_side(\w+)\b/).test(src.className) ) {
  1296. // set resize direction using className
  1297. CMODAL_resizeDirection = RegExp.$1;
  1298. // apply dragging style to frame
  1299. document.getElementById(CMODAL_ID).className += " CModal_dragging";
  1300. // hide content frame
  1301. document.getElementById(CMODAL_CONTENT_ID).style.visibility = "hidden";
  1302. }
  1303. if (e.returnValue) { e.returnValue = false; }
  1304. else if (e.preventDefault) { e.preventDefault(); }
  1305. else { return false; }
  1306. }
  1307. /*-----------------------------------------------------------------------------------------------------
  1308. Class : CMenuEntry
  1309. Description : Common superclass of CMenuItem and CInfoPanel
  1310. -----------------------------------------------------------------------------------------------------*/
  1311. function CMenuEntry() {
  1312. this.m_menu = null;
  1313. this.m_menuType="";
  1314. this.m_action = null;
  1315. this.m_bEnabled = true;
  1316. }
  1317. function CMenuEntry_setParent(parent) {
  1318. this.m_parent = parent;
  1319. }
  1320. function CMenuEntry_getParent() {
  1321. return this.m_parent;
  1322. }
  1323. function CMenuEntry_setWebContentRoot(sWebContentRoot) {
  1324. this.m_webContentRoot = sWebContentRoot;
  1325. }
  1326. function CMenuEntry_setId(id) {
  1327. this.m_id = id;
  1328. }
  1329. function CMenuEntry_getId() {
  1330. return this.m_id;
  1331. }
  1332. function CMenuEntry_getObservers() {
  1333. return this.m_observers;
  1334. }
  1335. function CMenuEntry_onkeydown(evt) {
  1336. //get the event in a cross-browser fashion
  1337. evt = (evt) ? evt : ((event) ? event : null);
  1338. if(typeof evt != "object" || evt == null) {
  1339. return;
  1340. }
  1341. var i = 0, ii, numItems, nextMenuItem, parent;
  1342. var performNotification = true;
  1343. var target = evt.currentTarget || evt.srcElement;
  1344. //if a Shift-Tab is detected
  1345. if (evt.keyCode == 9 && evt.shiftKey) {
  1346. parent = this.getParent();
  1347. for (i = 0; i < parent.getNumItems(); i++) {
  1348. if (parent.get(i) == this) {
  1349. parent.hide();
  1350. // notify our observers that we've closed the menu because of a tab keydown event
  1351. this.getObservers().notify("CMenuItem_closeMenuTabEvent");
  1352. var parentMenuType = parent.getMenuType ? parent.getMenuType() : null;
  1353. if (parentMenuType !== cHorizonalBar && parentMenuType !== cVerticalBar) {
  1354. //For menus with a parent item, suppress propogation of the
  1355. //shift+tab event so that focus goes to the correct member.
  1356. if (isIE()) {
  1357. evt.preventDefault();
  1358. }
  1359. else {
  1360. evt.returnValue = false;
  1361. }
  1362. }
  1363. break;
  1364. }
  1365. else if (this.getParent().get(i).m_bEnabled == true) {
  1366. break;
  1367. }
  1368. }
  1369. }
  1370. //if a normal Tab is detected
  1371. else if (evt.keyCode == 9) {
  1372. // If our parent is a CMenuItem, than we're part of a menu. Catch the
  1373. // tab event for the last menuItem in the menu so we can close the menu.
  1374. if (this.isInMenu())
  1375. {
  1376. for (i = (this.getParent().getNumItems() - 1); i >= 0; i++) {
  1377. if (this.getParent().get(i) == this) {
  1378. if (this.getMenu()) {
  1379. this.getMenu().hide();
  1380. }
  1381. this.getParent().hide();
  1382. // notify our observers that we've closed the menu because of a tab keydown event
  1383. this.getObservers().notify("CMenuItem_closeMenuTabEvent");
  1384. if (isIE()) {
  1385. evt.preventDefault();
  1386. }
  1387. else {
  1388. evt.returnValue = false;
  1389. }
  1390. break;
  1391. }
  1392. else if (this.getParent().get(i).m_bEnabled == true) {
  1393. break;
  1394. }
  1395. }
  1396. } else if (typeof this.getParent().closeAllMenus == "function") {
  1397. this.getParent().closeAllMenus();
  1398. } else if (typeof this.getParent().closeMenus == "function") {
  1399. this.getParent().closeMenus();
  1400. }
  1401. }
  1402. // down arrow, select the next menu item in the menu or close the menu
  1403. // if we're already at the last menu item -- or if is a dropdown,
  1404. // expand submenu.
  1405. else if (evt.keyCode == 40) {
  1406. if(this.isInMenu()) {
  1407. numItems = this.getParent().getNumItems();
  1408. for (i = 0; i < numItems; i++) {
  1409. if (this === this.getParent().get(i)) {
  1410. var iStart = 0;
  1411. var bStartedFromTop = true;
  1412. if (i != (numItems-1)) {
  1413. iStart = i+1;
  1414. bStartedFromTop = false;
  1415. }
  1416. for (ii = iStart; ii < numItems; ii++) {
  1417. nextMenuItem = this.getParent().get(ii);
  1418. if ( typeof nextMenuItem.isVisible == "function" && nextMenuItem.isVisible() &&
  1419. typeof nextMenuItem.setFocus == "function") {
  1420. nextMenuItem.setFocus();
  1421. break;
  1422. }
  1423. // If we reached the last item and didn't start from the top
  1424. // then keep going but start from the top
  1425. if (ii == (numItems-1) && !bStartedFromTop) {
  1426. ii = 0;
  1427. bStartedFromTop = true;
  1428. }
  1429. }
  1430. break;
  1431. }
  1432. }
  1433. } else if(this.isEnabled()) {
  1434. performNotification = false;
  1435. //For a drop-down menu, expand submenu
  1436. var menu = this.getMenu();
  1437. if(this.getMenuType() == 'dropDown') {
  1438. if(menu.isVisible() == false) {
  1439. // the user clicked on the menu
  1440. menu.setHTMLContainer(target.document ? target.document.body : target.ownerDocument.body);
  1441. menu.draw();
  1442. menu.show();
  1443. } else {
  1444. menu.remove();
  1445. }
  1446. }
  1447. }
  1448. }
  1449. // up arrow
  1450. else if (evt.keyCode == 38 && this.isInMenu()) {
  1451. numItems = this.getParent().getNumItems();
  1452. for (i = 0; i < numItems; i++) {
  1453. if (this === this.getParent().get(i)) {
  1454. var iStart = i-1;
  1455. var bStartedFromBottom = false;
  1456. if (i <= 0) {
  1457. iStart = numItems-1;
  1458. bStartedFromBottom = true;
  1459. }
  1460. for (ii = iStart; ii >= 0; ii--) {
  1461. nextMenuItem = this.getParent().get(ii);
  1462. if ( typeof nextMenuItem.isVisible == "function" && nextMenuItem.isVisible() &&
  1463. typeof nextMenuItem.setFocus == "function") {
  1464. nextMenuItem.setFocus();
  1465. break;
  1466. }
  1467. // If we reached the top but didn't start from the bottom,
  1468. // then keep going from the bottom
  1469. if (ii == 0 && !bStartedFromBottom) {
  1470. bStartedFromBottom = true;
  1471. ii = numItems;
  1472. }
  1473. }
  1474. break;
  1475. }
  1476. }
  1477. }
  1478. //left/right key
  1479. else if (evt.keyCode == 37 || evt.keyCode == 39) {
  1480. if(this.isEnabled() && this.getMenu() != null) {
  1481. //Expand menu if it will open to the left or right (cascaded menu)
  1482. var menu = this.getMenu();
  1483. if(this.getMenuType() == 'cascaded') {
  1484. // stop notification so we do not hide the menu
  1485. performNotification = false;
  1486. // show the menu
  1487. if(menu.isVisible() == false) {
  1488. menu.setHTMLContainer(target.document ? target.document.body : target.ownerDocument.body);
  1489. menu.draw();
  1490. menu.show();
  1491. }
  1492. }
  1493. } else {
  1494. //Collapse menu if it's been opened from the left or right (cascaded menu)
  1495. // stop notification so we do not hide the parent menu
  1496. performNotification = false;
  1497. parent = this.getParent();
  1498. if(parent && parent.getParent() && parent.getParent().getMenuType() == "cascaded") {
  1499. // hide the menu
  1500. parent.hide();
  1501. }
  1502. }
  1503. }
  1504. // send the message up to our parent
  1505. if(performNotification && this.getParent() != null && typeof this.getParent().onkeydown == "function") {
  1506. this.getParent().onkeydown(evt);
  1507. }
  1508. // notify our observers of this event
  1509. this.getObservers().notify(CMenuItem_onkeydown);
  1510. }
  1511. function CMenuEntry_onkeypress(evt) {
  1512. //get the event in a cross-browser fashion
  1513. evt = (evt) ? evt : ((event) ? event : null);
  1514. // in firefox the keyCode will always be zero, so use the charCode if it's there. In IE, the charCode is undefined.
  1515. var keyPressed = evt.keyCode;
  1516. if (keyPressed == 0 && typeof evt.charCode != "undefined") {
  1517. keyPressed = evt.charCode;
  1518. }
  1519. if(typeof evt == "object" && evt != null) {
  1520. var target = evt.currentTarget || evt.srcElement;
  1521. //flag which determines if we notify observers of the event
  1522. var performNotification = true;
  1523. // in Firefox the onkeypress gets called for the tab key. Make sure we don't notify our
  1524. // observers since the menu will get closed
  1525. if (keyPressed == 9 || keyPressed == 37 || keyPressed == 38 || keyPressed == 39 || keyPressed == 40) {
  1526. performNotification = false;
  1527. }
  1528. //check for the Enter or Space key
  1529. else if (keyPressed == 13 || keyPressed == 32) {
  1530. //menu item should always be enabled if you can tab to it, but just in case
  1531. if(!this.isEnabled()) {
  1532. return;
  1533. }
  1534. if(this.getMenu() != null) {
  1535. var menu = this.getMenu();
  1536. if(this.getMenuType() == 'cascaded') {
  1537. // stop notification so we do not hide the menu
  1538. performNotification = false;
  1539. // show the menu
  1540. if(menu.isVisible() == false) {
  1541. menu.setHTMLContainer(target.document ? target.document.body : target.ownerDocument.body);
  1542. menu.draw();
  1543. menu.show();
  1544. } else {
  1545. menu.remove();
  1546. }
  1547. } else if(this.getMenuType() == 'dropDown') {
  1548. if(menu.isVisible() == false) {
  1549. // the user clicked on the menu
  1550. menu.setHTMLContainer(target.document ? target.document.body : target.ownerDocument.body);
  1551. menu.draw();
  1552. menu.show();
  1553. } else {
  1554. menu.remove();
  1555. }
  1556. }
  1557. } else {
  1558. // handle the event
  1559. eval(this.getAction());
  1560. }
  1561. }
  1562. //check for Esc key
  1563. else if (keyPressed == 27) {
  1564. //close the menu
  1565. this.getParent().hide();
  1566. //cancel event being bubbled up the hierarchy since only one level of menus needs to hide
  1567. return;
  1568. }
  1569. if (performNotification) {
  1570. // send the message up to our parent
  1571. if(this.getParent() != null && typeof this.getParent().onkeypress == "function") {
  1572. this.getParent().onkeypress(evt);
  1573. }
  1574. // notify our observers of this event
  1575. this.getObservers().notify(CMenuItem_onkeypress);
  1576. }
  1577. }
  1578. // only cancel the event for the Enter k or Space ey
  1579. if (keyPressed == 13 || keyPressed == 0 || keyPressed == 40 || keyPressed == 38) {
  1580. if(evt != null) {
  1581. evt.cancelBubble = true;
  1582. }
  1583. return false;
  1584. }
  1585. return true;
  1586. }
  1587. function CMenuEntry_getMenu() {
  1588. return this.m_menu;
  1589. }
  1590. function CMenuEntry_getMenuType() {
  1591. return this.m_menuType;
  1592. }
  1593. function CMenuEntry_isEnabled() {
  1594. return this.m_bEnabled;
  1595. }
  1596. function CMenuEntry_isInMenu()
  1597. {
  1598. return this.getParent() instanceof CMenu;
  1599. }
  1600. function CMenuEntry_getAction() {
  1601. return this.m_action;
  1602. }
  1603. function CMenuEntry_setAction(action) {
  1604. this.m_action = action;
  1605. }
  1606. CMenuEntry.prototype.getObservers = CMenuEntry_getObservers;
  1607. CMenuEntry.prototype.setId = CMenuEntry_setId;
  1608. CMenuEntry.prototype.getId = CMenuEntry_getId;
  1609. CMenuEntry.prototype.onkeypress = CMenuEntry_onkeypress;
  1610. CMenuEntry.prototype.onkeydown = CMenuEntry_onkeydown;
  1611. CMenuEntry.prototype.getMenu = CMenuEntry_getMenu;
  1612. CMenuEntry.prototype.getMenuType = CMenuEntry_getMenuType;
  1613. CMenuEntry.prototype.setParent = CMenuEntry_setParent;
  1614. CMenuEntry.prototype.getParent = CMenuEntry_getParent;
  1615. CMenuEntry.prototype.setWebContentRoot = CMenuEntry_setWebContentRoot;
  1616. CMenuEntry.prototype.isEnabled = CMenuEntry_isEnabled;
  1617. CMenuEntry.prototype.isInMenu = CMenuEntry_isInMenu;
  1618. CMenuEntry.prototype.getAction = CMenuEntry_getAction;
  1619. CMenuEntry.prototype.setAction = CMenuEntry_setAction;
  1620. // Copyright (C) 2008 Cognos Incorporated. All rights reserved.
  1621. // Cognos (R) is a trademark of Cognos Incorporated.
  1622. /*-----------------------------------------------------------------------------------------------------
  1623. Class : CMenuItem
  1624. Description :
  1625. -----------------------------------------------------------------------------------------------------*/
  1626. var theMenuCnt = 1;
  1627. function CMenuItem(parent, label, action, iconPath, style, webContentRoot, skin) {
  1628. this.m_label = label;
  1629. if (this.m_label)
  1630. {
  1631. this.m_label = this.m_label.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
  1632. }
  1633. this.setId(escape(label) + theMenuCnt++);
  1634. this.m_bVisible = true;
  1635. this.setAction(action);
  1636. this.setWebContentRoot(webContentRoot);
  1637. var v_sIconPath = iconPath
  1638. if ((typeof gCognosViewer != "undefined") && (gCognosViewer.envParams["isTitan"]) && (gCognosViewer.envParams["isTitan"] == true))
  1639. {
  1640. v_sIconPath = "blankIcon";
  1641. }
  1642. this.m_icon = new CIcon(v_sIconPath, "", this.m_webContentRoot);
  1643. this.setParent(parent);
  1644. this.m_style = style;
  1645. this.m_observers = new CObserver(this);
  1646. //skin folder
  1647. if (typeof skin != "undefined" && skin != "")
  1648. {
  1649. this.m_sSkin = skin;
  1650. }
  1651. else
  1652. {
  1653. this.m_sSkin = (typeof getPromptSkin != "undefined" ? getPromptSkin() : this.m_webContentRoot + "/skins/corporate");
  1654. }
  1655. if(typeof this.m_parent == "object" && typeof this.m_parent.add == "function") {
  1656. this.m_parent.add(this);
  1657. }
  1658. this.m_sDropDownArrow = "dropdown_arrow_banner.gif";
  1659. }
  1660. CMenuItem.prototype = new CMenuEntry();
  1661. CMenuItem.prototype.setDropDownArrow = function(dropDownArrow)
  1662. {
  1663. this.m_sDropDownArrow = dropDownArrow;
  1664. };
  1665. CMenuItem.prototype.getDropDownArrow = function()
  1666. {
  1667. return this.m_sDropDownArrow;
  1668. };
  1669. function CMenuItem_setId(id) {
  1670. this.m_id = id;
  1671. }
  1672. function CMenuItem_setIcon(iconPath) {
  1673. this.m_icon.setPath(iconPath);
  1674. }
  1675. function CMenuItem_setToolTip(tooltip) {
  1676. this.m_icon.m_toolTip = tooltip;
  1677. }
  1678. function CMenuItem_getToolTip() {
  1679. return this.m_icon.m_toolTip;
  1680. }
  1681. function CMenuItem_setAltText(sAltText) {
  1682. this.m_sAltText = sAltText;
  1683. }
  1684. function CMenuItem_getAltText() {
  1685. if (this.m_sAltText) {
  1686. return this.m_sAltText;
  1687. } else {
  1688. return "";
  1689. }
  1690. }
  1691. function CMenuItem_genARIATags() {
  1692. var html = "";
  1693. if (this.isInMenu()) {
  1694. html += ' role="menuitem" ';
  1695. } else {
  1696. html += ' role="button" ';
  1697. }
  1698. if (this.m_menuType=='dropDown' || this.m_menuType == 'cascaded') {
  1699. html += ' aria-haspopup="true" ';
  1700. }
  1701. if (this.getAltText().length == 0) {
  1702. this.setAltText(this.m_label);
  1703. }
  1704. if ((this.getAltText() && this.getAltText().length > 0) || (this.m_icon && this.m_icon.getToolTip())) {
  1705. html += ' aria-labelledby="' + this.m_id + 'label" ';
  1706. }
  1707. if (!this.isEnabled()) {
  1708. html += ' aria-disabled="true" ';
  1709. }
  1710. return html;
  1711. }
  1712. function CMenuItem_genMenuItemAltText() {
  1713. var html = "";
  1714. if ((this.getAltText() && this.getAltText().length > 0) || (this.m_icon && this.m_icon.getToolTip())) {
  1715. html += '<div style="position: absolute; overflow: hidden; width: 0; height: 0;" id="' + this.m_id + 'label">';
  1716. if (this.getAltText() && this.getAltText().length > 0) {
  1717. html += this.getAltText();
  1718. } else {
  1719. html += this.m_icon.getToolTip();
  1720. }
  1721. html += '</div>';
  1722. }
  1723. return html;
  1724. }
  1725. function CMenuItem_draw() {
  1726. var html = '<div>';
  1727. var bSiblingContainsIcon = false, siblingCount = null, siblingMenuItem = null, siblingIdx = 0;
  1728. if(this.m_menu == null || this.m_menuType=='dropDown') {
  1729. html += '<table ';
  1730. html += this.genARIATags();
  1731. // If we're in a menu then allow the user to move to a disabled menuItem.
  1732. // If it's a toolbar button, don't let the user tab to it
  1733. if (this.isInMenu())
  1734. {
  1735. if (this.isEnabled()) {
  1736. html += ' hideFocus="true" ';
  1737. }
  1738. html += ' tabIndex="0" ';
  1739. }
  1740. else if (this.isEnabled())
  1741. {
  1742. html += ' tabIndex="0"';
  1743. }
  1744. html += ' width="100%" ';
  1745. html += 'class="';
  1746. if(typeof this.getStyle() == "object") {
  1747. if(this.isEnabled()) {
  1748. html += this.getStyle().getNormalState();
  1749. }
  1750. else {
  1751. html += this.getStyle().getDisabledState();
  1752. }
  1753. }
  1754. html += '" id="';
  1755. html += this.getId();
  1756. html += '" cellpadding="0" cellspacing="0" style="margin-bottom:1px;"><tr>';
  1757. bSiblingContainsIcon = false;
  1758. if(this.m_icon.getPath() == "" && this.m_parent instanceof CMenu) {
  1759. siblingCount = this.m_parent.getNumItems();
  1760. for(siblingIdx = 0; siblingIdx < siblingCount; ++siblingIdx) {
  1761. siblingMenuItem = this.m_parent.get(siblingIdx);
  1762. if(typeof siblingMenuItem.getIcon == "function" && siblingMenuItem.getIcon().getPath()) {
  1763. // temporary for now to get alignment working on the context menu.
  1764. bSiblingContainsIcon = true;
  1765. break;
  1766. }
  1767. }
  1768. }
  1769. if(bSiblingContainsIcon || this.m_icon.getPath() != "")
  1770. {
  1771. var f = "";
  1772. if(getViewerDirection()=="rtl"){
  1773. f = ' float: right;';
  1774. }
  1775. html += '<td width="16" style="padding-right: 2px; padding-left: 2px;'+ f + '">';
  1776. if(this.m_icon.getPath() != "")
  1777. {
  1778. html += this.m_icon.draw();
  1779. }
  1780. else
  1781. {
  1782. html += '<img alt="" src="' + this.m_webContentRoot + '/common/images/spacer.gif" width="16"/>';
  1783. }
  1784. html += '</td>';
  1785. }
  1786. if(getViewerDirection()=="rtl"){
  1787. html += '<td nowrap="nowrap" align="right">';
  1788. }else{
  1789. html += '<td nowrap="nowrap" align="left">';
  1790. }
  1791. html += this.m_label;
  1792. html += this.genMenuItemAltText();
  1793. html += '</td>';
  1794. if(this.m_menuType=='dropDown')
  1795. {
  1796. html += '<td width="10%" align="right" style="padding-right: 3px;padding-left: 3px">';
  1797. html += '<img alt="" src="' + this.m_sSkin;
  1798. // TODO remove this once dropdown_arrow.gif makes it into the shared directory
  1799. if (this.getDropDownArrow() == 'dropdown_arrow_banner.gif')
  1800. {
  1801. html += '/shared/images/';
  1802. }
  1803. else
  1804. {
  1805. html += '/portal/images/';
  1806. }
  1807. html += this.getDropDownArrow() + '" WIDTH="7" HEIGHT="16" style="vertical-align:middle;"/>';
  1808. html += '</td>';
  1809. }
  1810. html += '</tr></table></div>';
  1811. } else {
  1812. html += '<table';
  1813. html += this.genARIATags();
  1814. // If we're in a menu then allow the user to move to a disabled menuItem.
  1815. // If it's a toolbar button, don't let the user tab to it
  1816. if (this.isEnabled() || this.isInMenu())
  1817. {
  1818. html += ' tabIndex="0" hideFocus="true"';
  1819. }
  1820. html += ' width="100%" class="';
  1821. if(typeof this.getStyle() == "object") {
  1822. if(this.isEnabled()) {
  1823. html += this.getStyle().getNormalState();
  1824. }
  1825. else {
  1826. html += this.getStyle().getDisabledState();
  1827. }
  1828. }
  1829. html += '" id="';
  1830. html += this.getId();
  1831. html += '" cellpadding="0" cellspacing="0" style="margin-bottom:1px;"><tr>';
  1832. html += '<td';
  1833. bSiblingContainsIcon = false;
  1834. if(this.m_icon.getPath() == "") {
  1835. siblingCount = this.m_parent.getNumItems();
  1836. for(siblingIdx = 0; siblingIdx < siblingCount; ++siblingIdx) {
  1837. siblingMenuItem = this.m_parent.get(siblingIdx);
  1838. if(typeof siblingMenuItem.getIcon == "function" && siblingMenuItem.getIcon().getPath()) {
  1839. // temporary for now to get alignment working on the context menu.
  1840. bSiblingContainsIcon = true;
  1841. break;
  1842. }
  1843. }
  1844. }
  1845. if(bSiblingContainsIcon || this.m_icon.getPath() != "") {
  1846. html += ' width="16" style="padding-right: 2px; padding-left: 2px;">';
  1847. } else {
  1848. html += ' width="1">';
  1849. }
  1850. html += this.m_icon.draw();
  1851. html += '</td>';
  1852. if(getViewerDirection()=="rtl"){
  1853. html += '<td nowrap="nowrap" align="right">';
  1854. }else{
  1855. html += '<td nowrap="nowrap" align="left">';
  1856. }
  1857. html += this.m_label;
  1858. html += this.genMenuItemAltText();
  1859. html += '</td>';
  1860. if(getViewerDirection()=="rtl"){
  1861. html += '<td width="10%" align="left">';
  1862. html += '<img style="vertical-align:middle;" alt="" src="' + this.m_sSkin + '/viewer/images/menu_expand_rtl.gif" WIDTH="13" HEIGHT="13"/>';
  1863. }else{
  1864. html += '<td width="10%" align="right">';
  1865. html += '<img style="vertical-align:middle;" alt="" src="' + this.m_sSkin + '/viewer/images/menu_expand.gif" WIDTH="13" HEIGHT="13"/>';
  1866. }
  1867. html += '</td>';
  1868. html += '</tr></table>';
  1869. html += '</div>';
  1870. }
  1871. return html;
  1872. }
  1873. function CMenuItem_onmouseover(evt) {
  1874. //get the event in a cross-browser fashion
  1875. evt = (evt) ? evt : ((event) ? event : null);
  1876. // get the menu item from the html element which is handling the event
  1877. var menuItem = null;
  1878. if(typeof this.menuItem != "undefined") {
  1879. menuItem = this.menuItem;
  1880. }
  1881. else if (this instanceof CMenuItem) {
  1882. menuItem = this;
  1883. }
  1884. if(menuItem == null || !(menuItem instanceof CMenuItem) || !menuItem.isEnabled()) {
  1885. return;
  1886. }
  1887. var menu = menuItem.getMenu();
  1888. if(typeof menuItem.getStyle() == "object" && (menu != null || typeof menuItem.getIcon().getPath() != "undefined")) {
  1889. this.className = menuItem.getStyle().getRolloverState();
  1890. }
  1891. if(menu != null) {
  1892. var pageWidth = 0;
  1893. var pageHeight = 0;
  1894. if(typeof window.innerWidth != "undefined") {
  1895. pageWidth = window.innerWidth;
  1896. }
  1897. else {
  1898. pageWidth = document.body.clientWidth;
  1899. }
  1900. if(typeof window.innerHeight != "undefined") {
  1901. pageHeight = window.innerHeight;
  1902. }
  1903. else {
  1904. pageHeight = document.body.clientHeight;
  1905. }
  1906. if(menuItem.getMenuType() == 'cascaded') {
  1907. if(menu.isVisible() == false) {
  1908. menu.setHTMLContainer(this.document ? this.document.body : this.ownerDocument.body);
  1909. menu.draw();
  1910. menu.show();
  1911. }
  1912. } else if(menuItem.getMenuType() == 'dropDown') {
  1913. // check with the parent to see if there current are menus open. If there are, we'll automatically open this menu
  1914. var menuItemParent = menuItem.getParent();
  1915. var numOfItems = menuItemParent.getNumItems();
  1916. for(var i = 0; i < numOfItems; ++i) {
  1917. var currentItem = menuItemParent.get(i);
  1918. if(currentItem != menuItem && typeof currentItem.getMenu == "function" && currentItem.getMenu() && currentItem.getMenu().isVisible()) {
  1919. // the user clicked on the menu
  1920. menu.setHTMLContainer(this.document ? this.document.body : this.ownerDocument.body);
  1921. menu.draw();
  1922. menu.show();
  1923. break;
  1924. }
  1925. }
  1926. }
  1927. }
  1928. // send the message up to our parent
  1929. if(menuItem.getParent() != null && typeof menuItem.getParent().onmouseover == "function") {
  1930. menuItem.getParent().onmouseover(evt);
  1931. }
  1932. // notify our observers of this event
  1933. menuItem.getObservers().notify(CMenuItem_onmouseover);
  1934. }
  1935. function CMenuItem_onfocus(evt) {
  1936. //get the event in a cross-browser fashion
  1937. evt = (evt) ? evt : ((event) ? event : null);
  1938. // get the menu item from the html element which is handling the event
  1939. var menuItem = null;
  1940. if(typeof this.menuItem != "undefined") {
  1941. menuItem = this.menuItem;
  1942. }
  1943. else if (this instanceof CMenuItem) {
  1944. menuItem = this;
  1945. }
  1946. if(menuItem == null || !(menuItem instanceof CMenuItem) || !menuItem.isEnabled()) {
  1947. return;
  1948. }
  1949. if(typeof menuItem.getStyle() == "object") {
  1950. this.className = menuItem.getStyle().getRolloverState();
  1951. }
  1952. // send the message up to our parent (a fake mouseover)
  1953. if(menuItem.getParent() != null && typeof menuItem.getParent().onmouseover == "function") {
  1954. menuItem.getParent().onmouseover(evt);
  1955. }
  1956. // notify our observers of this event
  1957. menuItem.getObservers().notify(CMenuItem_onfocus);
  1958. }
  1959. function CMenuItem_onmouseout(evt) {
  1960. //get the event in a cross-browser fashion
  1961. evt = (evt) ? evt : ((event) ? event : null);
  1962. var menuItem = null;
  1963. if(typeof this.menuItem != "undefined") {
  1964. menuItem = this.menuItem;
  1965. }
  1966. else if (this instanceof CMenuItem) {
  1967. menuItem = this;
  1968. }
  1969. // get the menu item from the html element which is handling the event
  1970. if(menuItem == null || !(menuItem instanceof CMenuItem) || !menuItem.isEnabled()) {
  1971. return;
  1972. }
  1973. if(typeof menuItem.getStyle() == "object") {
  1974. this.className = menuItem.getStyle().getNormalState();
  1975. }
  1976. // send the message up to our parent
  1977. if(menuItem.getParent() != null && typeof menuItem.getParent().onmouseout == "function") {
  1978. menuItem.getParent().onmouseout(evt);
  1979. }
  1980. // notify our observers of this event
  1981. menuItem.getObservers().notify(CMenuItem_onmouseout);
  1982. }
  1983. function CMenuItem_onclick(evt) {
  1984. //get the event in a cross-browser fashion
  1985. evt = (evt) ? evt : ((event) ? event : null);
  1986. if(evt != null) {
  1987. evt.cancelBubble = true;
  1988. }
  1989. return false;
  1990. }
  1991. function CMenuItem_onmouseup(evt) {
  1992. //get the event in a cross-browser fashion
  1993. evt = (evt) ? evt : ((event) ? event : null);
  1994. var menuItem = null;
  1995. if(typeof this.menuItem != "undefined") {
  1996. menuItem = this.menuItem;
  1997. }
  1998. else if (this instanceof CMenuItem) {
  1999. menuItem = this;
  2000. }
  2001. if(menuItem != null && menuItem instanceof CMenuItem) {
  2002. if(!menuItem.isEnabled()) {
  2003. return;
  2004. }
  2005. if(menuItem.getMenu() != null) {
  2006. if(menuItem.getMenuType() == 'cascaded') {
  2007. // do nothing for now
  2008. } else if(menuItem.getMenuType() == 'dropDown')
  2009. {
  2010. var menu = menuItem.getMenu();
  2011. if(menu.isVisible() == false)
  2012. {
  2013. if (!this.document && !this.ownerDocument) {
  2014. return;
  2015. }
  2016. // the user clicked on the menu
  2017. menu.setHTMLContainer(this.document ? this.document.body : this.ownerDocument.body);
  2018. menu.draw();
  2019. menu.show();
  2020. } else {
  2021. menu.remove();
  2022. }
  2023. }
  2024. } else {
  2025. // handle the event
  2026. eval(menuItem.getAction());
  2027. }
  2028. if (typeof getReportFrame != "undefined" && typeof getReportFrame().clearTextSelection != "undefined") {
  2029. getReportFrame().clearTextSelection();
  2030. }
  2031. else if (typeof clearTextSelection != "undefined") {
  2032. clearTextSelection();
  2033. }
  2034. if(menuItem.getMenuType() != 'cascaded') {
  2035. // send the message up to our parent
  2036. if(menuItem.getParent() != null && typeof menuItem.getParent().onmouseup == "function") {
  2037. menuItem.getParent().onmouseup(evt);
  2038. }
  2039. // notify our observers of this event
  2040. menuItem.getObservers().notify(CMenuItem_onmouseup);
  2041. }
  2042. if(typeof this.menuItem != "undefined" && menuItem.getMenu()!=null && menuItem.getMenuType()=='cascaded' && menuItem.getAction() != "")
  2043. {
  2044. // handle the event
  2045. eval(menuItem.getAction());
  2046. }
  2047. }
  2048. if(evt != null) {
  2049. evt.cancelBubble = true;
  2050. }
  2051. return false;
  2052. }
  2053. function CMenuItem_onkeydown(evt) {
  2054. //get the event in a cross-browser fashion
  2055. var menuItem = null;
  2056. if(typeof this.menuItem != "undefined") {
  2057. menuItem = this.menuItem;
  2058. }
  2059. else if (this instanceof CMenuItem) {
  2060. menuItem = this;
  2061. }
  2062. if(menuItem == null || !(menuItem instanceof CMenuItem)) {
  2063. return;
  2064. }
  2065. return CMenuEntry_onkeydown.call(menuItem, evt);
  2066. }
  2067. function CMenuItem_onkeypress(evt) {
  2068. //get the event in a cross-browser fashion
  2069. evt = (evt) ? evt : ((event) ? event : null);
  2070. var menuItem = null;
  2071. if(typeof this.menuItem != "undefined") {
  2072. menuItem = this.menuItem;
  2073. }
  2074. else if (this instanceof CMenuItem) {
  2075. menuItem = this;
  2076. }
  2077. if(menuItem != null && menuItem instanceof CMenuItem) {
  2078. return CMenuEntry_onkeypress.call(menuItem, evt);
  2079. }
  2080. }
  2081. function CMenuItem_createDropDownMenu(menuStyle) {
  2082. this.m_menu = new CMenu('dropDownMenu_'+this.getId(),menuStyle, this.m_webContentRoot);
  2083. this.m_menu.setParent(this);
  2084. this.m_menuType = 'dropDown';
  2085. return this.m_menu;
  2086. }
  2087. function CMenuItem_createCascadedMenu(menuStyle) {
  2088. this.m_menu = new CMenu('cascadedMenu_'+this.getId(),menuStyle, this.m_webContentRoot);
  2089. this.m_menu.setParent(this);
  2090. this.m_originalMenuType = this.m_menuType;
  2091. this.m_menuType = 'cascaded';
  2092. return this.m_menu;
  2093. }
  2094. function CMenuItem_clearCascadedMenu()
  2095. {
  2096. if (this.m_menu) {
  2097. this.m_menu.remove();
  2098. this.m_menu = null;
  2099. }
  2100. if (this.m_originalMenuType) {
  2101. this.m_menuType = this.m_originalMenuType;
  2102. }
  2103. }
  2104. function CMenuItem_addOwnerDrawControl(control, type) {
  2105. this.m_menu = control;
  2106. this.m_menuType = type;
  2107. if(typeof control.setParent != "undefined") {
  2108. this.m_menu.setParent(this);
  2109. }
  2110. }
  2111. function CMenuItem_attachEvents() {
  2112. if(typeof this.getParent().getHTMLContainer != "function") {
  2113. return; // this method must be implemented by the parent
  2114. }
  2115. var htmlContainer = this.getParent().getHTMLContainer();
  2116. if(htmlContainer == null) {
  2117. return;
  2118. }
  2119. var hMenuItem = eval(htmlContainer.document ? htmlContainer.document.getElementById(this.getId()) : htmlContainer.ownerDocument.getElementById(this.getId()));
  2120. if(hMenuItem == null) {
  2121. return; // just to be safe
  2122. }
  2123. hMenuItem.onmouseover = this.onmouseover;
  2124. hMenuItem.onmouseout = this.onmouseout;
  2125. hMenuItem.onmouseup = this.onmouseup;
  2126. hMenuItem.onkeypress = this.onkeypress;
  2127. hMenuItem.onfocus = this.onfocus;
  2128. hMenuItem.onblur = this.onblur;
  2129. hMenuItem.onkeydown = this.onkeydown;
  2130. hMenuItem.onclick = this.onclick;
  2131. hMenuItem.menuItem = eval(this);
  2132. }
  2133. function CMenuItem_remove() {
  2134. }
  2135. function CMenuItem_getStyle() {
  2136. return this.m_style;
  2137. }
  2138. function CMenuItem_setStyle(style) {
  2139. this.m_style = style;
  2140. }
  2141. function CMenuItem_hide() {
  2142. this.m_bVisible = false;
  2143. }
  2144. function CMenuItem_show() {
  2145. this.m_bVisible = true;
  2146. }
  2147. function CMenuItem_enable() {
  2148. if(typeof this.getStyle() == "object") {
  2149. if(typeof this.getParent().getHTMLContainer == "function") {
  2150. var htmlContainer = this.getParent().getHTMLContainer();
  2151. if(htmlContainer != null) {
  2152. var htmlElement = htmlContainer.document ? htmlContainer.document.getElementById(this.getId()) : htmlContainer.ownerDocument.getElementById(this.getId());
  2153. if(htmlElement != null) {
  2154. htmlElement.className = this.getStyle().getNormalState();
  2155. }
  2156. }
  2157. }
  2158. this.m_bEnabled = true;
  2159. this.getIcon().enable();
  2160. this.updateHTML();
  2161. }
  2162. }
  2163. function CMenuItem_updateHTML()
  2164. {
  2165. if(typeof this.getStyle() == "object")
  2166. {
  2167. if(typeof this.getParent().getHTMLContainer == "function")
  2168. {
  2169. var htmlContainer = this.getParent().getHTMLContainer();
  2170. if(htmlContainer != null)
  2171. {
  2172. var htmlElement = htmlContainer.document ? htmlContainer.document.getElementById(this.getId()) : htmlContainer.ownerDocument.getElementById(this.getId());
  2173. if(htmlElement != null)
  2174. {
  2175. var toolbarImage = htmlElement.getElementsByTagName("img");
  2176. if(typeof toolbarImage != "undefined")
  2177. {
  2178. if (this.getIcon())
  2179. {
  2180. if(this.getIcon().isEnabled())
  2181. {
  2182. toolbarImage[0].src = this.getIcon().getPath();
  2183. }
  2184. else
  2185. {
  2186. toolbarImage[0].src = this.getIcon().getDisabledImagePath();
  2187. }
  2188. }
  2189. if(this.getToolTip())
  2190. {
  2191. htmlElement.title = this.getToolTip();
  2192. toolbarImage[0].title = this.getToolTip();
  2193. }
  2194. }
  2195. if (this.isEnabled())
  2196. {
  2197. if (htmlElement.getAttribute("aria-disabled"))
  2198. {
  2199. htmlElement.removeAttribute("aria-disabled");
  2200. }
  2201. }
  2202. else
  2203. {
  2204. htmlElement.setAttribute("aria-disabled", "true");
  2205. }
  2206. var dropDownIcon;
  2207. if(this.getStyle().getActiveState() != this.getStyle().getDisabledState())
  2208. {
  2209. htmlElement.tabIndex = 0;
  2210. if (this.getMenu() != null && !this.m_bHideDropDown && htmlElement.nextSibling)
  2211. {
  2212. htmlElement.nextSibling.tabIndex = 0;
  2213. htmlElement.nextSibling.title = this.getToolTip();
  2214. dropDownIcon = htmlElement.nextSibling.getElementsByTagName("img");
  2215. if(dropDownIcon != null)
  2216. {
  2217. dropDownIcon[0].title = this.getToolTip();
  2218. }
  2219. }
  2220. }
  2221. else
  2222. {
  2223. if (htmlElement.tabIndex != "undefined")
  2224. {
  2225. htmlElement.removeAttribute("tabIndex");
  2226. if (this.getMenu() != null)
  2227. {
  2228. htmlElement.nextSibling.removeAttribute("tabIndex");
  2229. htmlElement.nextSibling.title = this.getToolTip();
  2230. dropDownIcon = htmlElement.nextSibling.getElementsByTagName("img");
  2231. if(dropDownIcon != null)
  2232. {
  2233. dropDownIcon[0].title = this.getToolTip();
  2234. }
  2235. }
  2236. }
  2237. }
  2238. htmlElement.className = this.getStyle().getActiveState();
  2239. }
  2240. }
  2241. }
  2242. }
  2243. }
  2244. function CMenuItem_disable() {
  2245. if(typeof this.getStyle() == "object") {
  2246. if(typeof this.getParent().getHTMLContainer == "function") {
  2247. var htmlContainer = this.getParent().getHTMLContainer();
  2248. if(htmlContainer != null) {
  2249. var htmlElement = htmlContainer.document ? htmlContainer.document.getElementById(this.getId()) : htmlContainer.ownerDocument.getElementById(this.getId());
  2250. if(htmlElement != null) {
  2251. htmlElement.className = this.getStyle().getDisabledState();
  2252. }
  2253. }
  2254. }
  2255. this.m_bEnabled = false;
  2256. this.getIcon().disable();
  2257. this.updateHTML();
  2258. }
  2259. }
  2260. function CMenuItem_isVisible() {
  2261. return this.m_bVisible;
  2262. }
  2263. function CMenuItem_getIcon() {
  2264. return this.m_icon;
  2265. }
  2266. function CMenuItem_getLabel() {
  2267. return this.m_label;
  2268. }
  2269. function CMenuItem_setFocus() {
  2270. var e = document.getElementById(this.m_id);
  2271. if(e) {
  2272. e.focus();
  2273. return true;
  2274. }
  2275. return false;
  2276. }
  2277. CMenuItem.prototype.draw = CMenuItem_draw;
  2278. CMenuItem.prototype.onmouseover = CMenuItem_onmouseover;
  2279. CMenuItem.prototype.onmouseout = CMenuItem_onmouseout;
  2280. CMenuItem.prototype.onmouseup = CMenuItem_onmouseup;
  2281. CMenuItem.prototype.onkeypress = CMenuItem_onkeypress;
  2282. CMenuItem.prototype.onkeydown = CMenuItem_onkeydown;
  2283. CMenuItem.prototype.onfocus = CMenuItem_onfocus;
  2284. CMenuItem.prototype.onblur = CMenuItem_onmouseout;
  2285. CMenuItem.prototype.onclick = CMenuItem_onclick;
  2286. CMenuItem.prototype.attachEvents = CMenuItem_attachEvents;
  2287. CMenuItem.prototype.remove = CMenuItem_remove;
  2288. CMenuItem.prototype.setStyle = CMenuItem_setStyle;
  2289. CMenuItem.prototype.getStyle = CMenuItem_getStyle;
  2290. CMenuItem.prototype.createDropDownMenu = CMenuItem_createDropDownMenu;
  2291. CMenuItem.prototype.createCascadedMenu = CMenuItem_createCascadedMenu;
  2292. CMenuItem.prototype.clearCascadedMenu = CMenuItem_clearCascadedMenu;
  2293. CMenuItem.prototype.addOwnerDrawControl = CMenuItem_addOwnerDrawControl;
  2294. CMenuItem.prototype.isVisible = CMenuItem_isVisible;
  2295. CMenuItem.prototype.hide = CMenuItem_hide;
  2296. CMenuItem.prototype.show = CMenuItem_show;
  2297. CMenuItem.prototype.enable = CMenuItem_enable;
  2298. CMenuItem.prototype.disable = CMenuItem_disable;
  2299. CMenuItem.prototype.getIcon = CMenuItem_getIcon;
  2300. CMenuItem.prototype.setIcon = CMenuItem_setIcon;
  2301. CMenuItem.prototype.getLabel = CMenuItem_getLabel;
  2302. CMenuItem.prototype.setFocus = CMenuItem_setFocus;
  2303. CMenuItem.prototype.setToolTip = CMenuItem_setToolTip;
  2304. CMenuItem.prototype.getToolTip = CMenuItem_getToolTip;
  2305. CMenuItem.prototype.updateHTML = CMenuItem_updateHTML;
  2306. CMenuItem.prototype.update = new Function("return true");
  2307. CMenuItem.prototype.genARIATags = CMenuItem_genARIATags;
  2308. CMenuItem.prototype.setAltText = CMenuItem_setAltText;
  2309. CMenuItem.prototype.getAltText = CMenuItem_getAltText;
  2310. CMenuItem.prototype.genMenuItemAltText = CMenuItem_genMenuItemAltText;
  2311. /*
  2312. Class CSeperator
  2313. todo : Add commments describing class....
  2314. */
  2315. /*
  2316. CSeperator styles:
  2317. 1. horizonal_blank
  2318. 2. vertical_blank
  2319. 3. vertical_line
  2320. 4. horizonal_line
  2321. */
  2322. function CSeperator(type, size, style, webContentRoot) {
  2323. this.m_type=type;
  2324. this.m_size=size;
  2325. this.m_bVisible = true;
  2326. if(style !== null && typeof style == "object") {
  2327. this.m_style = new CUIStyle(style.getNormalState(),style.getRolloverState(),style.getDepressedState(),style.getDepressedRolloverState(),style.getDisabledState());
  2328. }
  2329. else {
  2330. this.m_style = new CUIStyle("","","","","");
  2331. }
  2332. if (typeof webContentRoot != "undefined" && webContentRoot != "")
  2333. {
  2334. this.m_webContentRoot = webContentRoot;
  2335. }
  2336. else
  2337. {
  2338. this.m_webContentRoot = "..";
  2339. }
  2340. this.m_toolbarSeperatorClass = "bannerDivider";
  2341. }
  2342. CSeperator.prototype.setToolbarSeperatorClass = function(seperatorClass)
  2343. {
  2344. this.m_toolbarSeperatorClass = seperatorClass;
  2345. };
  2346. CSeperator.prototype.getToolbarSeperatorClass = function()
  2347. {
  2348. return this.m_toolbarSeperatorClass;
  2349. };
  2350. CSeperator.prototype.setWebContentRoot = function(sWebContentRoot)
  2351. {
  2352. this.m_webContentRoot = sWebContentRoot;
  2353. };
  2354. function CSeperator_draw() {
  2355. if(this.m_style == "") {
  2356. return;
  2357. }
  2358. var html="";
  2359. switch(this.m_type) {
  2360. case "horizonal_blank":
  2361. html += '<td style="padding:0px;"><img border="0" alt="" src="' + this.m_webContentRoot + '/common/images/spacer.gif" height="1" width="';
  2362. html += this.m_size;
  2363. html += '"/></td>';
  2364. break;
  2365. case "horizontal_line":
  2366. html += '<div class="' + this.getStyle().getActiveState() + '"></div>';
  2367. break;
  2368. case "vertical_blank":
  2369. html += '<tr>';
  2370. html += '<td style="padding:0px;"><img border="0" alt="" src="' + this.m_webContentRoot + '/common/images/spacer.gif" width="1" height="';
  2371. html += this.m_size;
  2372. html += '"/></td></tr>';
  2373. break;
  2374. case "vertical_line":
  2375. html += '<td class="toolbarVerticalSeperator"><div class="' + this.getToolbarSeperatorClass() + '"/></td>';
  2376. break;
  2377. }
  2378. return html;
  2379. }
  2380. function CSeperator_getSize() {
  2381. return this.m_size;
  2382. }
  2383. function CSeperator_setSize(size) {
  2384. this.m_size = size;
  2385. }
  2386. function CSeperator_setStyle(style) {
  2387. this.m_style = style;
  2388. }
  2389. function CSeperator_getStyle() {
  2390. return this.m_style;
  2391. }
  2392. function CSeperator_setType(type) {
  2393. this.m_type = type;
  2394. }
  2395. function CSeperator_getType() {
  2396. return this.m_type;
  2397. }
  2398. function CSeperator_hide() {
  2399. this.m_bVisible = false;
  2400. }
  2401. function CSeperator_show() {
  2402. this.m_bVisible = true;
  2403. }
  2404. function CSeperator_isVisible() {
  2405. return this.m_bVisible;
  2406. }
  2407. CSeperator.prototype.draw = CSeperator_draw;
  2408. CSeperator.prototype.setSize = CSeperator_setSize;
  2409. CSeperator.prototype.getSize = CSeperator_getSize;
  2410. CSeperator.prototype.setStyle = CSeperator_setStyle;
  2411. CSeperator.prototype.getStyle = CSeperator_getStyle;
  2412. CSeperator.prototype.getType = CSeperator_getType;
  2413. CSeperator.prototype.setType = CSeperator_setType;
  2414. CSeperator.prototype.isVisible = CSeperator_isVisible;
  2415. CSeperator.prototype.show = CSeperator_show;
  2416. CSeperator.prototype.hide = CSeperator_hide;
  2417. /*
  2418. Class CInfoPanel
  2419. todo : Add commments describing class....
  2420. */
  2421. /*
  2422. CSeperator styles:
  2423. 1. horizonal_blank
  2424. 2. vertical_blank
  2425. 3. vertical_line
  2426. 4. horizonal_line
  2427. */
  2428. function CInfoPanel(size, webContentRoot, id) {
  2429. this.m_size=size;
  2430. this.m_bVisible = true;
  2431. this.m_properties = [];
  2432. this.setId(id);
  2433. this.m_observers = new CObserver(this);
  2434. this.setWebContentRoot(webContentRoot);
  2435. }
  2436. CInfoPanel.prototype = new CMenuEntry();
  2437. CInfoPanel.prototype.setWebContentRoot = function(sWebContentRoot)
  2438. {
  2439. this.m_webContentRoot = sWebContentRoot;
  2440. };
  2441. function CInfoPanel_addCheckedProperty(name, value) {
  2442. var o = {
  2443. 'name': name,
  2444. 'value': value,
  2445. 'type': "checkBox",
  2446. 'spacer': false
  2447. };
  2448. this.m_properties[this.m_properties.length] = o;
  2449. }
  2450. function CInfoPanel_addProperty(name, value) {
  2451. var o = {
  2452. 'name': name,
  2453. 'value': value,
  2454. 'spacer': false
  2455. };
  2456. this.m_properties[this.m_properties.length] = o;
  2457. }
  2458. function CInfoPanel_addSpacer(height) {
  2459. var o = {
  2460. 'spacer': true,
  2461. 'height': height
  2462. };
  2463. this.m_properties[this.m_properties.length] = o;
  2464. }
  2465. function CInfoPanel_draw()
  2466. {
  2467. var i=0;
  2468. var html='<table CELLPADDING="0" CELLSPACING="0" role="presentation">';
  2469. if (this.m_properties.length > 0) {
  2470. var contentHtml = "<tr><td>";
  2471. var summary = "";
  2472. for (i = 0; i < this.m_properties.length; i++) {
  2473. if (this.m_properties[i].spacer) {
  2474. //contentHtml += '<tr><td style="padding:0px;"><img border="0" alt="" src="' + this.m_webContentRoot + '/common/images/spacer.gif" height="' + this.m_properties[i].height + '" width="1"></td></tr>';
  2475. }
  2476. else {
  2477. if (this.m_properties[i].type != null && this.m_properties[i].type == 'checkBox') {
  2478. contentHtml += '<tr><td><span><span class="formText">';
  2479. if (this.m_properties[i].value == 'true') {
  2480. contentHtml += '<input type="checkbox" disabled="true" checked>';
  2481. }
  2482. else {
  2483. contentHtml += '<input type="checkbox" disabled="true">';
  2484. }
  2485. contentHtml += this.m_properties[i].name;
  2486. contentHtml += '</span>&nbsp;</input>';
  2487. contentHtml += '<span></td></tr>';
  2488. }
  2489. else {
  2490. contentHtml += '<tr><td><span><span class="menuItem_normal" style="font-weight:bold">';
  2491. contentHtml += this.m_properties[i].name;
  2492. contentHtml += '</span>&nbsp;<span class="menuItem_normal">';
  2493. contentHtml += this.m_properties[i].value;
  2494. contentHtml += '</span></span></td></tr>';
  2495. }
  2496. summary += this.m_properties[i].name + " " + this.m_properties[i].value + ", ";
  2497. }
  2498. }
  2499. var id = this.getId() ? "id=\"" + this.getId() + "\" " : "";
  2500. var tableHtml = "<table summary=\"" + summary + "\" role=\"presentation\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" " + id + " tabindex=\"0\" style=\"margin-bottom:1px;";
  2501. if (typeof this.m_size != "undefined" && this.m_size != "") {
  2502. tableHtml += "width:" + this.m_size;
  2503. }
  2504. tableHtml += "\"\t>";
  2505. html += tableHtml + contentHtml + "</table></td></tr>";
  2506. }
  2507. html += '</table>';
  2508. return html;
  2509. }
  2510. function CInfoPanel_getSize() {
  2511. return this.m_size;
  2512. }
  2513. function CInfoPanel_setSize(size) {
  2514. this.m_size = size;
  2515. }
  2516. function CInfoPanel_hide() {
  2517. this.m_bVisible = false;
  2518. }
  2519. function CInfoPanel_show() {
  2520. this.m_bVisible = true;
  2521. }
  2522. function CInfoPanel_isVisible() {
  2523. return this.m_bVisible;
  2524. }
  2525. function CInfoPanel_isEnabled() { return true; }
  2526. function CInfoPanel_onkeydown(evt) {
  2527. //get the event in a cross-browser fashion
  2528. var infoPanel = null;
  2529. if(typeof this.infoPanel != "undefined") {
  2530. infoPanel = this.infoPanel;
  2531. }
  2532. else if (this instanceof CInfoPanel) {
  2533. infoPanel = this;
  2534. }
  2535. if(infoPanel == null || !(infoPanel instanceof CInfoPanel)) {
  2536. return;
  2537. }
  2538. return CMenuEntry_onkeydown.call(infoPanel, evt);
  2539. }
  2540. function CInfoPanel_onkeypress(evt) {
  2541. //get the event in a cross-browser fashion
  2542. evt = (evt) ? evt : ((event) ? event : null);
  2543. var infoPanel = null;
  2544. if(typeof this.infoPanel != "undefined") {
  2545. infoPanel = this.infoPanel;
  2546. }
  2547. else if (this instanceof CInfoPanel) {
  2548. infoPanel = this;
  2549. }
  2550. if(infoPanel != null && infoPanel instanceof CInfoPanel) {
  2551. return CMenuEntry_onkeypress.call(infoPanel, evt);
  2552. }
  2553. }
  2554. function CInfoPanel_setFocus() {
  2555. if(this.getId()) {
  2556. document.getElementById(this.getId()).focus();
  2557. }
  2558. }
  2559. function CInfoPanel_attachEvents() {
  2560. if(typeof this.getParent().getHTMLContainer != "function") {
  2561. return; // this method must be implemented by the parent
  2562. }
  2563. var htmlContainer = this.getParent().getHTMLContainer();
  2564. if(htmlContainer == null) {
  2565. return;
  2566. }
  2567. var hMenuItem = eval(htmlContainer.document ? htmlContainer.document.getElementById(this.getId()) : htmlContainer.ownerDocument.getElementById(this.getId()));
  2568. if(hMenuItem == null) {
  2569. return; // just to be safe
  2570. }
  2571. hMenuItem.onkeypress = this.onkeypress;
  2572. hMenuItem.onkeydown = this.onkeydown;
  2573. hMenuItem.infoPanel = eval(this);
  2574. }
  2575. CInfoPanel.prototype.draw = CInfoPanel_draw;
  2576. CInfoPanel.prototype.onkeypress = CInfoPanel_onkeypress;
  2577. CInfoPanel.prototype.onkeydown = CInfoPanel_onkeydown;
  2578. CInfoPanel.prototype.addProperty = CInfoPanel_addProperty;
  2579. CInfoPanel.prototype.addCheckedProperty = CInfoPanel_addCheckedProperty;
  2580. CInfoPanel.prototype.addSpacer = CInfoPanel_addSpacer;
  2581. CInfoPanel.prototype.setSize = CInfoPanel_setSize;
  2582. CInfoPanel.prototype.getSize = CInfoPanel_getSize;
  2583. CInfoPanel.prototype.isVisible = CInfoPanel_isVisible;
  2584. CInfoPanel.prototype.show = CInfoPanel_show;
  2585. CInfoPanel.prototype.hide = CInfoPanel_hide;
  2586. CInfoPanel.prototype.isEnabled = CInfoPanel_isEnabled;
  2587. CInfoPanel.prototype.setFocus = CInfoPanel_setFocus;
  2588. CInfoPanel.prototype.attachEvents = CInfoPanel_attachEvents;
  2589. // Copyright (C) 2008 Cognos Incorporated. All rights reserved.
  2590. // Cognos (R) is a trademark of Cognos Incorporated.
  2591. /*-----------------------------------------------------------------------------------------------------
  2592. Class : CMenu
  2593. Description :
  2594. -----------------------------------------------------------------------------------------------------*/
  2595. var g_ownerDocument = null;
  2596. function CMenu(id,style,webContentRoot) {
  2597. this.m_htmlContainer = document.body;
  2598. this.m_bVisible = false;
  2599. this.m_id = id;
  2600. this.m_htmlDivElement = null;
  2601. this.m_parent = null;
  2602. this.m_menuItems = [];
  2603. this.m_style = style;
  2604. this.m_callback = null;
  2605. this.m_observers = new CObserver(this);
  2606. this.m_bForceCallback = false;
  2607. this.m_loadingMenuItem = false;
  2608. this.m_oCV = null;
  2609. if (typeof webContentRoot != "undefined" && webContentRoot != "")
  2610. {
  2611. this.m_webContentRoot = webContentRoot;
  2612. }
  2613. else
  2614. {
  2615. this.m_webContentRoot = "..";
  2616. }
  2617. }
  2618. function CMenu_setHTMLContainer(container) {
  2619. this.m_htmlContainer = container;
  2620. g_ownerDocument = this.m_htmlContainer.document ? this.m_htmlContainer.document : this.m_htmlContainer.ownerDocument;
  2621. }
  2622. function CMenu_getHTMLContainer() {
  2623. return this.m_htmlContainer;
  2624. }
  2625. function CMenu_setParent(parent) {
  2626. this.m_parent = parent;
  2627. }
  2628. function CMenu_getParent() {
  2629. return this.m_parent;
  2630. }
  2631. function CMenu_getId() {
  2632. return this.m_id;
  2633. }
  2634. function CMenu_getHTMLDiv() {
  2635. return this.m_htmlDivElement;
  2636. }
  2637. function CMenu_create() {
  2638. var newElement = this.m_htmlContainer.document ? this.m_htmlContainer.document.createElement("div") : this.m_htmlContainer.ownerDocument.createElement("div");
  2639. if(typeof this.getStyle() == "object") {
  2640. newElement.className = this.getStyle().getNormalState();
  2641. }
  2642. //Only set display=block when needed, because it causes flickering in Mozilla
  2643. newElement.style.display = "none";
  2644. newElement.style.visibility = "hidden";
  2645. newElement.style.position = "absolute";
  2646. newElement.style.left = "0px";
  2647. newElement.style.top = "0px";
  2648. newElement.id = this.m_id;
  2649. newElement.setAttribute("role", "region");
  2650. if (window.RV_RES) {
  2651. newElement.setAttribute("aria-label", RV_RES.IDS_JS_A11Y_DYNAMIC_MENU);
  2652. }
  2653. //append the new menu
  2654. this.m_htmlContainer.appendChild(newElement);
  2655. //create a reference to it
  2656. this.m_htmlDivElement = newElement;
  2657. }
  2658. function CMenu_setAltText(altText) {
  2659. this.m_altText = altText;
  2660. }
  2661. function CMenu_getAltText() {
  2662. if (this.m_altText) {
  2663. return this.m_altText;
  2664. } else {
  2665. return "";
  2666. }
  2667. }
  2668. function CMenu_genARIATags() {
  2669. var html = ' role="menu"';
  2670. if (this.getAltText() && this.getAltText().length > 0) {
  2671. html += ' aria-labelledby="' + this.m_id + 'label" ';
  2672. }
  2673. else if (window.RV_RES) {
  2674. html += ' aria-label="' + RV_RES.IDS_JS_A11Y_DYNAMIC_MENU + '" ';
  2675. }
  2676. return html;
  2677. }
  2678. function CMenu_genMenuAltText() {
  2679. var html = "";
  2680. if (this.getAltText() && this.getAltText().length > 0) {
  2681. html += '<tr><td><div style="position: absolute; overflow: hidden; width: 0; height: 0;" id="' + this.m_id + 'label">' + this.getAltText() + '</div></td></tr>';
  2682. }
  2683. return html;
  2684. }
  2685. function CMenu_draw() {
  2686. if(this.m_htmlContainer == null) {
  2687. return;
  2688. }
  2689. if(this.m_htmlDivElement == null) {
  2690. this.create();
  2691. }
  2692. var html="";
  2693. if(this.m_menuItems.length == 0 || this.m_bForceCallback == true) {
  2694. this.setForceCallback(false);
  2695. if(this.m_callback != null) {
  2696. this.setLoadingMenuItem(true);
  2697. var menu = this;
  2698. var callbackFunc = function() {if (menu && menu.executeCallback) {menu.executeCallback();}};
  2699. setTimeout(callbackFunc, 1000);
  2700. // build a html div with a wait cursor
  2701. html='<table class="menuItem_normal" CELLPADDING="0" CELLSPACING="0" tabindex="0" hidefocus="true"';
  2702. html += this.genARIATags();
  2703. html += '>';
  2704. html += this.genMenuAltText();
  2705. html += '<tr>';
  2706. var loadingMsg = "";
  2707. if (this.m_oCV && RV_RES.GOTO_LOADING) {
  2708. loadingMsg = RV_RES.GOTO_LOADING;
  2709. }
  2710. else if(typeof gUIFrameWorkMenuLoadingMessage != "undefined") {
  2711. loadingMsg = gUIFrameWorkMenuLoadingMessage;
  2712. } else {
  2713. loadingMsg = '...';
  2714. }
  2715. html += '<td>';
  2716. html += '<img style="vertical-align:middle;" alt="' + loadingMsg + '" width="16" height="16" src="' + this.m_webContentRoot + '/common/images/tv_loading.gif"/>';
  2717. html += '</td>';
  2718. html += '<td nowrap="nowrap" align="left">';
  2719. html += loadingMsg;
  2720. html += '</td>';
  2721. html += '</tr>';
  2722. html += '</table>';
  2723. }
  2724. } else {
  2725. this.setLoadingMenuItem(false);
  2726. //add the items
  2727. var i=0;
  2728. html='<table CELLPADDING="0" CELLSPACING="0" tabindex="0" style="outline: none;" hidefocus="true"';
  2729. html += this.genARIATags();
  2730. html += '>';
  2731. html += this.genMenuAltText();
  2732. var anyVisibleItems = false;
  2733. for (i=0; i < this.m_menuItems.length; i++) {
  2734. if(this.m_menuItems[i].isVisible()) {
  2735. anyVisibleItems = true;
  2736. html += '<tr><td>';
  2737. html += this.m_menuItems[i].draw();
  2738. html += '</td></tr>';
  2739. }
  2740. }
  2741. if (!anyVisibleItems) {
  2742. this.remove();
  2743. return;
  2744. }
  2745. html += '</table>';
  2746. }
  2747. try
  2748. {
  2749. this.m_htmlDivElement.innerHTML = html;
  2750. // attach the event handlers
  2751. this.attachEvents();
  2752. }
  2753. catch (e)
  2754. {
  2755. }
  2756. this.updateCoords();
  2757. // update hidden iframe
  2758. var iFrameId = "uiFrameworkHiddenIframe" + this.m_id;
  2759. var isNS7 = ((!isIE()) && (document.getElementById)) ? true : false;
  2760. setTimeout('updateIframeCoords("' + iFrameId + '", "' + this.m_htmlDivElement.id + '", ' + isNS7 + ')',50);
  2761. //Only gets applied when rv is in fragment mode
  2762. if ((typeof gCognosViewer != "undefined") && (gCognosViewer.envParams["cv.responseFormat"]) && (gCognosViewer.envParams["cv.responseFormat"] == 'fragment'))
  2763. {
  2764. AdjustPortalFont(this.m_htmlDivElement);
  2765. }
  2766. }
  2767. function CMenu_setLoadingMenuItem(bLoadingMenuItem)
  2768. {
  2769. this.m_loadingMenuItem = bLoadingMenuItem;
  2770. }
  2771. function CMenu_getLoadingMenuItem()
  2772. {
  2773. return this.m_loadingMenuItem;
  2774. }
  2775. /**
  2776. * CMenu_getScrollingPosition
  2777. * Cross Browser method to get the scroll position of a mouse click.
  2778. * QuirksMode supports document.body.scrollTop, document.body.scrollLeft
  2779. * Strict Mode
  2780. * Firefox, Opera, Safari, Konqueror support window.pageYOffset, window.pageXOffset
  2781. * IE 6.0 supports document.documentElement.scrollTop, document.documentElement.scrollLeft
  2782. * @return Object - contain x,y information of the position of the mouse click.
  2783. */
  2784. function CMenu_getScrollingPosition()
  2785. {
  2786. var position = {"x":0,"y": 0};
  2787. if (typeof window.pageYOffset != "undefined")
  2788. {
  2789. position = {"x":window.pageXOffset,"y":window.pageYOffset};
  2790. }
  2791. else if ((typeof document.documentElement.scrollTop != "undefined") &&
  2792. (document.documentElement.scrollTop > 0 || typeof document.body.scrollTop == "undefined" || document.body.scrollTop == document.documentElement.scrollTop))
  2793. {
  2794. position = {"x":document.documentElement.scrollLeft,"y":document.documentElement.scrollTop};
  2795. }
  2796. else if (typeof document.body.scrollTop != "undefined")
  2797. {
  2798. position = {"x":document.body.scrollLeft,"y":document.body.scrollTop};
  2799. }
  2800. return position;
  2801. }
  2802. /**
  2803. * AdjustPortalFont
  2804. * @author whelanp
  2805. * This function fixes a problem with font sizes in the portal environment,
  2806. * we are using the computed style of the fragment div to set the font on the menu item
  2807. * this keeps it consistent with the font being used by the rest of the page.
  2808. * Problems this solves, menus get appended to the body of the document, if the body does
  2809. * not set the font size correctly the font can either be too small or too big. If we are
  2810. * in fragment mode there is always a div created with the appropriate css rules applied to it
  2811. * thus getting the font size from the fragment div fixes the problem.
  2812. * To fix a browser bug that causes tables to not properly inherit there parents font size, we've appended
  2813. * a class to the menu as well. This class sets all table descendents of any element with PortalFontFix as a
  2814. * class to use font-size:100% this forces the tables to use 100% of there parents font-size.
  2815. * class is located in CRNFragment.css
  2816. * .PortalFontFix table {font-size:100%;}
  2817. *
  2818. */
  2819. function AdjustPortalFont(div)
  2820. {
  2821. var fragArray = fragments;
  2822. if (fragArray)
  2823. {
  2824. div.className += " PortalFontFix";
  2825. var fragDiv = null;
  2826. for (var frag in fragArray)
  2827. {
  2828. if (frag.indexOf("rvCanvas") > -1)
  2829. {
  2830. fragDiv = $(fragArray[frag].div);
  2831. if (fragDiv != null)
  2832. {
  2833. break;
  2834. }
  2835. }
  2836. }
  2837. if (fragDiv != null)
  2838. {
  2839. div.style.fontSize = xGetComputedStyle(fragDiv, "font-size");
  2840. }
  2841. }
  2842. }
  2843. function CMenu_updateCoords() {
  2844. var myParent = this.getParent();
  2845. var mnu = this.m_htmlDivElement;
  2846. if(mnu != null)
  2847. {
  2848. var myDocument = this.m_htmlContainer.document ? this.m_htmlContainer.document : this.m_htmlContainer.ownerDocument;
  2849. //Backup the visibilty and display properties of this menu
  2850. var originalVisibility = mnu.style.visibility;
  2851. var originalDisplay = mnu.style.display;
  2852. mnu.style.visibility = "hidden";
  2853. mnu.style.display = "block";
  2854. //This line is used to make sure the width of the DIV element is correct in Mozilla
  2855. if(mnu.firstChild != null) {
  2856. mnu.style.width = mnu.firstChild.offsetWidth;
  2857. }
  2858. var x=0, y=0;
  2859. var db = mnu.parentNode; //db = Document body
  2860. // calculate the page width
  2861. var pageWidth = db.clientWidth;
  2862. var pageHeight = db.clientHeight;
  2863. var pagePosition = CMenu_getScrollingPosition();
  2864. var scrollLeft = pagePosition.x;
  2865. var scrollTop = pagePosition.y;
  2866. if(myParent == null)
  2867. {
  2868. //If this is the main context menu...
  2869. x = mnu.style.left;
  2870. y = mnu.style.top;
  2871. //Remove "px" on x and y coordinates if it exists
  2872. if (x.substr(x.length - 2, 2) == "px")
  2873. {
  2874. x = parseInt(x.substring(0, x.length-2),10);
  2875. y = parseInt(y.substring(0, y.length-2),10);
  2876. }
  2877. //Change the y coordinate if the menu goes below the visible page
  2878. if (y + mnu.offsetHeight >= (pageHeight))
  2879. {
  2880. if (y - mnu.offsetHeight > 0) {
  2881. y = y + scrollTop - mnu.offsetHeight;
  2882. }
  2883. else {
  2884. y = Math.max(pageHeight - mnu.offsetHeight, 0);
  2885. }
  2886. }
  2887. else {
  2888. y = y + scrollTop;
  2889. }
  2890. //Change the x coordinate if the menu goes below the visible page
  2891. if (x + mnu.offsetWidth >= (pageWidth))
  2892. {
  2893. if (x - mnu.offsetWidth > 0) {
  2894. x = x + scrollLeft - mnu.offsetWidth;
  2895. }
  2896. else {
  2897. x = Math.max(pageWidth - mnu.offsetWidth, 0);
  2898. }
  2899. }
  2900. else {
  2901. x = x + scrollLeft;
  2902. }
  2903. }
  2904. else
  2905. {
  2906. //This is one of the menu items...
  2907. if(!(myParent instanceof CToolbarButton) && !(myParent instanceof CMenuItem)) {
  2908. return;
  2909. }
  2910. // make sure the parent has implemented the method "getMenuType"
  2911. if(typeof myParent.getMenuType != "function") {
  2912. return;
  2913. }
  2914. var myParentHTMLElement = myDocument.getElementById(this.getParent().getId());
  2915. var myParentDropdownButton = myDocument.getElementById('menu' + this.getParent().getId());
  2916. if(myParentHTMLElement == null) {
  2917. return;
  2918. }
  2919. var current = myParentHTMLElement;
  2920. // handle drop down menus
  2921. if(myParent.getMenuType() == 'dropDown') {
  2922. x = 0; y = myParentHTMLElement.offsetHeight;
  2923. while(current != null) {
  2924. x += current.offsetLeft; y += current.offsetTop;
  2925. current = current.offsetParent;
  2926. }
  2927. if(getViewerDirection()=="rtl"){
  2928. var xMirrored = x - (mnu.offsetWidth - myParentHTMLElement.offsetWidth);
  2929. if(xMirrored > scrollLeft){
  2930. x = xMirrored;
  2931. }
  2932. }
  2933. // For defect COGCQ00646908.
  2934. // If we are in a portlet we must also take into account its scrollable position.
  2935. // The caveat here is that the portlet div is scrollable and a parent element that is scrollable is not necessarily an
  2936. // offsetParent (and in this case it is not). Therefore, we must travel up the parentNode DOM tree and calculate the scroll
  2937. // position values of the portlet div (and any subsequent scrollable element) and subtract them accordingly.
  2938. if ((typeof gCognosViewer != "undefined") && (gCognosViewer.envParams["cv.responseFormat"]) && (gCognosViewer.envParams["cv.responseFormat"] == 'fragment')) {
  2939. var scrollPos = myParentHTMLElement;
  2940. while((scrollPos != document.body) && (scrollPos = scrollPos.parentNode)) {
  2941. // if the scroll values return a null, we must OR a 0-value to force return a number instead of null or NaN
  2942. x -= scrollPos.scrollLeft || 0;
  2943. y -= scrollPos.scrolltop || 0;
  2944. }
  2945. }
  2946. // if the right side of the drop down menu extends beyond browser window viewing area, adjust accordingly
  2947. if((x + mnu.offsetWidth) > (pageWidth + scrollLeft)) {
  2948. x = x + myParentHTMLElement.offsetWidth - mnu.offsetWidth;
  2949. if(myParentDropdownButton != null) {
  2950. x = x + myParentDropdownButton.offsetWidth;
  2951. }
  2952. }
  2953. // if the bottom of the drop down menu extends below the browser viewing area and there is enough room to draw at the top, then draw to the top
  2954. if(((y + mnu.offsetHeight) > (pageHeight + scrollTop)) && (y - (mnu.offsetHeight + myParentHTMLElement.clientHeight) >= 0)) {
  2955. y -= (mnu.offsetHeight + myParentHTMLElement.clientHeight);
  2956. }
  2957. } else if(myParent.getMenuType() == 'cascaded') {
  2958. x = myParentHTMLElement.offsetWidth;
  2959. while(current != null) {
  2960. x += current.offsetLeft; y += current.offsetTop;
  2961. current = current.offsetParent;
  2962. }
  2963. if(getViewerDirection()=="rtl"){
  2964. var xMirrored = x - (mnu.offsetWidth + myParentHTMLElement.offsetWidth);
  2965. if(xMirrored > scrollLeft){
  2966. x = xMirrored;
  2967. }
  2968. }
  2969. // if the right side of the cascaded menu extends beyond the viewing area of the browser window right side, render to the left insted of the right
  2970. if((x + mnu.offsetWidth) > (pageWidth + scrollLeft)) {
  2971. x -= (myParentHTMLElement.offsetWidth + mnu.offsetWidth);
  2972. }
  2973. // if the bottom of the cascaded menu extends beyond the bottom of the browser viewing area, draw to the top
  2974. if((y + mnu.offsetHeight) > (pageHeight + scrollTop)) {
  2975. y -= (mnu.offsetHeight-myParentHTMLElement.clientHeight);
  2976. }
  2977. }
  2978. }
  2979. //Restore the visibilty and display properties of this menu
  2980. mnu.style.visibility = originalVisibility;
  2981. mnu.style.display = originalDisplay;
  2982. this.setXCoord(x);
  2983. this.setYCoord(y);
  2984. this.setZIndex(500);
  2985. }
  2986. }
  2987. function CMenu_add(menuItem) {
  2988. if(typeof menuItem.getObservers == "function" && typeof menuItem.getObservers() == "object") {
  2989. menuItem.getObservers().attach(this, this.closeSubMenus, menuItem.onmouseover);
  2990. menuItem.getObservers().attach(this, this.closeAllMenus, menuItem.onmouseup);
  2991. menuItem.getObservers().attach(this, this.closeSubMenus, menuItem.onfocus);
  2992. menuItem.getObservers().attach(this, this.closeAllMenus, menuItem.onkeypress);
  2993. }
  2994. this.m_menuItems[this.m_menuItems.length] = menuItem;
  2995. }
  2996. function CMenu_get(index) {
  2997. if(index >= 0 && index < this.getNumItems()) {
  2998. return this.m_menuItems[index];
  2999. }
  3000. return null;
  3001. }
  3002. CMenu.prototype.getItem = function(sItemId)
  3003. {
  3004. var sId = sItemId;
  3005. if (this.m_oCV) {
  3006. sId = this.m_oCV.getId() + sItemId;
  3007. }
  3008. for (var iIndex=0; iIndex < this.getNumItems(); iIndex++)
  3009. {
  3010. var uiItem = this.get(iIndex);
  3011. if(typeof uiItem.getId == "function" && uiItem.getId() == sId)
  3012. {
  3013. return uiItem;
  3014. }
  3015. }
  3016. };
  3017. function CMenu_getNumItems() {
  3018. return this.m_menuItems.length;
  3019. }
  3020. function CMenu_hide() {
  3021. this.hideHiddenIframe();
  3022. if(this.m_htmlDivElement != null) {
  3023. this.m_htmlDivElement.style.visibility = "hidden";
  3024. }
  3025. this.m_bVisible = false;
  3026. // get the actual element that spawned the menu
  3027. var theControl = this.getParent();
  3028. if (theControl != null && typeof theControl.setFocus == "function") {
  3029. theControl.setFocus();
  3030. } else if (theControl != null && typeof theControl.focus == "function") {
  3031. theControl.focus();
  3032. } else if (typeof this.m_focusCell == "object" && typeof this.m_focusCell.focus == "function" ) {
  3033. this.m_focusCell.focus();
  3034. }
  3035. }
  3036. function CMenu_setFocus() {
  3037. try {
  3038. var menuItem = null;
  3039. for (var menuItemIndex = 0; menuItemIndex < this.getNumItems() && !menuItem; menuItemIndex++) {
  3040. var _menuItem = this.get(menuItemIndex);
  3041. if (_menuItem.isVisible && _menuItem.isVisible() ) {
  3042. menuItem = _menuItem;
  3043. }
  3044. }
  3045. if (!menuItem || !menuItem.setFocus()) {
  3046. this.m_htmlDivElement.childNodes[0].focus();
  3047. }
  3048. } catch (e) {}
  3049. }
  3050. function CMenu_show() {
  3051. if(this.m_htmlDivElement != null) {
  3052. this.m_bVisible = true;
  3053. // update the x and y coords
  3054. this.updateCoords();
  3055. var isNS7 = ((!isIE()) && (document.getElementById)) ? true : false;
  3056. var iFrameId = "uiFrameworkHiddenIframe" + this.m_id;
  3057. var hiddenIframeElement = this.m_htmlContainer.document ? this.m_htmlContainer.document.getElementById(iFrameId) : this.m_htmlContainer.ownerDocument.getElementById(iFrameId);
  3058. if (hiddenIframeElement == null) {
  3059. hiddenIframeElement = this.createHiddenIFrame(iFrameId);
  3060. }
  3061. if(hiddenIframeElement) {
  3062. hiddenIframeElement.style.display = "block";
  3063. hiddenIframeElement.style.left = "0px";
  3064. hiddenIframeElement.style.top = "0px";
  3065. updateIframeCoords(iFrameId, this.m_htmlDivElement.id, isNS7);
  3066. setTimeout('updateIframeCoords("'+iFrameId+'", "'+this.m_htmlDivElement.id+'", '+isNS7+')',50);
  3067. }
  3068. //Show the context menu
  3069. this.m_htmlDivElement.style.display = "block";
  3070. this.m_htmlDivElement.style.visibility = "visible";
  3071. this.setFocus();
  3072. // Only attach the onresize & onscroll events when we're not on an iOS. This is to fix an issue
  3073. // where we'd get a scroll event right away when displaying our menu, so the menu would
  3074. // show up and then get removed right away.
  3075. if (!window.isIOS()) {
  3076. var cmenuObj = this;
  3077. if (window.attachEvent) {
  3078. window.attachEvent("onresize", function() { cmenuObj.remove()});
  3079. window.attachEvent("onscroll", function() { cmenuObj.remove()});
  3080. }
  3081. else {
  3082. window.addEventListener("resize", function() { cmenuObj.remove()}, false);
  3083. window.addEventListener("scroll", function() { cmenuObj.remove()}, false);
  3084. }
  3085. var contentDiv = null;
  3086. if (this.m_oCV != null) {
  3087. contentDiv = document.getElementById(this.m_oCV.getId() + "content");
  3088. }
  3089. if (contentDiv) {
  3090. if (contentDiv.parentNode.parentNode.attachEvent) {
  3091. contentDiv.parentNode.parentNode.attachEvent("onscroll", function() { cmenuObj.remove()});
  3092. }
  3093. else {
  3094. contentDiv.parentNode.parentNode.addEventListener("scroll", function() { cmenuObj.remove()}, false);
  3095. }
  3096. }
  3097. }
  3098. }
  3099. }
  3100. function CMenu_createHiddenIFrame(iFrameId)
  3101. {
  3102. var container = this.getHTMLContainer();
  3103. var iframeElem = container.document ? container.document.createElement("iframe") : container.ownerDocument.createElement("iframe");
  3104. iframeElem.setAttribute("id",iFrameId);
  3105. iframeElem.setAttribute("src",this.m_webContentRoot + '/common/images/spacer.gif');
  3106. iframeElem.setAttribute("scrolling",'no');
  3107. iframeElem.setAttribute("frameborder",'0');
  3108. iframeElem.style.position="absolute";
  3109. iframeElem.style.minWidth="0px";
  3110. iframeElem.style.minHeight="0px";
  3111. iframeElem.style.left="0px";
  3112. iframeElem.style.top="0px";
  3113. iframeElem.style.zIndex=499;
  3114. iframeElem.style.display="none";
  3115. iframeElem.setAttribute("title", "Empty frame");
  3116. iframeElem.setAttribute("role", "presentation");
  3117. container.appendChild(iframeElem);
  3118. return iframeElem;
  3119. }
  3120. function CMenu_isVisible() {
  3121. return this.m_bVisible;
  3122. }
  3123. function CMenu_remove() {
  3124. this.removeHiddenIframe();
  3125. for(var i = 0; i < this.getNumItems(); ++i) {
  3126. var currentItem = this.get(i);
  3127. if(typeof currentItem.getMenu == "function" && currentItem.getMenu() != null) {
  3128. currentItem.getMenu().remove();
  3129. }
  3130. }
  3131. if(this.m_htmlContainer != null && this.m_htmlDivElement != null) {
  3132. this.m_htmlContainer.removeChild(this.m_htmlDivElement);
  3133. }
  3134. this.m_htmlDivElement = null;
  3135. this.m_bVisible = false;
  3136. }
  3137. function CMenu_removeHiddenIframe()
  3138. {
  3139. try
  3140. {
  3141. if (g_ownerDocument)
  3142. {
  3143. var hiddenIframeElement = g_ownerDocument.getElementById("uiFrameworkHiddenIframe" + this.m_id);
  3144. if (hiddenIframeElement != null) {
  3145. hiddenIframeElement.style.display = "none";
  3146. if (hiddenIframeElement.parentNode && hiddenIframeElement.parentNode.removeChild) {
  3147. hiddenIframeElement.parentNode.removeChild(hiddenIframeElement);
  3148. }
  3149. }
  3150. }
  3151. }
  3152. catch(e)
  3153. {
  3154. }
  3155. }
  3156. function CMenu_hideHiddenIframe() {
  3157. try
  3158. {
  3159. if (g_ownerDocument)
  3160. {
  3161. var hiddenIframeElement = g_ownerDocument.getElementById("uiFrameworkHiddenIframe" + this.m_id);
  3162. if(hiddenIframeElement) {
  3163. hiddenIframeElement.style.display = "none";
  3164. }
  3165. }
  3166. }
  3167. catch(e)
  3168. {
  3169. }
  3170. }
  3171. function CMenu_enable() {
  3172. }
  3173. function CMenu_disable() {
  3174. }
  3175. function CMenu_getState() {
  3176. }
  3177. function CMenu_clear() {
  3178. if(this.m_htmlDivElement != null) {
  3179. this.m_htmlDivElement.innerHTML="";
  3180. }
  3181. this.m_menuItems.splice(0, this.m_menuItems.length);
  3182. }
  3183. function CMenu_attachEvents() {
  3184. for(var i = 0; i < this.m_menuItems.length; i++) {
  3185. if(typeof this.m_menuItems[i].attachEvents == "function") {
  3186. this.m_menuItems[i].attachEvents();
  3187. }
  3188. }
  3189. this.m_htmlDivElement.onkeypress = this.onkeypress;
  3190. this.m_htmlDivElement.tbMenu = eval(this);
  3191. }
  3192. function CMenu_closeSubMenus(state) {
  3193. // Called during a notification...
  3194. // make sure we hide any submenus which have been opened.
  3195. for(var i = 0; i < this.m_menuItems.length; i++) {
  3196. var menuItem = this.m_menuItems[i];
  3197. var subject = state.getSubject();
  3198. if(menuItem != subject && typeof menuItem.getMenu == "function" && menuItem.getMenu() != null && menuItem.getMenu().isVisible()) {
  3199. menuItem.getMenu().remove();
  3200. }
  3201. }
  3202. }
  3203. function CMenu_closeAllMenus(state) {
  3204. // Called during a notification...
  3205. var current = this;
  3206. var highestMenu = null;
  3207. while(current) {
  3208. if(current instanceof CMenu) {
  3209. highestMenu = current;
  3210. }
  3211. current = current.getParent();
  3212. }
  3213. if(highestMenu != null) {
  3214. highestMenu.remove();
  3215. }
  3216. }
  3217. function CMenu_setStyle(style) {
  3218. this.m_style = style;
  3219. }
  3220. function CMenu_getStyle() {
  3221. return this.m_style;
  3222. }
  3223. function CMenu_setXCoord(x) {
  3224. var htmlDiv = this.getHTMLDiv();
  3225. if(htmlDiv != null) {
  3226. htmlDiv.style.left = x + "px";
  3227. }
  3228. }
  3229. function CMenu_setYCoord(y) {
  3230. var htmlDiv = this.getHTMLDiv();
  3231. if(htmlDiv != null) {
  3232. htmlDiv.style.top = y + "px";
  3233. }
  3234. }
  3235. function CMenu_setZIndex(zIndex) {
  3236. var htmlDiv = this.getHTMLDiv();
  3237. if(htmlDiv != null) {
  3238. htmlDiv.style.zIndex = zIndex;
  3239. }
  3240. }
  3241. // set a callback routine to populate the menu
  3242. function CMenu_registerCallback(callback) {
  3243. this.m_callback = callback;
  3244. }
  3245. function CMenu_executeCallback() {
  3246. if(typeof this.m_callback == "function")
  3247. {
  3248. this.m_callback();
  3249. }
  3250. else if(typeof this.m_callback == "string")
  3251. {
  3252. eval(this.m_callback);
  3253. }
  3254. }
  3255. function CMenu_getObservers() {
  3256. return this.m_observers;
  3257. }
  3258. function CMenu_onmouseover(evt) {
  3259. //get the event in a cross-browser fashion
  3260. evt = (evt) ? evt : ((event) ? event : null);
  3261. // notify our parent (if one exists) of this event
  3262. if(this.getParent() != null && typeof this.getParent().onmouseover == "function") {
  3263. this.getParent().onmouseover(evt);
  3264. }
  3265. // notify observers of this event
  3266. this.getObservers().notify(CMenu_onmouseover);
  3267. }
  3268. function CMenu_onmouseout(evt) {
  3269. //get the event in a cross-browser fashion
  3270. evt = (evt) ? evt : ((event) ? event : null);
  3271. // notify our parent (if one exists) of this event
  3272. if(this.getParent() != null && typeof this.getParent().onmouseout == "function") {
  3273. this.getParent().onmouseout(evt);
  3274. }
  3275. // notify observers of this event
  3276. this.getObservers().notify(CMenu_onmouseout);
  3277. }
  3278. function CMenu_onmouseup(evt) {
  3279. //get the event in a cross-browser fashion
  3280. evt = (evt) ? evt : ((event) ? event : null);
  3281. // notify our parent (if one exists) of this event
  3282. if(this.getParent() != null && typeof this.getParent().onmouseup == "function") {
  3283. this.getParent().onmouseup(evt);
  3284. }
  3285. // notify observers of this event
  3286. this.getObservers().notify(CMenu_onmouseup);
  3287. }
  3288. function CMenu_onkeypress(evt) {
  3289. //get the event in a cross-browser fashion
  3290. evt = (evt) ? evt : ((event) ? event : null);
  3291. var menu = this.tbMenu;
  3292. if (typeof menu == "object") {
  3293. // down arrow, select the first enabled item or close the menu if there aren't any enabled menu items
  3294. if (evt.keyCode == 40) {
  3295. var bMenuItemEnabled = false;
  3296. for(var i = 0; i < menu.m_menuItems.length; i++) {
  3297. var menuItem = menu.m_menuItems[i];
  3298. if ( typeof menuItem.isVisible == "function" && menuItem.isVisible() &&
  3299. typeof menuItem.setFocus == "function") {
  3300. menuItem.setFocus();
  3301. bMenuItemEnabled = true;
  3302. break;
  3303. }
  3304. }
  3305. if (!bMenuItemEnabled) {
  3306. menu.hide();
  3307. }
  3308. }
  3309. // up arrow, simply hide the menu
  3310. if (evt.keyCode == 38) {
  3311. menu.hide();
  3312. }
  3313. }
  3314. // notify our parent (if one exists) of this event
  3315. if(typeof this.getParent == "function" && this.getParent() != null && typeof this.getParent().onkeypress == 'function') {
  3316. this.getParent().onkeypress(evt);
  3317. }
  3318. // notify observers of this event
  3319. if (typeof this.getObservers == "function") {
  3320. this.getObservers().notify(CMenu_onkeypress);
  3321. }
  3322. }
  3323. function CMenu_getForceCallback()
  3324. {
  3325. return this.m_bForceCallback;
  3326. }
  3327. function CMenu_setForceCallback(forceCallback)
  3328. {
  3329. this.m_bForceCallback = forceCallback;
  3330. }
  3331. CMenu.prototype.draw = CMenu_draw;
  3332. CMenu.prototype.updateCoords = CMenu_updateCoords;
  3333. CMenu.prototype.add = CMenu_add;
  3334. CMenu.prototype.get = CMenu_get;
  3335. CMenu.prototype.getNumItems = CMenu_getNumItems;
  3336. CMenu.prototype.hide = CMenu_hide;
  3337. CMenu.prototype.hideHiddenIframe = CMenu_hideHiddenIframe;
  3338. CMenu.prototype.removeHiddenIframe = CMenu_removeHiddenIframe;
  3339. CMenu.prototype.show = CMenu_show;
  3340. CMenu.prototype.enable = CMenu_enable;
  3341. CMenu.prototype.disable = CMenu_disable;
  3342. CMenu.prototype.getState = CMenu_getState;
  3343. CMenu.prototype.clear = CMenu_clear;
  3344. CMenu.prototype.attachEvents = CMenu_attachEvents;
  3345. CMenu.prototype.setParent = CMenu_setParent;
  3346. CMenu.prototype.getParent = CMenu_getParent;
  3347. CMenu.prototype.getHTMLContainer = CMenu_getHTMLContainer;
  3348. CMenu.prototype.setHTMLContainer = CMenu_setHTMLContainer;
  3349. CMenu.prototype.getHTMLDiv = CMenu_getHTMLDiv;
  3350. CMenu.prototype.create = CMenu_create;
  3351. CMenu.prototype.remove = CMenu_remove;
  3352. CMenu.prototype.getId = CMenu_getId;
  3353. CMenu.prototype.isVisible = CMenu_isVisible;
  3354. CMenu.prototype.setStyle = CMenu_setStyle;
  3355. CMenu.prototype.getStyle = CMenu_getStyle;
  3356. CMenu.prototype.closeSubMenus = CMenu_closeSubMenus;
  3357. CMenu.prototype.closeAllMenus = CMenu_closeAllMenus;
  3358. CMenu.prototype.setXCoord = CMenu_setXCoord;
  3359. CMenu.prototype.setYCoord = CMenu_setYCoord;
  3360. CMenu.prototype.setZIndex = CMenu_setZIndex;
  3361. CMenu.prototype.update = new Function("return true");
  3362. CMenu.prototype.registerCallback = CMenu_registerCallback;
  3363. CMenu.prototype.executeCallback = CMenu_executeCallback;
  3364. CMenu.prototype.getObservers = CMenu_getObservers;
  3365. CMenu.prototype.onmouseover = CMenu_onmouseover;
  3366. CMenu.prototype.onmouseout = CMenu_onmouseout;
  3367. CMenu.prototype.onmouseup = CMenu_onmouseup;
  3368. CMenu.prototype.onkeypress = CMenu_onkeypress;
  3369. CMenu.prototype.createHiddenIFrame = CMenu_createHiddenIFrame;
  3370. CMenu.prototype.setForceCallback = CMenu_setForceCallback;
  3371. CMenu.prototype.getForceCallback = CMenu_getForceCallback;
  3372. CMenu.prototype.setFocus = CMenu_setFocus;
  3373. CMenu.prototype.genARIATags = CMenu_genARIATags;
  3374. CMenu.prototype.setAltText = CMenu_setAltText;
  3375. CMenu.prototype.getAltText = CMenu_getAltText;
  3376. CMenu.prototype.genMenuAltText = CMenu_genMenuAltText;
  3377. CMenu.prototype.setLoadingMenuItem = CMenu_setLoadingMenuItem;
  3378. CMenu.prototype.getLoadingMenuItem = CMenu_getLoadingMenuItem;
  3379. function updateIframeCoords(id, containerId, isNS7)
  3380. {
  3381. if (g_ownerDocument == null) {
  3382. return;
  3383. }
  3384. var container = g_ownerDocument.getElementById(containerId);
  3385. var hiddenIframeElement = g_ownerDocument.getElementById(id);
  3386. if (hiddenIframeElement && container) {
  3387. if(isNS7 == true) {
  3388. hiddenIframeElement.style.left = container.offsetLeft + "px";
  3389. hiddenIframeElement.style.top = container.offsetTop + "px";
  3390. hiddenIframeElement.style.width = container.offsetWidth + "px";
  3391. hiddenIframeElement.style.height = container.offsetHeight + "px";
  3392. } else {
  3393. hiddenIframeElement.style.pixelLeft = container.offsetLeft;
  3394. hiddenIframeElement.style.pixelTop = container.offsetTop;
  3395. hiddenIframeElement.style.pixelWidth = container.offsetWidth;
  3396. hiddenIframeElement.style.pixelHeight = container.offsetHeight;
  3397. }
  3398. }
  3399. }
  3400. // Copyright (C) 2008 Cognos Incorporated. All rights reserved.
  3401. // Cognos (R) is a trademark of Cognos Incorporated.
  3402. /*
  3403. Class CIcon
  3404. todo : Add commments describing class....
  3405. */
  3406. function CIcon(iconPath, toolTip, webContentRoot) {
  3407. this.m_iconPath = iconPath;
  3408. this.m_toolTip = toolTip;
  3409. this.m_enabled = true;
  3410. // The UI framework defaults the icon width/height to 16. If you need to change this, call setHeight and/or setWidth
  3411. this.m_height = 16;
  3412. this.m_width = 16;
  3413. if (typeof webContentRoot != "undefined" && webContentRoot != "")
  3414. {
  3415. this.m_webContentRoot = webContentRoot;
  3416. }
  3417. else
  3418. {
  3419. this.m_webContentRoot = "..";
  3420. }
  3421. }
  3422. function CIcon_draw() {
  3423. var html="";
  3424. html += '<img style="vertical-align:middle;" src="';
  3425. if(typeof this.m_iconPath != "undefined" && this.m_iconPath !== "" && this.m_iconPath != "blankIcon") {
  3426. if(this.m_enabled == true) {
  3427. html += this.m_iconPath;
  3428. }
  3429. else {
  3430. html += this.getDisabledImagePath();
  3431. }
  3432. html += '" title="';
  3433. if(typeof this.m_toolTip == "string" && this.m_toolTip.length > 0) {
  3434. html += this.m_toolTip;
  3435. }
  3436. html += '" alt="';
  3437. if(typeof this.m_toolTip == "string" && this.m_toolTip.length > 0) {
  3438. html += this.m_toolTip;
  3439. }
  3440. html += '" width="';
  3441. html += this.m_width;
  3442. html += '" height="';
  3443. html += this.m_height;
  3444. html += '"/>';
  3445. } else {
  3446. html += this.m_webContentRoot + '/common/images/spacer.gif';
  3447. html += '" alt=""';
  3448. if (this.m_iconPath == "blankIcon")
  3449. {
  3450. html += ' width="';
  3451. html += this.m_width;
  3452. html += '" height="';
  3453. html += this.m_height;
  3454. html += '"/>';
  3455. }
  3456. else
  3457. {
  3458. html += ' width="1" height="1"/>';
  3459. }
  3460. }
  3461. return html;
  3462. }
  3463. function CIcon_getDisabledImagePath() {
  3464. var imagePathArray = this.m_iconPath.split('/');
  3465. var iconPath="";
  3466. for(var i = 0; i < (imagePathArray.length -1); ++i) {
  3467. iconPath += imagePathArray[i] + '/';
  3468. }
  3469. iconPath += 'dis_' + imagePathArray[imagePathArray.length-1];
  3470. return iconPath;
  3471. }
  3472. function CIcon_getPath() {
  3473. return this.m_iconPath;
  3474. }
  3475. function CIcon_setPath(path) {
  3476. this.m_iconPath = path;
  3477. }
  3478. function CIcon_getToolTip() {
  3479. return this.m_toolTip;
  3480. }
  3481. function CIcon_setToolTip(toolTip) {
  3482. this.m_toolTip = toolTip;
  3483. }
  3484. function CIcon_enable() {
  3485. this.m_enabled = true;
  3486. }
  3487. function CIcon_disable() {
  3488. this.m_enabled = false;
  3489. }
  3490. function CIcon_isEnabled() {
  3491. return this.m_enabled;
  3492. }
  3493. function CIcon_setHeight(height) {
  3494. this.m_height = height;
  3495. }
  3496. function CIcon_getHeight() {
  3497. return this.m_height;
  3498. }
  3499. function CIcon_setWidth(width) {
  3500. this.m_width = width;
  3501. }
  3502. function CIcon_getWidth() {
  3503. return this.m_width;
  3504. }
  3505. CIcon.prototype.draw = CIcon_draw;
  3506. CIcon.prototype.enable = CIcon_enable;
  3507. CIcon.prototype.disable = CIcon_disable;
  3508. CIcon.prototype.isEnabled = CIcon_isEnabled;
  3509. CIcon.prototype.getDisabledImagePath = CIcon_getDisabledImagePath;
  3510. CIcon.prototype.getPath = CIcon_getPath;
  3511. CIcon.prototype.setPath = CIcon_setPath;
  3512. CIcon.prototype.setHeight = CIcon_setHeight;
  3513. CIcon.prototype.getHeight = CIcon_getHeight;
  3514. CIcon.prototype.setWidth = CIcon_setWidth;
  3515. CIcon.prototype.getWidth = CIcon_getWidth;
  3516. CIcon.prototype.getToolTip = CIcon_getToolTip;
  3517. CIcon.prototype.setToolTip = CIcon_setToolTip;
  3518. // Copyright (C) 2008 Cognos Incorporated. All rights reserved.
  3519. // Cognos (R) is a trademark of Cognos Incorporated.
  3520. /*-----------------------------------------------------------------------------------------------------
  3521. Class : CBar
  3522. Description :
  3523. -----------------------------------------------------------------------------------------------------*/
  3524. var cHorizonalBar = 0;
  3525. var cVerticalBar = 1;
  3526. function CBar(containerId, style, sId, imagePath, showTooltip, hideTooltip, cookieVar, cookieName) {
  3527. this.m_align = 'left';
  3528. this.m_items = [];
  3529. this.m_htmlContainerId = containerId;
  3530. this.m_htmlContainer = null;
  3531. this.m_id = 'cbar'+containerId;
  3532. this.m_menuType = cVerticalBar;
  3533. this.m_style = style;
  3534. this.m_parent = null;
  3535. this.m_observers = new CObserver(this);
  3536. this.m_cookieVar = cookieVar;
  3537. this.m_cookieName = cookieName;
  3538. //reference to the object name
  3539. this.m_sId = (sId) ? sId : null;
  3540. this.m_display = DISPLAY_INLINE;
  3541. this.m_imagePath = (imagePath) ? imagePath : '../common/images/toolbar/';
  3542. this.m_imgCollapseSrc = this.m_imagePath + 'toolbar_collapse.gif';
  3543. this.m_imgExpandSrc = this.m_imagePath + 'toolbar_expand.gif';
  3544. this.m_showTooltip = showTooltip ? showTooltip : null;
  3545. this.m_hideTooltip = hideTooltip ? hideTooltip : null;
  3546. }
  3547. function CBar_hideBar() {
  3548. var bar = document.getElementById('bar'+ this.m_id);
  3549. var barToggleIcon = document.getElementById('barIcon'+ this.m_id);
  3550. if(barToggleIcon)
  3551. {
  3552. barToggleIcon.src= this.m_imgExpandSrc;
  3553. if (this.m_showTooltip != null) {
  3554. barToggleIcon.alt = this.m_showTooltip;
  3555. barToggleIcon.title = this.m_showTooltip;
  3556. }
  3557. }
  3558. if(bar)
  3559. {
  3560. bar.style.display = DISPLAY_NONE;
  3561. if (typeof setQSCookie == "function") {
  3562. setQSCookie(this.m_cookieVar, this.m_cookieName, 0);
  3563. }
  3564. }
  3565. }
  3566. function CBar_showBar() {
  3567. var bar = document.getElementById('bar'+ this.m_id);
  3568. var barToggleIcon = document.getElementById('barIcon'+ this.m_id);
  3569. if(barToggleIcon)
  3570. {
  3571. barToggleIcon.src= this.m_imgCollapseSrc;
  3572. if (this.m_hideTooltip != null) {
  3573. barToggleIcon.alt = this.m_hideTooltip;
  3574. barToggleIcon.title = this.m_hideTooltip;
  3575. }
  3576. }
  3577. if(bar)
  3578. {
  3579. bar.style.display = this.m_display;
  3580. if (typeof setQSCookie == "function") {
  3581. setQSCookie(this.m_cookieVar, this.m_cookieName, 1);
  3582. }
  3583. }
  3584. }
  3585. function CBar_toggleBar(){
  3586. var bar = document.getElementById('bar'+ this.m_id);
  3587. var barDisplay = bar.style.display;
  3588. if ( (barDisplay == this.m_display) || (barDisplay==""))
  3589. {
  3590. this.hideBar();
  3591. }
  3592. else
  3593. {
  3594. this.showBar();
  3595. }
  3596. }
  3597. function CBar_getParent() {
  3598. return this.m_parent;
  3599. }
  3600. function CBar_setParent(parent) {
  3601. this.m_parent = parent;
  3602. }
  3603. function CBar_draw() {
  3604. if(this.m_htmlContainer == null) {
  3605. this.m_htmlContainer = document.getElementById(this.m_htmlContainerId);
  3606. if(this.m_htmlContainer == null) { // if we can't find the container, return
  3607. return;
  3608. }
  3609. }
  3610. var html = "";
  3611. html += '<table cellpadding="0" cellspacing="0" border="0" role="presentation"';
  3612. if (this.m_sId != null)
  3613. {
  3614. html += 'style="display: inline;"><tr>';
  3615. /*The height of 26 is chosen so that the collapse/expand icons will always line up in Firefox. Bug #483255*/
  3616. html += '<td'+(isFF() ? ' style="vertical-align:bottom"':'')+' style="height:26px"><img id="barIcon'+ this.m_id +'" border="0" src="'+ this.m_imgCollapseSrc + '"';
  3617. if (this.m_hideTooltip != null) {
  3618. html += ' alt="'+this.m_hideTooltip+'" title="'+this.m_hideTooltip+'"';
  3619. }
  3620. html +=' onclick="'+this.m_sId +'.toggleBar();" style="cursor:pointer;cursor:hand;"></td>';
  3621. }
  3622. else
  3623. {
  3624. var marginStyle = "";
  3625. if (this.m_htmlContainer.style.textAlign == "right") {
  3626. marginStyle = 'margin-left:auto; margin-right: 0;';
  3627. }
  3628. else if (this.m_htmlContainer.style.textAlign == 'left') {
  3629. marginStyle = 'margin-left:0; margin-right: auto;';
  3630. }
  3631. else if (this.m_htmlContainer.style.textAlign == 'center') {
  3632. marginStyle = 'margin-left:auto; margin-right: auto;';
  3633. }
  3634. if (marginStyle != "") {
  3635. html += ' style="'+marginStyle+'"';
  3636. }
  3637. html += '><tr>';
  3638. }
  3639. html += '<td id="bar'+ this.m_id +'">';
  3640. html += '<table cellpadding="0" cellspacing="0" border="0" role="presentation" class="';
  3641. if(this.getStyle() != null)
  3642. {
  3643. html += this.getStyle().getNormalState();
  3644. }
  3645. html += '" id="';
  3646. html += this.m_id;
  3647. html += '" style="'+ this.m_style +'"><tr>';
  3648. html += this.drawItems();
  3649. html += '</tr></table></td>';
  3650. html += '</tr></table>';
  3651. this.m_htmlContainer.innerHTML = html;
  3652. this.m_htmlContainer.style.textAlign = this.m_align;
  3653. //initialize any items
  3654. for(var i = 0; i < this.m_items.length; ++i) {
  3655. if(typeof this.m_items[i].init == "function")
  3656. {
  3657. this.m_items[i].init();
  3658. }
  3659. }
  3660. this.attachEvents();
  3661. }
  3662. function CBar_drawItems() {
  3663. var html = "";
  3664. for(var i = 0; i < this.m_items.length; ++i) {
  3665. if(typeof this.m_items[i].draw == "function") {
  3666. if(this.m_menuType == cHorizonalBar && !(this.m_items[i] instanceof CSeperator) ) {
  3667. html += '<td style="white-space:nowrap;';
  3668. if(this.m_items[i] instanceof CMenuItem)
  3669. {
  3670. html += ';padding-left:1px; padding-right: 1px;';
  3671. }
  3672. html += '">';
  3673. }
  3674. if(this.m_items[i].isVisible()) {
  3675. html += this.m_items[i].draw();
  3676. }
  3677. if(this.m_menuType == cHorizonalBar && !(this.m_items[i] instanceof CSeperator) ) {
  3678. html += '</td>';
  3679. }
  3680. }
  3681. }
  3682. return html;
  3683. }
  3684. function CBar_attachEvents() {
  3685. for(var i = 0; i < this.m_items.length; ++i) {
  3686. if(typeof this.m_items[i].attachEvents == "function" && this.m_items[i].isVisible()) {
  3687. this.m_items[i].attachEvents();
  3688. }
  3689. }
  3690. }
  3691. function CBar_add(item) {
  3692. if(typeof item.getObservers == "function" && typeof item.getObservers() == "object" && typeof item.onmouseover == "function" && item instanceof CMenuItem) {
  3693. item.getObservers().attach(this, this.closeMenus, item.onmouseover);
  3694. }
  3695. this.m_items[this.m_items.length] = item;
  3696. }
  3697. function CBar_getNumItems() {
  3698. return this.m_items.length;
  3699. }
  3700. function CBar_getId() {
  3701. return this.m_id;
  3702. }
  3703. function CBar_get(index) {
  3704. if(index >= 0 && index < this.getNumItems()) {
  3705. return this.m_items[index];
  3706. }
  3707. return null;
  3708. }
  3709. function CBar_hide(index) {
  3710. if(index > 0 && index < this.getNumItems()) {
  3711. if(typeof this.m_items[i].hide == "function") {
  3712. this.m_items[i].hide();
  3713. }
  3714. }
  3715. }
  3716. function CBar_show(index) {
  3717. if(index > 0 && index < this.getNumItems()) {
  3718. if(typeof this.m_items[i].show == "function") {
  3719. this.m_items[i].show();
  3720. }
  3721. }
  3722. }
  3723. function CBar_enable(index) {
  3724. if(index > 0 && index < this.getNumItems()) {
  3725. if(typeof this.m_items[i].enable == "function") {
  3726. this.m_items[i].enable();
  3727. }
  3728. }
  3729. }
  3730. function CBar_disable(index) {
  3731. if(index > 0 && index < this.getNumItems()) {
  3732. if(typeof this.m_items[i].disable == "function") {
  3733. this.m_items[i].disable();
  3734. }
  3735. }
  3736. }
  3737. function CBar_getState(index) {
  3738. if(index > 0 && index < this.getNumItems()) {
  3739. if(typeof this.m_items[i].getState == "function") {
  3740. this.m_items[i].getState();
  3741. }
  3742. }
  3743. }
  3744. function CBar_setMenuType(menuType) {
  3745. this.m_menuType = menuType;
  3746. }
  3747. function CBar_getMenuType() {
  3748. return this.m_menuType;
  3749. }
  3750. function CBar_setStyle(style) {
  3751. this.m_style = style;
  3752. }
  3753. function CBar_setAlign(align) {
  3754. this.m_align = align;
  3755. }
  3756. function CBar_getStyle() {
  3757. return this.m_style;
  3758. }
  3759. function CBar_closeMenus(state) {
  3760. // make sure we hide any submenus which have been opened.
  3761. for(var i = 0; i < this.getNumItems(); i++) {
  3762. var currentItem = this.get(i);
  3763. if(typeof state == "object") {
  3764. if(state.getSubject() == currentItem) {
  3765. continue;
  3766. }
  3767. }
  3768. if(typeof currentItem.getMenu == "function" && currentItem.getMenu() != null && currentItem.getMenu().isVisible()) {
  3769. currentItem.getMenu().remove();
  3770. }
  3771. }
  3772. }
  3773. function CBar_getHTMLContainer() {
  3774. return this.m_htmlContainer;
  3775. }
  3776. function CBar_getObservers() {
  3777. return this.m_observers;
  3778. }
  3779. function CBar_onmouseover(evt) {
  3780. //get the event in a cross-browser fashion
  3781. evt = (evt) ? evt : ((event) ? event : null);
  3782. // notify our parent (if one exists) of this event
  3783. if(this.getParent() != null && typeof this.getParent().onmouseover == "function") {
  3784. this.getParent().onmouseover(evt);
  3785. }
  3786. // notify observers of this event
  3787. this.getObservers().notify(CBar_onmouseover);
  3788. }
  3789. function CBar_onmouseout(evt) {
  3790. //get the event in a cross-browser fashion
  3791. evt = (evt) ? evt : ((event) ? event : null);
  3792. // notify our parent (if one exists) of this event
  3793. if(this.getParent() != null && typeof this.getParent().onmouseout == "function") {
  3794. this.getParent().onmouseout(evt);
  3795. }
  3796. // notify observers of this event
  3797. this.getObservers().notify(CBar_onmouseout);
  3798. }
  3799. function CBar_onmouseup(evt) {
  3800. //get the event in a cross-browser fashion
  3801. evt = (evt) ? evt : ((event) ? event : null);
  3802. // notify our parent (if one exists) of this event
  3803. if(this.getParent() != null && typeof this.getParent().onmouseup == "function") {
  3804. this.getParent().onmouseup(evt);
  3805. }
  3806. // notify observers of this event
  3807. this.getObservers().notify(CBar_onmouseup);
  3808. }
  3809. function CBar_onkeypress(evt) {
  3810. //get the event in a cross-browser fashion
  3811. evt = (evt) ? evt : ((event) ? event : null);
  3812. // notify our parent (if one exists) of this event
  3813. if(this.getParent() != null && typeof this.getParent().onkeypress == "function") {
  3814. this.getParent().onkeypress(evt);
  3815. }
  3816. // notify observers of this event
  3817. this.getObservers().notify(CBar_onkeypress);
  3818. }
  3819. CBar.prototype.draw = CBar_draw;
  3820. CBar.prototype.add = CBar_add;
  3821. CBar.prototype.get = CBar_get;
  3822. CBar.prototype.hide = CBar_hide;
  3823. CBar.prototype.show = CBar_show;
  3824. CBar.prototype.enable = CBar_enable;
  3825. CBar.prototype.disable = CBar_disable;
  3826. CBar.prototype.getState = CBar_getState;
  3827. CBar.prototype.attachEvents = CBar_attachEvents;
  3828. CBar.prototype.drawItems = CBar_drawItems;
  3829. CBar.prototype.getId = CBar_getId;
  3830. CBar.prototype.setMenuType = CBar_setMenuType;
  3831. CBar.prototype.getMenuType = CBar_getMenuType;
  3832. CBar.prototype.getNumItems = CBar_getNumItems;
  3833. CBar.prototype.setStyle = CBar_setStyle;
  3834. CBar.prototype.getStyle = CBar_getStyle;
  3835. CBar.prototype.setAlign = CBar_setAlign;
  3836. CBar.prototype.closeMenus = CBar_closeMenus;
  3837. CBar.prototype.setParent = CBar_setParent;
  3838. CBar.prototype.getParent = CBar_getParent;
  3839. CBar.prototype.getHTMLContainer = CBar_getHTMLContainer;
  3840. CBar.prototype.getObservers = CBar_getObservers;
  3841. CBar.prototype.update = new Function("return true");
  3842. CBar.prototype.getObservers = CBar_getObservers;
  3843. CBar.prototype.onmouseover = CBar_onmouseover;
  3844. CBar.prototype.onmouseout = CBar_onmouseout;
  3845. CBar.prototype.onmouseup = CBar_onmouseup;
  3846. CBar.prototype.onkeypress = CBar_onkeypress;
  3847. CBar.prototype.hideBar = CBar_hideBar;
  3848. CBar.prototype.showBar = CBar_showBar;
  3849. CBar.prototype.toggleBar = CBar_toggleBar;
  3850. /*
  3851. Class CStaticText
  3852. Static text to be shown in the banner or header
  3853. */
  3854. function CStaticText(text, style)
  3855. {
  3856. this.m_text = text;
  3857. this.m_style = style;
  3858. this.m_bVisible = true;
  3859. this.m_sId = "";
  3860. }
  3861. CStaticText.prototype.setId = function(sId)
  3862. {
  3863. this.m_sId = sId;
  3864. };
  3865. CStaticText.prototype.getId = function()
  3866. {
  3867. return this.m_sId;
  3868. };
  3869. CStaticText.prototype.setText = function(text)
  3870. {
  3871. this.m_text = text;
  3872. };
  3873. CStaticText.prototype.setLabelledBy = function(text)
  3874. {
  3875. this.m_labelledBy = text;
  3876. };
  3877. CStaticText.prototype.draw = function()
  3878. {
  3879. var html="";
  3880. html += '<td style="white-space: nowrap;" class="';
  3881. html += this.m_style.getNormalState() + '"';
  3882. if (this.getId() != "")
  3883. {
  3884. html += ' id="' + this.getId() + '"';
  3885. }
  3886. html += '>';
  3887. var labelledByAttribute = this.m_labelledBy ? 'aria-labelledby="' + this.getId() + 'label"' : "";
  3888. html += '<div role="presentation" tabIndex="0" ' + labelledByAttribute + '>';
  3889. html += this.m_text;
  3890. html += '</div>';
  3891. if (this.m_labelledBy) {
  3892. html += '<div style="position: absolute; overflow: hidden; width: 0; height: 0;" id="' + this.getId() + 'label">';
  3893. html += this.m_labelledBy;
  3894. html += '</div>';
  3895. }
  3896. html += '</td>';
  3897. return html;
  3898. };
  3899. CStaticText.prototype.isVisible = function()
  3900. {
  3901. return this.m_bVisible;
  3902. };
  3903. CStaticText.prototype.hide = function()
  3904. {
  3905. this.m_bVisible = false;
  3906. };
  3907. CStaticText.prototype.hide.show = function()
  3908. {
  3909. this.m_bVisible = true;
  3910. };
  3911. /* Constants */
  3912. var DISPLAY_INLINE = 'inline';
  3913. var DISPLAY_NONE = "none";
  3914. var DISPLAY_BLOCK = "block";