123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686 |
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: Viewer
- *| (C) Copyright IBM Corp. 2001, 2020
- *|
- *| US Government Users Restricted Rights - Use, duplication or
- *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- *|
- *+------------------------------------------------------------------------+
- */
- /*-----------------------------------------------------------------------------------------------------
- Class : CStyle
- Description :
- -----------------------------------------------------------------------------------------------------*/
- function CUIStyle(normal, rollover, depressed, depressed_rollover, disabled) {
- this.m_active = normal;
- this.m_normal = normal;
- this.m_rollover = rollover;
- this.m_activeRollover = rollover;
- this.m_depressed = depressed;
- this.m_depressed_rollover = depressed_rollover;
- this.m_disabled = disabled;
- }
- function CUIStyle_getActiveState() {
- return this.m_active;
- }
- function CUIStyle_setActiveState(state) {
- switch(state) {
- case "normal":
- this.m_active = this.m_normal;
- break;
- case "depressed":
- this.m_active = this.m_depressed;
- break;
- case "disabled":
- this.m_active = this.m_disabled;
- break;
- default:
- this.m_active = this.m_normal;
- }
- }
- function CUIStyle_getActiveRolloverState() {
- return this.m_activeRollover;
- }
- function CUIStyle_setActiveRolloverState(state) {
- switch(state) {
- case "normal":
- this.m_activeRollover = this.m_rollover;
- break;
- case "depressed":
- this.m_activeRollover = this.m_depressed_rollover;
- break;
- case "disabled":
- this.m_activeRollover = this.m_disabled;
- break;
- default:
- this.m_activeRollover = this.m_rollover;
- }
- }
- function CUIStyle_getNormalState() {
- return this.m_normal;
- }
- function CUIStyle_getRolloverState() {
- return this.m_rollover;
- }
- function CUIStyle_getDepressedState() {
- return this.m_depressed;
- }
- function CUIStyle_getDepressedRolloverState() {
- return this.m_depressed_rollover;
- }
- function CUIStyle_getDisabledState() {
- return this.m_disabled;
- }
- function CUIStyle_setNormalState(state) {
- this.m_normal = state;
- }
- function CUIStyle_setRolloverState(state) {
- this.m_rollover = state;
- }
- function CUIStyle_setDepressedState(state) {
- this.m_depressed = state;
- }
- function CUIStyle_setDepressedRolloverState(state) {
- this.m_depressed_rollover = state;
- }
- function CUIStyle_setDisabledState(state) {
- this.m_disabled = state;
- }
- CUIStyle.prototype.getNormalState = CUIStyle_getNormalState;
- CUIStyle.prototype.getRolloverState = CUIStyle_getRolloverState;
- CUIStyle.prototype.getDepressedState = CUIStyle_getDepressedState;
- CUIStyle.prototype.getDepressedRolloverState = CUIStyle_getDepressedRolloverState;
- CUIStyle.prototype.getDisabledState = CUIStyle_getDisabledState;
- CUIStyle.prototype.setNormalState = CUIStyle_setNormalState;
- CUIStyle.prototype.setRolloverState = CUIStyle_setRolloverState;
- CUIStyle.prototype.setDepressedState = CUIStyle_setDepressedState;
- CUIStyle.prototype.setDepressedRolloverState = CUIStyle_setDepressedRolloverState;
- CUIStyle.prototype.setDisabledState = CUIStyle_setDisabledState;
- CUIStyle.prototype.setActiveState = CUIStyle_setActiveState;
- CUIStyle.prototype.getActiveState = CUIStyle_getActiveState;
- CUIStyle.prototype.getActiveRolloverState = CUIStyle_getActiveRolloverState;
- CUIStyle.prototype.setActiveRolloverState = CUIStyle_setActiveRolloverState;
- // Copyright (C) 2008 Cognos Incorporated. All rights reserved.
- // Cognos (R) is a trademark of Cognos Incorporated.
- /*-----------------------------------------------------------------------------------------------------
- Class : CToolbarSelect
- Description :
- -----------------------------------------------------------------------------------------------------*/
- function CToolbarSelect(parent, name, command, label, toolTip) {
- this.m_parent = parent;
- this.m_name = name;
- this.m_command = command;
- this.m_label = label;
- this.m_toolTip = toolTip;
- this.m_items = [];
- if(typeof this.m_parent == "object" && typeof this.m_parent.add == "function")
- {
- this.m_parent.add(this);
- }
- //add a defalt item
- if (label)
- {
- this.add("", label);
- }
- }
- function CToolbarSelect_draw() {
- var html = '<select id="' + this.m_name + '" name="' + this.m_name + '" onchange="' + this.m_command + '"';
- if (this.m_toolTip != "") {
- html += ' title="' + this.m_toolTip + '"';
- }
- html += '>';
- html += this.drawItems();
- html += '</select>';
- return html;
- }
- function CToolbarSelect_drawItems()
- {
- var html="";
- for (var i=0; i<this.m_items.length; i++)
- {
- html += '<option value="'+ this.m_items[i].getUse() +'">'+ this.m_items[i].getDisplay() +'</option>';
- }
- return html;
- }
- function CToolbarSelect_add(sUse, sDisplay)
- {
- var newItem = new CSelectItem(sUse, sDisplay);
- this.m_items = this.m_items.concat(newItem);
- }
- function CToolbarSelect_isVisible() {
- //return this.m_bVisible;
- return true;
- }
- CToolbarSelect.prototype.draw = CToolbarSelect_draw;
- CToolbarSelect.prototype.drawItems = CToolbarSelect_drawItems;
- CToolbarSelect.prototype.isVisible = CToolbarSelect_isVisible;
- CToolbarSelect.prototype.add = CToolbarSelect_add;
- function CSelectItem (sUse, sDisplay)
- {
- this.m_sUse = sUse;
- this.m_sDisplay = sDisplay;
- }
- function CSelectItem_getUse()
- {
- return this.m_sUse;
- }
- function CSelectItem_getDisplay()
- {
- return this.m_sDisplay;
- }
- CSelectItem.prototype.getUse = CSelectItem_getUse;
- CSelectItem.prototype.getDisplay = CSelectItem_getDisplay;
- // Copyright (C) 2008 Cognos Incorporated. All rights reserved.
- // Cognos (R) is a trademark of Cognos Incorporated.
- /*-----------------------------------------------------------------------------------------------------
- Class : CToolbarPicker
- Description : Toolbar Button wrapper for the CColorPicker and CAlignmentPicker prompt controls
- -----------------------------------------------------------------------------------------------------*/
- function CToolbarPicker(parent, sCommand, sPromptId, sRef, sType) {
- this.m_parent = parent;
- this.m_command = sCommand;
- this.m_oPicker = null;
- this.m_sPromptId = sPromptId;
- this.m_sRef = sRef;
- this.m_sType = sType;
- if(typeof this.m_parent == "object" && typeof this.m_parent.add == "function")
- {
- this.m_parent.add(this);
- }
- }
- function CToolbarPicker_draw() {
- var html = '<div id="' + this.m_sType + this.m_sPromptId + '" onclick="' + this.m_sRef + '.preventBubbling(event);"></div>';
- return html;
- }
- function CToolbarPicker_init()
- {
- this.m_oPicker = eval (this.m_command);
- g_pickerObservers = g_pickerObservers.concat(this.m_sRef);
- }
- function CToolbarPicker_isVisible() {
- //return this.m_bVisible;
- return true;
- }
- function CToolbarPicker_togglePicker()
- {
- this.m_oPicker.togglePicker();
- }
- function CToolbarPicker_setActiveColor(s)
- {
- this.m_oPicker.setActiveColor(s);
- }
- function CToolbarPicker_setColor(s)
- {
- this.m_oPicker.setColor(s);
- }
- function CToolbarPicker_setAlignment(s)
- {
- this.m_oPicker.setAlignment(s);
- }
- function CToolbarPicker_setActiveAlignment(s)
- {
- this.m_oPicker.setActiveAlignment(s);
- }
- function CToolbarPicker_setPalette(s)
- {
- this.m_oPicker.setPalette(s);
- }
- function CToolbarPicker_applyCustomStyle()
- {
- this.m_oPicker.applyCustomStyle();
- }
- function CToolbarPicker_updateCustomStyle()
- {
- this.m_oPicker.updateCustomStyle();
- }
- function CToolbarPicker_hide()
- {
- this.m_oPicker.hide();
- }
- function CToolbarPicker_preventBubbling(e)
- {
- this.m_oPicker.preventBubbling(e);
- }
- function CToolbarPicker_buttonMouseHandler(button, action)
- {
- this.m_oPicker.buttonMouseHandler(button, action);
- }
- CToolbarPicker.prototype.draw = CToolbarPicker_draw;
- CToolbarPicker.prototype.isVisible = CToolbarPicker_isVisible;
- CToolbarPicker.prototype.init = CToolbarPicker_init;
- CToolbarPicker.prototype.togglePicker = CToolbarPicker_togglePicker;
- CToolbarPicker.prototype.setColor = CToolbarPicker_setColor;
- CToolbarPicker.prototype.setAlignment = CToolbarPicker_setAlignment;
- CToolbarPicker.prototype.setActiveAlignment = CToolbarPicker_setActiveAlignment;
- CToolbarPicker.prototype.setActiveColor = CToolbarPicker_setActiveColor;
- CToolbarPicker.prototype.setPalette = CToolbarPicker_setPalette;
- CToolbarPicker.prototype.applyCustomStyle = CToolbarPicker_applyCustomStyle;
- CToolbarPicker.prototype.updateCustomStyle = CToolbarPicker_updateCustomStyle;
- CToolbarPicker.prototype.hide = CToolbarPicker_hide;
- CToolbarPicker.prototype.preventBubbling = CToolbarPicker_preventBubbling;
- CToolbarPicker.prototype.buttonMouseHandler = CToolbarPicker_buttonMouseHandler;
- // Copyright (C) 2008 Cognos Incorporated. All rights reserved.
- // Cognos (R) is a trademark of Cognos Incorporated.
- /*-----------------------------------------------------------------------------------------------------
- Class : CToolbarButton
- Description :
- -----------------------------------------------------------------------------------------------------*/
- var tbUniqueId = 0;
- function makeId() {
- return tbUniqueId++;
- }
- gDropDownButtonStyle = new CUIStyle('dropDownArrow','dropDownArrowOver',"","","");
- gHeaderDropDownButtonStyle = new CUIStyle('bannerDropDownArrow','bannerDropDownArrowOver',"","","");
- function CToolbarButton(parent, action, iconPath, toolTip, style, bHideDropDown, label, dropDownToolTip, webContentRoot) {
- this.m_id = 'tbbutton'+makeId();
- this.m_bVisible = true;
- this.m_action = action;
- this.m_toolTip = toolTip;
- if (typeof webContentRoot != "undefined" && webContentRoot != "")
- {
- this.m_webContentRoot = webContentRoot;
- }
- else
- {
- this.m_webContentRoot = "..";
- }
- this.m_icon = (iconPath) ? new CIcon(iconPath, toolTip, this.webContentRoot) : null;
- this.m_parent = parent;
- this.m_menu = null;
- if (typeof bHideDropDown == "boolean") {
- this.m_bHideDropDown = bHideDropDown;
- }
- else {
- this.m_bHideDropDown = false;
- }
- this.m_style = new CUIStyle(style.getNormalState(),style.getRolloverState(),style.getDepressedState(),style.getDepressedRolloverState(),style.getDisabledState());
- this.m_observers = new CObserver(this);
- if(typeof this.m_parent == "object" && typeof this.m_parent.add == "function") {
- this.m_parent.add(this);
- }
- this.m_label = (label) ? label : null;
- this.m_dropDownToolTip = (dropDownToolTip) ? dropDownToolTip : this.m_toolTip;
- this.m_dropDownStyle = gDropDownButtonStyle;
- }
- function CToolbarButton_getId() {
- return this.m_id;
- }
- function CToolbarButton_draw() {
- var html="";
- html += '<div style="margin-right:3px;"><button type="button" id="';
- html += this.m_id;
- html += '"';
- if(typeof this.getStyle() == "object")
- {
- html += ' class="' + this.getStyle().getActiveState() + '"';
- if (this.getStyle().getActiveState() != this.getStyle().getDisabledState())
- {
- if (this.isEnabled())
- {
- html += ' tabIndex="1"';
- }
- html += ' hideFocus="true"';
- }
- }
- if (this.m_toolTip != "")
- {
- html += ' title="' + this.m_toolTip + '"';
- }
- html += '>';
- if (this.m_icon != null)
- {
- html += this.m_icon.draw();
- }
- if (this.m_label != null)
- {
- html += this.m_label;
- }
- html += '</button>';
- if(this.m_menu != null && !this.m_bHideDropDown)
- {
- html += '<button type="button" id="';
- html += ('menu' + this.getId());
- html += '"';
- if(typeof this.getStyle() == "object")
- {
- html += ' class="'+this.getDropDownStyle().getActiveState() + '"';
- if (this.getStyle().getActiveState() != this.getStyle().getDisabledState())
- {
- if (this.isEnabled())
- {
- html += ' tabIndex="1"';
- }
- html += ' hideFocus="true"';
- }
- }
- if (this.m_dropDownToolTip != "")
- {
- html += ' title="' + this.m_dropDownToolTip + '"';
- }
- html += '><img style="vertical-align:middle;" border="0" src="' + this.m_webContentRoot + '/common/images/toolbar_drop_arrow.gif"';
- if (this.m_dropDownToolTip != "")
- {
- html += ' alt="' + this.m_dropDownToolTip + '"';
- html += ' title="' + this.m_dropDownToolTip + '"';
- }
- else
- {
- html += ' alt=""';
- }
- html += ' width="7" height="16"/></button>';
- }
- html += '</div>';
- return html;
- }
- function CToolbarButton_attachEvents() {
- if(typeof this.getParent().getHTMLContainer != "function") {
- return; // this method must be implemented by the parent
- }
- var htmlContainer = this.getParent().getHTMLContainer();
- if(htmlContainer == null) {
- return;
- }
- var hTbItem = eval(htmlContainer.document ? htmlContainer.document.getElementById(this.m_id) : htmlContainer.ownerDocument.getElementById(this.m_id));
- if(hTbItem == null) {
- return; // just to be safe
- }
- hTbItem.onmouseover = this.onmouseover;
- hTbItem.onmouseout = this.onmouseout;
- hTbItem.onclick = this.onclick;
- hTbItem.onkeypress = this.onkeypress;
- hTbItem.onfocus = this.onfocus;
- hTbItem.onblur = this.onblur;
- hTbItem.tbItem = eval(this);
- // attach the drop down arrow event handlers to the toolbar button as well
- if(this.m_menu != null && !this.m_bHideDropDown)
- {
- var hmenu = eval(htmlContainer.document ? htmlContainer.document.getElementById('menu'+this.getId()) : htmlContainer.ownerDocument.getElementById('menu'+this.getId()));
- hmenu.onmouseover = this.onmouseover;
- hmenu.onmouseout = this.onmouseout;
- hmenu.onclick = this.onclick;
- hmenu.onkeypress = this.onkeypress;
- hmenu.onfocus = this.onfocus;
- hmenu.onblur = this.onblur;
- hmenu.tbItem = eval(this);
- }
- }
- function CToolbarButton_createDropDownMenu(menuStyle, dropDownToolTip) {
- this.m_dropDownToolTip = (dropDownToolTip) ? dropDownToolTip : this.m_toolTip;
- this.m_menu = new CMenu('dropDown'+this.getId(),menuStyle, this.m_webContentRoot);
- this.m_menu.setParent(this);
- return this.m_menu;
- }
- function CToolbarButton_addOwnerDrawControl(control) {
- this.m_menu = control;
- if(typeof control.setParent != "undefined") {
- this.m_menu.setParent(this);
- }
- }
- function CToolbarButton_getParent() {
- return this.m_parent;
- }
- function CToolbarButton_setParent(parent) {
- this.m_parent = parent;
- }
- function CToolbarButton_getAction() {
- return this.m_action;
- }
- function CToolbarButton_setAction(action) {
- this.m_action = action;
- }
- function CToolbarButton_getToolTip() {
- return this.m_toolTip;
- }
- function CToolbarButton_setToolTip(tooltip) {
- this.m_toolTip = tooltip;
- }
- function CToolbarButton_getDropDownToolTip() {
- return this.m_dropDownToolTip;
- }
- function CToolbarButton_setDropDownToolTip(tooltip) {
- this.m_dropDownToolTip = tooltip;
- }
- function CToolbarButton_getIcon() {
- return this.m_icon;
- }
- function CToolbarButton_setIcon(iconPath) {
- this.m_icon.setPath(iconPath);
- }
- function CToolbarButton_onmouseover(evt)
- {
- var toolbarButton = this.tbItem;
- if(typeof toolbarButton == "object")
- {
- if(!toolbarButton.isEnabled()) {
- return;
- }
- if(toolbarButton.getMenu() != null && !toolbarButton.m_bHideDropDown && ('menu'+toolbarButton.getId()) == this.id) {
- this.className = toolbarButton.getDropDownStyle().getActiveRolloverState();
- }
- else
- {
- if(typeof toolbarButton.getStyle() == "object") {
- this.className = toolbarButton.getStyle().getActiveRolloverState();
- }
- if(toolbarButton.getMenu() != null && !toolbarButton.m_bHideDropDown)
- {
- var dropDownArrow = this.document ? this.document.getElementById('menu'+toolbarButton.getId()) : this.ownerDocument.getElementById('menu'+toolbarButton.getId());
- if(typeof dropDownArrow == "object") {
- dropDownArrow.className = toolbarButton.getDropDownStyle().getActiveRolloverState();
- }
- }
- }
- // send the message up to our parent
- if(toolbarButton.getParent() != null && typeof toolbarButton.getParent().onmouseover == "function") {
- toolbarButton.getParent().onmouseover(evt);
- }
- // notify our observers of this event
- toolbarButton.getObservers().notify(CToolbarButton_onmouseover);
- }
- }
- function CToolbarButton_onmouseout(evt) {
- var toolbarButton = this.tbItem;
- if(typeof toolbarButton == "object")
- {
- if(!toolbarButton.isEnabled()) {
- return;
- }
- if(toolbarButton.getMenu() != null && !toolbarButton.m_bHideDropDown && ('menu'+toolbarButton.getId()) == this.id) {
- this.className = toolbarButton.getDropDownStyle().getActiveState();
- }
- else
- {
- if(typeof toolbarButton.getStyle() == "object") {
- this.className = toolbarButton.getStyle().getActiveState();
- }
- if(toolbarButton.getMenu() != null && !toolbarButton.m_bHideDropDown)
- {
- var dropDownArrow = this.document ? this.document.getElementById('menu'+toolbarButton.getId()) : this.ownerDocument.getElementById('menu'+toolbarButton.getId());
- if(typeof dropDownArrow == "object") {
- dropDownArrow.className = toolbarButton.getDropDownStyle().getActiveState();
- }
- }
- }
- // send the message up to our parent
- if(toolbarButton.getParent() != null && typeof toolbarButton.getParent().onmouseout == "function") {
- toolbarButton.getParent().onmouseout(evt);
- }
- // notify our observers of this event
- toolbarButton.getObservers().notify(CToolbarButton_onmouseout);
- }
- }
- function CToolbarButton_onclick(evt) {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- // get the toolbar button from the html element
- var toolbarButton = this.tbItem;
- if(toolbarButton != null) {
- if(!toolbarButton.isEnabled()) {
- return;
- }
- var menu = toolbarButton.getMenu();
- if(menu != null && ((this.id == ('menu'+toolbarButton.getId())) || (toolbarButton.m_bHideDropDown && this.id == toolbarButton.getId()))) {
- if(menu.isVisible()) {
- menu.remove();
- } else {
- // the user clicked the drop down arrow
- if(typeof menu.setHTMLContainer != "undefined") {
- menu.setHTMLContainer(this.document ? this.document.body : this.ownerDocument.body);
- }
- //Close all the other dropdown menus first
- if(typeof toolbarButton.m_parent.closeMenus == "function") {
- toolbarButton.m_parent.closeMenus();
- }
- menu.draw();
- menu.show();
- }
- } else {
- eval(this.tbItem.m_action);
- }
- // send the message up to our parent
- if(toolbarButton.getParent() != null && typeof toolbarButton.getParent().onclick == "function") {
- toolbarButton.getParent().onclick(evt);
- }
- // notify our observers of this event
- toolbarButton.getObservers().notify(CToolbarButton_onclick);
- }
- if (this.blur) {
- this.blur();
- }
- evt.cancelBubble = true;
- return false;
- }
- function CToolbarButton_onkeypress(evt) {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- //check for the Enter or Space key
- if (evt.keyCode == 13 || evt.keyCode == 0) {
- // get the toolbar button from the html element
- var toolbarButton = this.tbItem;
- if(toolbarButton != null) {
- if(!toolbarButton.isEnabled()) {
- return;
- }
- var menu = toolbarButton.getMenu();
- if(menu != null && ((this.id == ('menu'+toolbarButton.getId())) || (toolbarButton.m_bHideDropDown && this.id == toolbarButton.getId()))) {
- if(menu.isVisible()) {
- menu.remove();
- } else {
- // the user clicked the drop down arrow
- if(typeof menu.setHTMLContainer != "undefined") {
- menu.setHTMLContainer(this.document ? this.document.body : this.ownerDocument.body);
- }
- menu.draw();
- menu.show();
- }
- } else {
- eval(this.tbItem.m_action);
- }
- // send the message up to our parent
- if(toolbarButton.getParent() != null && typeof toolbarButton.getParent().onkeypress == "function") {
- toolbarButton.getParent().onkeypress(evt);
- }
- // notify our observers of this event
- toolbarButton.getObservers().notify(CToolbarButton_onkeypress);
- }
- return false;
- }
- evt.cancelBubble = true;
- return true;
- }
- function CToolbarButton_getMenu() {
- return this.m_menu;
- }
- function CToolbarButton_getMenuType() {
- // current toolbar buttons only support drop down menus
- return 'dropDown';
- }
- function CToolbarButton_setStyle(style) {
- this.m_style = style;
- }
- function CToolbarButton_getStyle() {
- return this.m_style;
- }
- function CToolbarButton_getDropDownStyle() {
- return this.m_dropDownStyle;
- }
- function CToolbarButton_setDropDownStyle(style) {
- this.m_dropDownStyle = style;
- }
- function CToolbarButton_isVisible() {
- return this.m_bVisible;
- }
- function CToolbarButton_hide() {
- this.m_bVisible = false;
- }
- function CToolbarButton_show() {
- this.m_bVisible = true;
- }
- function CToolbarButton_enable() {
- this.getStyle().setActiveState('normal');
- this.getStyle().setActiveRolloverState('normal');
- if (this.getIcon())
- {
- this.getIcon().enable();
- }
- this.updateHTML();
- }
- function CToolbarButton_disable() {
- this.getStyle().setActiveState('disabled');
- this.getStyle().setActiveRolloverState('disabled');
- if (this.getIcon())
- {
- this.getIcon().disable();
- }
- this.updateHTML();
- }
- function CToolbarButton_isEnabled() {
- if (this.getIcon())
- {
- return this.getIcon().isEnabled();
- }
- else
- {
- return true;
- }
- }
- function CToolbarButton_pressed() {
- this.getStyle().setActiveState('depressed');
- this.getStyle().setActiveRolloverState('depressed');
- this.updateHTML();
- }
- function CToolbarButton_reset() {
- this.getStyle().setActiveState('normal');
- this.getStyle().setActiveRolloverState('normal');
- this.updateHTML();
- }
- function CToolbarButton_updateHTML() {
- if(typeof this.getStyle() == "object")
- {
- if(typeof this.getParent().getHTMLContainer == "function")
- {
- var htmlContainer = this.getParent().getHTMLContainer();
- if(htmlContainer != null)
- {
- var htmlElement = htmlContainer.document ? htmlContainer.document.getElementById(this.getId()) : htmlContainer.ownerDocument.getElementById(this.getId());
- if(htmlElement != null)
- {
- var toolbarImage = htmlElement.getElementsByTagName("img");
- if(typeof toolbarImage != "undefined" && toolbarImage instanceof Array && toolbarImage.length > 0)
- {
- if (this.getIcon())
- {
- if(this.getIcon().isEnabled())
- {
- toolbarImage[0].src = this.getIcon().getPath();
- }
- else
- {
- toolbarImage[0].src = this.getIcon().getDisabledImagePath();
- }
- }
- if(this.getToolTip())
- {
- htmlElement.title = this.getToolTip();
- toolbarImage[0].title = this.getToolTip();
- }
- }
- var dropDownIcon;
- if(this.getStyle().getActiveState() != this.getStyle().getDisabledState())
- {
- htmlElement.tabIndex = 1;
- if (this.getMenu() != null && !this.m_bHideDropDown)
- {
- htmlElement.nextSibling.tabIndex = 1;
- htmlElement.nextSibling.title = this.getToolTip();
- dropDownIcon = htmlElement.nextSibling.getElementsByTagName("img");
- if(dropDownIcon != null)
- {
- dropDownIcon[0].title = this.getToolTip();
- }
- }
- }
- else
- {
- if (htmlElement.tabIndex != "undefined")
- {
- htmlElement.removeAttribute("tabIndex");
- if (this.getMenu() != null)
- {
- htmlElement.nextSibling.removeAttribute("tabIndex");
- htmlElement.nextSibling.title = this.getToolTip();
- dropDownIcon = htmlElement.nextSibling.getElementsByTagName("img");
- if(dropDownIcon != null)
- {
- dropDownIcon[0].title = this.getToolTip();
- }
- }
- }
- }
- htmlElement.className = this.getStyle().getActiveState();
- }
- }
- }
- }
- }
- function CToolbarButton_getObservers() {
- return this.m_observers;
- }
- function CToolbarButton_setFocus() {
- if (this.m_menu != null && !this.m_bHideDropDown) {
- document.getElementById(this.m_id).nextSibling.focus();
- }
- else {
- document.getElementById(this.m_id).focus();
- }
- }
- CToolbarButton.prototype.draw = CToolbarButton_draw;
- CToolbarButton.prototype.attachEvents = CToolbarButton_attachEvents;
- CToolbarButton.prototype.onblur = CToolbarButton_onmouseout;
- CToolbarButton.prototype.onfocus = CToolbarButton_onmouseover;
- CToolbarButton.prototype.onkeypress = CToolbarButton_onkeypress;
- CToolbarButton.prototype.onmouseover = CToolbarButton_onmouseover;
- CToolbarButton.prototype.onmouseout = CToolbarButton_onmouseout;
- CToolbarButton.prototype.onclick = CToolbarButton_onclick;
- CToolbarButton.prototype.setParent = CToolbarButton_setParent;
- CToolbarButton.prototype.getParent = CToolbarButton_getParent;
- CToolbarButton.prototype.getAction = CToolbarButton_getAction;
- CToolbarButton.prototype.setAction = CToolbarButton_setAction;
- CToolbarButton.prototype.getToolTip = CToolbarButton_getToolTip;
- CToolbarButton.prototype.setToolTip = CToolbarButton_setToolTip;
- CToolbarButton.prototype.getDropDownToolTip = CToolbarButton_getDropDownToolTip;
- CToolbarButton.prototype.setDropDownToolTip = CToolbarButton_setDropDownToolTip;
- CToolbarButton.prototype.getIcon = CToolbarButton_getIcon;
- CToolbarButton.prototype.setIcon = CToolbarButton_setIcon;
- CToolbarButton.prototype.getMenu = CToolbarButton_getMenu;
- CToolbarButton.prototype.getMenuType = CToolbarButton_getMenuType;
- CToolbarButton.prototype.getId = CToolbarButton_getId;
- CToolbarButton.prototype.setStyle = CToolbarButton_setStyle;
- CToolbarButton.prototype.getStyle = CToolbarButton_getStyle;
- CToolbarButton.prototype.getDropDownStyle = CToolbarButton_getDropDownStyle;
- CToolbarButton.prototype.setDropDownStyle = CToolbarButton_setDropDownStyle;
- CToolbarButton.prototype.createDropDownMenu = CToolbarButton_createDropDownMenu;
- CToolbarButton.prototype.addOwnerDrawControl = CToolbarButton_addOwnerDrawControl;
- CToolbarButton.prototype.getObservers = CToolbarButton_getObservers;
- CToolbarButton.prototype.update = new Function("return true");
- CToolbarButton.prototype.isVisible = CToolbarButton_isVisible;
- CToolbarButton.prototype.hide = CToolbarButton_hide;
- CToolbarButton.prototype.show = CToolbarButton_show;
- CToolbarButton.prototype.isEnabled = CToolbarButton_isEnabled;
- CToolbarButton.prototype.enable = CToolbarButton_enable;
- CToolbarButton.prototype.disable = CToolbarButton_disable;
- CToolbarButton.prototype.pressed = CToolbarButton_pressed;
- CToolbarButton.prototype.reset = CToolbarButton_reset;
- CToolbarButton.prototype.setFocus = CToolbarButton_setFocus;
- CToolbarButton.prototype.updateHTML = CToolbarButton_updateHTML;
- // Copyright (C) 2008 Cognos Incorporated. All rights reserved.
- // Cognos (R) is a trademark of Cognos Incorporated.
- /**
- Class: CModal
- Description:
- @param title String to show in the header. [Mandatory]
- @param sCloseToolTip String to use as tooltip for close button. [Madatory]
- @param parent The container of this dialog. [Optional]
- @param t Top coordinate. [Optional] By Default the dialog is centered.
- @param l Left coordinate. [Optional] By Default the dialog is centered.
- @param h Height of the dialog. [Optional] By Default the dialog is centered.
- @param w Width of the dialog. [Optional] By Default the dialog is centered.
- */
- /* Constants */
- var CMODAL_ID = 'CMODAL_FRAME';
- var CMODAL_BLUR = 'CMODAL_BLUR';
- var CMODAL_CONTENT_ID = 'CMODAL_CONTENT';
- var CMODAL_HEADER = 'CMODAL_HEADER';
- var CMODAL_BACKGROUND_LAYER_ID = 'CMODAL_BK';
- var CMODAL_BACK_IFRAME_ID = 'CMODAL_BK_IFRAME';
- var CMODAL_ZINDEX = 111;
- /* Global variables */
- var CMODAL_dragEnabled = false;
- var CMODAL_resizeDirection = null;
- var CMODAL_startLeft = null;
- var CMODAL_startTop = null;
- var CMODAL_startWidth = null;
- var CMODAL_startHeight = null;
- var CMODAL_deltaX = null;
- var CMODAL_deltaY = null;
- function CModal(title, sCloseToolTip, parent, t, l, h, w, hideButtonBar, hideHeader, dynamicSize, blurBackground, webContentRoot)
- {
- this.m_hideButtonBar = false;
- if(typeof hideButtonBar != "undefined")
- {
- this.m_hideButtonBar = hideButtonBar;
- }
- this.m_hideHeader = false;
- if(typeof hideHeader != "undefined")
- {
- this.m_hideHeader= hideHeader;
- }
- this.m_title = title;
- this.m_sCloseToolTip = sCloseToolTip;
- if (parent) {
- this.m_parent = parent;
- } else {
- this.m_parent = (document.body ? document.body : document.documentElement);
- }
- var oBL = document.getElementById(CMODAL_BACKGROUND_LAYER_ID);
- if(oBL)
- {
- oBL.parentNode.removeChild(oBL);
- }
- if (typeof webContentRoot != "undefined" && webContentRoot != "")
- {
- this.m_webContentRoot = webContentRoot;
- }
- else
- {
- this.m_webContentRoot = "..";
- }
- oBL = document.createElement("div");
- oBL.id = CMODAL_BACKGROUND_LAYER_ID;
- oBL.style.display = "none";
- oBL.style.position = "absolute";
- oBL.style.top = "0px";
- oBL.style.left = "0px";
- oBL.style.zIndex = (CMODAL_ZINDEX - 2);
- oBL.style.width = "100%";
- oBL.style.height = "100%";
- if(typeof blurBackground != "undefined" && blurBackground)
- {
- oBL.style.backgroundColor = 'rgb(238, 238, 238)';
- oBL.style.opacity = '0.6';
- oBL.style.filter = 'alpha(opacity:60)';
- }
- oBL.innerHTML = '<table width="100%" height="100%" role="presentation"><tr><td role="presentation" onmousemove="CModalEvent_mousemoving(event)" onmouseup="CModalEvent_disableDrag(event)"></td></tr></table>';
- this.m_parent.appendChild(oBL);
- this.m_backLayer = oBL;
- this.m_top = (t == null ? 0 : t);
- this.m_left = (l == null ? 0 : l);
- this.m_height = (h == null ? 0 : h);
- this.m_width = (w == null ? 0 : w);
- if(typeof dynamicSize != "undefined" && dynamicSize == true)
- {
- this.m_height = CModal_dynamicHeight();
- this.m_width = CModal_dynamicWidth();
- }
- if (window.attachEvent)
- {
- window.attachEvent("onresize", CModalEvent_onWindowResize);
- window.attachEvent("onscroll", CModalEvent_onWindowResize);
- }
- else
- {
- window.addEventListener("resize", CModalEvent_onWindowResize, false);
- window.addEventListener("scroll", CModalEvent_onWindowResize, false);
- }
- var f = document.getElementById(CMODAL_ID);
- if(f)
- {
- f.parentNode.removeChild(f);
- }
- f = document.createElement("span");
- f.id = CMODAL_ID;
- f.CModal = this;
- f.className = 'CModal_frame';
- f.style.zIndex = CMODAL_ZINDEX;
- f.style.border = "#99aacc 1px solid";
- var div = this.createHiddenDiv("CMODAL_TAB_LOOP_BEFORE", 0);
- div.onfocus = function() {document.getElementById("CMODAL_AFTER_PLACEHOLDER").focus();};
- this.m_parent.appendChild(f);
- div = this.createHiddenDiv("CMODAL_AFTER_PLACEHOLDER", -1);
- div = this.createHiddenDiv("CMODAL_TAB_LOOP_AFTER", 0);
- div.onfocus = function() {document.getElementById(CMODAL_CONTENT_ID).contentWindow.focus();};
- this.m_back_iframe = document.getElementById(CMODAL_BACK_IFRAME_ID);
- if(this.m_back_iframe)
- {
- this.m_back_iframe.parentNode.removeChild(this.m_back_iframe);
- }
- this.m_back_iframe = document.createElement("iframe");
- this.m_back_iframe.id = CMODAL_BACK_IFRAME_ID;
- this.m_back_iframe.frameBorder = 0;
- this.m_back_iframe.src = this.m_webContentRoot + "/common/blank.html";
- this.m_back_iframe.style.position = "absolute";
- this.m_back_iframe.style.zIndex = CMODAL_ZINDEX - 1;
- this.m_back_iframe.onfocus = function() {document.getElementById(CMODAL_BACKGROUND_LAYER_ID).focus();};
- this.m_back_iframe.tabIndex = 1;
- this.m_back_iframe.title = "Empty frame";
- this.m_back_iframe.role = "presentation";
- this.m_parent.appendChild(this.m_back_iframe);
- // render framework of the modal dialog
- f.innerHTML = this.renderDialogFrame();
- this.m_frame = f;
- }
- function CModal_createHiddenDiv(divId, tabIndex) {
- var div = document.getElementById(divId);
- if (div)
- {
- div.parentNode.removeChild(div);
- }
- div = document.createElement("div");
- div.id = divId;
- div.tabIndex = tabIndex;
- div.style.position = "absolute";
- div.style.overflow = "hidden";
- div.style.width = "0px";
- div.style.height = "0px";
- this.m_parent.appendChild(div);
- return div;
- }
- function CModal_hide() {
- this.m_top = parseInt(this.m_frame.offsetTop,10);
- this.m_left = parseInt(this.m_frame.offsetLeft,10);
- this.m_height = parseInt(this.m_frame.offsetHeight,10);
- this.m_width = parseInt(this.m_frame.offsetWidth,10);
- this.m_backLayer.style.display = "none";
- this.m_frame.style.display = "none";
- if (this.m_back_iframe) {
- this.m_back_iframe.style.display = "none";
- }
- }
- function CModal_reCenter() {
- this.m_left = (document.getElementById(CMODAL_BACKGROUND_LAYER_ID).clientWidth - this.m_width)/2;
- this.m_top = (document.getElementById(CMODAL_BACKGROUND_LAYER_ID).clientHeight - this.m_height)/2;
- }
- function CModal_renderDialogFrame() {
- var sTableAttrs = 'summary="" cellpadding="0" cellspacing="0" border="0" role="presentation"';
- var out =
- '<table role="presentation" style="width:100%; height:99%; padding-top:2px;" ' + sTableAttrs + ' onmouseup="CModalEvent_disableDrag(event)" onmousemove="CModalEvent_mousemoving(event)">';
- if(!this.m_hideHeader)
- {
- out += '' +
- '<tr>' +
- '<td role="presentation" onmousedown="CModalEvent_enableDrag(event);">' +
- '<table class="dialogHeader" width="100%" ' + sTableAttrs + '>' +
- '<tr>' +
- '<td id="' + CMODAL_HEADER + '" valign="top" class="dialogHeaderTitle" width="100%" nowrap="nowrap">' +
- getConfigFrame().htmlencode(this.m_title) +
- '</td><td align="right" valign="middle">' +
- '<a onclick="hideCModal()" style="cursor:pointer;">' +
- '<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) + '">' +
- '</a>' +
- '</td>' +
- '</tr>' +
- '</table>' +
- '</td>' +
- '</tr>';
- }
- out += '<tr><td role="presentation" width="100%" height="100%" class="body_dialog_modal" onmousemove="CModalEvent_mousemoving(event)" onmouseup="CModalEvent_disableDrag(event)">' +
- '<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>' +
- '</td></tr>';
- if(!this.m_hideButtonBar)
- {
- out += '<tr><td>' +
- '<table ' + sTableAttrs + ' class="dialogButtonBar" style="padding:0px">' +
- '<tr>' +
- '<td width="2" valign="middle"><img width="2" alt="" src="' + this.m_webContentRoot + '/ps/images/space.gif"></td>' +
- '<td valign="middle"><table border="0" cellpadding="1" cellspacing="0" role="presentation">' +
- '<tr>' +
- '<td><img height="1" width="8" alt="" src="' + this.m_webContentRoot + '/ps/images/space.gif"></td>' +
- '<td>' + CModal_renderButton(msgQS['OK'], 'okCModal()') + '</td>' +
- '<td><img height="1" width="8" alt="" src="' + this.m_webContentRoot + '/ps/images/space.gif"></td>' +
- '<td>' + CModal_renderButton(msgQS['CANCEL'], 'cancelCModal()') + '</td>' +
- '<td><img height="1" width="8" alt="" src="' + this.m_webContentRoot + '/ps/images/space.gif"></td>' +
- '</tr></table>' +
- '</td><td width="100%"> </td>' +
- '<td style="padding:3px;" valign="bottom" class="CModal_sideSE" onmousedown="CModalEvent_enableResize(event)">' +
- '<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;">' +
- '</td>' +
- '</tr></table></td></tr>';
- }
- out += '</table>';
- return out;
- }
- function CModal_renderButton(label, jsFct) {
- var out = '<table cellpadding="0" cellspacing="0" style="padding: 2px 10px 3px;" class="commandButton" onmouseover="this.className=\'commandButtonOver\'"' +
- ' onmouseout="this.className = \'commandButton\'" onmousedown="this.className=\'commandButtonDown\'">' +
- '<tr>' +
- '<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>' +
- label + '</td></tr></table>';
- return out;
- }
- function CModal_show() {
- this.m_backLayer.style.display = "";
- this.reCenter();
- var position = CMenu_getScrollingPosition();
- this.m_frame.style.top = (position.y + this.m_top) + "px";
- this.m_frame.style.left = (position.x + this.m_left) + "px";
- this.m_frame.style.height = this.m_height + "px";
- this.m_frame.style.width = this.m_width + "px";
- this.m_frame.style.display = 'inline';
- this.m_frame.focus();
- if (this.m_back_iframe) {
- this.m_back_iframe.style.top = this.m_frame.offsetTop + "px";
- this.m_back_iframe.style.left = this.m_frame.offsetLeft + "px";
- this.m_back_iframe.style.height = this.m_frame.offsetHeight + "px";
- this.m_back_iframe.style.width = this.m_frame.offsetWidth + "px";
- this.m_back_iframe.style.display = "block";
- }
- }
- CModal.prototype.hide = CModal_hide;
- CModal.prototype.createHiddenDiv = CModal_createHiddenDiv;
- CModal.prototype.reCenter = CModal_reCenter;
- CModal.prototype.renderDialogFrame = CModal_renderDialogFrame;
- CModal.prototype.show = CModal_show;
- /* Event handlers for CModal (global functions) */
- function hideCModal() {
- var cdlg = document.getElementById(CMODAL_ID);
- if (cdlg && cdlg.CModal) {
- cdlg.CModal.hide();
- }
- }
- function destroyCModal() {
- var oBL = document.getElementById(CMODAL_BACKGROUND_LAYER_ID);
- if(oBL)
- {
- oBL.style.display = "none";
- }
- var modelContent = document.getElementById(CMODAL_ID);
- if(modelContent)
- {
- modelContent.style.display = "none";
- }
- var back_iframe = document.getElementById(CMODAL_BACK_IFRAME_ID);
- if(back_iframe)
- {
- back_iframe.style.display = "none";
- }
- if (window.detachEvent)
- {
- window.detachEvent("onresize", CModalEvent_onWindowResize);
- window.detachEvent("onscroll", CModalEvent_onWindowResize);
- }
- else
- {
- window.removeEventListener("resize", CModalEvent_onWindowResize, false);
- window.removeEventListener("scroll", CModalEvent_onWindowResize, false);
- }
- }
- function cancelCModal() {
- var iframe = document.getElementById(CMODAL_CONTENT_ID);
- if (iframe && iframe.contentWindow && typeof iframe.contentWindow.cancelDialog == "function") {
- iframe.contentWindow.cancelDialog();
- }
- else {
- hideCModal();
- }
- }
- function okCModal() {
- var iframe = document.getElementById(CMODAL_CONTENT_ID);
- if (iframe && iframe.contentWindow && typeof iframe.contentWindow.execute == "function") {
- iframe.contentWindow.execute();
- }
- else {
- hideCModal();
- }
- }
- function CModal_dynamicWidth()
- {
- return (window.innerWidth != null ? window.innerWidth: document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth:document.body != null? document.body.clientWidth:null)-150;
- }
- function CModal_dynamicHeight()
- {
- return (window.innerHeight != null? window.innerHeight: document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight:document.body != null? document.body.clientHeight:null)-150;
- }
- function CModal_setModalHeight(modalDialog)
- {
- var storedHeight = modalDialog.getAttribute("storedHeight");
- if(modalDialog.offsetHeight > document.getElementById(CMODAL_BACKGROUND_LAYER_ID).clientHeight)
- {
- if(storedHeight == null)
- {
- modalDialog.setAttribute("storedHeight", modalDialog.offsetHeight);
- }
- modalDialog.style.height = document.getElementById(CMODAL_BACKGROUND_LAYER_ID).clientHeight + "px";
- }
- else if(storedHeight != null)
- {
- if(storedHeight < document.getElementById(CMODAL_BACKGROUND_LAYER_ID).clientHeight)
- {
- modalDialog.style.height = storedHeight + "px";
- }
- else
- {
- modalDialog.style.height = document.getElementById(CMODAL_BACKGROUND_LAYER_ID).clientHeight + "px";
- }
- }
- }
- function CModal_setModalWidth(modalDialog)
- {
- var storedWidth = modalDialog.getAttribute("storedWidth");
- if(modalDialog.offsetWidth > document.getElementById(CMODAL_BACKGROUND_LAYER_ID).clientWidth)
- {
- if(storedWidth == null)
- {
- modalDialog.setAttribute("storedWidth", modalDialog.offsetWidth);
- }
- modalDialog.style.width = document.getElementById(CMODAL_BACKGROUND_LAYER_ID).clientWidth + "px";
- }
- else if(storedWidth != null)
- {
- if(storedWidth < document.getElementById(CMODAL_BACKGROUND_LAYER_ID).clientWidth)
- {
- modalDialog.removeAttribute("storedWidth");
- modalDialog.style.width = storedWidth + "px";
- }
- else
- {
- modalDialog.style.width = document.getElementById(CMODAL_BACKGROUND_LAYER_ID).clientWidth + "px";
- }
- }
- }
- function CModalEvent_onWindowResize(e){
- var modalDialog = document.getElementById(CMODAL_ID);
- var backLayer = document.getElementById(CMODAL_BACKGROUND_LAYER_ID);
- var back_iframe = document.getElementById(CMODAL_BACK_IFRAME_ID);
- if(modalDialog && backLayer && back_iframe)
- {
- CModal_setModalWidth(modalDialog);
- CModal_setModalHeight(modalDialog);
- var position = CMenu_getScrollingPosition();
- var topCoord = (position.y + ((backLayer.clientHeight - modalDialog.offsetHeight)/2));
- var leftCoord = (position.x + ((backLayer.clientWidth - modalDialog.offsetWidth)/2));
- modalDialog.style.top = topCoord + "px";
- modalDialog.style.left = leftCoord + "px";
- back_iframe.style.top = topCoord + "px";
- back_iframe.style.width = modalDialog.style.width;
- back_iframe.style.height = modalDialog.style.height;
- back_iframe.style.left = leftCoord + "px";
- }
- }
- function CModalEvent_mousemoving(e) {
- var oDlg = null;
- var oIFrame = null;
- if (CMODAL_dragEnabled) {
- if (e == null && (typeof event == "object") && event.clientX != null) {
- e = event;
- }
- oDlg = document.getElementById(CMODAL_ID);
- if (CMODAL_startLeft == null) {
- CMODAL_startLeft = parseInt(oDlg.style.left,10) - e.clientX;
- CMODAL_startTop = parseInt(oDlg.style.top,10) - e.clientY;
- }
- oDlg.style.left = CMODAL_startLeft + e.clientX;
- oDlg.style.top = CMODAL_startTop + e.clientY;
- oIFrame = document.getElementById(CMODAL_BACK_IFRAME_ID);
- if (oIFrame) {
- oIFrame.style.left = oDlg.style.left;
- oIFrame.style.top = oDlg.style.top;
- }
- }
- if (CMODAL_resizeDirection) {
- if (e == null && (typeof event == "object") && event.clientX != null) {
- e = event;
- }
- oDlg = document.getElementById(CMODAL_ID);
- if (CMODAL_startLeft == null) {
- CMODAL_startLeft = parseInt(oDlg.style.left,10);
- CMODAL_startTop = parseInt(oDlg.style.top,10);
- CMODAL_startHeight = parseInt(oDlg.style.height,10);
- CMODAL_startWidth = parseInt(oDlg.style.width,10);
- }
- var h = 0, w = 0;
- switch (CMODAL_resizeDirection) {
- case 'NE':
- case 'E':
- case 'SE':
- w = (e.clientX - CMODAL_startLeft + CMODAL_deltaX);
- if (w < 100) {
- w = 100;
- }
- oDlg.style.width = w + "px";
- }
- switch (CMODAL_resizeDirection) {
- case 'SW':
- case 'S':
- case 'SE':
- h = (e.clientY - CMODAL_startTop + CMODAL_deltaY);
- if (h < 100) {
- h = 100;
- }
- oDlg.style.height = h + "px";
- }
- switch (CMODAL_resizeDirection) {
- case 'NW':
- case 'N':
- case 'NE':
- oDlg.style.top = e.clientY;
- h = (CMODAL_startHeight + (CMODAL_startTop - e.clientY) + CMODAL_deltaY);
- if (h < 100) {
- h = 100;
- }
- oDlg.style.height = h + "px";
- }
- switch (CMODAL_resizeDirection) {
- case 'NW':
- case 'W':
- case 'SW':
- oDlg.style.left = e.clientX;
- w = (CMODAL_startWidth + (CMODAL_startLeft - e.clientX) + CMODAL_deltaX);
- if (w < 100) {
- w = 100;
- }
- oDlg.style.width = w + "px";
- }
- oIFrame = document.getElementById(CMODAL_BACK_IFRAME_ID);
- if (oIFrame) {
- oIFrame.style.left = oDlg.offsetLeft;
- oIFrame.style.top = oDlg.offsetTop;
- oIFrame.style.height = oDlg.offsetHeight;
- oIFrame.style.width = oDlg.offsetWidth;
- }
- }
- if (e.returnValue) { e.returnValue = false; }
- else if (e.preventDefault) { e.preventDefault(); }
- else { return false; }
- }
- function CModalEvent_disableDrag(e) {
- CMODAL_dragEnabled = false;
- CMODAL_resizeDirection = null;
- CMODAL_startLeft = null;
- CMODAL_startTop = null;
- CMODAL_deltaX = 0;
- CMODAL_deltaY = 0;
- // remove dragging style
- var cn = document.getElementById(CMODAL_ID).className;
- var modelHeader = document.getElementById(CMODAL_HEADER);
- if(modelHeader != null)
- {
- modelHeader.style.cursor = 'default';
- }
- document.getElementById(CMODAL_ID).className = cn.replace(/\s*\bCModal_dragging\b/g, "");
- // show content frame
- document.getElementById(CMODAL_CONTENT_ID).style.visibility = "visible";
- if (typeof document.getElementById(CMODAL_CONTENT_ID).contentWindow.refreshContent == "function") {
- document.getElementById(CMODAL_CONTENT_ID).contentWindow.refreshContent();
- }
- if (e.returnValue) { e.returnValue = false; }
- else if (e.preventDefault) { e.preventDefault(); }
- else { return false; }
- }
- function CModalEvent_enableDrag(e) {
- CMODAL_dragEnabled = true;
- CMODAL_startLeft = null;
- CMODAL_startTop = null;
- if (e == null && (typeof event == "object") && event.clientX != null) {
- e = event;
- }
- // apply dragging style to frame
- document.getElementById(CMODAL_ID).className += " CModal_dragging";
- document.getElementById(CMODAL_HEADER).style.cursor = 'move';
- // hide content frame
- document.getElementById(CMODAL_CONTENT_ID).style.visibility = "hidden";
- if (e.returnValue) { e.returnValue = false; }
- else if (e.preventDefault) { e.preventDefault(); }
- else { return false; }
- }
- function CModalEvent_enableResize(e) {
- CMODAL_startLeft = null;
- CMODAL_startTop = null;
- CMODAL_startWidth = null;
- CMODAL_startHeight = null;
- CMODAL_deltaX = 0;
- CMODAL_deltaY = 0;
- if (e == null && (typeof event == "object") && event.clientX != null) {
- e = event;
- }
- var oDlg = document.getElementById(CMODAL_ID);
- CMODAL_startLeft = parseInt(oDlg.style.left,10);
- CMODAL_startTop = parseInt(oDlg.style.top,10);
- CMODAL_startHeight = parseInt(oDlg.style.height,10);
- CMODAL_startWidth = parseInt(oDlg.style.width,10);
- CMODAL_deltaX = (CMODAL_startLeft + CMODAL_startWidth - e.clientX);
- CMODAL_deltaY = (CMODAL_startTop + CMODAL_startHeight - e.clientY);
- var src = (e.srcElement ? e.srcElement : e.target);
- if ( (/\bCModal_side(\w+)\b/).test(src.className) ) {
- // set resize direction using className
- CMODAL_resizeDirection = RegExp.$1;
- // apply dragging style to frame
- document.getElementById(CMODAL_ID).className += " CModal_dragging";
- // hide content frame
- document.getElementById(CMODAL_CONTENT_ID).style.visibility = "hidden";
- }
- if (e.returnValue) { e.returnValue = false; }
- else if (e.preventDefault) { e.preventDefault(); }
- else { return false; }
- }
- /*-----------------------------------------------------------------------------------------------------
- Class : CMenuEntry
- Description : Common superclass of CMenuItem and CInfoPanel
- -----------------------------------------------------------------------------------------------------*/
- function CMenuEntry() {
- this.m_menu = null;
- this.m_menuType="";
- this.m_action = null;
- this.m_bEnabled = true;
- }
- function CMenuEntry_setParent(parent) {
- this.m_parent = parent;
- }
- function CMenuEntry_getParent() {
- return this.m_parent;
- }
- function CMenuEntry_setWebContentRoot(sWebContentRoot) {
- this.m_webContentRoot = sWebContentRoot;
- }
- function CMenuEntry_setId(id) {
- this.m_id = id;
- }
- function CMenuEntry_getId() {
- return this.m_id;
- }
- function CMenuEntry_getObservers() {
- return this.m_observers;
- }
- function CMenuEntry_onkeydown(evt) {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
-
- if(typeof evt != "object" || evt == null) {
- return;
- }
- var i = 0, ii, numItems, nextMenuItem, parent;
- var performNotification = true;
- var target = evt.currentTarget || evt.srcElement;
- //if a Shift-Tab is detected
- if (evt.keyCode == 9 && evt.shiftKey) {
- parent = this.getParent();
- for (i = 0; i < parent.getNumItems(); i++) {
- if (parent.get(i) == this) {
- parent.hide();
- // notify our observers that we've closed the menu because of a tab keydown event
- this.getObservers().notify("CMenuItem_closeMenuTabEvent");
- var parentMenuType = parent.getMenuType ? parent.getMenuType() : null;
- if (parentMenuType !== cHorizonalBar && parentMenuType !== cVerticalBar) {
- //For menus with a parent item, suppress propogation of the
- //shift+tab event so that focus goes to the correct member.
- if (isIE()) {
- evt.preventDefault();
- }
- else {
- evt.returnValue = false;
- }
- }
- break;
- }
- else if (this.getParent().get(i).m_bEnabled == true) {
- break;
- }
- }
- }
- //if a normal Tab is detected
- else if (evt.keyCode == 9) {
- // If our parent is a CMenuItem, than we're part of a menu. Catch the
- // tab event for the last menuItem in the menu so we can close the menu.
- if (this.isInMenu())
- {
- for (i = (this.getParent().getNumItems() - 1); i >= 0; i++) {
- if (this.getParent().get(i) == this) {
- if (this.getMenu()) {
- this.getMenu().hide();
- }
- this.getParent().hide();
- // notify our observers that we've closed the menu because of a tab keydown event
- this.getObservers().notify("CMenuItem_closeMenuTabEvent");
- if (isIE()) {
- evt.preventDefault();
- }
- else {
- evt.returnValue = false;
- }
- break;
- }
- else if (this.getParent().get(i).m_bEnabled == true) {
- break;
- }
- }
- } else if (typeof this.getParent().closeAllMenus == "function") {
- this.getParent().closeAllMenus();
- } else if (typeof this.getParent().closeMenus == "function") {
- this.getParent().closeMenus();
- }
- }
- // down arrow, select the next menu item in the menu or close the menu
- // if we're already at the last menu item -- or if is a dropdown,
- // expand submenu.
- else if (evt.keyCode == 40) {
- if(this.isInMenu()) {
- numItems = this.getParent().getNumItems();
- for (i = 0; i < numItems; i++) {
- if (this === this.getParent().get(i)) {
- var iStart = 0;
- var bStartedFromTop = true;
-
- if (i != (numItems-1)) {
- iStart = i+1;
- bStartedFromTop = false;
- }
- for (ii = iStart; ii < numItems; ii++) {
- nextMenuItem = this.getParent().get(ii);
- if ( typeof nextMenuItem.isVisible == "function" && nextMenuItem.isVisible() &&
- typeof nextMenuItem.setFocus == "function") {
- nextMenuItem.setFocus();
- break;
- }
-
- // If we reached the last item and didn't start from the top
- // then keep going but start from the top
- if (ii == (numItems-1) && !bStartedFromTop) {
- ii = 0;
- bStartedFromTop = true;
- }
- }
- break;
- }
- }
- } else if(this.isEnabled()) {
- performNotification = false;
-
- //For a drop-down menu, expand submenu
- var menu = this.getMenu();
- if(this.getMenuType() == 'dropDown') {
- if(menu.isVisible() == false) {
- // the user clicked on the menu
- menu.setHTMLContainer(target.document ? target.document.body : target.ownerDocument.body);
- menu.draw();
- menu.show();
- } else {
- menu.remove();
- }
- }
- }
- }
- // up arrow
- else if (evt.keyCode == 38 && this.isInMenu()) {
- numItems = this.getParent().getNumItems();
- for (i = 0; i < numItems; i++) {
- if (this === this.getParent().get(i)) {
- var iStart = i-1;
- var bStartedFromBottom = false;
- if (i <= 0) {
- iStart = numItems-1;
- bStartedFromBottom = true;
- }
- for (ii = iStart; ii >= 0; ii--) {
- nextMenuItem = this.getParent().get(ii);
- if ( typeof nextMenuItem.isVisible == "function" && nextMenuItem.isVisible() &&
- typeof nextMenuItem.setFocus == "function") {
- nextMenuItem.setFocus();
- break;
- }
-
- // If we reached the top but didn't start from the bottom,
- // then keep going from the bottom
- if (ii == 0 && !bStartedFromBottom) {
- bStartedFromBottom = true;
- ii = numItems;
- }
- }
- break;
- }
- }
- }
-
- //left/right key
- else if (evt.keyCode == 37 || evt.keyCode == 39) {
- if(this.isEnabled() && this.getMenu() != null) {
- //Expand menu if it will open to the left or right (cascaded menu)
- var menu = this.getMenu();
- if(this.getMenuType() == 'cascaded') {
- // stop notification so we do not hide the menu
- performNotification = false;
- // show the menu
- if(menu.isVisible() == false) {
- menu.setHTMLContainer(target.document ? target.document.body : target.ownerDocument.body);
- menu.draw();
- menu.show();
- }
- }
- } else {
- //Collapse menu if it's been opened from the left or right (cascaded menu)
-
- // stop notification so we do not hide the parent menu
- performNotification = false;
-
- parent = this.getParent();
- if(parent && parent.getParent() && parent.getParent().getMenuType() == "cascaded") {
- // hide the menu
- parent.hide();
- }
- }
- }
- // send the message up to our parent
- if(performNotification && this.getParent() != null && typeof this.getParent().onkeydown == "function") {
- this.getParent().onkeydown(evt);
- }
- // notify our observers of this event
- this.getObservers().notify(CMenuItem_onkeydown);
- }
- function CMenuEntry_onkeypress(evt) {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- // in firefox the keyCode will always be zero, so use the charCode if it's there. In IE, the charCode is undefined.
- var keyPressed = evt.keyCode;
- if (keyPressed == 0 && typeof evt.charCode != "undefined") {
- keyPressed = evt.charCode;
- }
- if(typeof evt == "object" && evt != null) {
-
- var target = evt.currentTarget || evt.srcElement;
- //flag which determines if we notify observers of the event
- var performNotification = true;
- // in Firefox the onkeypress gets called for the tab key. Make sure we don't notify our
- // observers since the menu will get closed
- if (keyPressed == 9 || keyPressed == 37 || keyPressed == 38 || keyPressed == 39 || keyPressed == 40) {
- performNotification = false;
- }
- //check for the Enter or Space key
- else if (keyPressed == 13 || keyPressed == 32) {
- //menu item should always be enabled if you can tab to it, but just in case
- if(!this.isEnabled()) {
- return;
- }
- if(this.getMenu() != null) {
- var menu = this.getMenu();
- if(this.getMenuType() == 'cascaded') {
- // stop notification so we do not hide the menu
- performNotification = false;
- // show the menu
- if(menu.isVisible() == false) {
- menu.setHTMLContainer(target.document ? target.document.body : target.ownerDocument.body);
- menu.draw();
- menu.show();
- } else {
- menu.remove();
- }
- } else if(this.getMenuType() == 'dropDown') {
- if(menu.isVisible() == false) {
- // the user clicked on the menu
- menu.setHTMLContainer(target.document ? target.document.body : target.ownerDocument.body);
- menu.draw();
- menu.show();
- } else {
- menu.remove();
- }
- }
- } else {
- // handle the event
- eval(this.getAction());
- }
- }
- //check for Esc key
- else if (keyPressed == 27) {
- //close the menu
- this.getParent().hide();
- //cancel event being bubbled up the hierarchy since only one level of menus needs to hide
- return;
- }
- if (performNotification) {
- // send the message up to our parent
- if(this.getParent() != null && typeof this.getParent().onkeypress == "function") {
- this.getParent().onkeypress(evt);
- }
- // notify our observers of this event
- this.getObservers().notify(CMenuItem_onkeypress);
- }
- }
- // only cancel the event for the Enter k or Space ey
- if (keyPressed == 13 || keyPressed == 0 || keyPressed == 40 || keyPressed == 38) {
- if(evt != null) {
- evt.cancelBubble = true;
- }
- return false;
- }
- return true;
- }
- function CMenuEntry_getMenu() {
- return this.m_menu;
- }
- function CMenuEntry_getMenuType() {
- return this.m_menuType;
- }
- function CMenuEntry_isEnabled() {
- return this.m_bEnabled;
- }
- function CMenuEntry_isInMenu()
- {
- return this.getParent() instanceof CMenu;
- }
- function CMenuEntry_getAction() {
- return this.m_action;
- }
- function CMenuEntry_setAction(action) {
- this.m_action = action;
- }
- CMenuEntry.prototype.getObservers = CMenuEntry_getObservers;
- CMenuEntry.prototype.setId = CMenuEntry_setId;
- CMenuEntry.prototype.getId = CMenuEntry_getId;
- CMenuEntry.prototype.onkeypress = CMenuEntry_onkeypress;
- CMenuEntry.prototype.onkeydown = CMenuEntry_onkeydown;
- CMenuEntry.prototype.getMenu = CMenuEntry_getMenu;
- CMenuEntry.prototype.getMenuType = CMenuEntry_getMenuType;
- CMenuEntry.prototype.setParent = CMenuEntry_setParent;
- CMenuEntry.prototype.getParent = CMenuEntry_getParent;
- CMenuEntry.prototype.setWebContentRoot = CMenuEntry_setWebContentRoot;
- CMenuEntry.prototype.isEnabled = CMenuEntry_isEnabled;
- CMenuEntry.prototype.isInMenu = CMenuEntry_isInMenu;
- CMenuEntry.prototype.getAction = CMenuEntry_getAction;
- CMenuEntry.prototype.setAction = CMenuEntry_setAction;
- // Copyright (C) 2008 Cognos Incorporated. All rights reserved.
- // Cognos (R) is a trademark of Cognos Incorporated.
- /*-----------------------------------------------------------------------------------------------------
- Class : CMenuItem
- Description :
- -----------------------------------------------------------------------------------------------------*/
- var theMenuCnt = 1;
- function CMenuItem(parent, label, action, iconPath, style, webContentRoot, skin) {
- this.m_label = label;
- if (this.m_label)
- {
- this.m_label = this.m_label.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
- }
- this.setId(escape(label) + theMenuCnt++);
- this.m_bVisible = true;
- this.setAction(action);
- this.setWebContentRoot(webContentRoot);
- var v_sIconPath = iconPath
- if ((typeof gCognosViewer != "undefined") && (gCognosViewer.envParams["isTitan"]) && (gCognosViewer.envParams["isTitan"] == true))
- {
- v_sIconPath = "blankIcon";
- }
- this.m_icon = new CIcon(v_sIconPath, "", this.m_webContentRoot);
- this.setParent(parent);
- this.m_style = style;
- this.m_observers = new CObserver(this);
- //skin folder
- if (typeof skin != "undefined" && skin != "")
- {
- this.m_sSkin = skin;
- }
- else
- {
- this.m_sSkin = (typeof getPromptSkin != "undefined" ? getPromptSkin() : this.m_webContentRoot + "/skins/corporate");
- }
- if(typeof this.m_parent == "object" && typeof this.m_parent.add == "function") {
- this.m_parent.add(this);
- }
- this.m_sDropDownArrow = "dropdown_arrow_banner.gif";
- }
- CMenuItem.prototype = new CMenuEntry();
- CMenuItem.prototype.setDropDownArrow = function(dropDownArrow)
- {
- this.m_sDropDownArrow = dropDownArrow;
- };
- CMenuItem.prototype.getDropDownArrow = function()
- {
- return this.m_sDropDownArrow;
- };
- function CMenuItem_setId(id) {
- this.m_id = id;
- }
- function CMenuItem_setIcon(iconPath) {
- this.m_icon.setPath(iconPath);
- }
- function CMenuItem_setToolTip(tooltip) {
- this.m_icon.m_toolTip = tooltip;
- }
- function CMenuItem_getToolTip() {
- return this.m_icon.m_toolTip;
- }
- function CMenuItem_setAltText(sAltText) {
- this.m_sAltText = sAltText;
- }
- function CMenuItem_getAltText() {
- if (this.m_sAltText) {
- return this.m_sAltText;
- } else {
- return "";
- }
- }
- function CMenuItem_genARIATags() {
- var html = "";
- if (this.isInMenu()) {
- html += ' role="menuitem" ';
- } else {
- html += ' role="button" ';
- }
- if (this.m_menuType=='dropDown' || this.m_menuType == 'cascaded') {
- html += ' aria-haspopup="true" ';
- }
- if (this.getAltText().length == 0) {
- this.setAltText(this.m_label);
- }
- if ((this.getAltText() && this.getAltText().length > 0) || (this.m_icon && this.m_icon.getToolTip())) {
- html += ' aria-labelledby="' + this.m_id + 'label" ';
- }
-
- if (!this.isEnabled()) {
- html += ' aria-disabled="true" ';
- }
- return html;
- }
- function CMenuItem_genMenuItemAltText() {
- var html = "";
- if ((this.getAltText() && this.getAltText().length > 0) || (this.m_icon && this.m_icon.getToolTip())) {
- html += '<div style="position: absolute; overflow: hidden; width: 0; height: 0;" id="' + this.m_id + 'label">';
- if (this.getAltText() && this.getAltText().length > 0) {
- html += this.getAltText();
- } else {
- html += this.m_icon.getToolTip();
- }
- html += '</div>';
- }
- return html;
- }
- function CMenuItem_draw() {
- var html = '<div>';
- var bSiblingContainsIcon = false, siblingCount = null, siblingMenuItem = null, siblingIdx = 0;
- if(this.m_menu == null || this.m_menuType=='dropDown') {
- html += '<table ';
- html += this.genARIATags();
- // If we're in a menu then allow the user to move to a disabled menuItem.
- // If it's a toolbar button, don't let the user tab to it
- if (this.isInMenu())
- {
- if (this.isEnabled()) {
- html += ' hideFocus="true" ';
- }
- html += ' tabIndex="0" ';
- }
- else if (this.isEnabled())
- {
- html += ' tabIndex="0"';
- }
- html += ' width="100%" ';
- html += 'class="';
- if(typeof this.getStyle() == "object") {
- if(this.isEnabled()) {
- html += this.getStyle().getNormalState();
- }
- else {
- html += this.getStyle().getDisabledState();
- }
- }
- html += '" id="';
- html += this.getId();
- html += '" cellpadding="0" cellspacing="0" style="margin-bottom:1px;"><tr>';
- bSiblingContainsIcon = false;
- if(this.m_icon.getPath() == "" && this.m_parent instanceof CMenu) {
- siblingCount = this.m_parent.getNumItems();
- for(siblingIdx = 0; siblingIdx < siblingCount; ++siblingIdx) {
- siblingMenuItem = this.m_parent.get(siblingIdx);
- if(typeof siblingMenuItem.getIcon == "function" && siblingMenuItem.getIcon().getPath()) {
- // temporary for now to get alignment working on the context menu.
- bSiblingContainsIcon = true;
- break;
- }
- }
- }
- if(bSiblingContainsIcon || this.m_icon.getPath() != "")
- {
- var f = "";
- if(getViewerDirection()=="rtl"){
- f = ' float: right;';
- }
- html += '<td width="16" style="padding-right: 2px; padding-left: 2px;'+ f + '">';
- if(this.m_icon.getPath() != "")
- {
- html += this.m_icon.draw();
- }
- else
- {
- html += '<img alt="" src="' + this.m_webContentRoot + '/common/images/spacer.gif" width="16"/>';
- }
- html += '</td>';
- }
- if(getViewerDirection()=="rtl"){
- html += '<td nowrap="nowrap" align="right">';
- }else{
- html += '<td nowrap="nowrap" align="left">';
- }
- html += this.m_label;
- html += this.genMenuItemAltText();
- html += '</td>';
- if(this.m_menuType=='dropDown')
- {
- html += '<td width="10%" align="right" style="padding-right: 3px;padding-left: 3px">';
- html += '<img alt="" src="' + this.m_sSkin;
- // TODO remove this once dropdown_arrow.gif makes it into the shared directory
- if (this.getDropDownArrow() == 'dropdown_arrow_banner.gif')
- {
- html += '/shared/images/';
- }
- else
- {
- html += '/portal/images/';
- }
- html += this.getDropDownArrow() + '" WIDTH="7" HEIGHT="16" style="vertical-align:middle;"/>';
- html += '</td>';
- }
- html += '</tr></table></div>';
- } else {
- html += '<table';
- html += this.genARIATags();
- // If we're in a menu then allow the user to move to a disabled menuItem.
- // If it's a toolbar button, don't let the user tab to it
- if (this.isEnabled() || this.isInMenu())
- {
- html += ' tabIndex="0" hideFocus="true"';
- }
- html += ' width="100%" class="';
- if(typeof this.getStyle() == "object") {
- if(this.isEnabled()) {
- html += this.getStyle().getNormalState();
- }
- else {
- html += this.getStyle().getDisabledState();
- }
- }
- html += '" id="';
- html += this.getId();
- html += '" cellpadding="0" cellspacing="0" style="margin-bottom:1px;"><tr>';
- html += '<td';
- bSiblingContainsIcon = false;
- if(this.m_icon.getPath() == "") {
- siblingCount = this.m_parent.getNumItems();
- for(siblingIdx = 0; siblingIdx < siblingCount; ++siblingIdx) {
- siblingMenuItem = this.m_parent.get(siblingIdx);
- if(typeof siblingMenuItem.getIcon == "function" && siblingMenuItem.getIcon().getPath()) {
- // temporary for now to get alignment working on the context menu.
- bSiblingContainsIcon = true;
- break;
- }
- }
- }
- if(bSiblingContainsIcon || this.m_icon.getPath() != "") {
- html += ' width="16" style="padding-right: 2px; padding-left: 2px;">';
- } else {
- html += ' width="1">';
- }
- html += this.m_icon.draw();
- html += '</td>';
- if(getViewerDirection()=="rtl"){
- html += '<td nowrap="nowrap" align="right">';
- }else{
- html += '<td nowrap="nowrap" align="left">';
- }
- html += this.m_label;
- html += this.genMenuItemAltText();
- html += '</td>';
- if(getViewerDirection()=="rtl"){
- html += '<td width="10%" align="left">';
- html += '<img style="vertical-align:middle;" alt="" src="' + this.m_sSkin + '/viewer/images/menu_expand_rtl.gif" WIDTH="13" HEIGHT="13"/>';
- }else{
- html += '<td width="10%" align="right">';
- html += '<img style="vertical-align:middle;" alt="" src="' + this.m_sSkin + '/viewer/images/menu_expand.gif" WIDTH="13" HEIGHT="13"/>';
- }
- html += '</td>';
- html += '</tr></table>';
- html += '</div>';
- }
- return html;
- }
- function CMenuItem_onmouseover(evt) {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- // get the menu item from the html element which is handling the event
- var menuItem = null;
- if(typeof this.menuItem != "undefined") {
- menuItem = this.menuItem;
- }
- else if (this instanceof CMenuItem) {
- menuItem = this;
- }
- if(menuItem == null || !(menuItem instanceof CMenuItem) || !menuItem.isEnabled()) {
- return;
- }
- var menu = menuItem.getMenu();
- if(typeof menuItem.getStyle() == "object" && (menu != null || typeof menuItem.getIcon().getPath() != "undefined")) {
- this.className = menuItem.getStyle().getRolloverState();
- }
- if(menu != null) {
- var pageWidth = 0;
- var pageHeight = 0;
- if(typeof window.innerWidth != "undefined") {
- pageWidth = window.innerWidth;
- }
- else {
- pageWidth = document.body.clientWidth;
- }
- if(typeof window.innerHeight != "undefined") {
- pageHeight = window.innerHeight;
- }
- else {
- pageHeight = document.body.clientHeight;
- }
- if(menuItem.getMenuType() == 'cascaded') {
- if(menu.isVisible() == false) {
- menu.setHTMLContainer(this.document ? this.document.body : this.ownerDocument.body);
- menu.draw();
- menu.show();
- }
- } else if(menuItem.getMenuType() == 'dropDown') {
- // check with the parent to see if there current are menus open. If there are, we'll automatically open this menu
- var menuItemParent = menuItem.getParent();
- var numOfItems = menuItemParent.getNumItems();
- for(var i = 0; i < numOfItems; ++i) {
- var currentItem = menuItemParent.get(i);
- if(currentItem != menuItem && typeof currentItem.getMenu == "function" && currentItem.getMenu() && currentItem.getMenu().isVisible()) {
- // the user clicked on the menu
- menu.setHTMLContainer(this.document ? this.document.body : this.ownerDocument.body);
- menu.draw();
- menu.show();
- break;
- }
- }
- }
- }
- // send the message up to our parent
- if(menuItem.getParent() != null && typeof menuItem.getParent().onmouseover == "function") {
- menuItem.getParent().onmouseover(evt);
- }
- // notify our observers of this event
- menuItem.getObservers().notify(CMenuItem_onmouseover);
- }
- function CMenuItem_onfocus(evt) {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- // get the menu item from the html element which is handling the event
- var menuItem = null;
- if(typeof this.menuItem != "undefined") {
- menuItem = this.menuItem;
- }
- else if (this instanceof CMenuItem) {
- menuItem = this;
- }
- if(menuItem == null || !(menuItem instanceof CMenuItem) || !menuItem.isEnabled()) {
- return;
- }
- if(typeof menuItem.getStyle() == "object") {
- this.className = menuItem.getStyle().getRolloverState();
- }
- // send the message up to our parent (a fake mouseover)
- if(menuItem.getParent() != null && typeof menuItem.getParent().onmouseover == "function") {
- menuItem.getParent().onmouseover(evt);
- }
- // notify our observers of this event
- menuItem.getObservers().notify(CMenuItem_onfocus);
- }
- function CMenuItem_onmouseout(evt) {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- var menuItem = null;
- if(typeof this.menuItem != "undefined") {
- menuItem = this.menuItem;
- }
- else if (this instanceof CMenuItem) {
- menuItem = this;
- }
- // get the menu item from the html element which is handling the event
- if(menuItem == null || !(menuItem instanceof CMenuItem) || !menuItem.isEnabled()) {
- return;
- }
- if(typeof menuItem.getStyle() == "object") {
- this.className = menuItem.getStyle().getNormalState();
- }
- // send the message up to our parent
- if(menuItem.getParent() != null && typeof menuItem.getParent().onmouseout == "function") {
- menuItem.getParent().onmouseout(evt);
- }
- // notify our observers of this event
- menuItem.getObservers().notify(CMenuItem_onmouseout);
- }
- function CMenuItem_onclick(evt) {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- if(evt != null) {
- evt.cancelBubble = true;
- }
- return false;
- }
- function CMenuItem_onmouseup(evt) {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- var menuItem = null;
- if(typeof this.menuItem != "undefined") {
- menuItem = this.menuItem;
- }
- else if (this instanceof CMenuItem) {
- menuItem = this;
- }
- if(menuItem != null && menuItem instanceof CMenuItem) {
- if(!menuItem.isEnabled()) {
- return;
- }
- if(menuItem.getMenu() != null) {
- if(menuItem.getMenuType() == 'cascaded') {
- // do nothing for now
- } else if(menuItem.getMenuType() == 'dropDown')
- {
- var menu = menuItem.getMenu();
- if(menu.isVisible() == false)
- {
- if (!this.document && !this.ownerDocument) {
- return;
- }
- // the user clicked on the menu
- menu.setHTMLContainer(this.document ? this.document.body : this.ownerDocument.body);
- menu.draw();
- menu.show();
- } else {
- menu.remove();
- }
- }
- } else {
- // handle the event
- eval(menuItem.getAction());
- }
- if (typeof getReportFrame != "undefined" && typeof getReportFrame().clearTextSelection != "undefined") {
- getReportFrame().clearTextSelection();
- }
- else if (typeof clearTextSelection != "undefined") {
- clearTextSelection();
- }
- if(menuItem.getMenuType() != 'cascaded') {
- // send the message up to our parent
- if(menuItem.getParent() != null && typeof menuItem.getParent().onmouseup == "function") {
- menuItem.getParent().onmouseup(evt);
- }
- // notify our observers of this event
- menuItem.getObservers().notify(CMenuItem_onmouseup);
- }
- if(typeof this.menuItem != "undefined" && menuItem.getMenu()!=null && menuItem.getMenuType()=='cascaded' && menuItem.getAction() != "")
- {
- // handle the event
- eval(menuItem.getAction());
- }
- }
- if(evt != null) {
- evt.cancelBubble = true;
- }
- return false;
- }
- function CMenuItem_onkeydown(evt) {
- //get the event in a cross-browser fashion
- var menuItem = null;
- if(typeof this.menuItem != "undefined") {
- menuItem = this.menuItem;
- }
- else if (this instanceof CMenuItem) {
- menuItem = this;
- }
- if(menuItem == null || !(menuItem instanceof CMenuItem)) {
- return;
- }
- return CMenuEntry_onkeydown.call(menuItem, evt);
- }
- function CMenuItem_onkeypress(evt) {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- var menuItem = null;
- if(typeof this.menuItem != "undefined") {
- menuItem = this.menuItem;
- }
- else if (this instanceof CMenuItem) {
- menuItem = this;
- }
- if(menuItem != null && menuItem instanceof CMenuItem) {
- return CMenuEntry_onkeypress.call(menuItem, evt);
- }
- }
- function CMenuItem_createDropDownMenu(menuStyle) {
- this.m_menu = new CMenu('dropDownMenu_'+this.getId(),menuStyle, this.m_webContentRoot);
- this.m_menu.setParent(this);
- this.m_menuType = 'dropDown';
- return this.m_menu;
- }
- function CMenuItem_createCascadedMenu(menuStyle) {
- this.m_menu = new CMenu('cascadedMenu_'+this.getId(),menuStyle, this.m_webContentRoot);
- this.m_menu.setParent(this);
- this.m_originalMenuType = this.m_menuType;
- this.m_menuType = 'cascaded';
- return this.m_menu;
- }
- function CMenuItem_clearCascadedMenu()
- {
- if (this.m_menu) {
- this.m_menu.remove();
- this.m_menu = null;
- }
- if (this.m_originalMenuType) {
- this.m_menuType = this.m_originalMenuType;
- }
- }
- function CMenuItem_addOwnerDrawControl(control, type) {
- this.m_menu = control;
- this.m_menuType = type;
- if(typeof control.setParent != "undefined") {
- this.m_menu.setParent(this);
- }
- }
- function CMenuItem_attachEvents() {
- if(typeof this.getParent().getHTMLContainer != "function") {
- return; // this method must be implemented by the parent
- }
- var htmlContainer = this.getParent().getHTMLContainer();
- if(htmlContainer == null) {
- return;
- }
- var hMenuItem = eval(htmlContainer.document ? htmlContainer.document.getElementById(this.getId()) : htmlContainer.ownerDocument.getElementById(this.getId()));
- if(hMenuItem == null) {
- return; // just to be safe
- }
- hMenuItem.onmouseover = this.onmouseover;
- hMenuItem.onmouseout = this.onmouseout;
- hMenuItem.onmouseup = this.onmouseup;
- hMenuItem.onkeypress = this.onkeypress;
- hMenuItem.onfocus = this.onfocus;
- hMenuItem.onblur = this.onblur;
- hMenuItem.onkeydown = this.onkeydown;
- hMenuItem.onclick = this.onclick;
- hMenuItem.menuItem = eval(this);
- }
- function CMenuItem_remove() {
- }
- function CMenuItem_getStyle() {
- return this.m_style;
- }
- function CMenuItem_setStyle(style) {
- this.m_style = style;
- }
- function CMenuItem_hide() {
- this.m_bVisible = false;
- }
- function CMenuItem_show() {
- this.m_bVisible = true;
- }
- function CMenuItem_enable() {
- if(typeof this.getStyle() == "object") {
- if(typeof this.getParent().getHTMLContainer == "function") {
- var htmlContainer = this.getParent().getHTMLContainer();
- if(htmlContainer != null) {
- var htmlElement = htmlContainer.document ? htmlContainer.document.getElementById(this.getId()) : htmlContainer.ownerDocument.getElementById(this.getId());
- if(htmlElement != null) {
- htmlElement.className = this.getStyle().getNormalState();
- }
- }
- }
- this.m_bEnabled = true;
- this.getIcon().enable();
- this.updateHTML();
- }
- }
- function CMenuItem_updateHTML()
- {
- if(typeof this.getStyle() == "object")
- {
- if(typeof this.getParent().getHTMLContainer == "function")
- {
- var htmlContainer = this.getParent().getHTMLContainer();
- if(htmlContainer != null)
- {
- var htmlElement = htmlContainer.document ? htmlContainer.document.getElementById(this.getId()) : htmlContainer.ownerDocument.getElementById(this.getId());
- if(htmlElement != null)
- {
- var toolbarImage = htmlElement.getElementsByTagName("img");
- if(typeof toolbarImage != "undefined")
- {
- if (this.getIcon())
- {
- if(this.getIcon().isEnabled())
- {
- toolbarImage[0].src = this.getIcon().getPath();
- }
- else
- {
- toolbarImage[0].src = this.getIcon().getDisabledImagePath();
- }
- }
- if(this.getToolTip())
- {
- htmlElement.title = this.getToolTip();
- toolbarImage[0].title = this.getToolTip();
- }
- }
-
- if (this.isEnabled())
- {
- if (htmlElement.getAttribute("aria-disabled"))
- {
- htmlElement.removeAttribute("aria-disabled");
- }
- }
- else
- {
- htmlElement.setAttribute("aria-disabled", "true");
- }
- var dropDownIcon;
- if(this.getStyle().getActiveState() != this.getStyle().getDisabledState())
- {
- htmlElement.tabIndex = 0;
- if (this.getMenu() != null && !this.m_bHideDropDown && htmlElement.nextSibling)
- {
- htmlElement.nextSibling.tabIndex = 0;
- htmlElement.nextSibling.title = this.getToolTip();
- dropDownIcon = htmlElement.nextSibling.getElementsByTagName("img");
- if(dropDownIcon != null)
- {
- dropDownIcon[0].title = this.getToolTip();
- }
- }
- }
- else
- {
- if (htmlElement.tabIndex != "undefined")
- {
- htmlElement.removeAttribute("tabIndex");
- if (this.getMenu() != null)
- {
- htmlElement.nextSibling.removeAttribute("tabIndex");
- htmlElement.nextSibling.title = this.getToolTip();
- dropDownIcon = htmlElement.nextSibling.getElementsByTagName("img");
- if(dropDownIcon != null)
- {
- dropDownIcon[0].title = this.getToolTip();
- }
- }
- }
- }
- htmlElement.className = this.getStyle().getActiveState();
- }
- }
- }
- }
- }
- function CMenuItem_disable() {
- if(typeof this.getStyle() == "object") {
- if(typeof this.getParent().getHTMLContainer == "function") {
- var htmlContainer = this.getParent().getHTMLContainer();
- if(htmlContainer != null) {
- var htmlElement = htmlContainer.document ? htmlContainer.document.getElementById(this.getId()) : htmlContainer.ownerDocument.getElementById(this.getId());
- if(htmlElement != null) {
- htmlElement.className = this.getStyle().getDisabledState();
- }
- }
- }
- this.m_bEnabled = false;
- this.getIcon().disable();
- this.updateHTML();
- }
- }
- function CMenuItem_isVisible() {
- return this.m_bVisible;
- }
- function CMenuItem_getIcon() {
- return this.m_icon;
- }
- function CMenuItem_getLabel() {
- return this.m_label;
- }
- function CMenuItem_setFocus() {
- var e = document.getElementById(this.m_id);
- if(e) {
- e.focus();
- return true;
- }
- return false;
- }
- CMenuItem.prototype.draw = CMenuItem_draw;
- CMenuItem.prototype.onmouseover = CMenuItem_onmouseover;
- CMenuItem.prototype.onmouseout = CMenuItem_onmouseout;
- CMenuItem.prototype.onmouseup = CMenuItem_onmouseup;
- CMenuItem.prototype.onkeypress = CMenuItem_onkeypress;
- CMenuItem.prototype.onkeydown = CMenuItem_onkeydown;
- CMenuItem.prototype.onfocus = CMenuItem_onfocus;
- CMenuItem.prototype.onblur = CMenuItem_onmouseout;
- CMenuItem.prototype.onclick = CMenuItem_onclick;
- CMenuItem.prototype.attachEvents = CMenuItem_attachEvents;
- CMenuItem.prototype.remove = CMenuItem_remove;
- CMenuItem.prototype.setStyle = CMenuItem_setStyle;
- CMenuItem.prototype.getStyle = CMenuItem_getStyle;
- CMenuItem.prototype.createDropDownMenu = CMenuItem_createDropDownMenu;
- CMenuItem.prototype.createCascadedMenu = CMenuItem_createCascadedMenu;
- CMenuItem.prototype.clearCascadedMenu = CMenuItem_clearCascadedMenu;
- CMenuItem.prototype.addOwnerDrawControl = CMenuItem_addOwnerDrawControl;
- CMenuItem.prototype.isVisible = CMenuItem_isVisible;
- CMenuItem.prototype.hide = CMenuItem_hide;
- CMenuItem.prototype.show = CMenuItem_show;
- CMenuItem.prototype.enable = CMenuItem_enable;
- CMenuItem.prototype.disable = CMenuItem_disable;
- CMenuItem.prototype.getIcon = CMenuItem_getIcon;
- CMenuItem.prototype.setIcon = CMenuItem_setIcon;
- CMenuItem.prototype.getLabel = CMenuItem_getLabel;
- CMenuItem.prototype.setFocus = CMenuItem_setFocus;
- CMenuItem.prototype.setToolTip = CMenuItem_setToolTip;
- CMenuItem.prototype.getToolTip = CMenuItem_getToolTip;
- CMenuItem.prototype.updateHTML = CMenuItem_updateHTML;
- CMenuItem.prototype.update = new Function("return true");
- CMenuItem.prototype.genARIATags = CMenuItem_genARIATags;
- CMenuItem.prototype.setAltText = CMenuItem_setAltText;
- CMenuItem.prototype.getAltText = CMenuItem_getAltText;
- CMenuItem.prototype.genMenuItemAltText = CMenuItem_genMenuItemAltText;
- /*
- Class CSeperator
- todo : Add commments describing class....
- */
- /*
- CSeperator styles:
- 1. horizonal_blank
- 2. vertical_blank
- 3. vertical_line
- 4. horizonal_line
- */
- function CSeperator(type, size, style, webContentRoot) {
- this.m_type=type;
- this.m_size=size;
- this.m_bVisible = true;
- if(style !== null && typeof style == "object") {
- this.m_style = new CUIStyle(style.getNormalState(),style.getRolloverState(),style.getDepressedState(),style.getDepressedRolloverState(),style.getDisabledState());
- }
- else {
- this.m_style = new CUIStyle("","","","","");
- }
- if (typeof webContentRoot != "undefined" && webContentRoot != "")
- {
- this.m_webContentRoot = webContentRoot;
- }
- else
- {
- this.m_webContentRoot = "..";
- }
- this.m_toolbarSeperatorClass = "bannerDivider";
- }
- CSeperator.prototype.setToolbarSeperatorClass = function(seperatorClass)
- {
- this.m_toolbarSeperatorClass = seperatorClass;
- };
- CSeperator.prototype.getToolbarSeperatorClass = function()
- {
- return this.m_toolbarSeperatorClass;
- };
- CSeperator.prototype.setWebContentRoot = function(sWebContentRoot)
- {
- this.m_webContentRoot = sWebContentRoot;
- };
- function CSeperator_draw() {
- if(this.m_style == "") {
- return;
- }
- var html="";
- switch(this.m_type) {
- case "horizonal_blank":
- html += '<td style="padding:0px;"><img border="0" alt="" src="' + this.m_webContentRoot + '/common/images/spacer.gif" height="1" width="';
- html += this.m_size;
- html += '"/></td>';
- break;
- case "horizontal_line":
- html += '<div class="' + this.getStyle().getActiveState() + '"></div>';
- break;
- case "vertical_blank":
- html += '<tr>';
- html += '<td style="padding:0px;"><img border="0" alt="" src="' + this.m_webContentRoot + '/common/images/spacer.gif" width="1" height="';
- html += this.m_size;
- html += '"/></td></tr>';
- break;
- case "vertical_line":
- html += '<td class="toolbarVerticalSeperator"><div class="' + this.getToolbarSeperatorClass() + '"/></td>';
- break;
- }
- return html;
- }
- function CSeperator_getSize() {
- return this.m_size;
- }
- function CSeperator_setSize(size) {
- this.m_size = size;
- }
- function CSeperator_setStyle(style) {
- this.m_style = style;
- }
- function CSeperator_getStyle() {
- return this.m_style;
- }
- function CSeperator_setType(type) {
- this.m_type = type;
- }
- function CSeperator_getType() {
- return this.m_type;
- }
- function CSeperator_hide() {
- this.m_bVisible = false;
- }
- function CSeperator_show() {
- this.m_bVisible = true;
- }
- function CSeperator_isVisible() {
- return this.m_bVisible;
- }
- CSeperator.prototype.draw = CSeperator_draw;
- CSeperator.prototype.setSize = CSeperator_setSize;
- CSeperator.prototype.getSize = CSeperator_getSize;
- CSeperator.prototype.setStyle = CSeperator_setStyle;
- CSeperator.prototype.getStyle = CSeperator_getStyle;
- CSeperator.prototype.getType = CSeperator_getType;
- CSeperator.prototype.setType = CSeperator_setType;
- CSeperator.prototype.isVisible = CSeperator_isVisible;
- CSeperator.prototype.show = CSeperator_show;
- CSeperator.prototype.hide = CSeperator_hide;
- /*
- Class CInfoPanel
- todo : Add commments describing class....
- */
- /*
- CSeperator styles:
- 1. horizonal_blank
- 2. vertical_blank
- 3. vertical_line
- 4. horizonal_line
- */
- function CInfoPanel(size, webContentRoot, id) {
- this.m_size=size;
- this.m_bVisible = true;
- this.m_properties = [];
- this.setId(id);
- this.m_observers = new CObserver(this);
- this.setWebContentRoot(webContentRoot);
- }
- CInfoPanel.prototype = new CMenuEntry();
- CInfoPanel.prototype.setWebContentRoot = function(sWebContentRoot)
- {
- this.m_webContentRoot = sWebContentRoot;
- };
- function CInfoPanel_addCheckedProperty(name, value) {
- var o = {
- 'name': name,
- 'value': value,
- 'type': "checkBox",
- 'spacer': false
- };
- this.m_properties[this.m_properties.length] = o;
- }
- function CInfoPanel_addProperty(name, value) {
- var o = {
- 'name': name,
- 'value': value,
- 'spacer': false
- };
- this.m_properties[this.m_properties.length] = o;
- }
- function CInfoPanel_addSpacer(height) {
- var o = {
- 'spacer': true,
- 'height': height
- };
- this.m_properties[this.m_properties.length] = o;
- }
- function CInfoPanel_draw()
- {
- var i=0;
- var html='<table CELLPADDING="0" CELLSPACING="0" role="presentation">';
- if (this.m_properties.length > 0) {
- var contentHtml = "<tr><td>";
- var summary = "";
- for (i = 0; i < this.m_properties.length; i++) {
- if (this.m_properties[i].spacer) {
- //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>';
- }
- else {
- if (this.m_properties[i].type != null && this.m_properties[i].type == 'checkBox') {
- contentHtml += '<tr><td><span><span class="formText">';
- if (this.m_properties[i].value == 'true') {
- contentHtml += '<input type="checkbox" disabled="true" checked>';
- }
- else {
- contentHtml += '<input type="checkbox" disabled="true">';
- }
- contentHtml += this.m_properties[i].name;
- contentHtml += '</span> </input>';
- contentHtml += '<span></td></tr>';
- }
- else {
- contentHtml += '<tr><td><span><span class="menuItem_normal" style="font-weight:bold">';
- contentHtml += this.m_properties[i].name;
- contentHtml += '</span> <span class="menuItem_normal">';
- contentHtml += this.m_properties[i].value;
- contentHtml += '</span></span></td></tr>';
- }
- summary += this.m_properties[i].name + " " + this.m_properties[i].value + ", ";
- }
- }
- var id = this.getId() ? "id=\"" + this.getId() + "\" " : "";
- var tableHtml = "<table summary=\"" + summary + "\" role=\"presentation\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" " + id + " tabindex=\"0\" style=\"margin-bottom:1px;";
- if (typeof this.m_size != "undefined" && this.m_size != "") {
- tableHtml += "width:" + this.m_size;
- }
- tableHtml += "\"\t>";
- html += tableHtml + contentHtml + "</table></td></tr>";
- }
- html += '</table>';
- return html;
- }
- function CInfoPanel_getSize() {
- return this.m_size;
- }
- function CInfoPanel_setSize(size) {
- this.m_size = size;
- }
- function CInfoPanel_hide() {
- this.m_bVisible = false;
- }
- function CInfoPanel_show() {
- this.m_bVisible = true;
- }
- function CInfoPanel_isVisible() {
- return this.m_bVisible;
- }
- function CInfoPanel_isEnabled() { return true; }
- function CInfoPanel_onkeydown(evt) {
- //get the event in a cross-browser fashion
- var infoPanel = null;
- if(typeof this.infoPanel != "undefined") {
- infoPanel = this.infoPanel;
- }
- else if (this instanceof CInfoPanel) {
- infoPanel = this;
- }
- if(infoPanel == null || !(infoPanel instanceof CInfoPanel)) {
- return;
- }
- return CMenuEntry_onkeydown.call(infoPanel, evt);
- }
- function CInfoPanel_onkeypress(evt) {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- var infoPanel = null;
- if(typeof this.infoPanel != "undefined") {
- infoPanel = this.infoPanel;
- }
- else if (this instanceof CInfoPanel) {
- infoPanel = this;
- }
- if(infoPanel != null && infoPanel instanceof CInfoPanel) {
- return CMenuEntry_onkeypress.call(infoPanel, evt);
- }
- }
- function CInfoPanel_setFocus() {
- if(this.getId()) {
- document.getElementById(this.getId()).focus();
- }
- }
- function CInfoPanel_attachEvents() {
-
- if(typeof this.getParent().getHTMLContainer != "function") {
- return; // this method must be implemented by the parent
- }
- var htmlContainer = this.getParent().getHTMLContainer();
- if(htmlContainer == null) {
- return;
- }
- var hMenuItem = eval(htmlContainer.document ? htmlContainer.document.getElementById(this.getId()) : htmlContainer.ownerDocument.getElementById(this.getId()));
- if(hMenuItem == null) {
- return; // just to be safe
- }
- hMenuItem.onkeypress = this.onkeypress;
- hMenuItem.onkeydown = this.onkeydown;
-
- hMenuItem.infoPanel = eval(this);
- }
- CInfoPanel.prototype.draw = CInfoPanel_draw;
- CInfoPanel.prototype.onkeypress = CInfoPanel_onkeypress;
- CInfoPanel.prototype.onkeydown = CInfoPanel_onkeydown;
- CInfoPanel.prototype.addProperty = CInfoPanel_addProperty;
- CInfoPanel.prototype.addCheckedProperty = CInfoPanel_addCheckedProperty;
- CInfoPanel.prototype.addSpacer = CInfoPanel_addSpacer;
- CInfoPanel.prototype.setSize = CInfoPanel_setSize;
- CInfoPanel.prototype.getSize = CInfoPanel_getSize;
- CInfoPanel.prototype.isVisible = CInfoPanel_isVisible;
- CInfoPanel.prototype.show = CInfoPanel_show;
- CInfoPanel.prototype.hide = CInfoPanel_hide;
- CInfoPanel.prototype.isEnabled = CInfoPanel_isEnabled;
- CInfoPanel.prototype.setFocus = CInfoPanel_setFocus;
- CInfoPanel.prototype.attachEvents = CInfoPanel_attachEvents;
- // Copyright (C) 2008 Cognos Incorporated. All rights reserved.
- // Cognos (R) is a trademark of Cognos Incorporated.
- /*-----------------------------------------------------------------------------------------------------
- Class : CMenu
- Description :
- -----------------------------------------------------------------------------------------------------*/
- var g_ownerDocument = null;
- function CMenu(id,style,webContentRoot) {
- this.m_htmlContainer = document.body;
- this.m_bVisible = false;
- this.m_id = id;
- this.m_htmlDivElement = null;
- this.m_parent = null;
- this.m_menuItems = [];
- this.m_style = style;
- this.m_callback = null;
- this.m_observers = new CObserver(this);
- this.m_bForceCallback = false;
- this.m_loadingMenuItem = false;
- this.m_oCV = null;
- if (typeof webContentRoot != "undefined" && webContentRoot != "")
- {
- this.m_webContentRoot = webContentRoot;
- }
- else
- {
- this.m_webContentRoot = "..";
- }
- }
- function CMenu_setHTMLContainer(container) {
- this.m_htmlContainer = container;
- g_ownerDocument = this.m_htmlContainer.document ? this.m_htmlContainer.document : this.m_htmlContainer.ownerDocument;
- }
- function CMenu_getHTMLContainer() {
- return this.m_htmlContainer;
- }
- function CMenu_setParent(parent) {
- this.m_parent = parent;
- }
- function CMenu_getParent() {
- return this.m_parent;
- }
- function CMenu_getId() {
- return this.m_id;
- }
- function CMenu_getHTMLDiv() {
- return this.m_htmlDivElement;
- }
- function CMenu_create() {
- var newElement = this.m_htmlContainer.document ? this.m_htmlContainer.document.createElement("div") : this.m_htmlContainer.ownerDocument.createElement("div");
- if(typeof this.getStyle() == "object") {
- newElement.className = this.getStyle().getNormalState();
- }
- //Only set display=block when needed, because it causes flickering in Mozilla
- newElement.style.display = "none";
- newElement.style.visibility = "hidden";
- newElement.style.position = "absolute";
- newElement.style.left = "0px";
- newElement.style.top = "0px";
- newElement.id = this.m_id;
-
- newElement.setAttribute("role", "region");
- if (window.RV_RES) {
- newElement.setAttribute("aria-label", RV_RES.IDS_JS_A11Y_DYNAMIC_MENU);
- }
- //append the new menu
- this.m_htmlContainer.appendChild(newElement);
- //create a reference to it
- this.m_htmlDivElement = newElement;
- }
- function CMenu_setAltText(altText) {
- this.m_altText = altText;
- }
- function CMenu_getAltText() {
- if (this.m_altText) {
- return this.m_altText;
- } else {
- return "";
- }
- }
- function CMenu_genARIATags() {
- var html = ' role="menu"';
- if (this.getAltText() && this.getAltText().length > 0) {
- html += ' aria-labelledby="' + this.m_id + 'label" ';
- }
- else if (window.RV_RES) {
- html += ' aria-label="' + RV_RES.IDS_JS_A11Y_DYNAMIC_MENU + '" ';
- }
- return html;
- }
- function CMenu_genMenuAltText() {
- var html = "";
- if (this.getAltText() && this.getAltText().length > 0) {
- html += '<tr><td><div style="position: absolute; overflow: hidden; width: 0; height: 0;" id="' + this.m_id + 'label">' + this.getAltText() + '</div></td></tr>';
- }
- return html;
- }
- function CMenu_draw() {
- if(this.m_htmlContainer == null) {
- return;
- }
- if(this.m_htmlDivElement == null) {
- this.create();
- }
- var html="";
- if(this.m_menuItems.length == 0 || this.m_bForceCallback == true) {
- this.setForceCallback(false);
- if(this.m_callback != null) {
- this.setLoadingMenuItem(true);
- var menu = this;
- var callbackFunc = function() {if (menu && menu.executeCallback) {menu.executeCallback();}};
- setTimeout(callbackFunc, 1000);
- // build a html div with a wait cursor
- html='<table class="menuItem_normal" CELLPADDING="0" CELLSPACING="0" tabindex="0" hidefocus="true"';
- html += this.genARIATags();
- html += '>';
- html += this.genMenuAltText();
- html += '<tr>';
- var loadingMsg = "";
- if (this.m_oCV && RV_RES.GOTO_LOADING) {
- loadingMsg = RV_RES.GOTO_LOADING;
- }
- else if(typeof gUIFrameWorkMenuLoadingMessage != "undefined") {
- loadingMsg = gUIFrameWorkMenuLoadingMessage;
- } else {
- loadingMsg = '...';
- }
- html += '<td>';
- html += '<img style="vertical-align:middle;" alt="' + loadingMsg + '" width="16" height="16" src="' + this.m_webContentRoot + '/common/images/tv_loading.gif"/>';
- html += '</td>';
- html += '<td nowrap="nowrap" align="left">';
- html += loadingMsg;
- html += '</td>';
- html += '</tr>';
- html += '</table>';
- }
- } else {
- this.setLoadingMenuItem(false);
- //add the items
- var i=0;
- html='<table CELLPADDING="0" CELLSPACING="0" tabindex="0" style="outline: none;" hidefocus="true"';
- html += this.genARIATags();
- html += '>';
- html += this.genMenuAltText();
- var anyVisibleItems = false;
- for (i=0; i < this.m_menuItems.length; i++) {
- if(this.m_menuItems[i].isVisible()) {
- anyVisibleItems = true;
- html += '<tr><td>';
- html += this.m_menuItems[i].draw();
- html += '</td></tr>';
- }
- }
- if (!anyVisibleItems) {
- this.remove();
- return;
- }
- html += '</table>';
- }
- try
- {
- this.m_htmlDivElement.innerHTML = html;
- // attach the event handlers
- this.attachEvents();
- }
- catch (e)
- {
- }
- this.updateCoords();
- // update hidden iframe
- var iFrameId = "uiFrameworkHiddenIframe" + this.m_id;
- var isNS7 = ((!isIE()) && (document.getElementById)) ? true : false;
- setTimeout('updateIframeCoords("' + iFrameId + '", "' + this.m_htmlDivElement.id + '", ' + isNS7 + ')',50);
- //Only gets applied when rv is in fragment mode
- if ((typeof gCognosViewer != "undefined") && (gCognosViewer.envParams["cv.responseFormat"]) && (gCognosViewer.envParams["cv.responseFormat"] == 'fragment'))
- {
- AdjustPortalFont(this.m_htmlDivElement);
- }
- }
- function CMenu_setLoadingMenuItem(bLoadingMenuItem)
- {
- this.m_loadingMenuItem = bLoadingMenuItem;
- }
- function CMenu_getLoadingMenuItem()
- {
- return this.m_loadingMenuItem;
- }
- /**
- * CMenu_getScrollingPosition
- * Cross Browser method to get the scroll position of a mouse click.
- * QuirksMode supports document.body.scrollTop, document.body.scrollLeft
- * Strict Mode
- * Firefox, Opera, Safari, Konqueror support window.pageYOffset, window.pageXOffset
- * IE 6.0 supports document.documentElement.scrollTop, document.documentElement.scrollLeft
- * @return Object - contain x,y information of the position of the mouse click.
- */
- function CMenu_getScrollingPosition()
- {
- var position = {"x":0,"y": 0};
- if (typeof window.pageYOffset != "undefined")
- {
- position = {"x":window.pageXOffset,"y":window.pageYOffset};
- }
- else if ((typeof document.documentElement.scrollTop != "undefined") &&
- (document.documentElement.scrollTop > 0 || typeof document.body.scrollTop == "undefined" || document.body.scrollTop == document.documentElement.scrollTop))
- {
- position = {"x":document.documentElement.scrollLeft,"y":document.documentElement.scrollTop};
- }
- else if (typeof document.body.scrollTop != "undefined")
- {
- position = {"x":document.body.scrollLeft,"y":document.body.scrollTop};
- }
- return position;
- }
- /**
- * AdjustPortalFont
- * @author whelanp
- * This function fixes a problem with font sizes in the portal environment,
- * we are using the computed style of the fragment div to set the font on the menu item
- * this keeps it consistent with the font being used by the rest of the page.
- * Problems this solves, menus get appended to the body of the document, if the body does
- * not set the font size correctly the font can either be too small or too big. If we are
- * in fragment mode there is always a div created with the appropriate css rules applied to it
- * thus getting the font size from the fragment div fixes the problem.
- * To fix a browser bug that causes tables to not properly inherit there parents font size, we've appended
- * a class to the menu as well. This class sets all table descendents of any element with PortalFontFix as a
- * class to use font-size:100% this forces the tables to use 100% of there parents font-size.
- * class is located in CRNFragment.css
- * .PortalFontFix table {font-size:100%;}
- *
- */
- function AdjustPortalFont(div)
- {
- var fragArray = fragments;
- if (fragArray)
- {
- div.className += " PortalFontFix";
- var fragDiv = null;
- for (var frag in fragArray)
- {
- if (frag.indexOf("rvCanvas") > -1)
- {
- fragDiv = $(fragArray[frag].div);
- if (fragDiv != null)
- {
- break;
- }
- }
- }
- if (fragDiv != null)
- {
- div.style.fontSize = xGetComputedStyle(fragDiv, "font-size");
- }
- }
- }
- function CMenu_updateCoords() {
- var myParent = this.getParent();
- var mnu = this.m_htmlDivElement;
- if(mnu != null)
- {
- var myDocument = this.m_htmlContainer.document ? this.m_htmlContainer.document : this.m_htmlContainer.ownerDocument;
- //Backup the visibilty and display properties of this menu
- var originalVisibility = mnu.style.visibility;
- var originalDisplay = mnu.style.display;
- mnu.style.visibility = "hidden";
- mnu.style.display = "block";
- //This line is used to make sure the width of the DIV element is correct in Mozilla
- if(mnu.firstChild != null) {
- mnu.style.width = mnu.firstChild.offsetWidth;
- }
- var x=0, y=0;
- var db = mnu.parentNode; //db = Document body
- // calculate the page width
- var pageWidth = db.clientWidth;
- var pageHeight = db.clientHeight;
- var pagePosition = CMenu_getScrollingPosition();
- var scrollLeft = pagePosition.x;
- var scrollTop = pagePosition.y;
- if(myParent == null)
- {
- //If this is the main context menu...
- x = mnu.style.left;
- y = mnu.style.top;
- //Remove "px" on x and y coordinates if it exists
- if (x.substr(x.length - 2, 2) == "px")
- {
- x = parseInt(x.substring(0, x.length-2),10);
- y = parseInt(y.substring(0, y.length-2),10);
- }
- //Change the y coordinate if the menu goes below the visible page
- if (y + mnu.offsetHeight >= (pageHeight))
- {
- if (y - mnu.offsetHeight > 0) {
- y = y + scrollTop - mnu.offsetHeight;
- }
- else {
- y = Math.max(pageHeight - mnu.offsetHeight, 0);
- }
- }
- else {
- y = y + scrollTop;
- }
- //Change the x coordinate if the menu goes below the visible page
- if (x + mnu.offsetWidth >= (pageWidth))
- {
- if (x - mnu.offsetWidth > 0) {
- x = x + scrollLeft - mnu.offsetWidth;
- }
- else {
- x = Math.max(pageWidth - mnu.offsetWidth, 0);
- }
- }
- else {
- x = x + scrollLeft;
- }
- }
- else
- {
- //This is one of the menu items...
- if(!(myParent instanceof CToolbarButton) && !(myParent instanceof CMenuItem)) {
- return;
- }
- // make sure the parent has implemented the method "getMenuType"
- if(typeof myParent.getMenuType != "function") {
- return;
- }
- var myParentHTMLElement = myDocument.getElementById(this.getParent().getId());
- var myParentDropdownButton = myDocument.getElementById('menu' + this.getParent().getId());
- if(myParentHTMLElement == null) {
- return;
- }
- var current = myParentHTMLElement;
- // handle drop down menus
- if(myParent.getMenuType() == 'dropDown') {
- x = 0; y = myParentHTMLElement.offsetHeight;
- while(current != null) {
- x += current.offsetLeft; y += current.offsetTop;
- current = current.offsetParent;
- }
- if(getViewerDirection()=="rtl"){
- var xMirrored = x - (mnu.offsetWidth - myParentHTMLElement.offsetWidth);
- if(xMirrored > scrollLeft){
- x = xMirrored;
- }
- }
- // For defect COGCQ00646908.
- // If we are in a portlet we must also take into account its scrollable position.
- // The caveat here is that the portlet div is scrollable and a parent element that is scrollable is not necessarily an
- // offsetParent (and in this case it is not). Therefore, we must travel up the parentNode DOM tree and calculate the scroll
- // position values of the portlet div (and any subsequent scrollable element) and subtract them accordingly.
- if ((typeof gCognosViewer != "undefined") && (gCognosViewer.envParams["cv.responseFormat"]) && (gCognosViewer.envParams["cv.responseFormat"] == 'fragment')) {
- var scrollPos = myParentHTMLElement;
- while((scrollPos != document.body) && (scrollPos = scrollPos.parentNode)) {
- // if the scroll values return a null, we must OR a 0-value to force return a number instead of null or NaN
- x -= scrollPos.scrollLeft || 0;
- y -= scrollPos.scrolltop || 0;
- }
-
- }
- // if the right side of the drop down menu extends beyond browser window viewing area, adjust accordingly
- if((x + mnu.offsetWidth) > (pageWidth + scrollLeft)) {
- x = x + myParentHTMLElement.offsetWidth - mnu.offsetWidth;
- if(myParentDropdownButton != null) {
- x = x + myParentDropdownButton.offsetWidth;
- }
- }
- // 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
- if(((y + mnu.offsetHeight) > (pageHeight + scrollTop)) && (y - (mnu.offsetHeight + myParentHTMLElement.clientHeight) >= 0)) {
- y -= (mnu.offsetHeight + myParentHTMLElement.clientHeight);
- }
- } else if(myParent.getMenuType() == 'cascaded') {
- x = myParentHTMLElement.offsetWidth;
- while(current != null) {
- x += current.offsetLeft; y += current.offsetTop;
- current = current.offsetParent;
- }
- if(getViewerDirection()=="rtl"){
- var xMirrored = x - (mnu.offsetWidth + myParentHTMLElement.offsetWidth);
- if(xMirrored > scrollLeft){
- x = xMirrored;
- }
- }
- // 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
- if((x + mnu.offsetWidth) > (pageWidth + scrollLeft)) {
- x -= (myParentHTMLElement.offsetWidth + mnu.offsetWidth);
- }
- // if the bottom of the cascaded menu extends beyond the bottom of the browser viewing area, draw to the top
- if((y + mnu.offsetHeight) > (pageHeight + scrollTop)) {
- y -= (mnu.offsetHeight-myParentHTMLElement.clientHeight);
- }
- }
- }
- //Restore the visibilty and display properties of this menu
- mnu.style.visibility = originalVisibility;
- mnu.style.display = originalDisplay;
- this.setXCoord(x);
- this.setYCoord(y);
- this.setZIndex(500);
- }
- }
- function CMenu_add(menuItem) {
- if(typeof menuItem.getObservers == "function" && typeof menuItem.getObservers() == "object") {
- menuItem.getObservers().attach(this, this.closeSubMenus, menuItem.onmouseover);
- menuItem.getObservers().attach(this, this.closeAllMenus, menuItem.onmouseup);
- menuItem.getObservers().attach(this, this.closeSubMenus, menuItem.onfocus);
- menuItem.getObservers().attach(this, this.closeAllMenus, menuItem.onkeypress);
- }
- this.m_menuItems[this.m_menuItems.length] = menuItem;
- }
- function CMenu_get(index) {
- if(index >= 0 && index < this.getNumItems()) {
- return this.m_menuItems[index];
- }
- return null;
- }
- CMenu.prototype.getItem = function(sItemId)
- {
- var sId = sItemId;
- if (this.m_oCV) {
- sId = this.m_oCV.getId() + sItemId;
- }
- for (var iIndex=0; iIndex < this.getNumItems(); iIndex++)
- {
- var uiItem = this.get(iIndex);
- if(typeof uiItem.getId == "function" && uiItem.getId() == sId)
- {
- return uiItem;
- }
- }
- };
- function CMenu_getNumItems() {
- return this.m_menuItems.length;
- }
- function CMenu_hide() {
- this.hideHiddenIframe();
- if(this.m_htmlDivElement != null) {
- this.m_htmlDivElement.style.visibility = "hidden";
- }
- this.m_bVisible = false;
- // get the actual element that spawned the menu
- var theControl = this.getParent();
- if (theControl != null && typeof theControl.setFocus == "function") {
- theControl.setFocus();
- } else if (theControl != null && typeof theControl.focus == "function") {
- theControl.focus();
- } else if (typeof this.m_focusCell == "object" && typeof this.m_focusCell.focus == "function" ) {
- this.m_focusCell.focus();
- }
- }
- function CMenu_setFocus() {
- try {
- var menuItem = null;
- for (var menuItemIndex = 0; menuItemIndex < this.getNumItems() && !menuItem; menuItemIndex++) {
- var _menuItem = this.get(menuItemIndex);
- if (_menuItem.isVisible && _menuItem.isVisible() ) {
- menuItem = _menuItem;
- }
- }
- if (!menuItem || !menuItem.setFocus()) {
- this.m_htmlDivElement.childNodes[0].focus();
- }
- } catch (e) {}
- }
- function CMenu_show() {
- if(this.m_htmlDivElement != null) {
- this.m_bVisible = true;
-
- // update the x and y coords
- this.updateCoords();
- var isNS7 = ((!isIE()) && (document.getElementById)) ? true : false;
- var iFrameId = "uiFrameworkHiddenIframe" + this.m_id;
- var hiddenIframeElement = this.m_htmlContainer.document ? this.m_htmlContainer.document.getElementById(iFrameId) : this.m_htmlContainer.ownerDocument.getElementById(iFrameId);
- if (hiddenIframeElement == null) {
- hiddenIframeElement = this.createHiddenIFrame(iFrameId);
- }
- if(hiddenIframeElement) {
- hiddenIframeElement.style.display = "block";
- hiddenIframeElement.style.left = "0px";
- hiddenIframeElement.style.top = "0px";
- updateIframeCoords(iFrameId, this.m_htmlDivElement.id, isNS7);
- setTimeout('updateIframeCoords("'+iFrameId+'", "'+this.m_htmlDivElement.id+'", '+isNS7+')',50);
- }
- //Show the context menu
- this.m_htmlDivElement.style.display = "block";
- this.m_htmlDivElement.style.visibility = "visible";
- this.setFocus();
- // Only attach the onresize & onscroll events when we're not on an iOS. This is to fix an issue
- // where we'd get a scroll event right away when displaying our menu, so the menu would
- // show up and then get removed right away.
- if (!window.isIOS()) {
- var cmenuObj = this;
-
- if (window.attachEvent) {
- window.attachEvent("onresize", function() { cmenuObj.remove()});
- window.attachEvent("onscroll", function() { cmenuObj.remove()});
- }
- else {
- window.addEventListener("resize", function() { cmenuObj.remove()}, false);
- window.addEventListener("scroll", function() { cmenuObj.remove()}, false);
- }
-
- var contentDiv = null;
- if (this.m_oCV != null) {
- contentDiv = document.getElementById(this.m_oCV.getId() + "content");
- }
-
- if (contentDiv) {
- if (contentDiv.parentNode.parentNode.attachEvent) {
- contentDiv.parentNode.parentNode.attachEvent("onscroll", function() { cmenuObj.remove()});
- }
- else {
- contentDiv.parentNode.parentNode.addEventListener("scroll", function() { cmenuObj.remove()}, false);
- }
- }
- }
- }
- }
- function CMenu_createHiddenIFrame(iFrameId)
- {
- var container = this.getHTMLContainer();
- var iframeElem = container.document ? container.document.createElement("iframe") : container.ownerDocument.createElement("iframe");
- iframeElem.setAttribute("id",iFrameId);
- iframeElem.setAttribute("src",this.m_webContentRoot + '/common/images/spacer.gif');
- iframeElem.setAttribute("scrolling",'no');
- iframeElem.setAttribute("frameborder",'0');
- iframeElem.style.position="absolute";
- iframeElem.style.minWidth="0px";
- iframeElem.style.minHeight="0px";
- iframeElem.style.left="0px";
- iframeElem.style.top="0px";
- iframeElem.style.zIndex=499;
- iframeElem.style.display="none";
- iframeElem.setAttribute("title", "Empty frame");
- iframeElem.setAttribute("role", "presentation");
- container.appendChild(iframeElem);
- return iframeElem;
- }
- function CMenu_isVisible() {
- return this.m_bVisible;
- }
- function CMenu_remove() {
- this.removeHiddenIframe();
- for(var i = 0; i < this.getNumItems(); ++i) {
- var currentItem = this.get(i);
- if(typeof currentItem.getMenu == "function" && currentItem.getMenu() != null) {
- currentItem.getMenu().remove();
- }
- }
- if(this.m_htmlContainer != null && this.m_htmlDivElement != null) {
- this.m_htmlContainer.removeChild(this.m_htmlDivElement);
- }
- this.m_htmlDivElement = null;
- this.m_bVisible = false;
- }
- function CMenu_removeHiddenIframe()
- {
- try
- {
- if (g_ownerDocument)
- {
- var hiddenIframeElement = g_ownerDocument.getElementById("uiFrameworkHiddenIframe" + this.m_id);
- if (hiddenIframeElement != null) {
- hiddenIframeElement.style.display = "none";
- if (hiddenIframeElement.parentNode && hiddenIframeElement.parentNode.removeChild) {
- hiddenIframeElement.parentNode.removeChild(hiddenIframeElement);
- }
- }
- }
- }
- catch(e)
- {
- }
- }
- function CMenu_hideHiddenIframe() {
- try
- {
- if (g_ownerDocument)
- {
- var hiddenIframeElement = g_ownerDocument.getElementById("uiFrameworkHiddenIframe" + this.m_id);
- if(hiddenIframeElement) {
- hiddenIframeElement.style.display = "none";
- }
- }
- }
- catch(e)
- {
- }
- }
- function CMenu_enable() {
- }
- function CMenu_disable() {
- }
- function CMenu_getState() {
- }
- function CMenu_clear() {
- if(this.m_htmlDivElement != null) {
- this.m_htmlDivElement.innerHTML="";
- }
- this.m_menuItems.splice(0, this.m_menuItems.length);
- }
- function CMenu_attachEvents() {
- for(var i = 0; i < this.m_menuItems.length; i++) {
- if(typeof this.m_menuItems[i].attachEvents == "function") {
- this.m_menuItems[i].attachEvents();
- }
- }
- this.m_htmlDivElement.onkeypress = this.onkeypress;
- this.m_htmlDivElement.tbMenu = eval(this);
- }
- function CMenu_closeSubMenus(state) {
- // Called during a notification...
- // make sure we hide any submenus which have been opened.
- for(var i = 0; i < this.m_menuItems.length; i++) {
- var menuItem = this.m_menuItems[i];
- var subject = state.getSubject();
- if(menuItem != subject && typeof menuItem.getMenu == "function" && menuItem.getMenu() != null && menuItem.getMenu().isVisible()) {
- menuItem.getMenu().remove();
- }
- }
- }
- function CMenu_closeAllMenus(state) {
- // Called during a notification...
- var current = this;
- var highestMenu = null;
- while(current) {
- if(current instanceof CMenu) {
- highestMenu = current;
- }
- current = current.getParent();
- }
- if(highestMenu != null) {
- highestMenu.remove();
- }
- }
- function CMenu_setStyle(style) {
- this.m_style = style;
- }
- function CMenu_getStyle() {
- return this.m_style;
- }
- function CMenu_setXCoord(x) {
- var htmlDiv = this.getHTMLDiv();
- if(htmlDiv != null) {
- htmlDiv.style.left = x + "px";
- }
- }
- function CMenu_setYCoord(y) {
- var htmlDiv = this.getHTMLDiv();
- if(htmlDiv != null) {
- htmlDiv.style.top = y + "px";
- }
- }
- function CMenu_setZIndex(zIndex) {
- var htmlDiv = this.getHTMLDiv();
- if(htmlDiv != null) {
- htmlDiv.style.zIndex = zIndex;
- }
- }
- // set a callback routine to populate the menu
- function CMenu_registerCallback(callback) {
- this.m_callback = callback;
- }
- function CMenu_executeCallback() {
- if(typeof this.m_callback == "function")
- {
- this.m_callback();
- }
- else if(typeof this.m_callback == "string")
- {
- eval(this.m_callback);
- }
- }
- function CMenu_getObservers() {
- return this.m_observers;
- }
- function CMenu_onmouseover(evt) {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- // notify our parent (if one exists) of this event
- if(this.getParent() != null && typeof this.getParent().onmouseover == "function") {
- this.getParent().onmouseover(evt);
- }
- // notify observers of this event
- this.getObservers().notify(CMenu_onmouseover);
- }
- function CMenu_onmouseout(evt) {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- // notify our parent (if one exists) of this event
- if(this.getParent() != null && typeof this.getParent().onmouseout == "function") {
- this.getParent().onmouseout(evt);
- }
- // notify observers of this event
- this.getObservers().notify(CMenu_onmouseout);
- }
- function CMenu_onmouseup(evt) {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- // notify our parent (if one exists) of this event
- if(this.getParent() != null && typeof this.getParent().onmouseup == "function") {
- this.getParent().onmouseup(evt);
- }
- // notify observers of this event
- this.getObservers().notify(CMenu_onmouseup);
- }
- function CMenu_onkeypress(evt) {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- var menu = this.tbMenu;
- if (typeof menu == "object") {
- // down arrow, select the first enabled item or close the menu if there aren't any enabled menu items
- if (evt.keyCode == 40) {
- var bMenuItemEnabled = false;
- for(var i = 0; i < menu.m_menuItems.length; i++) {
- var menuItem = menu.m_menuItems[i];
- if ( typeof menuItem.isVisible == "function" && menuItem.isVisible() &&
- typeof menuItem.setFocus == "function") {
- menuItem.setFocus();
- bMenuItemEnabled = true;
- break;
- }
- }
- if (!bMenuItemEnabled) {
- menu.hide();
- }
- }
- // up arrow, simply hide the menu
- if (evt.keyCode == 38) {
- menu.hide();
- }
- }
- // notify our parent (if one exists) of this event
- if(typeof this.getParent == "function" && this.getParent() != null && typeof this.getParent().onkeypress == 'function') {
- this.getParent().onkeypress(evt);
- }
- // notify observers of this event
- if (typeof this.getObservers == "function") {
- this.getObservers().notify(CMenu_onkeypress);
- }
- }
- function CMenu_getForceCallback()
- {
- return this.m_bForceCallback;
- }
- function CMenu_setForceCallback(forceCallback)
- {
- this.m_bForceCallback = forceCallback;
- }
- CMenu.prototype.draw = CMenu_draw;
- CMenu.prototype.updateCoords = CMenu_updateCoords;
- CMenu.prototype.add = CMenu_add;
- CMenu.prototype.get = CMenu_get;
- CMenu.prototype.getNumItems = CMenu_getNumItems;
- CMenu.prototype.hide = CMenu_hide;
- CMenu.prototype.hideHiddenIframe = CMenu_hideHiddenIframe;
- CMenu.prototype.removeHiddenIframe = CMenu_removeHiddenIframe;
- CMenu.prototype.show = CMenu_show;
- CMenu.prototype.enable = CMenu_enable;
- CMenu.prototype.disable = CMenu_disable;
- CMenu.prototype.getState = CMenu_getState;
- CMenu.prototype.clear = CMenu_clear;
- CMenu.prototype.attachEvents = CMenu_attachEvents;
- CMenu.prototype.setParent = CMenu_setParent;
- CMenu.prototype.getParent = CMenu_getParent;
- CMenu.prototype.getHTMLContainer = CMenu_getHTMLContainer;
- CMenu.prototype.setHTMLContainer = CMenu_setHTMLContainer;
- CMenu.prototype.getHTMLDiv = CMenu_getHTMLDiv;
- CMenu.prototype.create = CMenu_create;
- CMenu.prototype.remove = CMenu_remove;
- CMenu.prototype.getId = CMenu_getId;
- CMenu.prototype.isVisible = CMenu_isVisible;
- CMenu.prototype.setStyle = CMenu_setStyle;
- CMenu.prototype.getStyle = CMenu_getStyle;
- CMenu.prototype.closeSubMenus = CMenu_closeSubMenus;
- CMenu.prototype.closeAllMenus = CMenu_closeAllMenus;
- CMenu.prototype.setXCoord = CMenu_setXCoord;
- CMenu.prototype.setYCoord = CMenu_setYCoord;
- CMenu.prototype.setZIndex = CMenu_setZIndex;
- CMenu.prototype.update = new Function("return true");
- CMenu.prototype.registerCallback = CMenu_registerCallback;
- CMenu.prototype.executeCallback = CMenu_executeCallback;
- CMenu.prototype.getObservers = CMenu_getObservers;
- CMenu.prototype.onmouseover = CMenu_onmouseover;
- CMenu.prototype.onmouseout = CMenu_onmouseout;
- CMenu.prototype.onmouseup = CMenu_onmouseup;
- CMenu.prototype.onkeypress = CMenu_onkeypress;
- CMenu.prototype.createHiddenIFrame = CMenu_createHiddenIFrame;
- CMenu.prototype.setForceCallback = CMenu_setForceCallback;
- CMenu.prototype.getForceCallback = CMenu_getForceCallback;
- CMenu.prototype.setFocus = CMenu_setFocus;
- CMenu.prototype.genARIATags = CMenu_genARIATags;
- CMenu.prototype.setAltText = CMenu_setAltText;
- CMenu.prototype.getAltText = CMenu_getAltText;
- CMenu.prototype.genMenuAltText = CMenu_genMenuAltText;
- CMenu.prototype.setLoadingMenuItem = CMenu_setLoadingMenuItem;
- CMenu.prototype.getLoadingMenuItem = CMenu_getLoadingMenuItem;
- function updateIframeCoords(id, containerId, isNS7)
- {
- if (g_ownerDocument == null) {
- return;
- }
- var container = g_ownerDocument.getElementById(containerId);
- var hiddenIframeElement = g_ownerDocument.getElementById(id);
- if (hiddenIframeElement && container) {
- if(isNS7 == true) {
- hiddenIframeElement.style.left = container.offsetLeft + "px";
- hiddenIframeElement.style.top = container.offsetTop + "px";
- hiddenIframeElement.style.width = container.offsetWidth + "px";
- hiddenIframeElement.style.height = container.offsetHeight + "px";
- } else {
- hiddenIframeElement.style.pixelLeft = container.offsetLeft;
- hiddenIframeElement.style.pixelTop = container.offsetTop;
- hiddenIframeElement.style.pixelWidth = container.offsetWidth;
- hiddenIframeElement.style.pixelHeight = container.offsetHeight;
- }
- }
- }
- // Copyright (C) 2008 Cognos Incorporated. All rights reserved.
- // Cognos (R) is a trademark of Cognos Incorporated.
- /*
- Class CIcon
- todo : Add commments describing class....
- */
- function CIcon(iconPath, toolTip, webContentRoot) {
- this.m_iconPath = iconPath;
- this.m_toolTip = toolTip;
- this.m_enabled = true;
- // The UI framework defaults the icon width/height to 16. If you need to change this, call setHeight and/or setWidth
- this.m_height = 16;
- this.m_width = 16;
- if (typeof webContentRoot != "undefined" && webContentRoot != "")
- {
- this.m_webContentRoot = webContentRoot;
- }
- else
- {
- this.m_webContentRoot = "..";
- }
- }
- function CIcon_draw() {
- var html="";
- html += '<img style="vertical-align:middle;" src="';
- if(typeof this.m_iconPath != "undefined" && this.m_iconPath !== "" && this.m_iconPath != "blankIcon") {
- if(this.m_enabled == true) {
- html += this.m_iconPath;
- }
- else {
- html += this.getDisabledImagePath();
- }
- html += '" title="';
- if(typeof this.m_toolTip == "string" && this.m_toolTip.length > 0) {
- html += this.m_toolTip;
- }
- html += '" alt="';
- if(typeof this.m_toolTip == "string" && this.m_toolTip.length > 0) {
- html += this.m_toolTip;
- }
- html += '" width="';
- html += this.m_width;
- html += '" height="';
- html += this.m_height;
- html += '"/>';
- } else {
- html += this.m_webContentRoot + '/common/images/spacer.gif';
- html += '" alt=""';
- if (this.m_iconPath == "blankIcon")
- {
- html += ' width="';
- html += this.m_width;
- html += '" height="';
- html += this.m_height;
- html += '"/>';
- }
- else
- {
- html += ' width="1" height="1"/>';
- }
- }
- return html;
- }
- function CIcon_getDisabledImagePath() {
- var imagePathArray = this.m_iconPath.split('/');
- var iconPath="";
- for(var i = 0; i < (imagePathArray.length -1); ++i) {
- iconPath += imagePathArray[i] + '/';
- }
- iconPath += 'dis_' + imagePathArray[imagePathArray.length-1];
- return iconPath;
- }
- function CIcon_getPath() {
- return this.m_iconPath;
- }
- function CIcon_setPath(path) {
- this.m_iconPath = path;
- }
- function CIcon_getToolTip() {
- return this.m_toolTip;
- }
- function CIcon_setToolTip(toolTip) {
- this.m_toolTip = toolTip;
- }
- function CIcon_enable() {
- this.m_enabled = true;
- }
- function CIcon_disable() {
- this.m_enabled = false;
- }
- function CIcon_isEnabled() {
- return this.m_enabled;
- }
- function CIcon_setHeight(height) {
- this.m_height = height;
- }
- function CIcon_getHeight() {
- return this.m_height;
- }
- function CIcon_setWidth(width) {
- this.m_width = width;
- }
- function CIcon_getWidth() {
- return this.m_width;
- }
- CIcon.prototype.draw = CIcon_draw;
- CIcon.prototype.enable = CIcon_enable;
- CIcon.prototype.disable = CIcon_disable;
- CIcon.prototype.isEnabled = CIcon_isEnabled;
- CIcon.prototype.getDisabledImagePath = CIcon_getDisabledImagePath;
- CIcon.prototype.getPath = CIcon_getPath;
- CIcon.prototype.setPath = CIcon_setPath;
- CIcon.prototype.setHeight = CIcon_setHeight;
- CIcon.prototype.getHeight = CIcon_getHeight;
- CIcon.prototype.setWidth = CIcon_setWidth;
- CIcon.prototype.getWidth = CIcon_getWidth;
- CIcon.prototype.getToolTip = CIcon_getToolTip;
- CIcon.prototype.setToolTip = CIcon_setToolTip;
- // Copyright (C) 2008 Cognos Incorporated. All rights reserved.
- // Cognos (R) is a trademark of Cognos Incorporated.
- /*-----------------------------------------------------------------------------------------------------
- Class : CBar
- Description :
- -----------------------------------------------------------------------------------------------------*/
- var cHorizonalBar = 0;
- var cVerticalBar = 1;
- function CBar(containerId, style, sId, imagePath, showTooltip, hideTooltip, cookieVar, cookieName) {
- this.m_align = 'left';
- this.m_items = [];
- this.m_htmlContainerId = containerId;
- this.m_htmlContainer = null;
- this.m_id = 'cbar'+containerId;
- this.m_menuType = cVerticalBar;
- this.m_style = style;
- this.m_parent = null;
- this.m_observers = new CObserver(this);
- this.m_cookieVar = cookieVar;
- this.m_cookieName = cookieName;
- //reference to the object name
- this.m_sId = (sId) ? sId : null;
- this.m_display = DISPLAY_INLINE;
- this.m_imagePath = (imagePath) ? imagePath : '../common/images/toolbar/';
- this.m_imgCollapseSrc = this.m_imagePath + 'toolbar_collapse.gif';
- this.m_imgExpandSrc = this.m_imagePath + 'toolbar_expand.gif';
- this.m_showTooltip = showTooltip ? showTooltip : null;
- this.m_hideTooltip = hideTooltip ? hideTooltip : null;
- }
- function CBar_hideBar() {
- var bar = document.getElementById('bar'+ this.m_id);
- var barToggleIcon = document.getElementById('barIcon'+ this.m_id);
- if(barToggleIcon)
- {
- barToggleIcon.src= this.m_imgExpandSrc;
- if (this.m_showTooltip != null) {
- barToggleIcon.alt = this.m_showTooltip;
- barToggleIcon.title = this.m_showTooltip;
- }
- }
- if(bar)
- {
- bar.style.display = DISPLAY_NONE;
- if (typeof setQSCookie == "function") {
- setQSCookie(this.m_cookieVar, this.m_cookieName, 0);
- }
- }
- }
- function CBar_showBar() {
- var bar = document.getElementById('bar'+ this.m_id);
- var barToggleIcon = document.getElementById('barIcon'+ this.m_id);
- if(barToggleIcon)
- {
- barToggleIcon.src= this.m_imgCollapseSrc;
- if (this.m_hideTooltip != null) {
- barToggleIcon.alt = this.m_hideTooltip;
- barToggleIcon.title = this.m_hideTooltip;
- }
- }
- if(bar)
- {
- bar.style.display = this.m_display;
- if (typeof setQSCookie == "function") {
- setQSCookie(this.m_cookieVar, this.m_cookieName, 1);
- }
- }
- }
- function CBar_toggleBar(){
- var bar = document.getElementById('bar'+ this.m_id);
- var barDisplay = bar.style.display;
- if ( (barDisplay == this.m_display) || (barDisplay==""))
- {
- this.hideBar();
- }
- else
- {
- this.showBar();
- }
- }
- function CBar_getParent() {
- return this.m_parent;
- }
- function CBar_setParent(parent) {
- this.m_parent = parent;
- }
- function CBar_draw() {
- if(this.m_htmlContainer == null) {
- this.m_htmlContainer = document.getElementById(this.m_htmlContainerId);
- if(this.m_htmlContainer == null) { // if we can't find the container, return
- return;
- }
- }
- var html = "";
- html += '<table cellpadding="0" cellspacing="0" border="0" role="presentation"';
- if (this.m_sId != null)
- {
- html += 'style="display: inline;"><tr>';
- /*The height of 26 is chosen so that the collapse/expand icons will always line up in Firefox. Bug #483255*/
- html += '<td'+(isFF() ? ' style="vertical-align:bottom"':'')+' style="height:26px"><img id="barIcon'+ this.m_id +'" border="0" src="'+ this.m_imgCollapseSrc + '"';
- if (this.m_hideTooltip != null) {
- html += ' alt="'+this.m_hideTooltip+'" title="'+this.m_hideTooltip+'"';
- }
- html +=' onclick="'+this.m_sId +'.toggleBar();" style="cursor:pointer;cursor:hand;"></td>';
- }
- else
- {
- var marginStyle = "";
- if (this.m_htmlContainer.style.textAlign == "right") {
- marginStyle = 'margin-left:auto; margin-right: 0;';
- }
- else if (this.m_htmlContainer.style.textAlign == 'left') {
- marginStyle = 'margin-left:0; margin-right: auto;';
- }
- else if (this.m_htmlContainer.style.textAlign == 'center') {
- marginStyle = 'margin-left:auto; margin-right: auto;';
- }
- if (marginStyle != "") {
- html += ' style="'+marginStyle+'"';
- }
- html += '><tr>';
- }
- html += '<td id="bar'+ this.m_id +'">';
- html += '<table cellpadding="0" cellspacing="0" border="0" role="presentation" class="';
- if(this.getStyle() != null)
- {
- html += this.getStyle().getNormalState();
- }
- html += '" id="';
- html += this.m_id;
- html += '" style="'+ this.m_style +'"><tr>';
- html += this.drawItems();
- html += '</tr></table></td>';
- html += '</tr></table>';
- this.m_htmlContainer.innerHTML = html;
- this.m_htmlContainer.style.textAlign = this.m_align;
- //initialize any items
- for(var i = 0; i < this.m_items.length; ++i) {
- if(typeof this.m_items[i].init == "function")
- {
- this.m_items[i].init();
- }
- }
- this.attachEvents();
- }
- function CBar_drawItems() {
- var html = "";
- for(var i = 0; i < this.m_items.length; ++i) {
- if(typeof this.m_items[i].draw == "function") {
- if(this.m_menuType == cHorizonalBar && !(this.m_items[i] instanceof CSeperator) ) {
- html += '<td style="white-space:nowrap;';
- if(this.m_items[i] instanceof CMenuItem)
- {
- html += ';padding-left:1px; padding-right: 1px;';
- }
- html += '">';
- }
- if(this.m_items[i].isVisible()) {
- html += this.m_items[i].draw();
- }
- if(this.m_menuType == cHorizonalBar && !(this.m_items[i] instanceof CSeperator) ) {
- html += '</td>';
- }
- }
- }
- return html;
- }
- function CBar_attachEvents() {
- for(var i = 0; i < this.m_items.length; ++i) {
- if(typeof this.m_items[i].attachEvents == "function" && this.m_items[i].isVisible()) {
- this.m_items[i].attachEvents();
- }
- }
- }
- function CBar_add(item) {
- if(typeof item.getObservers == "function" && typeof item.getObservers() == "object" && typeof item.onmouseover == "function" && item instanceof CMenuItem) {
- item.getObservers().attach(this, this.closeMenus, item.onmouseover);
- }
- this.m_items[this.m_items.length] = item;
- }
- function CBar_getNumItems() {
- return this.m_items.length;
- }
- function CBar_getId() {
- return this.m_id;
- }
- function CBar_get(index) {
- if(index >= 0 && index < this.getNumItems()) {
- return this.m_items[index];
- }
- return null;
- }
- function CBar_hide(index) {
- if(index > 0 && index < this.getNumItems()) {
- if(typeof this.m_items[i].hide == "function") {
- this.m_items[i].hide();
- }
- }
- }
- function CBar_show(index) {
- if(index > 0 && index < this.getNumItems()) {
- if(typeof this.m_items[i].show == "function") {
- this.m_items[i].show();
- }
- }
- }
- function CBar_enable(index) {
- if(index > 0 && index < this.getNumItems()) {
- if(typeof this.m_items[i].enable == "function") {
- this.m_items[i].enable();
- }
- }
- }
- function CBar_disable(index) {
- if(index > 0 && index < this.getNumItems()) {
- if(typeof this.m_items[i].disable == "function") {
- this.m_items[i].disable();
- }
- }
- }
- function CBar_getState(index) {
- if(index > 0 && index < this.getNumItems()) {
- if(typeof this.m_items[i].getState == "function") {
- this.m_items[i].getState();
- }
- }
- }
- function CBar_setMenuType(menuType) {
- this.m_menuType = menuType;
- }
- function CBar_getMenuType() {
- return this.m_menuType;
- }
- function CBar_setStyle(style) {
- this.m_style = style;
- }
- function CBar_setAlign(align) {
- this.m_align = align;
- }
- function CBar_getStyle() {
- return this.m_style;
- }
- function CBar_closeMenus(state) {
- // make sure we hide any submenus which have been opened.
- for(var i = 0; i < this.getNumItems(); i++) {
- var currentItem = this.get(i);
- if(typeof state == "object") {
- if(state.getSubject() == currentItem) {
- continue;
- }
- }
- if(typeof currentItem.getMenu == "function" && currentItem.getMenu() != null && currentItem.getMenu().isVisible()) {
- currentItem.getMenu().remove();
- }
- }
- }
- function CBar_getHTMLContainer() {
- return this.m_htmlContainer;
- }
- function CBar_getObservers() {
- return this.m_observers;
- }
- function CBar_onmouseover(evt) {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- // notify our parent (if one exists) of this event
- if(this.getParent() != null && typeof this.getParent().onmouseover == "function") {
- this.getParent().onmouseover(evt);
- }
- // notify observers of this event
- this.getObservers().notify(CBar_onmouseover);
- }
- function CBar_onmouseout(evt) {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- // notify our parent (if one exists) of this event
- if(this.getParent() != null && typeof this.getParent().onmouseout == "function") {
- this.getParent().onmouseout(evt);
- }
- // notify observers of this event
- this.getObservers().notify(CBar_onmouseout);
- }
- function CBar_onmouseup(evt) {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- // notify our parent (if one exists) of this event
- if(this.getParent() != null && typeof this.getParent().onmouseup == "function") {
- this.getParent().onmouseup(evt);
- }
- // notify observers of this event
- this.getObservers().notify(CBar_onmouseup);
- }
- function CBar_onkeypress(evt) {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- // notify our parent (if one exists) of this event
- if(this.getParent() != null && typeof this.getParent().onkeypress == "function") {
- this.getParent().onkeypress(evt);
- }
- // notify observers of this event
- this.getObservers().notify(CBar_onkeypress);
- }
- CBar.prototype.draw = CBar_draw;
- CBar.prototype.add = CBar_add;
- CBar.prototype.get = CBar_get;
- CBar.prototype.hide = CBar_hide;
- CBar.prototype.show = CBar_show;
- CBar.prototype.enable = CBar_enable;
- CBar.prototype.disable = CBar_disable;
- CBar.prototype.getState = CBar_getState;
- CBar.prototype.attachEvents = CBar_attachEvents;
- CBar.prototype.drawItems = CBar_drawItems;
- CBar.prototype.getId = CBar_getId;
- CBar.prototype.setMenuType = CBar_setMenuType;
- CBar.prototype.getMenuType = CBar_getMenuType;
- CBar.prototype.getNumItems = CBar_getNumItems;
- CBar.prototype.setStyle = CBar_setStyle;
- CBar.prototype.getStyle = CBar_getStyle;
- CBar.prototype.setAlign = CBar_setAlign;
- CBar.prototype.closeMenus = CBar_closeMenus;
- CBar.prototype.setParent = CBar_setParent;
- CBar.prototype.getParent = CBar_getParent;
- CBar.prototype.getHTMLContainer = CBar_getHTMLContainer;
- CBar.prototype.getObservers = CBar_getObservers;
- CBar.prototype.update = new Function("return true");
- CBar.prototype.getObservers = CBar_getObservers;
- CBar.prototype.onmouseover = CBar_onmouseover;
- CBar.prototype.onmouseout = CBar_onmouseout;
- CBar.prototype.onmouseup = CBar_onmouseup;
- CBar.prototype.onkeypress = CBar_onkeypress;
- CBar.prototype.hideBar = CBar_hideBar;
- CBar.prototype.showBar = CBar_showBar;
- CBar.prototype.toggleBar = CBar_toggleBar;
- /*
- Class CStaticText
- Static text to be shown in the banner or header
- */
- function CStaticText(text, style)
- {
- this.m_text = text;
- this.m_style = style;
- this.m_bVisible = true;
- this.m_sId = "";
- }
- CStaticText.prototype.setId = function(sId)
- {
- this.m_sId = sId;
- };
- CStaticText.prototype.getId = function()
- {
- return this.m_sId;
- };
- CStaticText.prototype.setText = function(text)
- {
- this.m_text = text;
- };
- CStaticText.prototype.setLabelledBy = function(text)
- {
- this.m_labelledBy = text;
- };
- CStaticText.prototype.draw = function()
- {
- var html="";
- html += '<td style="white-space: nowrap;" class="';
- html += this.m_style.getNormalState() + '"';
- if (this.getId() != "")
- {
- html += ' id="' + this.getId() + '"';
- }
- html += '>';
- var labelledByAttribute = this.m_labelledBy ? 'aria-labelledby="' + this.getId() + 'label"' : "";
- html += '<div role="presentation" tabIndex="0" ' + labelledByAttribute + '>';
- html += this.m_text;
- html += '</div>';
- if (this.m_labelledBy) {
- html += '<div style="position: absolute; overflow: hidden; width: 0; height: 0;" id="' + this.getId() + 'label">';
- html += this.m_labelledBy;
- html += '</div>';
- }
-
- html += '</td>';
- return html;
- };
- CStaticText.prototype.isVisible = function()
- {
- return this.m_bVisible;
- };
- CStaticText.prototype.hide = function()
- {
- this.m_bVisible = false;
- };
- CStaticText.prototype.hide.show = function()
- {
- this.m_bVisible = true;
- };
- /* Constants */
- var DISPLAY_INLINE = 'inline';
- var DISPLAY_NONE = "none";
- var DISPLAY_BLOCK = "block";
|