123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677 |
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| BI and PM: prmt
- *| (C) Copyright IBM Corp. 2002, 2021
- *|
- *| US Government Users Restricted Rights - Use, duplication or
- *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- *|
- *+------------------------------------------------------------------------+
- */
- // Constants
- var giDRAW_BLOCKSIZE = 50;
- var giDRAW_INTERVAL = 50;
- var gsCTREE_checkbox = "checkbox";
- var gsCTREE_click = "click";
- var gsCTREE_contextmenu = "contextmenu";
- var gsCTREE_dblclick = "dblclick";
- var gsCTREE_dragRef = "dragRef";
- var gsCTREE_dragTree = "dragTree";
- var gsCTREE_drag = "drag";
- var gsCTREE_dragend = "dragend";
- var gsCTREE_dragstart = "dragstart";
- var gsCTREE_icon = "icon";
- var gsCTREE_img = "img";
- var gsCTREE_indicator = "indicator";
- var gsCTREE_indicatorSpan = "indicatorSpan";
- var gsCTREE_keypress = "keypress";
- var gsCTREE_label = "label";
- var gsCTREE_labelText = "labelText";
- var gsCTREE_middle = "middle";
- var gsCTREE_nobr = "nobr";
- var gsCTREE_onclick = "onclick";
- var gsCTREE_oncontextmenu = "oncontextmenu";
- var gsCTREE_ondblclick = "ondblclick";
- var gsCTREE_ondrag = "ondrag";
- var gsCTREE_ondragend = "ondragend";
- var gsCTREE_ondragstart = "ondragstart";
- var gsCTREE_onkeypress = "onkeypress";
- var gsCTREE_toggle = "toggle_";
- var gsCTREE_tree = "tree";
- var gsCTREE_treeRef = "treeRef";
- // Fix for COGCQ00685248 - Icon text is top-aligned in Firefox in Query Studio
- // changed this.m_oTREELINE.align = gsCTREE_middle; to
- // this.m_oTREELINE.className = CLS_TREE_TEXTICON_ALIGNFIX;
- // This fix aligns the Icon and the text correctly
- //TREE CONTROL
- // oPane: the HTML element where the tree will be rendered
- // oSubmit: the form control to submit selections to the server
- // bRequired: is this a required field [true|false]
- // bMultiSelect: can the user pick more than one value [true|false]
- // sRef: the name of this object
- // oImgTest: the image object used for validation handling
- // oErrorFeedback: object used to provide validation feedback
- // oBidi: object used to provide Bidi methods
- function CTree(oPane, oSubmit, bRequired, bMultiSelect, sRef, oImgTest, oErrorFeedback, sCVId, sStyle, oBidi)
- {
- this.contentLocale = null;
- this.setCVId(sCVId);
- this.m_style = sStyle;
- //html div element where adornments will be rendered
- this.m_oOuterPane = oPane;
- //html element where the tree will be rendered
- this.m_oPane = null;
- //create a root node for the tree
- //new nodes are added by calling the appendChild method for each node
- this.m_oRoot = new CTreeNode(null, tntRoot, true, 'root', 'root', false);
- this.m_oRoot.m_oTree = this;
- this.m_oRoot.setTreeRef(K_PRMT_sEMPTY);
- if (this.m_oOuterPane != null) {
- this.m_oOuterPane.setAttribute("role", "tree");
- }
- this.m_oSubmit = oSubmit;
- this.m_bRequired = bRequired;
-
- //determine the selection mode for the tree
- if (bMultiSelect == false)
- {
- this.m_iSelectionMode = SINGLE_TREE_SELECTION;
- this.m_sSelectTreeUI = NORMAL_TREE;
- }
- else
- {
- this.m_iSelectionMode = DISCONTIGUOUS_TREE_SELECTION;
- this.m_sSelectTreeUI = CHECKBOX_TREE;
- }
- //check the state of the control?
- //this needs to happen after the nodes are added
- this.m_bValid = false;
- this.m_sRef = sRef;
- //maintain a list of selections
- this.m_sTreeProcessResult = K_PRMT_sEMPTY;
- this.m_oErrorFeedback = oErrorFeedback;
- //../prompting/images for handling errors
- this.m_oImgCheck = oImgTest;
- if (this.m_oImgCheck != null)
- {
- this.m_oImgErrorFalse= new Image();
- this.m_oImgErrorFalse.src = ERROR_TIMED_SMALL_OFF;
- this.m_oImgErrorTrue = new Image();
- this.m_oImgErrorTrue.src = ERROR_TIMED_SMALL;
- }
- this.m_bShowRootNode = false;
- this.m_bLoadOnTheFly = false;
- this.m_iIsLoading = 0;
- this.m_bForceSelectionAtLowestLevel = false;
- this.m_bAllowSelectionToggle = true;
- this.m_oAnchorNode = null;
- this.m_bAllowDragDrop = false;
- this.m_fOnDragStartFunc = null;
- this.m_fOnDragFunc = null;
- this.m_fOnDragEndFunc = null;
- this.m_fOnContextMenu = null;
- this.m_bTrackSelectionOrder = false;
- this.m_aSelectionOrder = new Array();
- this.m_fSingleClickFunc = null;
- this.m_fDoubleClickFunc = null;
- this.m_bHideAdornments = false;
- this.m_bMustChangeDefault = false;
- this.m_bHideOuterTable = false;
- this.m_bRecursiveSelect = true;
- this.m_bPromptTree = false;
- this.m_iMaxValueCount = 5000;
- this.m_bShowPreviousValues = true;
- this.m_aAllSelections = null;
- this.m_iContainerWidth = null;
- this.m_iContainerHeight = null;
- this.m_bNodesCanHaveChildren = true;
- this.m_bIsDisabled = false;
- this.m_bHasBeenDrawn = false;
- this.m_oLastSelectedNode = null;
- this.m_itemTabIndex = 1;
-
- // A11Y check for Event Studio keyboard support
- if (typeof AccessibilityHandler != "undefined") {
- this.m_itemTabIndex = -1;
- }
- //skin folder
- this.m_sSkin = (typeof getPromptSkin != K_PRMT_sUNDEFINED ? getPromptSkin() : K_PRMT_sDEFAULTSKIN);
- if (typeof gDispatcher != K_PRMT_sUNDEFINED) // Try to find global dispatcher object first
- {
- this.m_oDispatcher = gDispatcher;
- }
- else if (typeof CDispatcher != K_PRMT_sUNDEFINED)
- {
- this.m_oDispatcher = new CDispatcher();
- }
- else
- {
- this.m_oDispatcher = null;
- }
- this.m_sServerPath = this.getGateway();
- // DOM objects used to create child nodes.
- this.m_oTREELINE = document.createElement("IMG");
- this.m_oTREELINE.src = TREE_I_ONLY;
- this.m_oTREELINE.className = CLS_TREE_TEXTICON_ALIGNFIX;
- this.m_oTREELINE.alt = "";
- this.m_oTREELINE.setAttribute(gsCTREE_treeRef, gsCTREE_img);
- this.m_oDIVnewElement = document.createElement("DIV");
-
- this.m_oNOBR = document.createElement("NOBR");
- this.m_oNOBR.setAttribute(gsCTREE_treeRef, gsCTREE_nobr);
- this.m_oIcon = document.createElement("IMG");
- this.m_oIcon.setAttribute(gsCTREE_treeRef, gsCTREE_img);
- this.m_oIndicatorSPAN = document.createElement("SPAN");
- this.m_oIndicatorSPAN.style.paddingLeft = 3;
- this.m_oIndicatorIMG = document.createElement("IMG");
- this.m_oIndicatorIMG.className = CLS_TREE_TEXTICON_ALIGNFIX;
- this.m_oTextSPAN = document.createElement("SPAN");
- this.m_oToggleIMG = document.createElement("IMG");
- this.m_oToggleIMG.className = CLS_TREE_TEXTICON_ALIGNFIX;
- this.m_oToggleIMG.onclick = null;
- this.m_oToggleIMG.src = TREE_L_ONLY;
- this.m_oToggleIMG.alt = "";
- this.m_oCheckIMG = document.createElement("IMG");
- this.m_oCheckIMG.className = CLS_TREE_TEXTICON_ALIGNFIX;
- this.m_oLabelSPAN = document.createElement("SPAN");
- this.m_oLabelA = document.createElement("A");
- this.m_oLabelA.className = CLS_TREE_TEXT_NO_LINK;
- if (window.ie11)
- {
- this.m_oLabelA.href = "#";
- this.m_oLabelA.addEventListener("mouseover", function() {window.status=K_PRMT_sEMPTY;return true;});
- this.m_oLabelA.addEventListener("mouseout", function() {window.status=K_PRMT_sEMPTY;return true;});
- this.m_oLabelA.addEventListener("mouseup", function(e) {window.status=K_PRMT_sEMPTY;e.returnValue = false;});
- this.m_oLabelA.addEventListener("mousedown", function(e) {window.status=K_PRMT_sEMPTY;e.returnValue = false;});
- this.m_oLabelA.addEventListener("mousemove", function(e) {window.status=K_PRMT_sEMPTY;e.returnValue = false;});
- this.m_oLabelA.addEventListener(gsCTREE_click, function(e) {window.status=K_PRMT_sEMPTY;e.returnValue = false;});
- }
- else if (window.ie)
- {
- this.m_oLabelA.href = "#";
- this.m_oLabelA.attachEvent("onmouseover", function() {window.status=K_PRMT_sEMPTY;return true;});
- this.m_oLabelA.attachEvent("onmouseout", function() {window.status=K_PRMT_sEMPTY;return true;});
- this.m_oLabelA.attachEvent("onmouseup", function(e) {window.status=K_PRMT_sEMPTY;e.returnValue = false;});
- this.m_oLabelA.attachEvent("onmousedown", function(e) {window.status=K_PRMT_sEMPTY;e.returnValue = false;});
- this.m_oLabelA.attachEvent("onmousemove", function(e) {window.status=K_PRMT_sEMPTY;e.returnValue = false;});
- this.m_oLabelA.attachEvent(gsCTREE_onclick, function(e) {window.status=K_PRMT_sEMPTY;e.returnValue = false;});
- }
- else
- {
- this.m_oLabelA.addEventListener("mouseover", function() {window.status=K_PRMT_sEMPTY;return false;}, true);
- this.m_oLabelA.addEventListener("mouseout", function() {window.status=K_PRMT_sEMPTY;return false;}, true);
- this.m_oLabelA.addEventListener("mouseup", function(e) {window.status=K_PRMT_sEMPTY;e.preventDefault();return false;}, true);
- this.m_oLabelA.addEventListener("mousedown", function(e) {window.status=K_PRMT_sEMPTY;e.preventDefault();return false;}, true);
- this.m_oLabelA.addEventListener("mousemove", function(e) {window.status=K_PRMT_sEMPTY;e.preventDefault();return false;}, true);
- this.m_oLabelA.addEventListener(gsCTREE_click, function(e) {window.status=K_PRMT_sEMPTY;e.preventDefault();return false;}, true);
- }
- this.m_oAncestry = null;
- this.m_oBidi = oBidi;
-
- this.cacheKeyPrefix = "";
- this.bAllowStateCache = false;
- this.m_oTreeControl = null;
- }
- CTree.prototype = new CPromptControl();
- CTree.prototype.setItemTabIndex = function(val)
- {
- this.m_itemTabIndex = val;
- }
- CTree.prototype.setAllowStateCache = function(bAllowStateCache, keyPrefix){
- this.bAllowStateCache = bAllowStateCache;
- this.cacheKeyPrefix = keyPrefix;
- };
- CTree.prototype.savePromptControlRef = function (oPromptControl)
- {
- this.m_oTreeControl = oPromptControl;
- };
- // Set this to the tree's parameter name if this is a prompt control tree
- // getPromptValues OM function will be called automatically if this is a prompting tree
- CTree.prototype.setPromptingTree = function(val)
- {
- this.m_bPromptTree = val;
- };
- CTree.prototype.setLocale = function(val)
- {
- this.contentLocale = val;
- };
- CTree.prototype.setLabel = function(treeLabel){
- if (treeLabel != null){
- this.m_oOuterPane.setAttribute("aria-label", treeLabel);
- }
- };
- CTree.prototype.getGateway = function()
- {
- var v_sGateway = document.location.pathname;
- var v_oCV = (this.getCV ? this.getCV() : null);
- if (v_oCV && v_oCV.getGateway) {
- v_sGateway = v_oCV.getGateway();
- }
- return v_sGateway;
- };
- CTree.prototype.getPromptingTree = function()
- {
- return this.m_bPromptTree;
- };
- CTree.prototype.setDisabled = function(val)
- {
- this.m_bIsDisabled = val;
- };
- CTree.prototype.getDisabled = function()
- {
- return this.m_bIsDisabled;
- };
- CTree.prototype.setMaxValueCount = function(val)
- {
- this.m_iMaxValueCount = val;
- };
- CTree.prototype.getMaxValueCount = function()
- {
- return this.m_iMaxValueCount;
- };
- CTree.prototype.getHasBeenDrawn = function()
- {
- return this.m_bHasBeenDrawn;
- };
- CTree.prototype.setContainerWidth = function(val)
- {
- this.m_iContainerWidth = val;
- };
- CTree.prototype.getContainerWidth = function()
- {
- return this.m_iContainerWidth;
- };
- CTree.prototype.setContainerHeight = function(val)
- {
- this.m_iContainerHeight = val;
- };
- CTree.prototype.getContainerHeight = function()
- {
- return this.m_iContainerHeight;
- };
- CTree.prototype.getStyle = function()
- {
- return this.m_style;
- };
- //deprecated, use addToPrevSelArray
- CTree.prototype.addToPreviousSelections = function(val)
- {
- val = sDecodeU003( val );
- if (this.m_aAllSelections == null) {
- this.m_aAllSelections = new Array();
- }
- this.m_aAllSelections[this.m_aAllSelections.length] = val;
- };
- //deprecated, use getPrevSelArray
- CTree.prototype.getPreviousSelections = function()
- {
- return this.m_aAllSelections;
- };
- //deprecated, use clearPrevSelArray
- CTree.prototype.clearPreviousSelections = function()
- {
- this.clearPrevSelArray();
- };
- CTree.prototype.addToPrevSelArray = function(useVal, displayVal)
- {
- if (this.m_aAllSelections == null) {
- this.m_aAllSelections = new Array();
- }
- useVal = sDecodeU003( useVal );
- displayVal = sDecodeU003( displayVal );
- this.m_aAllSelections[this.m_aAllSelections.length] = new Array (displayVal, useVal);
- };
- CTree.prototype.removeFromPrevSelArray = function( v_sValue, v_sName )
- {
- if (this.m_aAllSelections == null)
- {
- return;
- }
- for (var v_idxPS = 0; v_idxPS < this.m_aAllSelections.length; v_idxPS++)
- {
- var v_sUse = this.m_aAllSelections[v_idxPS];
- var v_sDisplay = v_sUse;
- if ( typeof v_sUse == K_PRMT_sOBJECT && v_sUse.length )
- {
- v_sDisplay = v_sUse[0];
- v_sUse = v_sUse[1];
- }
- if ( typeof v_sName == K_PRMT_sUNDEFINED )
- {
- v_sName = v_sValue;
- }
- if ( v_sUse == v_sValue && v_sDisplay == v_sName )
- {
- this.m_aAllSelections.splice( v_idxPS, 1 );
- v_idxPS--;
- }
- }
- if (this.m_aAllSelections.length < 1)
- {
- this.m_aAllSelections = null;
- }
- };
- CTree.prototype.getPrevSelArray = function()
- {
- return this.m_aAllSelections;
- };
- CTree.prototype.clearPrevSelArray = function()
- {
- this.m_aAllSelections = null;
- this.m_oAncestry = null;
- };
- CTree.prototype.setShowPreviousValues = function(val)
- {
- this.m_bShowPreviousValues = val;
- };
- CTree.prototype.getShowPreviousValues = function()
- {
- return this.m_bShowPreviousValues;
- };
- CTree.prototype.setSingleClickFunc = function(val)
- {
- this.m_fSingleClickFunc = val;
- };
- CTree.prototype.getSingleClickFunc = function()
- {
- return this.m_fSingleClickFunc;
- };
- CTree.prototype.setDoubleClickFunc = function(val)
- {
- this.m_fDoubleClickFunc = val;
- };
- CTree.prototype.getDoubleClickFunc = function()
- {
- return this.m_fDoubleClickFunc;
- };
- CTree.prototype.setLastSelectedNode = function(val)
- {
- this.m_oLastSelectedNode = val;
- };
- CTree.prototype.getLastSelectedNode = function()
- {
- return this.m_oLastSelectedNode;
- };
- CTree.prototype.addToSelectionOrder = function(node)
- {
- for (var i = 0; i < this.m_aSelectionOrder.length; i++)
- {
- if (this.m_aSelectionOrder[i] == node)
- {
- return;
- }
- }
- this.m_aSelectionOrder[this.m_aSelectionOrder.length] = node;
- };
- CTree.prototype.removeFromSelectionOrder = function(node)
- {
- for (var i = 0; i < this.m_aSelectionOrder.length; i++)
- {
- if (this.m_aSelectionOrder[i] == node)
- {
- delete this.m_aSelectionOrder[i];
- break;
- }
- }
- };
- CTree.prototype.getSelectionOrder = function()
- {
- var tempArr = new Array();
- for (var i = 0; i < this.m_aSelectionOrder.length; i++)
- {
- if (this.m_aSelectionOrder[i] != null) {
- tempArr[tempArr.length] = this.m_aSelectionOrder[i];
- }
- }
- return tempArr;
- };
- CTree.prototype.clearSelectionOrder = function()
- {
- this.m_aSelectionOrder = new Array();
- };
- CTree.prototype.setTrackSelectionOrder = function(val)
- {
- this.m_bTrackSelectionOrder = val;
- };
- CTree.prototype.getTrackSelectionOrder = function()
- {
- return this.m_bTrackSelectionOrder;
- };
- CTree.prototype.setContextMenu = function(val)
- {
- this.m_fOnContextMenu = val;
- };
- CTree.prototype.getContextMenu = function()
- {
- return this.m_fOnContextMenu;
- };
- CTree.prototype.setAllowDragDrop = function(val)
- {
- this.m_bAllowDragDrop = val;
- };
- CTree.prototype.getAllowDragDrop = function()
- {
- return this.m_bAllowDragDrop;
- };
- CTree.prototype.setOnDragEnd = function(val)
- {
- this.m_fOnDragEndFunc = val;
- };
- CTree.prototype.getOnDragEnd = function()
- {
- return this.m_fOnDragEndFunc;
- };
- CTree.prototype.setOnDragStart = function(val)
- {
- this.m_fOnDragStartFunc = val;
- };
- CTree.prototype.getOnDragStart = function()
- {
- return this.m_fOnDragStartFunc;
- };
- CTree.prototype.setOnDrag = function(val)
- {
- this.m_fOnDragFunc = val;
- };
- CTree.prototype.getOnDrag = function()
- {
- return this.m_fOnDragFunc;
- };
- CTree.prototype.setAnchorNode = function(val)
- {
- this.m_oAnchorNode = val;
- };
- CTree.prototype.getAnchorNode = function()
- {
- return this.m_oAnchorNode;
- };
- CTree.prototype.setMustChangeDefaultValue = function(val)
- {
- this.m_bMustChangeDefault = val;
- this.m_aDefaultSelNodes = new Array();
- // flag to make sure selected values are only added to default selection array when control is created
- this.setDefaultSelectLock(true);
- };
- CTree.prototype.getMustChangeDefaultValue = function()
- {
- return this.m_bMustChangeDefault;
- };
- CTree.prototype.setAllowSelectionToggle = function(val)
- {
- this.m_bAllowSelectionToggle = val;
- };
- CTree.prototype.getAllowSelectionToggle = function()
- {
- return this.m_bAllowSelectionToggle;
- };
- CTree.prototype.setSelectTreeUI = function(val)
- {
- this.m_sSelectTreeUI = val;
- if (val == NORMAL_TREE) {
- this.setAllowSelectionToggle(false);
- }
- };
- CTree.prototype.getSelectTreeUI = function()
- {
- return this.m_sSelectTreeUI;
- };
- CTree.prototype.setRootNodeShowing = function(val)
- {
- this.m_bShowRootNode = val;
- };
- CTree.prototype.getRootNodeShowing = function()
- {
- return this.m_bShowRootNode;
- };
- CTree.prototype.setForceSelectionAtLowestLevel = function(val)
- {
- this.m_bForceSelectionAtLowestLevel = val;
- };
- CTree.prototype.getForceSelectionAtLowestLevel = function()
- {
- return this.m_bForceSelectionAtLowestLevel;
- };
- CTree.prototype.setLoadOnTheFlyFunction = function(funcVal)
- {
- this.m_bLoadOnTheFly = funcVal;
- };
- CTree.prototype.getLoadOnTheFly = function()
- {
- return this.m_bLoadOnTheFly;
- };
- CTree.prototype.setLoading = function(val)
- {
- if (val) {
- this.m_iIsLoading += 1;
- }
- else if (this.m_iIsLoading > 0) {
- this.m_iIsLoading -= 1;
- }
- };
- CTree.prototype.getLoading = function()
- {
- return this.m_iIsLoading;
- };
- //can any node (other than those at the root) contain other nodes
- CTree.prototype.nodesCanHaveChildren = function()
- {
- return this.m_bNodesCanHaveChildren;
- };
- CTree.prototype.setNodesCanHaveChildren = function(val)
- {
- this.m_bNodesCanHaveChildren = val;
- };
- //string return the javascript object name of the tree
- CTree.prototype.getName = function()
- {
- return this.m_sRef;
- };
- //search paths are used to identify the correct node
- //CTree: return tree root node
- CTree.prototype.getRootNode = function()
- {
- return this.m_oRoot;
- };
- //UI related
- CTree.prototype.drawAll = function()
- {
- if (this.m_oPane == null) {
- this.setupOuterTable();
- }
- this.draw(this.getRootNode(), this.m_oPane);
- if (this.getDefaultSelectLock() == true && this.getMustChangeDefaultValue() == true) {
- this.setDefaultSelectLock(false);
- }
- };
- CTree.prototype.setupOuterTable = function()
- {
- if (this.getHideOuterTable() == false)
- {
- this.drawOuterTable();
- this.m_oPane = document.getElementById("treePane" + this.m_sRef);
- }
- else {
- this.m_oPane = this.m_oOuterPane;
- }
- if (window.ie)
- {
- this.m_oPane.onselectstart = function () {document.selection.empty(); return false;};
- }
- };
- CTree.prototype.setHideAdornments = function(val)
- {
- this.m_bHideAdornments = val;
- };
- CTree.prototype.getHideAdornments = function()
- {
- return this.m_bHideAdornments;
- };
- CTree.prototype.setHideOuterTable = function(val)
- {
- this.m_bHideOuterTable = val;
- };
- CTree.prototype.getHideOuterTable = function()
- {
- return this.m_bHideOuterTable;
- };
- CTree.prototype.getErrorFeedbackWidget = function()
- {
- return this.m_oErrorFeedback;
- };
- CTree.prototype.setErrorFeedbackWidget = function(obj)
- {
- this.m_oErrorFeedback = obj;
- };
- CTree.prototype.getImgCheck = function()
- {
- return this.m_oImgCheck;
- };
- CTree.prototype.setImgCheck = function(obj)
- {
- this.m_oImgCheck = obj;
- };
- CTree.prototype.setImgErrorFalse = function(path)
- {
- this.m_oImgErrorFalse= new Image();
- this.m_oImgErrorFalse.src = path;
- };
- CTree.prototype.setImgErrorTrue = function(path)
- {
- this.m_oImgErrorTrue = new Image();
- this.m_oImgErrorTrue.src = path;
- };
- CTree.prototype.setRecursiveSelect = function(val)
- {
- this.m_bRecursiveSelect = val;
- };
- CTree.prototype.getRecursiveSelect = function()
- {
- return this.m_bRecursiveSelect;
- };
- //select all the items in a tree
- CTree.prototype.selectAll = function ()
- {
- this.getRootNode().setSelected(true, true);
- this.redraw();
- this.checkData();
- };
- //remove any selections
- CTree.prototype.deSelectAll = function ()
- {
- this.getRootNode().setSelected(false, true);
- this.clearPrevSelArray();
- if (this.getTrackSelectionOrder())
- {
- this.clearSelectionOrder();
- }
- this.redraw();
- this.checkData();
- };
- //redraw the tree
- CTree.prototype.redraw = function ()
- {
- redrawChildren(this.getRootNode(),this.getName());
- };
- //integer enumeration: determine the selection mode for the tree (e.g. single select, multiple select)
- CTree.prototype.getSelectionMode = function()
- {
- return this.m_iSelectionMode;
- };
- CTree.prototype.setSelectionMode = function(iSelectionMode)
- {
- this.m_iSelectionMode = iSelectionMode;
- };
- //other get/set functions
- CTree.prototype.getRequired = function()
- {
- return this.m_bRequired;
- };
- CTree.prototype.getDefaultSelectedNodes = function()
- {
- return this.m_aDefaultSelNodes;
- };
- CTree.prototype.addDefaultSelectedNode = function(node)
- {
- this.m_aDefaultSelNodes[this.m_aDefaultSelNodes.length] = node;
- };
- CTree.prototype.setDefaultSelectLock = function(val)
- {
- this.m_bSetDefaultSelection = val;
- };
- CTree.prototype.getDefaultSelectLock = function()
- {
- return this.m_bSetDefaultSelection;
- };
- /*
- When processing, start at the top to the tree iterate down a path if the there is at least one
- selected child (at any level). Stop when the current node is selected (regardless whether the
- children are selected or not).
- Note that only selected nodes appear in the selectChoices list (this is a flat list)
- <selectChoices>
- <selectTreeOption displayValue="[user value]" useValue="[system value]"/>
- <selectTreeOption displayValue="[user value]" useValue="[system value]"/>
- </selectChoices>
- */
- CTree.prototype.preProcess = function ()
- {
- //convert the data to XML and submit
- var sURLValues = K_PRMT_sEMPTY;
- this.m_sTreeProcessResult = K_PRMT_sEMPTY;
- //move recursively and render all children
- var children = this.getRootNode().getChildren();
- if (children.length > 0)
- {
- for (var j = 0; j < children.length; j++)
- {
- this.processTree(children[j]);
- }
- }
- var prevSels = this.getPreviousSelections();
- if (prevSels != null)
- {
- for (var i = 0; i < prevSels.length; i++)
- {
- if (typeof prevSels[i] == K_PRMT_sSTRING) //deprecated
- {
- this.m_sTreeProcessResult += '<selectOption displayValue="' + sXmlEncode(prevSels[i]) + '" useValue="' + sXmlEncode(prevSels[i]) + '"/>';
- }
- else if (typeof prevSels[i] == K_PRMT_sOBJECT)
- {
- this.m_sTreeProcessResult += '<selectOption displayValue="' + sXmlEncode(prevSels[i][0]) + '" useValue="' + sXmlEncode(prevSels[i][1]) + '"/>';
- }
- }
- }
- sURLValues += this.m_sTreeProcessResult;
- addSelectChoices(this.m_oSubmit, sURLValues);
- };
- //loop through the tree recursively to build the tree
- CTree.prototype.processTree = function (node)
- {
- if (node.isSelected())
- {
- var isSelectedAlready = false;
- var prevSels = this.getPreviousSelections();
- if (prevSels != null)
- {
- var value = node.getValue();
- for (var i = 0; i < prevSels.length; i++)
- {
- if ((typeof prevSels[i] == K_PRMT_sSTRING) && (prevSels[i] == value))
- {
- isSelectedAlready = true;
- break;
- }
- else if ((typeof prevSels[i] == K_PRMT_sOBJECT) && (prevSels[i][1] == value))
- {
- isSelectedAlready = true;
- // make sure the display value is set ( RSVP isn't setting it )
- if ( !prevSels[i][0] )
- {
- prevSels[i][0] = node.getName();
- }
- break;
- }
- }
- }
- if (!isSelectedAlready)
- {
- this.m_sTreeProcessResult += '<selectOption displayValue="' + sXmlEncode(node.getName()) + '" useValue="' + sXmlEncode(node.getValue()) + '"/>';
- }
- }
- if (this.nodesCanHaveChildren() && node.hasSelectedChildren())
- {
- //get any children
- var children = node.getChildren();
- //move recursively and find all children
- for (var iChildCounter = 0; iChildCounter < children.length; iChildCounter++)
- {
- this.processTree(children[iChildCounter]);
- }
- }
- };
- CTree.prototype.getSelectedLeafNodes = function (node)
- {
- if (!node) {
- node = this.getRootNode();
- }
- var selectedNodes = new Array();
- if (node.canHaveChildren() && node.hasSelectedChildren())
- {
- //get any children
- var children = node.getChildren();
- //move recursively and find all children
- for (var iChildCounter = 0; iChildCounter < children.length; iChildCounter++)
- {
- var theSelectedNodes = this.getSelectedLeafNodes(children[iChildCounter]);
- for (var i in theSelectedNodes)
- {
- selectedNodes[selectedNodes.length] = theSelectedNodes[i];
- }
- }
- if(node.getTree().getSelectTreeUI() == CHECKBOX_TREE && node.getTree().getSelectionMode() == DISCONTIGUOUS_TREE_SELECTION && node.isSelected() && node.getNodeTypeObject().getRecursiveSelect() == false)
- {
- // can select this node separately from its children
- selectedNodes[selectedNodes.length] = node;
- }
- }
- else if (node.getNodeType() == TREE_ITEM && node.isSelected())
- {
- selectedNodes[selectedNodes.length] = node;
- }
- return selectedNodes;
- };
- CTree.prototype.getSelectedFolderNodes = function (node)
- {
- if (!node) {
- node = this.getRootNode();
- }
- var selectedNodes = new Array();
- if (node.canHaveChildren())
- {
- if (node.getNodeType() == TREE_FOLDER && node.isSelected())
- {
- selectedNodes[selectedNodes.length] = node;
- }
- //get any children
- var children = node.getChildren();
- //move recursively and find all children
- for (var iChildCounter = 0; iChildCounter < children.length; iChildCounter++)
- {
- var theSelectedNodes = this.getSelectedFolderNodes(children[iChildCounter]);
- for (var i in theSelectedNodes)
- {
- selectedNodes[selectedNodes.length] = theSelectedNodes[i];
- }
- }
- }
- return selectedNodes;
- };
- CTree.prototype.getSelectedUnfetchedChildren = function ()
- {
- var theFolderNodes = this.getSelectedFolderNodes();
- var unfetchedChildren = false;
- for (var i in theFolderNodes)
- {
- if (this.m_bRecursiveSelect && theFolderNodes[i].getNodeTypeObject().getRecursiveSelect() &&
- theFolderNodes[i].canHaveChildren() && !theFolderNodes[i].hasChildren())
- {
- theFolderNodes[i].fetchChildren();
- unfetchedChildren = true;
- }
- }
- return unfetchedChildren;
- };
- //check whether the default value must be changed.. if yes, also check whether it has changed
- CTree.prototype.checkDefaultValid = function ()
- {
- var selectionValid = true;
- var selectedNodes = new Array();
- if (this.m_bMustChangeDefault)
- {
- selectedNodes = this.getSelectedLeafNodes(this.getRootNode());
- selectedNodes = selectedNodes.concat(this.getSelectedFolderNodes(this.getRootNode()));
- // can potentially determine right away if selection is valid
- if (selectedNodes.length != this.getDefaultSelectedNodes().length) {
- return true;
- }
- var longArray, shortArray;
- if (selectedNodes.length > this.getDefaultSelectedNodes().length)
- {
- longArray = selectedNodes;
- shortArray = this.getDefaultSelectedNodes();
- }
- else
- {
- longArray = this.getDefaultSelectedNodes();
- shortArray = selectedNodes;
- }
- for (var i = 0; i < longArray.length; i++)
- {
- for (var j = 0; j < shortArray.length; j++)
- {
- if (shortArray[j].getId() == longArray[i].getId())
- {
- selectionValid = false;
- break;
- }
- }
- if (selectionValid == true)
- {
- return true;
- }
- selectionValid = true;
- }
- return false;
- }
- return true;
- };
- //called by observer notification when a Reprompt button is selected
- CTree.prototype.handleNotify = function()
- {
- this.cleanCacheValues(true);
- };
- //check whether the user has selected a value
- CTree.prototype.checkData = function()
- {
- if ( this.m_oWrapper )
- {
- return this.m_oWrapper.checkData();
- }
- if (this.getDisabled() == true)
- {
- if (this.isRequired() == false)
- {
- this.m_bValid = true;
- this.checkPass();
- }
- else
- {
- this.m_bValid = false;
- this.checkFail();
- }
- }
- else if ((((this.isRequired() == false) || (this.getRootNode().hasSelectedChildren() == true)) && this.checkDefaultValid() == true) || this.getPreviousSelections() != null)
- {
- this.m_bValid = true;
- this.checkPass();
- }
- else
- {
- this.m_bValid = false;
- this.checkFail();
- }
- };
- //render the validated state
- CTree.prototype.checkPass = function ()
- {
- if ((this.m_oImgCheck != null) && (this.m_oImgCheck.src != this.m_oImgErrorFalse.src))
- {
- this.m_oImgCheck.src = this.m_oImgErrorFalse.src;
- }
- if (this.m_oErrorFeedback)
- {
- this.m_oErrorFeedback.className ="clsFeedbackWidget";
- }
- this.notify();
- };
- //render the validation error state
- CTree.prototype.checkFail = function ()
- {
- if ((this.m_oImgCheck != null) && (this.m_oImgCheck.src != this.m_oImgErrorTrue.src))
- {
- this.m_oImgCheck.src = this.m_oImgErrorTrue.src;
- }
- if (this.m_oErrorFeedback)
- {
- this.m_oErrorFeedback.className ="clsFeedbackWidgetParseError";
- }
- this.notify(gFAIL, this);
- };
- //set the control's validity
- CTree.prototype.setValid = function (bValid)
- {
- this.m_bValid = bValid;
- };
- CTree.prototype.redrawNodeToggle = function (node, nodeId) {
- var newToggleIcon = document.getElementById(nodeId + gsCTREE_toggle + node.getTreeHierarchy());
- if (newToggleIcon != null) {
- //pick what to draw
- if (node.isLast() == true && node.getParent().getMoreData() != true) {
- if (node.canHaveChildren() == true) {
- if (node.isOpen() == true) {
- newToggleIcon.src = TREE_L_MINUS;
- newToggleIcon.title = PMT_TRE_COLLAPSE;
- newToggleIcon.alt = PMT_TRE_COLLAPSE;
- }
- else {
- newToggleIcon.src = TREE_L_PLUS;
- newToggleIcon.title = PMT_TRE_EXPAND;
- newToggleIcon.alt = PMT_TRE_EXPAND;
- }
- newToggleIcon.tabIndex = this.m_itemTabIndex;
- newToggleIcon.onclick = toggle;
- if (window.ie11) {
- newToggleIcon.addEventListener(gsCTREE_keypress, toggle);
- } else if (window.ie) {
- newToggleIcon.attachEvent(gsCTREE_onkeypress, toggle);
- } else {
- newToggleIcon.addEventListener(gsCTREE_keypress, toggle, true);
- }
- }
- else {
- newToggleIcon.src = TREE_L_ONLY;
- newToggleIcon.alt = "";
- newToggleIcon.onclick = null;
- }
- }
- else {
- if (node.canHaveChildren() == true) {
- if (node.isOpen() == true) {
- newToggleIcon.src = TREE_T_MINUS;
- newToggleIcon.title = PMT_TRE_COLLAPSE;
- newToggleIcon.alt = PMT_TRE_COLLAPSE;
- }
- else {
- newToggleIcon.src = TREE_T_PLUS;
- newToggleIcon.title = PMT_TRE_EXPAND;
- newToggleIcon.alt = PMT_TRE_EXPAND;
- }
- newToggleIcon.tabIndex = this.m_itemTabIndex;
- newToggleIcon.onclick = toggle;
- if (window.ie11) {
- newToggleIcon.addEventListener(gsCTREE_keypress, toggle);
- } else if (window.ie) {
- newToggleIcon.attachEvent(gsCTREE_onkeypress, toggle);
- } else {
- newToggleIcon.addEventListener(gsCTREE_keypress, toggle, true);
- }
- }
- else {
- newToggleIcon.src = TREE_T_ONLY;
- newToggleIcon.alt = "";
- newToggleIcon.onclick = null;
- }
- }
- }
- };
- CTree.prototype.drawLoading = function(node, nodeId)
- {
- var theElement = document.getElementById(nodeId);
- if (!theElement && node.getNodeType() == TREE_ROOT && this.getRootNodeShowing() == false)
- {
- theElement = this.m_oPane;
- }
- if (theElement != null)
- {
- var newDivContainer = document.createElement("DIV");
- newDivContainer.className = CLS_TREE_LEVEL;
- newDivContainer.id = this.getName() + node.getTreeRef() + "loading";
- newDivContainer.style.width = "100%";
- var newNobrLoadingContainer = document.createElement("NOBR");
- this.drawTreeLines(node, newNobrLoadingContainer, node.getLevel() + 1);
- if (!(node.getNodeType() == TREE_ROOT && node.getTree().getRootNodeShowing() == false && node.getMoreData() != true))
- {
- var newLIcon = document.createElement("IMG");
- newLIcon.className = CLS_TREE_TEXTICON_ALIGNFIX;
- newLIcon.src = TREE_L_ONLY;
- newLIcon.alt="";
- newNobrLoadingContainer.appendChild(newLIcon);
- }
- var newLoadingIcon = document.createElement("IMG");
- newLoadingIcon.className = CLS_TREE_TEXTICON_ALIGNFIX;
- newLoadingIcon.src = TREE_LOADING;
- newNobrLoadingContainer.appendChild(newLoadingIcon);
- var newLabelContainer = document.createElement("SPAN");
- newLabelContainer.className = CLS_TREE_NODE_UNSELECTED + K_PRMT_sSP + CLS_TREE_TEXT;
- //We need the localized string for "Loading..." here
- if (typeof PMT_TRE_TREE_LOADING != K_PRMT_sUNDEFINED)
- {
- var newLoadingText = document.createTextNode(PMT_TRE_TREE_LOADING);
- newLabelContainer.appendChild(newLoadingText);
- newLabelContainer.title = PMT_TRE_TREE_LOADING;
- }
- newNobrLoadingContainer.appendChild(newLabelContainer);
- newDivContainer.appendChild(newNobrLoadingContainer);
- theElement.appendChild(newDivContainer);
- }
- };
- CTree.prototype.removeLoading = function(node)
- {
- var loadingDiv = document.getElementById(this.getName() + node.getTreeRef() + "loading");
- if (!loadingDiv && node.getNodeType() == TREE_ROOT && this.getRootNodeShowing() == false)
- {
- loadingDiv = this.m_oPane;
- }
- if (loadingDiv)
- {
- loadingDiv.parentNode.removeChild(loadingDiv);
- }
- };
- CTree.prototype.drawMoreData = function(node, nodeId)
- {
- var theElement = document.getElementById(nodeId);
- if (!theElement && node.getNodeType() == TREE_ROOT && this.getRootNodeShowing() == false)
- {
- theElement = this.m_oPane;
- }
- if (theElement != null)
- {
- var newDivContainer = document.createElement("DIV");
- newDivContainer.className = CLS_TREE_LEVEL;
- newDivContainer.id = this.getName() + node.getTreeRef() + "moredata";
- newDivContainer.style.width = "100%";
- var newNobrMoreDataContainer = document.createElement("NOBR");
- this.drawTreeLines(node, newNobrMoreDataContainer, node.getLevel() + 1);
- var newLIcon = document.createElement("IMG");
- newLIcon.className = CLS_TREE_TEXTICON_ALIGNFIX;
- newLIcon.src = TREE_L_ONLY;
- newIcon.alt="";
- newNobrMoreDataContainer.appendChild(newLIcon);
- var newMoreDataIcon = document.createElement("IMG");
- newMoreDataIcon.className = CLS_TREE_TEXTICON_ALIGNFIX;
- newMoreDataIcon.src = TREE_MORE_DATA;
- newNobrMoreDataContainer.appendChild(newMoreDataIcon);
- var newLabelContainer = document.createElement("SPAN");
- newLabelContainer.className = CLS_TREE_NODE_UNSELECTED + K_PRMT_sSP + CLS_TREE_TEXT_LINK;
- //We need the localized string for "More" here
- if (typeof PMT_TRE_MORE != K_PRMT_sUNDEFINED)
- {
- var newMoreDataText = document.createTextNode(PMT_TRE_MORE);
- newLabelContainer.appendChild(newMoreDataText);
- newLabelContainer.title = PMT_TRE_MORE;
- }
- newLabelContainer.id = this.getName() + node.getTreeRef() + "moredatalabel";
- newLabelContainer.setAttribute(gsCTREE_tree, this.getName());
- newLabelContainer.setAttribute(gsCTREE_treeRef, node.getTreeRef());
- newLabelContainer.tabIndex = this.m_itemTabIndex;
- if (window.ie11) {
- newLabelContainer.addEventListener(gsCTREE_click, getMoreDataForTreeNode);
- newLabelContainer.addEventListener(gsCTREE_keypress, getMoreDataForTreeNode);
- } else if (window.ie) {
- newLabelContainer.attachEvent(gsCTREE_onclick, getMoreDataForTreeNode);
- newLabelContainer.attachEvent(gsCTREE_onkeypress, getMoreDataForTreeNode);
- }
- else
- {
- newLabelContainer.addEventListener(gsCTREE_click, getMoreDataForTreeNode, true);
- newLabelContainer.addEventListener(gsCTREE_keypress, getMoreDataForTreeNode, true);
- }
- newNobrMoreDataContainer.appendChild(newLabelContainer);
- newDivContainer.appendChild(newNobrMoreDataContainer);
- theElement.appendChild(newDivContainer);
- }
- };
- CTree.prototype.removeMoreData = function(node)
- {
- var moreDataDiv = document.getElementById(this.getName() + node.getTreeRef() + "moredata");
- if (!moreDataDiv && node.getNodeType() == TREE_ROOT && this.getRootNodeShowing() == false)
- {
- moreDataDiv = this.m_oPane;
- }
- if (moreDataDiv)
- {
- moreDataDiv.parentNode.removeChild(moreDataDiv);
- }
- };
- CTree.prototype.drawTreeLines = function(node, newElement, drawToLevel)
- {
- // put in appropriate spacers
- if (drawToLevel > 1)
- {
- for (var n = 1; n < drawToLevel; n++)
- {
- var spacerIcon = this.m_oTREELINE.cloneNode(true);
- var oParent = node.getParentAtLevel(n);
- if (oParent.isLast() == true && oParent.getParent().getMoreData() != true)
- {
- //if the parent was last
- spacerIcon.src = TREE_SPACE;
- spacerIcon.alt="";
- }
- newElement.appendChild(spacerIcon);
- }
- }
- };
- CTree.prototype.drawOuterTable = function()
- {
- if (this.m_oOuterPane != null)
- {
- var sId = this.m_sRef;
- var sStyle = this.getStyle();
- var HTMLOut = "<fieldset class='clsFieldSet' style='" + cssParser(sStyle, gsCSS_DEFAULT_STYLE + ',height') +"'><table cellpading='0' cellspacing='0' border='0' onclick='treeContainerClicked(event)' class='clsPromptComponent' style='"+cssParser(sStyle,"visibility,height")+"'>" +
- "<tr>";
- if (this.getHideAdornments() != true)
- {
- HTMLOut += "<td valign='top' width='10px'>" +
- "<table cellpadding='0' cellspacing='0' border='0' width='10' height='20'>";
- if (this.getRequired() == true)
- {
- HTMLOut += "<tr>" +
- "<td valign='top'><img src='" + this.m_sSkin + "/prompting/images/icon_required.gif' class='clsErrorRequired' align='top' height='10' width='10' border='0'/></td>" +
- "</tr>";
- }
- HTMLOut += "<tr>" +
- "<td valign='middle'><img id='imgTest_tree" + sId + "' name='imgTest_tree" + sId + "' class='clsErrorRequired' src='" + this.m_sSkin + "/prompting/images/error_timed_small_off.gif' align='bottom' height='10' width='10' border='0'/></td>" +
- "</tr>" +
- "</table>" +
- "</td>";
- }
- HTMLOut += "<td>" +
- "<table cellpadding='0' cellspacing='0' border='0' width='100%'>" +
- "<tr>" +
- "<td><div id='treePane" + sId + "' class='clsTreePane pa'";
- if (this.getContainerWidth() != null || this.getContainerHeight() != null)
- {
- HTMLOut += " style='";
- if (this.getContainerWidth() != null) {
- HTMLOut += "width:" + this.getContainerWidth() + ";";
- }
- if (this.getContainerHeight() != null) {
- HTMLOut += "height:" + this.getContainerHeight() + ";";
- }
- HTMLOut += "'";
- }
- HTMLOut += "></div></td>" +
- "</tr>";
- if (this.getHideAdornments() != true)
- {
- HTMLOut += "<tr>" +
- "<td><div id='feedback_tree" + sId + "' class='clsFeedbackWidget'><IMG name='sizer_tree" + sId + "' src='" + this.m_sSkin + "/prompting/images/spacer.gif' alt='' width='100%' height='3'/></div></td>" +
- "</tr>";
- }
- if (this.getSelectionMode() != SINGLE_TREE_SELECTION)
- {
- HTMLOut += "<tr>" +
- "<td align='right'>";
- if (this.getSelectTreeUI() != CHECKBOX_TREE || this.getSelectionMode() != DISCONTIGUOUS_TREE_SELECTION) {
- HTMLOut += "<A href='javascript:" + sId + ".selectAll()' class='clsLink pl'>" + PMT_UIM_SELECTALL + "</A> ";
- }
- HTMLOut += "<A href='javascript:" + sId + ".deSelectAll()' class='clsLink pl'>" + PMT_UIM_DESELECTALL + "</A>" +
- "</td>" +
- "</tr>";
- }
- HTMLOut += "</table>" +
- "</td>" +
- "</tr>" +
- "</table></fieldset>";
- this.m_oOuterPane.innerHTML = HTMLOut;
- if (this.getErrorFeedbackWidget() == null) {
- this.setErrorFeedbackWidget(document.getElementById("feedback_tree" + sId));
- }
- if (this.getImgCheck() == null)
- {
- this.setImgCheck(document.getElementById("imgTest_tree" + sId));
- if (this.getImgCheck() != null)
- {
- this.setImgErrorFalse(ERROR_TIMED_SMALL_OFF);
- this.setImgErrorTrue(ERROR_TIMED_SMALL);
- }
- }
- }
- };
- CTree.prototype.draw = function(node, oParentElement)
- {
- if (node.getTree().getDisabled() == true)
- {
- return false;
- }
- var treeRef = node.getTreeRef();
- var treeName = this.getName();
- //if the node is the root node, removes the old root node so that the entire tree is redrawn
- //this takes care of the case where a loading tree is replaced with real data
- if (node.getNodeType() == TREE_ROOT)
- {
- var rootNode = document.getElementById(treeName);
- if (rootNode != null) {
- oParentElement.removeChild(rootNode);
- }
- oParentElement.setAttribute(gsCTREE_treeRef, treeRef);
- oParentElement.setAttribute(gsCTREE_tree, treeName);
- }
- var newElement = this.m_oDIVnewElement.cloneNode(true);
-
-
- if (this.getAllowDragDrop() == true && (this.getSelectTreeUI() == NORMAL_TREE || this.getSelectionMode() == SINGLE_TREE_SELECTION))
- {
- if (window.ie11)
- {
- newElement.addEventListener(gsCTREE_dragstart, dragStartOnNode);
- newElement.addEventListener(gsCTREE_drag, dragOnNode);
- newElement.addEventListener(gsCTREE_dragend, dragEndOnNode);
- }
- else if (window.ie)
- {
- newElement.attachEvent(gsCTREE_ondragstart, dragStartOnNode);
- newElement.attachEvent(gsCTREE_ondrag, dragOnNode);
- newElement.attachEvent(gsCTREE_ondragend, dragEndOnNode);
- }
- else
- {
- newElement.setAttribute("draggable", "true");
- newElement.addEventListener(gsCTREE_dragstart, dragStartOnNode);
- newElement.addEventListener(gsCTREE_drag, dragOnNode);
- newElement.addEventListener(gsCTREE_dragend, dragEndOnNode);
- }
- // Chrome browser require it for firing dragstart event properly.
- if (window.chrome) {
- newElement.addEventListener("mousemove", function(e) {cancelBub(e);});
- }
- }
- newElement.setAttribute(gsCTREE_treeRef, treeRef);
- newElement.setAttribute(gsCTREE_tree, treeName);
- newElement.id = treeName + treeRef;
-
- if (!(node.getNodeType() == TREE_ROOT && this.getRootNodeShowing() == false))
- {
- newElement.className = CLS_TREE_LEVEL;
- var newNobr = this.m_oNOBR.cloneNode(true);
- newNobr.setAttribute(gsCTREE_tree, treeName);
- newElement.appendChild(newNobr);
- this.drawTreeLines(node, newNobr, node.getLevel());
- var newElementIcon = this.m_oIcon.cloneNode(true);
- newElementIcon.id = treeName + treeRef + gsCTREE_icon;
- newElementIcon.setAttribute(gsCTREE_dragRef, treeRef.toString());
- newElementIcon.setAttribute(gsCTREE_dragTree, treeName);
- // put in the indicator if there is one
- var newElementIndicator = null;
- if (node.getIndicator() != null)
- {
- // create indicator span
- newElementIndicator = this.m_oIndicatorSPAN.cloneNode(true);
- newElementIndicator.id = treeName + treeRef + gsCTREE_indicatorSpan;
- newElementIndicator.setAttribute(gsCTREE_treeRef, treeRef);
- newElementIndicator.setAttribute(gsCTREE_dragRef, treeRef.toString());
- newElementIndicator.setAttribute(gsCTREE_dragTree, treeName);
- newElementIndicator.setAttribute(gsCTREE_tree, treeName);
- // create the indicator image
- var newElementIndicatorImage = this.m_oIndicatorIMG.cloneNode(true);
- newElementIndicatorImage.id = treeName + treeRef + gsCTREE_indicator;
- newElementIndicatorImage.setAttribute(gsCTREE_treeRef, treeRef);
- newElementIndicatorImage.setAttribute(gsCTREE_dragRef, treeRef.toString());
- newElementIndicatorImage.setAttribute(gsCTREE_dragTree, treeName);
- newElementIndicatorImage.setAttribute(gsCTREE_tree, treeName);
- // set the image
- newElementIndicatorImage.src = node.getIndicator();
- // add this into the span
- newElementIndicator.appendChild(newElementIndicatorImage);
- }
- //get the current state
- var newElementText = this.m_oTextSPAN.cloneNode(true);
- newElementText.id = treeName + treeRef + gsCTREE_label;
- newElementText.setAttribute(gsCTREE_treeRef, treeRef);
- newElementText.setAttribute(gsCTREE_dragRef, treeRef.toString());
- newElementText.setAttribute(gsCTREE_dragTree, treeName);
- newElementText.setAttribute(gsCTREE_tree, treeName);
- if (node.getTooltip() != false) {
- newElementText.title = this.bidiSafeText(node.getTooltip());
- }
- else {
- newElementText.title = this.bidiSafeText(node.getName());
- }
- newElementIcon.src = getIconSrc(node);
- var altText = node.getNodeTypeObject().m_sIconAltText;
- if (altText != null){
- newElementIcon.alt = altText;
- }
- newElementIcon.className = CLS_TREE_TEXTICON_ALIGNFIX;
- newElement.setAttribute(gsCTREE_dragRef, treeRef.toString());
- newElement.setAttribute(gsCTREE_dragTree, treeName);
- if (node.getNodeType() == TREE_ROOT) {
- newElementText.onclick = function() {return false;};
- node.m_sTreeItemId = newElementText.id;
- }
- else
- {
- var newToggleIcon = this.m_oToggleIMG.cloneNode(true);
- //pick what to draw
- if (node.isLast() == true && node.getParent().getMoreData() != true)
- {
- if (node.canHaveChildren() == true)
- {
- if (node.isOpen() == true)
- {
- newToggleIcon.src = TREE_L_MINUS;
- newToggleIcon.title = PMT_TRE_COLLAPSE;
- newToggleIcon.alt = PMT_TRE_COLLAPSE;
- }
- else
- {
- newToggleIcon.src = TREE_L_PLUS;
- newToggleIcon.title = PMT_TRE_EXPAND;
- newToggleIcon.alt = PMT_TRE_EXPAND;
- }
- newToggleIcon.tabIndex = this.m_itemTabIndex;
- newToggleIcon.onclick = toggle;
- newToggleIcon.className = CLS_TRE_EXPAND_COLLAPSE_HOVER;
- if (window.ie11) {
- newToggleIcon.addEventListener(gsCTREE_keypress, toggle);
- } else if (window.ie) {
- newToggleIcon.attachEvent(gsCTREE_onkeypress, toggle);
- }
- else
- {
- newToggleIcon.addEventListener(gsCTREE_keypress, toggle, true);
- }
- }
- else
- {
- newToggleIcon.src = TREE_L_ONLY;
- newToggleIcon.alt="";
- }
- }
- else
- {
- if (node.canHaveChildren() == true)
- {
- if (node.isOpen() == true)
- {
- newToggleIcon.src = TREE_T_MINUS;
- newToggleIcon.title = PMT_TRE_COLLAPSE;
- newToggleIcon.alt = PMT_TRE_COLLAPSE;
- }
- else
- {
- newToggleIcon.src = TREE_T_PLUS;
- newToggleIcon.title = PMT_TRE_EXPAND;
- newToggleIcon.alt = PMT_TRE_EXPAND;
- }
- newToggleIcon.tabIndex = this.m_itemTabIndex;
- newToggleIcon.onclick = toggle;
- newToggleIcon.className = CLS_TRE_EXPAND_COLLAPSE_HOVER;
- if (window.ie11) {
- newToggleIcon.addEventListener(gsCTREE_keypress, toggle);
- } else if (window.ie) {
- newToggleIcon.attachEvent(gsCTREE_onkeypress, toggle);
- }
- else
- {
- newToggleIcon.addEventListener(gsCTREE_keypress, toggle, true);
- }
- }
- else
- {
- newToggleIcon.src = TREE_T_ONLY;
- newToggleIcon.alt = "";
- }
- }
- newToggleIcon.setAttribute(gsCTREE_treeRef, gsCTREE_img);
- newToggleIcon.id = treeName + treeRef + gsCTREE_toggle + node.getTreeHierarchy();
- node.m_sToggleIconId = newToggleIcon.id;
- newNobr.appendChild(newToggleIcon);
- if ((node.getTree().getForceSelectionAtLowestLevel() == true && node.getNodeType() == TREE_ITEM) || (node.getTree().getForceSelectionAtLowestLevel() == false))
- {
- newElementText.tabIndex = this.m_itemTabIndex;
- PRMTTreeUtils.f_addEvent(newElementText, gsCTREE_click, selectNode, true);
- if (node.getTree().getSingleClickFunc() != null)
- {
- if (window.ie11) {
- newElementText.addEventListener(gsCTREE_click, singleClickCaller, true);
- newElementText.addEventListener(gsCTREE_keypress, singleClickCaller, true);
- } else if (window.ie) {
- newElementText.attachEvent(gsCTREE_onclick, singleClickCaller);
- newElementText.attachEvent(gsCTREE_onkeypress, singleClickCaller);
- }
- else
- {
- newElementText.addEventListener(gsCTREE_click, singleClickCaller, true);
- newElementText.addEventListener(gsCTREE_keypress, singleClickCaller, true);
- }
- }
- if (node.getTree().getDoubleClickFunc() != null)
- {
- if (window.ie11) {
- newElementText.addEventListener(gsCTREE_dblclick, doubleClickCaller);
- } else if (window.ie) {
- newElementText.attachEvent(gsCTREE_ondblclick, doubleClickCaller);
- }
- else
- {
- newElementText.addEventListener(gsCTREE_dblclick, doubleClickCaller, true);
- // A11Y check for Event Studio keyboard support
- if (typeof AccessibilityHandler != "undefined") {
- newElementText.addEventListener(gsCTREE_keypress, doubleClickCaller, true);
- }
- }
- }
- newElementText.onmouseover = treeNodeMouseOver;
- newElementText.onmouseout = treeNodeMouseOut;
- if (window.ie11) {
- newElementText.addEventListener(gsCTREE_contextmenu, contextMenuCaller);
- newElementText.addEventListener(gsCTREE_keypress, selectNode);
- } else if (window.ie)
- {
- newElementText.attachEvent(gsCTREE_oncontextmenu, contextMenuCaller);
- newElementText.attachEvent(gsCTREE_onkeypress, selectNode);
- }
- else
- {
- newElementText.addEventListener(gsCTREE_contextmenu, contextMenuCaller, true);
- newElementText.addEventListener(gsCTREE_keypress, selectNode, true);
- }
- }
- //add a checkbox for multiselect trees
- if (this.getSelectionMode() != SINGLE_TREE_SELECTION && this.getSelectTreeUI() == CHECKBOX_TREE)
- {
- var newCheckBoxIcon = this.m_oCheckIMG.cloneNode(true);
- newCheckBoxIcon.src = getCheckBoxSrc(node);
- newCheckBoxIcon.setAttribute(gsCTREE_treeRef, gsCTREE_checkbox);
- newCheckBoxIcon.id = treeName + treeRef + gsCTREE_checkbox;
- //set up events
- if ((node.getTree().getForceSelectionAtLowestLevel() == true && node.getNodeType() == TREE_ITEM) || (node.getTree().getForceSelectionAtLowestLevel() == false))
- {
- if (window.ie11) {
- newCheckBoxIcon.tabIndex = this.m_itemTabIndex;
- newCheckBoxIcon.onclick = selectNode;
- newCheckBoxIcon.addEventListener(gsCTREE_contextmenu, contextMenuCaller);
- newCheckBoxIcon.addEventListener(gsCTREE_keypress, selectNode);
- } else if (window.ie) {
- newCheckBoxIcon.tabIndex = this.m_itemTabIndex;
- newCheckBoxIcon.onclick = selectNode;
- newCheckBoxIcon.attachEvent(gsCTREE_oncontextmenu, contextMenuCaller);
- newCheckBoxIcon.attachEvent(gsCTREE_onkeypress, selectNode);
- }
- else
- {
- newCheckBoxIcon.addEventListener(gsCTREE_click, selectNode, true);
- newCheckBoxIcon.addEventListener(gsCTREE_contextmenu, contextMenuCaller, true);
- newCheckBoxIcon.addEventListener(gsCTREE_keypress, selectNode, true);
- }
- }
- newNobr.appendChild(newCheckBoxIcon);
- }
- }
- newElementText.setAttribute("role","treeitem");
- if (this.contentLocale != null){
- newElementText.setAttribute("lang",this.contentLocale);
- }
- //icon
- newElementText.appendChild(newElementIcon);
- // add the indicator if there is one
- if (newElementIndicator != null)
- {
- newElementText.appendChild(newElementIndicator);
- }
- //text
- var newElementLabelContainer = this.m_oLabelSPAN.cloneNode(true);
- newElementLabelContainer.id = treeName + treeRef + gsCTREE_labelText;
- newElementLabelContainer.className = getClassName(node, this);
- newElementLabelContainer.setAttribute(gsCTREE_treeRef, treeRef);
- newElementLabelContainer.setAttribute(gsCTREE_dragRef, treeRef.toString());
- newElementLabelContainer.setAttribute(gsCTREE_dragTree, treeName);
- newElementLabelContainer.setAttribute(gsCTREE_tree, treeName);
- node.m_oLabelText = newElementLabelContainer;
- node.m_sTreeItemId = newElementLabelContainer.id;
-
- // A11Y check for Event Studio keyboard support
- if (typeof AccessibilityHandler != "undefined" && AccessibilityHandler.isEnabled()) {
- if(node.getNodeType() == TREE_ROOT || node.getParent().getLableText() == null && node.getIndex() == 0) {
- newElementLabelContainer.setAttribute("tabindex", "0");
- }
- else {
- newElementLabelContainer.setAttribute("tabindex", "-1");
- }
- newElementLabelContainer.setAttribute("role", "treeitem");
- newElementText.removeAttribute("role");
- }
- var newElementLabelLink = this.m_oLabelA.cloneNode(true);
- var newElementLabel = document.createTextNode(this.bidiSafeText(node.getName()));
- newElementLabelLink.appendChild(newElementLabel);
- newElementLabelLink.setAttribute("id", node.getTreeHierarchy());
- var sStyle = this.getStyle();
- newElementLabelLink.style.color= cssParser(sStyle,"color",true);
- newElementLabelLink.style.backgroundColor= cssParser(sStyle,"background-color",true);
- newElementLabelLink.style.fontFamily= cssParser(sStyle,"font-family",true);
- newElementLabelLink.style.fontSize= cssParser(sStyle,"font-size",true);
- newElementLabelLink.style.fontWeight= cssParser(sStyle,"font-weight",true);
- newElementLabelLink.style.fontStyle= cssParser(sStyle,"font-style",true);
- newElementLabelLink.style.fontVariant= cssParser(sStyle,"font-variant",true);
- newElementLabelLink.style.textAlign= cssParser(sStyle,"text-align",true);
- newElementLabelLink.style.textVariant= cssParser(sStyle,"text-variant",true);
- newElementLabelLink.style.textIndent= cssParser(sStyle,"text-indent",true);
- newElementLabelLink.style.textTransform= cssParser(sStyle,"text-transform",true);
- newElementLabelLink.setAttribute(gsCTREE_treeRef, treeRef);
- newElementLabelLink.setAttribute(gsCTREE_dragRef, treeRef.toString());
- newElementLabelLink.setAttribute(gsCTREE_dragTree, treeName);
- newElementLabelLink.setAttribute(gsCTREE_tree, treeName);
- newElementLabelContainer.appendChild(newElementLabelLink);
- newElementText.appendChild(newElementLabelContainer);
- newNobr.appendChild(newElementText);
- if (node.isOpen())
- {
- node.setRendered(true);
- }
- }
- oParentElement.appendChild(newElement);
-
- // A11Y check for Event Studio keyboard support
- if (typeof AccessibilityHandler != "undefined" && AccessibilityHandler.isEnabled()) {
- node.attachEvents();
- }
- if (node.hasChildren() == true)
- {
- if (node.isOpen() == true)
- {
- //get any children
- var children = node.getChildren();
- var parent = node.getParent();
- // make sure setSelected is run only once, since it traverses through all the child nodes.
- if (node.isSelected() == true && parent != null && parent.isSelected() == false)
- {
- node.setSelected(true);
- }
- //move recursively and render all children
- for (var iChildCounter = 0; iChildCounter < children.length; iChildCounter++)
- {
- this.draw(children[iChildCounter], newElement);
- }
- }
- else
- {
- var unopenedSelectedChildren = this.hasUnopenedSelectedChild(node);
- if ((node.isSelected() == false) && unopenedSelectedChildren == true)
- {
- node.setHasSelectedChildren(true);
- node.updateNodeSelection();
- }
- if (node.hasSelectedChildren() == true || unopenedSelectedChildren == true)
- {
- if (this.getSelectionMode() == CONTIGUOUS_TREE_SELECTION) {
- node.updateParent();
- }
- else {
- node.partialSelectParent();
- }
- }
- }
- }
- else
- {
- if ((node.getNodeType() == TREE_ROOT) && ((node.getTree().getPromptingTree() != false) || (node.getTree().getLoadOnTheFly() != false)))
- {
- node.setRendered(false);
- node.fetchChildren();
- }
- else if ((node.isSelected() == true))
- {
- if (this.getSelectionMode() == CONTIGUOUS_TREE_SELECTION) {
- node.updateParent();
- }
- else {
- node.partialSelectParent();
- }
- }
- }
- this.m_bHasBeenDrawn = true;
- };
- //update selections
- //loop through the tree recursively to paint selections
- CTree.prototype.updateSelections = function (node, otherSelections)
- {
- if (typeof otherSelections == K_PRMT_sUNDEFINED) {
- otherSelections = false;
- }
- if (node.isSelected())
- {
- if ((this.getForceSelectionAtLowestLevel() == true && otherSelections == false) || this.getSelectionMode() != SINGLE_TREE_SELECTION || (this.getSelectionMode() == SINGLE_TREE_SELECTION && otherSelections == false))
- {
- //select all the children
- node.setSelected(true);
- //update the parent
- node.updateParent();
- return true;
- }
- else
- {
- //unselect all the children
- node.setSelected(false);
- //update the parent
- node.updateParent();
- return false;
- }
- }
- else
- {
- //get any children
- var children = node.getChildren();
- //move recursively and check all children
- for (var iChildCounter = children.length - 1; iChildCounter >= 0; iChildCounter--)
- {
- if (this.updateSelections(children[iChildCounter], otherSelections)) {
- otherSelections = true;
- }
- }
- return otherSelections;
- }
- };
- CTree.prototype.hasUnopenedSelectedChild = function (node)
- {
- //get any children
- var children = node.getChildren();
- //move recursively and check if any children are selected
- for (var iChildCounter = children.length - 1; iChildCounter >= 0; iChildCounter--)
- {
- if (children[iChildCounter].isSelected() || this.hasUnopenedSelectedChild(children[iChildCounter])) {
- return true;
- }
- }
- return false;
- };
- CTree.prototype.childrenReadyForNode = function (node)
- {
- var theNode = this.findTreeNode(this.getRootNode(), node);
- theNode.setLoading(false);
- this.setLoading(false);
- if (theNode.getShowUI()) {
- this.removeLoading(theNode);
- }
- var theNodeRef = this.getName() + theNode.getTreeRef();
- if (theNode.getChildren().length > 0)
- {
- theNode.setCanHaveChildren(true);
- if (theNode.isOpen() && theNode.getRendered() == false && theNode.getShowUI())
- {
- // get the parent element
- var oParentElement = document.getElementById(theNodeRef);
- gDrawChildren(theNode, oParentElement,
- function() {
- theNode.setRendered(true);
- if (theNode.getShowUI())
- {
- var oTree = theNode.getTree();
- oTree.redrawNodeToggle(theNode, theNodeRef);
- oTree.updateSelections(theNode, false);
- oTree.redraw();
- oTree.checkData();
- if (theNode.getMoreData() == true)
- {
- oTree.drawMoreData(theNode, theNodeRef);
- }
- }
- theNode.setShowUI(true);
- }
- );
- return;
- }
- }
- else
- {
- theNode.setCanHaveChildren(false);
- }
- if (theNode.getShowUI())
- {
- this.redrawNodeToggle(theNode, theNodeRef);
- theNode.getTree().updateSelections(theNode, false);
- theNode.getTree().redraw();
- theNode.getTree().checkData();
- if (theNode.getMoreData() == true)
- {
- this.drawMoreData(theNode, theNodeRef);
- }
- }
- theNode.setShowUI(true);
- };
- CTree.prototype.findTreeNode = function (rootNode, node)
- {
- if (rootNode.m_sId != node.m_sId)
- {
- if (rootNode.hasChildren())
- {
- var theChildren = rootNode.getChildren();
- for (var i = 0; i < theChildren.length; i++)
- {
- var thisChild = this.findTreeNode(theChildren[i], node);
- if (thisChild != null)
- {
- return thisChild;
- }
- }
- }
- return null;
- }
- return rootNode;
- };
- CTree.prototype.setRootNodeType = function(oTreeNodeType)
- {
- // we should make sure that the type is a rootNodeType
- if (oTreeNodeType != null && oTreeNodeType instanceof CTreeNodeType && oTreeNodeType.m_iType == TREE_ROOT) {
- this.m_oRoot.setNodeTypeObject(oTreeNodeType);
- }
- };
- CTree.prototype.setWrapper = function( v_oWrapper )
- {
- this.m_oWrapper = v_oWrapper;
- };
- CTree.prototype.bidiSafeText = function( v_text )
- {
- return (typeof this.m_oBidi != "undefined" && typeof this.m_oBidi["btdInjectUCCIntoStr"] != "undefined" ? this.m_oBidi.btdInjectUCCIntoStr( v_text ) : v_text);
- };
- CTree.prototype.getTracking = function()
- {
- return this.m_oTreeControl.getTracking();
-
- };
- CTree.prototype.getConversation = function(){
-
- var sConversation = K_PRMT_sEMPTY;
- var oCV = this.getCV();
- if (oCV && typeof oCV.getConversation == K_PRMT_sFUNCTION)
- {
- sConversation = oCV.getConversation();
- }
- else
- {
- // can't find ui.conversation in CCognosViewer, trying with a form
- var oForm = document.getElementById("formWarpRequest" + this.getCVId());
- if (!oForm) {
- document.getElementById("formWarpRequest");
- }
- if (oForm) {
- if (typeof oForm.elements["ui.conversation"] != K_PRMT_sUNDEFINED) {
- sConversation = oForm.elements["ui.conversation"].value;
- }
- }
- }
-
- return sConversation;
- };
- CTree.prototype.getUniqueKey = function (key)
- {
- var promptKey = "";
- var rootChildren = "root_children";
- var sTrackingInfo = this.getTracking();
- if (key.toUpperCase() == rootChildren.toUpperCase())
- {
- if (this.bAllowStateCache)
- {
- // try to get cached prompt names
- var sPromptNames = this.m_oTreeControl.getCachedPromptNames(sTrackingInfo);
- var v_aPromptIds = [];
- var v_oPromptControlLookup = {};
- var sMyself = this.m_oTreeControl.getName();
-
- if ((sPromptNames != null) && (sPromptNames.length != 0))
- {
- var aPromptNames = sPromptNames.split(":");
- // get display values of prompts
- for (var i = 0; i < aPromptNames.length; i++)
- {
- // ignore myself
- if (aPromptNames[i] != sMyself)
- {
- v_aPromptIds.push(aPromptNames[i]);
- var sPromptDisplayValues = this.m_oTreeControl.getCachedDisplayValues(sTrackingInfo,aPromptNames[i]);
- v_oPromptControlLookup[aPromptNames[i]] = sPromptDisplayValues;
- }
- }
- // sort the ids
- v_aPromptIds.sort();
- for (var i = 0; i < v_aPromptIds.length; i++)
- {
- promptKey += v_aPromptIds[i];
- promptKey += "_";
- promptKey += v_oPromptControlLookup[v_aPromptIds[i]];
- }
- }
- }
- }
-
- return "PRMT_TREE_" + sTrackingInfo + promptKey + this.cacheKeyPrefix + key;
- }
- CTree.prototype.setCacheValue = function( key, value, bNoRetryWhenFull){
- var uniqueKey = this.getUniqueKey(key);
- var valueToSet = value;
- var cachedValue = window.sessionStorage.getItem(uniqueKey);
- if (this.bAllowStateCache && window.sessionStorage){
- try {
- if(cachedValue != null && cachedValue != valueToSet) // merge any new child values to the existing set of child values
- {
- valueToSet = PRMTTreeUtils.mergeChildrenInfo(cachedValue, valueToSet);
- }
- window.sessionStorage.setItem(uniqueKey, valueToSet);
- } catch(e) {
- // This could happen if we exceed the maximum of allowed storage size.
- if (!bNoRetryWhenFull){
- // Try to recover by clear the cache and try to set the value again
- this.cleanCacheValues();
- this.setCacheValue(key, valueToSet, true);
- }
- }
- }
-
- };
- CTree.prototype.cleanCacheValues = function(removeAll){
- if (this.bAllowStateCache && window.sessionStorage){
- var currentKeyPrefix = "PRMT_TREE_" + this.getTracking();
- for (var key in window.sessionStorage){
- if (removeAll){
- // In this case we want to dump the cache state because the Reprompt button has been selected
- if (key.indexOf("PRMT_TREE_") == 0){
- window.sessionStorage.removeItem(key);
- }
- } else {
- // We only remove the entries with a different tracking number so that we don't affect the current tree state
- if (key.indexOf("PRMT_TREE_") == 0 && key.indexOf(currentKeyPrefix) == -1 ){
- window.sessionStorage.removeItem(key);
- }
- }
- }
- }
- };
- CTree.prototype.getCacheValue = function( key ){
- var value = null;
- if (this.bAllowStateCache && window.sessionStorage){
- var uniqueKey = this.getUniqueKey(key);
- value = window.sessionStorage.getItem(uniqueKey);
- }
-
- return value;
-
- };
- CTree.prototype.removeCacheValue = function( key ){
- var value = null;
- if (this.bAllowStateCache && window.sessionStorage){
-
- var uniqueKey = this.getUniqueKey(key);
- value = window.sessionStorage.removeItem(uniqueKey);
- }
-
- return value;
-
- };
- /////////////
- //tree event handlers
- function toggle(evt, uiNode)
- {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- //cancel any text selection
- clearSelection();
- //prevent the event from bubbling to other elements
- cancelBub(evt);
- //get UI Node
- if (!uiNode)
- {
- uiNode = getUINode(evt);
- }
- else
- {
- uiNode = getUINode(null, uiNode);
- }
- var uiNodeTreeRef = uiNode.getAttribute(gsCTREE_treeRef).toString();
- //get the tree object
- var tree = uiNode.getAttribute(gsCTREE_tree).toString();
- //get tree Node
- var node = getTreeNode(tree, uiNodeTreeRef);
- //toggle folders
- var k = 0, j = 0, children = null;
- if ((node.getTree().getPromptingTree() != false) || (typeof node.getTree().getLoadOnTheFly() == K_PRMT_sFUNCTION))
- {
- if (((node.getTree().getPromptingTree() != false) && (typeof activeFetchingTreeNode == K_PRMT_sUNDEFINED || activeFetchingTreeNode == null)) || (typeof node.getTree().getLoadOnTheFly() == K_PRMT_sFUNCTION))
- {
- if (node.isOpen() == false)
- {
- //shows either the children or the loading message
- for (k = 0; k < uiNode.childNodes.length; k ++)
- {
- if ((uiNode.childNodes[k].nodeType == 1) && (uiNode.childNodes[k].tagName != 'IMG') && (uiNode.childNodes[k].tagName != 'SPAN') && (uiNode.childNodes[k].tagName != 'NOBR'))
- {
- uiNode.childNodes[k].style.display = "block";
- }
- }
- if (node.hasChildren())
- {
- //draw the nodes if they haven't been rendered
- if (node.getRendered() == false)
- {
- gDrawChildren(node, uiNode,
- function() {
- node.setRendered(true);
- node.setOpen(true);
- updateToggleIcon(node, tree);
- }
- );
- return;
- }
- }
- else
- {
- if (node.fetchChildren() == false) {
- return false;
- }
- }
- node.setOpen(true);
- }
- else
- {
- //hides either the children or the loading message
- for (k = 0; k < uiNode.childNodes.length; k ++)
- {
- if ((uiNode.childNodes[k].nodeType == 1) && (uiNode.childNodes[k].tagName != 'IMG') && (uiNode.childNodes[k].tagName != 'SPAN') && (uiNode.childNodes[k].tagName != 'NOBR'))
- {
- uiNode.childNodes[k].style.display = "none";
- }
- }
- node.setOpen(false);
- }
- }
- else {
- return false;
- }
- }
- else
- {
- if (node.isOpen() == false)
- {
- for (k = 0; k < uiNode.childNodes.length; k ++)
- {
- if ((uiNode.childNodes[k].nodeType == 1) && (uiNode.childNodes[k].tagName != 'IMG') && (uiNode.childNodes[k].tagName != 'SPAN') && (uiNode.childNodes[k].tagName != 'NOBR'))
- {
- uiNode.childNodes[k].style.display = "block";
- }
- }
- node.setOpen(true);
- //draw the nodes if they haven't been rendered
- if (node.getRendered() == false)
- {
- children = node.getChildren();
- for (j = 0; j < children.length; j ++)
- {
- node.getTree().draw (children[j], uiNode);
- }
- node.setRendered(true);
- }
- }
- else
- {
- for (k = 0; k < uiNode.childNodes.length; k ++)
- {
- if ((uiNode.childNodes[k].nodeType == 1) && (uiNode.childNodes[k].tagName != 'IMG') && (uiNode.childNodes[k].tagName != 'SPAN') && (uiNode.childNodes[k].tagName != 'NOBR'))
- {
- uiNode.childNodes[k].style.display = "none";
- }
- }
- node.setOpen(false);
- }
- }
- updateToggleIcon(node, tree);
- }
- function gDrawChildren(oNode, oParentUI, oFctWhenComplete, iStart)
- {
- var aChildren = oNode.getChildren();
- var oTree = oNode.getTree();
- if (!iStart) {
- iStart = 0;
- }
- var iMax = Math.min((iStart + giDRAW_BLOCKSIZE), aChildren.length);
- var idxChild = iStart;
- for (idxChild = iStart; idxChild < iMax; idxChild++)
- {
- oTree.draw(aChildren[idxChild], oParentUI);
- }
- if (idxChild < aChildren.length)
- {
- setTimeout(
- function () {
- gDrawChildren(oNode, oParentUI, oFctWhenComplete, idxChild);
- }
- ,
- giDRAW_INTERVAL );
- }
- else if (typeof oFctWhenComplete == K_PRMT_sFUNCTION)
- {
- oFctWhenComplete();
- }
- }
- function updateToggleIcon(oNode, sTreeName)
- {
- //update the icons
- var icon = document.getElementById(sTreeName + oNode.getTreeRef() + gsCTREE_icon);
- if (icon)
- {
- icon.src = getIconSrc(oNode);
- var toggleIcon = document.getElementById(sTreeName + oNode.getTreeRef() + gsCTREE_toggle + oNode.getTreeHierarchy());
- toggleIcon.src = getToggleSrc(oNode);
- toggleIcon.title = getToggleTitle(oNode);
- }
- }
- function treeContainerClicked(evt)
- {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- //cancel any text selection
- clearSelection();
- //prevent the event from bubbling to other elements
- cancelBub(evt);
- try
- {
- //get UI Node
- var uiNode = getUINode(evt);
- //get the tree object
- var tree = eval(uiNode.getAttribute(gsCTREE_tree).toString());
- if (tree.getSelectTreeUI() != CHECKBOX_TREE) {
- tree.getRootNode().setSelected(false);
- }
- tree.setLastSelectedNode(null);
- tree.redraw();
- tree.checkData();
- }
- catch (e)
- {
- }
- }
- function contextMenuCaller(evt)
- {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- //cancel any text selection
- clearSelection();
- //prevent the event from bubbling to other elements
- cancelBub(evt);
- //get UI Node
- var uiNode = getUINode(evt);
- var uiNodeTreeRef = uiNode.getAttribute(gsCTREE_treeRef).toString();
- //get the tree object
- var tree = uiNode.getAttribute(gsCTREE_tree).toString();
- //get tree Node
- var node = getTreeNode(tree, uiNodeTreeRef);
- if (node.getTree().getContextMenu() != null)
- {
- var contextMenuFunc = node.getTree().getContextMenu();
- contextMenuFunc(evt);
- cancelBub(evt);
-
- if((evt != null) && (typeof evt.preventDefault === "function"))
- {
- evt.preventDefault();
- }
- return false;
- }
- }
- function singleClickCaller(evt)
- {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- if ((evt !== null) && (evt.keyCode != null) && (evt.keyCode != 13) && (evt.keyCode !== 0))
- {
- return false;
- }
- //cancel any text selection
- clearSelection();
- //prevent the event from bubbling to other elements
- cancelBub(evt);
- //get UI Node
- var uiNode = getUINode(evt);
- var uiNodeTreeRef = uiNode.getAttribute(gsCTREE_treeRef).toString();
- //get the tree object
- var tree = uiNode.getAttribute(gsCTREE_tree).toString();
- //get tree Node
- var node = getTreeNode(tree, uiNodeTreeRef);
- var singleClickFunc = node.getTree().getSingleClickFunc();
- if (singleClickFunc != null)
- {
- singleClickFunc(evt);
- cancelBub(evt);
- if (!window.ie)
- {
- evt.preventDefault();
- }
- return false;
- }
- }
- function doubleClickCaller(evt)
- {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- // A11Y check for Event Studio keyboard support
- if (typeof AccessibilityHandler != "undefined" && AccessibilityHandler.isEnabled() && evt.keyCode != 13 && evt.keyCode != null) {
- return false;
- }
-
- // For Event Studio Metadata tree items Enter key press
- if (typeof AccessibilityHandler != "undefined") {
- selectNode(evt);
- }
-
- //cancel any text selection
- clearSelection();
- //prevent the event from bubbling to other elements
- cancelBub(evt);
- //get UI Node
- var uiNode = getUINode(evt);
- var uiNodeTreeRef = uiNode.getAttribute(gsCTREE_treeRef).toString();
- //get the tree object
- var tree = uiNode.getAttribute(gsCTREE_tree).toString();
- //get tree Node
- var node = getTreeNode(tree, uiNodeTreeRef);
- if (node.getTree().getDoubleClickFunc() != null)
- {
- var doubleClickFunc = node.getTree().getDoubleClickFunc();
- doubleClickFunc(evt);
- cancelBub(evt);
- if (!window.ie)
- {
- evt.preventDefault();
- }
- return false;
- }
- }
- function selectNode(evt)
- {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- if ((evt !== null) && (evt.keyCode != null) && (evt.keyCode != 13) && (evt.keyCode !== 0))
- {
- return false;
- }
- //cancel any text selection
- clearSelection();
- //prevent the event from bubbling to other elements
- cancelBub(evt);
- //get UI Node
- var uiNode = getUINode(evt);
- var uiNodeTreeRef = uiNode.getAttribute(gsCTREE_treeRef).toString();
- //get the tree object
- var tree = uiNode.getAttribute(gsCTREE_tree).toString();
- //get tree Node
- var node = getTreeNode(tree, uiNodeTreeRef);
- var oTree = node.getTree();
- //handle multiple select
- if (oTree.getSelectionMode() != SINGLE_TREE_SELECTION)
- {
- if ((evt.ctrlKey == false) && (evt.shiftKey == false) && (oTree.getSelectTreeUI() != CHECKBOX_TREE))
- {
- oTree.clearPreviousSelections();
- }
- var normalTreeNeedsRedraw = ((oTree.getSelectTreeUI() == NORMAL_TREE) && (evt.ctrlKey == false) && (evt.shiftKey == false));
- var unselectNode = ((oTree.getSelectTreeUI() == CHECKBOX_TREE) || ((oTree.getSelectTreeUI() == NORMAL_TREE) && ((oTree.getAllowSelectionToggle() == true) || ((oTree.getAllowSelectionToggle() == false) && (evt.ctrlKey == true)))));
- if (normalTreeNeedsRedraw)
- {
- oTree.getRootNode().setSelected(false);
- if (oTree.getTrackSelectionOrder())
- {
- oTree.clearSelectionOrder();
- }
- }
- //setSelected
- var nodeWasSelected = node.isSelected();
- if ((oTree.getSelectTreeUI() == NORMAL_TREE) && (evt.shiftKey == true))
- {
- var anchorNode = oTree.getAnchorNode();
- if (anchorNode != null && node.getRootNode().hasSelectedChildren())
- {
- if (node.getParent() == anchorNode.getParent())
- {
- var anchorNodeIndex = anchorNode.getIndex();
- var nodeIndex = node.getIndex();
- var iCurrentNode = anchorNodeIndex;
- var iIncrement;
- if (anchorNodeIndex > nodeIndex)
- {
- iIncrement = -1;
- }
- else
- {
- iIncrement = 1;
- }
- //select all of the children between the anchor node and the selected node
- while (iCurrentNode != nodeIndex + iIncrement)
- {
- var siblingNode = node.getParent().m_oChildren[iCurrentNode];
- siblingNode.setSelected(true);
- var oLabel = siblingNode.getLabel(tree);
- oLabel.className = getClassName(siblingNode, oTree);
- redrawChildren(siblingNode, tree);
- iCurrentNode += iIncrement;
- }
- }
- }
- }
- if (nodeWasSelected == true)
- {
- if (unselectNode)
- {
- node.setSelected(false);
- oTree.setLastSelectedNode(null);
- oTree.removeFromPrevSelArray( node.getValue(), node.getName() );
- }
- }
- else
- {
- node.setSelected(true);
- oTree.setLastSelectedNode(node);
- }
- node.updateNodeSelection();
- node.updateParent();
- var label = node.getLabel(tree);
- label.className = getClassName(node, oTree);
- oTree.checkData();
- if (normalTreeNeedsRedraw)
- {
- oTree.redraw();
- oTree.checkData();
- }
- else
- {
- redrawChildren(node, tree);
- redrawParents(node, tree);
- }
- if (unselectNode && nodeWasSelected)
- {
- oTree.setAnchorNode(null);
- }
- else
- {
- oTree.setAnchorNode(node);
- }
- }
- else
- {
- //single select remove all other selections
- oTree.clearPreviousSelections();
- if (node.isSelected() == true && oTree.getAllowSelectionToggle() == true)
- {
- oTree.getRootNode().setSelected(false);
- oTree.setLastSelectedNode(null);
- }
- else
- {
- oTree.getRootNode().setSelected(false);
- node.setSelected(true);
- oTree.setLastSelectedNode(node);
- }
- node.updateParent();
- oTree.redraw();
- oTree.checkData();
- }
- if (!window.ie)
- {
- evt.stopPropagation();
- evt.preventDefault();
- }
- return false;
- }
- function redrawChildren(node,tree)
- {
- //has the child node been rendered?
- //draw the nodes if they haven't been rendered
- if (node.getRendered() == true)
- {
- var children = node.getChildren();
- var oTree = node.getTree();
- var oParentUI = document.getElementById(tree + node.getTreeRef());
- for (var j = 0; j < children.length; j++)
- {
- var oChild = children[j];
- var label = oChild.getLabel(tree);
- if (label == null)
- {
- if (j > 0)
- {
- oTree.redrawNodeToggle(children[j - 1], tree + children[j - 1].getTreeRef());
- }
- oTree.draw(oChild, oParentUI);
- if (node.isOpen() == false)
- {
- document.getElementById(tree + oChild.getTreeRef()).style.display = "none";
- }
- }
- else
- {
- label.className = getClassName(oChild, oTree);
- if (oTree.getSelectionMode() != SINGLE_TREE_SELECTION)
- {
- if (oTree.getSelectTreeUI() == CHECKBOX_TREE)
- {
- var checkbox = oChild.getCheckbox(tree);
- if (checkbox) checkbox.src = getCheckBoxSrc(oChild);
- }
- }
- }
- redrawChildren(oChild,tree);
- }
- }
- }
- function redrawParents(node, tree)
- {
- var parentNode = node.getParent();
- if (parentNode != null)
- {
- var label = parentNode.getLabel(tree);
- if (label != null)
- {
- label.className = getClassName(parentNode, parentNode.getTree());
- if (node.getTree().getSelectionMode() != SINGLE_TREE_SELECTION)
- {
- if (parentNode.getTreeRef() != null && parentNode.getTreeRef().length !== 0)
- {
- if (node.getTree().getSelectTreeUI() == CHECKBOX_TREE)
- {
- var checkbox = parentNode.getCheckbox(tree);
- checkbox.src = getCheckBoxSrc(parentNode);
- }
- redrawParents(parentNode, tree);
- }
- }
- }
- }
- }
- function dragStartOnNode(evt)
- {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- //cancel any text selection
- clearSelection();
- //prevent the event from bubbling to other elements
- cancelBub(evt);
- var dragRef = (evt.srcElement) ? evt.srcElement.getAttribute(gsCTREE_dragRef) : ((evt.originalTarget) ? evt.originalTarget.getAttribute(gsCTREE_dragRef) : null);
- if (dragRef != null && typeof dragRef == K_PRMT_sSTRING && dragRef.length !== 0)
- {
- var uiNode = getUINode(evt);
- if (uiNode)
- {
- //get the tree object
- var tree = uiNode.getAttribute(gsCTREE_dragTree).toString();
- //get tree Node
- var node = getTreeNode(tree, dragRef);
- var treeObj = node.getTree();
- if (!node.isSelected())
- {
- if ((evt.ctrlKey == false) && (evt.shiftKey == false))
- {
- treeObj.getRootNode().setSelected(false);
- treeObj.clearPreviousSelections();
- if (treeObj.getTrackSelectionOrder())
- {
- treeObj.clearSelectionOrder();
- }
- }
- //select all the children
- node.setSelected(true);
- //update the parent
- node.updateParent();
- var label = node.getLabel();
- label.className = getClassName(node, treeObj);
- if ((evt.ctrlKey == false) && (evt.shiftKey == false))
- {
- treeObj.redraw();
- treeObj.checkData();
- }
- }
- var selectedNodes = treeObj.getSelectedFolderNodes();
- selectedNodes = selectedNodes.concat(treeObj.getSelectedLeafNodes());
- var selNodesStr = tree + "~~~~~";
- for (var i = 0; i < selectedNodes.length; i++)
- {
- if (i > 0)
- {
- selNodesStr += "~~~";
- }
- selNodesStr += selectedNodes[i].getTreeRef();
- }
- evt.dataTransfer.setData("Text", selNodesStr);
- if (treeObj.getOnDragStart() != null)
- {
- var dragStartFunction = treeObj.getOnDragStart();
- dragStartFunction(evt);
- }
- }
- }
- }
- function dragOnNode(evt)
- {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- //cancel any text selection
- clearSelection();
- //prevent the event from bubbling to other elements
- cancelBub(evt);
- var dragRef = (evt.srcElement) ? evt.srcElement.getAttribute(gsCTREE_dragRef) : ((evt.originalTarget) ? evt.originalTarget.getAttribute(gsCTREE_dragRef) : null);
- if (dragRef != null && typeof dragRef == K_PRMT_sSTRING && dragRef.length !== 0)
- {
- var uiNode = getUINode(evt);
- if (uiNode)
- {
- //get the tree object
- var tree = uiNode.getAttribute(gsCTREE_dragTree).toString();
- //get tree Node
- var node = getTreeNode(tree, dragRef);
- var treeObj = node.getTree();
- if (treeObj.getOnDrag() != null)
- {
- var dragFunction = treeObj.getOnDrag();
- dragFunction(evt);
- }
- }
- }
- if (!window.ie)
- {
- evt.preventDefault();
- }
- }
- function dragEndOnNode(evt)
- {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- //cancel any text selection
- clearSelection();
- //prevent the event from bubbling to other elements
- cancelBub(evt);
- var dragRef = (evt.srcElement) ? evt.srcElement.getAttribute(gsCTREE_dragRef) : ((evt.originalTarget) ? evt.originalTarget.getAttribute(gsCTREE_dragRef) : null);
- if (dragRef != null && typeof dragRef == K_PRMT_sSTRING && dragRef.length !== 0)
- {
- var uiNode = getUINode(evt);
- if (uiNode)
- {
- //get the tree object
- var tree = uiNode.getAttribute(gsCTREE_dragTree).toString();
- //get tree Node
- var node = getTreeNode(tree, dragRef);
- var treeObj = node.getTree();
- if (treeObj.getOnDragEnd() != null)
- {
- var dragEndFunction = treeObj.getOnDragEnd();
- dragEndFunction(evt);
- }
- }
- }
- if (!window.ie)
- {
- evt.preventDefault();
- }
- }
- /////////////////////
- //utility functions
- //cancel any text selection
- function clearSelection()
- {
- if (typeof document.selection != K_PRMT_sUNDEFINED && typeof document.selection.createRange == K_PRMT_sFUNCTION && document.selection.createRange().text != K_PRMT_sEMPTY)
- {
- //IE specific
- document.selection.empty();
- }
- else if (typeof window.getSelection == K_PRMT_sFUNCTION && typeof window.getSelection() == K_PRMT_sOBJECT)
- {
- //NS6 specific
- window.getSelection().removeAllRanges();
- }
- }
- //find the element that the event occurred
- function getUINode (evt, uiNode)
- {
- if (!uiNode)
- {
- //get the element that trapped the event in a cross-browser fashion
- uiNode = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
- }
- //check to see if this is a text node.
- while (uiNode.nodeType == 3)
- {
- //this is a text node, get the parent node
- uiNode = uiNode.parentNode;
- }
- var uiNodeTreeRef = uiNode.getAttribute(gsCTREE_treeRef).toString();
- //bubble event to the correct node
- if ((uiNodeTreeRef == gsCTREE_img) || (uiNodeTreeRef == gsCTREE_label) || (uiNodeTreeRef == gsCTREE_checkbox))
- {
- //pass the event from icon to the parent node
- uiNode = uiNode.parentNode;
- }
- uiNodeTreeRef = uiNode.getAttribute(gsCTREE_treeRef).toString();
- if (uiNodeTreeRef == gsCTREE_nobr)
- {
- //pass the event from icon to the parent node
- uiNode = uiNode.parentNode;
- }
- return uiNode;
- }
- //get the javascript treenode for a given tree
- //and tree reference
- function getTreeNode(tree, uiNodeTreeRef)
- {
- var node = null;
- if (uiNodeTreeRef != K_PRMT_sEMPTY)
- {
- //find the target tree node
- var arTreeNodeArray = uiNodeTreeRef.split(K_PRMT_sDOT);
- var treeNode = K_PRMT_sEMPTY;
- for (var k = 0; k < arTreeNodeArray.length; k++)
- {
- if (arTreeNodeArray[k] != K_PRMT_sEMPTY)
- {
- treeNode += ".m_oChildren[" + arTreeNodeArray[k] + "]";
- }
- }
- node = eval(tree + ".getRootNode()" + treeNode);
- }
- else
- {
- node = eval(tree + ".getRootNode()");
- }
- return node;
- }
- //return the appropriate classname for the given node
- function getClassName(node,tree)
- {
- var newClassName = CLS_TREE_NODE_UNSELECTED;
- //get the current state
- //the selection classnames only apply to single select trees
- if ((tree.getSelectionMode() == SINGLE_TREE_SELECTION || tree.getSelectTreeUI() == NORMAL_TREE) && tree.getRootNode() != node)
- {
- switch (node.getState())
- {
- case NODE_PARTIAL:
- newClassName = CLS_TREE_NODE_PARTIAL;
- break;
- case NODE_SELECTED:
- newClassName = CLS_TREE_NODE_SELECTED;
- break;
- }
- }
- return newClassName;
- }
- //return appropriate checkbox image src for the given node
- function getCheckBoxSrc(node)
- {
- var newImageSrc = K_PRMT_sEMPTY;
- //get the current state
- switch (node.getState())
- {
- case NODE_UNSELECTED:
- newImageSrc = CHECKBOX_UNSELECTED;
- break;
- case NODE_PARTIAL:
- newImageSrc = CHECKBOX_PARTIAL;
- break;
- case NODE_SELECTED:
- newImageSrc = CHECKBOX_SELECTED;
- break;
- }
- return newImageSrc;
- }
- function getIconSrc(node)
- {
- var newImageSrc = K_PRMT_sEMPTY;
- if (node.isOpen() == true)
- {
- newImageSrc = node.getNodeTypeObject().m_sIconOpenSrc;
- }
- else
- {
- newImageSrc = node.getNodeTypeObject().m_sIconSrc;
- }
- return newImageSrc;
- }
- function getIconAlign(node)
- {
- //node.getNodeTypeObject().m_sIconAlign;
- // Removed the attribute m_sIconAlign, for backward compatibility
- return gsCTREE_middle;
- }
- //return plus or minus icons for the given node
- function getToggleSrc(node)
- {
- if (node.isOpen() == true)
- {
- if (node.isLast() == true && node.getParent().getMoreData() != true)
- {
- return TREE_L_MINUS;
- }
- else
- {
- return TREE_T_MINUS;
- }
- }
- else
- {
- if (node.isLast() == true && node.getParent().getMoreData() != true)
- {
- return TREE_L_PLUS;
- }
- else
- {
- return TREE_T_PLUS;
- }
- }
- }
- //return plus or minus title for the given node
- function getToggleTitle(node)
- {
- if (node.isOpen() == true)
- {
- return PMT_TRE_COLLAPSE;
- }
- else
- {
- return PMT_TRE_EXPAND;
- }
- }
- function treeNodeMouseOver(evt)
- {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- //cancel any text selection
- clearSelection();
- //prevent the event from bubbling to other elements
- cancelBub(evt);
- //get UI Node
- var uiNode = getUINode(evt);
- var uiNodeTreeRef = uiNode.getAttribute(gsCTREE_treeRef).toString();
- //get the tree object
- var tree = uiNode.getAttribute(gsCTREE_tree).toString();
- //get tree Node
- var node = getTreeNode(tree, uiNodeTreeRef);
- window.status = K_PRMT_sEMPTY;
- if (node.getNodeTypeObject().getSelectable() && node.isSelected() == false && node.hasSelectedChildren() == false)
- {
- var label = node.getLabel(tree);
- label.className = CLS_TREE_NODE_HOVER;
- }
- }
- function treeNodeMouseOut(evt)
- {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- //cancel any text selection
- clearSelection();
- //prevent the event from bubbling to other elements
- cancelBub(evt);
- //get UI Node
- var uiNode = getUINode(evt);
- var uiNodeTreeRef = uiNode.getAttribute(gsCTREE_treeRef).toString();
- //get the tree object
- var tree = uiNode.getAttribute(gsCTREE_tree).toString();
- //get tree Node
- var node = getTreeNode(tree, uiNodeTreeRef);
- window.status = K_PRMT_sEMPTY;
- if (node.isSelected() == false && node.hasSelectedChildren() == false)
- {
- var label = node.getLabel(tree);
- label.className = CLS_TREE_NODE_UNSELECTED;
- }
- }
- /////////////////////////////////
- // Tree node object
- // oParentTreeNode: the parent node - null for the root node
- // oTreeNodeType: the type of node, a TreeNodeType object (e.g. folder/leaf)
- // bOpenState: if this is a container, whether the the default state is open or closed [true|false]
- // name: the display value for the tree node
- // value: the use value for the tree node
- // bSelected: whether this node has been selected or not
- //Tree nodes
- function CTreeNode(oParentTreeNode, oTreeNodeType, bOpenState, sName, value, bSelected)
- {
- if (oTreeNodeType)
- {
- this.init(oParentTreeNode, oTreeNodeType, bOpenState, sName, value, bSelected);
- }
- }
- CTreeNode.prototype.init = function(oParentTreeNode, oTreeNodeType, bOpenState, sName, value, bSelected)
- {
- //id is the searchpath
- this.m_sId = this.generateId();
- this.m_sName = sDecodeU003( sName );
- this.m_sValue = sDecodeU003( value );
-
- this.m_oChildren = [];
- this.m_iSelectedChildrenCount = 0;
- this.m_bOpen = bOpenState;
- //has this node been rendered?
- this.m_bRendered = bOpenState;
- //tree reference
- this.m_sTreeRef = null;
- if (oParentTreeNode != null)
- {
- this.m_oParentTreeNode = oParentTreeNode;
- this.setLevel(this.m_oParentTreeNode.getLevel() + 1);
- if (((this.getTree().getForceSelectionAtLowestLevel() == true && oTreeNodeType.m_iType == TREE_ITEM) || (this.getTree().getForceSelectionAtLowestLevel() == false)) && (this.getTree().getShowPreviousValues() == true))
- {
- this.m_bSelected = bSelected;
- }
- else
- {
- this.m_bSelected = false;
- }
- this.m_oParentTreeNode.appendChild(this);
- var prevSels = this.getTree().getPreviousSelections();
- if (prevSels != null)
- {
- for (var i = 0; i < prevSels.length; i++)
- {
- if ((typeof prevSels[i] == K_PRMT_sSTRING) && (prevSels[i] == this.m_sValue))
- {
- this.m_bSelected = true;
- break;
- }
- else if ((typeof prevSels[i] == K_PRMT_sOBJECT) && (prevSels[i][1] == this.m_sValue))
- {
- this.m_bSelected = true;
- break;
- }
- }
- }
- }
- else
- {
- this.m_oParentTreeNode = null;
- this.setLevel(0);
- this.m_bSelected = false;
- }
- //node type
- this.m_oTreeNodeType = oTreeNodeType;
- if (oTreeNodeType.m_isContainer == true && (oParentTreeNode != null && this.getTree().nodesCanHaveChildren() == true))
- {
- this.setCanHaveChildren(true);
- }
- else
- {
- this.setCanHaveChildren(false);
- }
- this.m_bHasSelectedChildren = false;
- this.m_oRoot = null;
- this.m_bIsLoading = false;
- this.m_sToolTip = false;
- this.m_bIsMoreData = false;
- this.m_iSkipValueCount = 0;
- // default indicator - used for QoS
- this.m_sIndicator = null;
- this.allowUIForChildren = true;
- var v_oTree = this.getTree();
- if ( v_oTree && v_oTree.m_oAncestry && v_oTree.m_oAncestry[this.m_sValue] )
- {
- this.setHasSelectedChildren(true);
- }
- }
- CTreeNode.prototype.attachEvents = function() {
- var treeItem = this.getHTMLTreeItem();
- if(treeItem == null)
- return; // just to be safe
- treeItem.onkeypress = this.onkeypress;
- treeItem.treeNode = eval(this);
- }
- CTreeNode.prototype.onkeypress = function(evt) {
- evt = (evt) ? evt : ((event) ? event : null);
- var keyCode = evt.keyCode || evt.which;
- var treeNode = this.treeNode;
- var parentNode = treeNode.getParent();
- var toggleIcon = treeNode.getHTMLToggleIcon();
-
- // check for root node
- if (parentNode == null) {
- // only for Down key
- if (keyCode == 40) {
- treeNode.getChild(0).getHTMLTreeItem().focus();
- }
- // other key press do nothing
- }
- // check for Left key press
- else if (keyCode == 37) {
- if (treeNode.isOpen()) {
- toggleIcon.click();
- }
- else if (parentNode.getHTMLTreeItem() != null) {
- parentNode.getHTMLTreeItem().focus();
- if (parentNode != treeNode.getRootNode()) {
- parentNode.getHTMLToggleIcon().click();
- }
- }
- }
-
- // check for Right key press
- else if (keyCode == 39) {
- if (!treeNode.isOpen()) {
- toggleIcon.click();
- }
- }
-
- // check for Up and Down key press
- else if (keyCode == 38 || keyCode == 40) {
- var nextTreeNode = treeNode.getNextTreeNode(keyCode);
- if (nextTreeNode != null && nextTreeNode.getHTMLTreeItem() != null) {
- nextTreeNode.getHTMLTreeItem().focus();
- }
- }
- }
- CTreeNode.prototype.getNextTreeNode = function(keyCode) {
- var current, next, first = 0;
- var parentNode = this.getParent();
- var nextTreeNode = null;
- for (var i=0; i<parentNode.getChildrenLength(); i++) {
- if(this == parentNode.getChild(i)) {
- current = i;
- break;
- }
- }
- if (keyCode == 38) {
- next = current -1;
- if (current == first) {
- next = first;
- if (parentNode.isOpen()) {
- return parentNode;
- }
- }
- nextTreeNode = parentNode.getChild(next);
-
- while (nextTreeNode.isOpen()) {
- var last = nextTreeNode.getChildrenLength() - 1;
- nextTreeNode = nextTreeNode.getChild(last);
- }
- }
-
- else if (keyCode == 40) {
- if (this.isOpen()) {
- return this.getChild(0);
- }
- next = current + 1;
- nextTreeNode = parentNode.getChild(next);
- if (this.isLast()) {
- while (parentNode != this.getRootNode()) {
- if (parentNode.isLast()) {
- parentNode = parentNode.getParent();
- }
- else {
- return parentNode.getParent().getChild(parentNode.getIndex() + 1);
- }
- }
- nextTreeNode = null;
- }
- }
- return nextTreeNode;
- }
- CTreeNode.prototype.getHTMLTreeItem = function() {
- return document.getElementById(this.m_sTreeItemId);
- }
- CTreeNode.prototype.getHTMLToggleIcon = function() {
- return document.getElementById(this.m_sToggleIconId);
- }
- CTreeNode.prototype.getLableText = function() {
- return this.m_oLabelText;
- }
- CTreeNode.prototype.getTreeHierarchy = function()
- {
- var iLevel = this.getLevel();
- var sHierarchyName = this.getName();
- var iParentLevel;
- var oCurrentNode = this;
- for (iParentLevel = iLevel-1; iParentLevel >= 0; iParentLevel--)
- {
- oCurrentNode = oCurrentNode.getParent();
- sHierarchyName = oCurrentNode.getName() + "_" + sHierarchyName;
- }
- return sHierarchyName;
- };
- CTreeNode.prototype.setSkipValueCount = function(val)
- {
- this.m_iSkipValueCount = val;
- };
- CTreeNode.prototype.getSkipValueCount = function()
- {
- return this.m_iSkipValueCount;
- };
- CTreeNode.prototype.getTooltip = function ()
- {
- return this.m_sToolTip;
- };
- CTreeNode.prototype.setTooltip = function (val)
- {
- this.m_sToolTip = val;
- };
- CTreeNode.prototype.getNodeTypeObject = function ()
- {
- return this.m_oTreeNodeType;
- };
- CTreeNode.prototype.setNodeTypeObject = function(oTreeNodeType)
- {
- this.m_oTreeNodeType = oTreeNodeType;
- };
- CTreeNode.prototype.getNodeType = function ()
- {
- return this.getNodeTypeObject().m_iType;
- };
- CTreeNode.prototype.generateId = function ()
- {
- return (Date.parse((new Date()).toString()) / 1000000) + Math.random();
- };
- CTreeNode.prototype.getRootNode = function ()
- {
- if (this.m_oRoot == null)
- {
- var theRoot = this;
- while (theRoot.getLevel() != 0)
- {
- theRoot = theRoot.getParent();
- }
- this.m_oRoot = theRoot;
- }
- return this.m_oRoot;
- };
- CTreeNode.prototype.getTree = function ()
- {
- return this.getRootNode().m_oTree;
- };
- CTreeNode.prototype.getParentAtLevel = function (iLevel)
- {
- var parentAtLevel = this;
- var iCurrentLevel = this.getLevel();
- if (this.getLevel() > iLevel)
- {
- for ( var j=iLevel; j < iCurrentLevel; j++)
- {
- parentAtLevel = parentAtLevel.getParent();
- }
- }
- return parentAtLevel;
- };
- CTreeNode.prototype.isLast = function ()
- {
- if ((this.getParent() != null) && (this.getTreeRef() == this.getParent().m_oChildren[this.getParent().getChildrenLength() - 1].getTreeRef()))
- {
- return true;
- }
- else
- {
- return false;
- }
- };
- CTreeNode.prototype.getCheckbox = function (sTreeRef)
- {
- if (!this.m_oCheckbox) {
- this.m_oCheckbox = document.getElementById(sTreeRef + this.getTreeRef() + gsCTREE_checkbox);
- }
- return this.m_oCheckbox;
- };
- CTreeNode.prototype.getLabel = function (sTreeRef)
- {
- if (!this.m_oLabelText) {
- this.m_oLabelText = document.getElementById(sTreeRef + this.getTreeRef() + gsCTREE_labelText);
- }
- return this.m_oLabelText;
- };
- //integer: has this tree node been rendered yet?
- CTreeNode.prototype.setLevel = function (iLevel)
- {
- this.m_oLevel = iLevel;
- };
- CTreeNode.prototype.getLevel = function ()
- {
- return this.m_oLevel;
- };
- //boolean: has this tree node been rendered yet?
- CTreeNode.prototype.setRendered = function (bRendered)
- {
- this.m_bRendered = bRendered;
- };
- CTreeNode.prototype.getRendered = function ()
- {
- return this.m_bRendered;
- };
- //treeRef: a comma separated list that uniquely identifies tree nodes
- CTreeNode.prototype.setTreeRef = function (sTreeRef)
- {
- this.m_sTreeRef = sTreeRef;
- };
- CTreeNode.prototype.getTreeRef = function ()
- {
- return this.m_sTreeRef;
- };
- //boolean: returns whether the node has children or not
- CTreeNode.prototype.hasChildren = function ()
- {
- if (this.getChildrenLength() > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- };
- //container: can this node contain other nodes
- CTreeNode.prototype.canHaveChildren = function ()
- {
- return this.m_bCanHaveChildren;
- };
- CTreeNode.prototype.setCanHaveChildren = function (val)
- {
- this.m_bCanHaveChildren = val;
- };
- //selected: user choice state for the node
- CTreeNode.prototype.isSelected = function ()
- {
- return this.m_bSelected;
- };
- //boolean: does this node have any selected children at any level?
- CTreeNode.prototype.setHasSelectedChildren = function (bSelectedChildren)
- {
- this.m_bHasSelectedChildren = bSelectedChildren;
- };
- CTreeNode.prototype.hasSelectedChildren = function ()
- {
- return this.m_bHasSelectedChildren;
- };
- //recurse through the tree and select all children
- CTreeNode.prototype.setSelected = function (bSelected, bForceRecurs)
- {
- if (this.getNodeTypeObject().getSelectable())
- {
- this.m_bSelected = bSelected;
- //add to default selected list only when tree is first rendered
- if (this.isSelected() && this.getTree().getDefaultSelectLock())
- {
- this.getTree().addDefaultSelectedNode(this);
- }
- if (this.getTree().getTrackSelectionOrder())
- {
- if (bSelected) {
- this.getTree().addToSelectionOrder(this);
- }
- else {
- this.getTree().removeFromSelectionOrder(this);
- }
- }
- }
- //select children too
- if (bForceRecurs == true || ((this.getTree().getSelectTreeUI() != CHECKBOX_TREE || this.getTree().getSelectionMode() != DISCONTIGUOUS_TREE_SELECTION) && (!bSelected || (this.getTree().getRecursiveSelect() && this.getNodeTypeObject().getRecursiveSelect()))))
- {
- this.setHasSelectedChildren(bSelected);
- for (var j=0; j < this.getChildrenLength(); j++)
- {
- this.m_oChildren[j].setSelected(bSelected, bForceRecurs);
- }
- }
- };
- //Update this nodes childrens references to their position in the tree
- //this is called when removing nodes
- CTreeNode.prototype.updateTreeRefs = function ()
- {
- var children = this.getChildren();
- for (var j = 0; j < this.getChildrenLength(); j++)
- {
- var treeRef = K_PRMT_sEMPTY + children[j].getTreeRef();
- var ref_replace_regex = /(\.{0,1})[0-9]+$/;
- treeRef = treeRef.replace(ref_replace_regex, "$1" + j);
- //re create the refs
- children[j].setTreeRef(treeRef);
- }
- };
- //Update this node
- CTreeNode.prototype.update = function ()
- {
- if (this.getTree().getSelectTreeUI() != CHECKBOX_TREE || this.getTree().getSelectionMode() != DISCONTIGUOUS_TREE_SELECTION) {
- this.m_bSelected = false;
- }
- var hasSelectedChildren = false;
- var iSelectedChildren = 0;
- var children = this.getChildren();
- for (var j = 0; j < this.getChildrenLength(); j++)
- {
- if(children[j].isSelected() == true)
- {
- iSelectedChildren += 1;
- hasSelectedChildren = true;
- }
- else if(children[j].hasSelectedChildren())
- {
- //parent.setHasSelectedChildren
- hasSelectedChildren = true;
- }
- }
- this.setSelectedChildrenCount(iSelectedChildren);
- this.setHasSelectedChildren(hasSelectedChildren);
- if (this.getNodeTypeObject().getRecursiveSelect() == true)
- {
- if (
- this.getTree().getSelectionMode() == CONTIGUOUS_TREE_SELECTION &&
- iSelectedChildren == this.getChildrenLength() &&
- this.getNodeTypeObject().getFullChildSelectable()
- ) {
- this.m_bSelected = true;
- }
- this.updateNodeSelection();
- }
- this.updateParent();
- };
- //Update the parent
- CTreeNode.prototype.updateParent = function ()
- {
- var parent = this.getParent();
- if (parent)
- {
- parent.update();
- }
- };
- //if it is known that a child is selected, just iterate through and partial select all parents
- CTreeNode.prototype.partialSelectParent = function ()
- {
- var parent = this.getParent();
- if (parent != null)
- {
- parent.setHasSelectedChildren(true);
- if (parent != this.getRootNode())
- {
- parent.updateNodeSelection();
- parent.partialSelectParent();
- }
- }
- };
- CTreeNode.prototype.updateNodeSelection = function ()
- {
- if (this.getTree().getSelectTreeUI() == NORMAL_TREE)
- {
- if (this.getTree().getSelectionMode() == CONTIGUOUS_TREE_SELECTION && this.isSelected() == false && this.getNodeType() == TREE_FOLDER && this.getChildrenLength() == this.getSelectedChildrenCount()) {
- this.m_bSelected = true;
- }
- var label = this.getLabel(this.getTree().getName());
- if (label != null) {
- label.className = getClassName(this, this.getTree());
- }
- }
- else
- {
- var checkbox = this.getCheckbox(this.getTree().getName());
- if (checkbox != null) {
- checkbox.src = getCheckBoxSrc(this);
- }
- }
- };
- //open: specifies whether the children of a container node should be displayed
- CTreeNode.prototype.isOpen = function ()
- {
- return this.m_bOpen;
- };
- CTreeNode.prototype.setOpen = function (bOpen)
- {
- this.m_bOpen = bOpen;
- };
- //string: return the id of the node
- CTreeNode.prototype.getId = function ()
- {
- return this.m_sId;
- };
- //string: return the name of the node
- CTreeNode.prototype.getName = function ()
- {
- return this.m_sName;
- };
- //void: set the name of the node
- CTreeNode.prototype.setName = function (name)
- {
- this.m_sName = name;
- };
- //string: return the value of the node
- CTreeNode.prototype.getValue = function ()
- {
- return this.m_sValue;
- };
- //void: set the value of the node
- CTreeNode.prototype.setValue = function (value)
- {
- this.m_sValue = sDecodeU003( value );
- };
- //tree node array: return the children
- CTreeNode.prototype.getChildren = function ()
- {
- return this.m_oChildren;
- };
- //tree node array: return the children array length
- CTreeNode.prototype.getChildrenLength = function ()
- {
- return this.m_oChildren.length;
- };
- //tree node array: return the parent node
- CTreeNode.prototype.getParent = function ()
- {
- return this.m_oParentTreeNode;
- };
- //node manipulation functions
- CTreeNode.prototype.appendChild = function (obj)
- {
- var iAppendPos = this.getChildrenLength();
- this.m_oChildren[iAppendPos] = obj;
- if (obj.isSelected() == true) {
- this.m_iSelectedChildrenCount += 1;
- }
- var newTreeRef;
- if (this.getTreeRef() != null && this.getTreeRef().length !== 0)
- {
- newTreeRef = this.getTreeRef() + K_PRMT_sDOT + iAppendPos;
- }
- else
- {
- newTreeRef = iAppendPos;
- }
- this.m_oChildren[iAppendPos].setTreeRef(newTreeRef);
- };
- //take the passed node out of this node
- CTreeNode.prototype.removeChild = function (obj)
- {
- //is it a node we know
- if (!obj.m_sId)
- {
- return;
- }
- var iSize = this.getChildrenLength();
- var oNewChildren = new Array();
- for (var i = 0; i < iSize; i++)
- {
- if (obj.m_sId != this.m_oChildren[i].m_sId)
- {
- oNewChildren.push(this.m_oChildren[i]);
- }
- }
- //replace the children with the filtered results
- this.m_oChildren = oNewChildren;
- //rejig the tree refs
- this.updateTreeRefs();
- };
- //return the child at the appropriate position
- CTreeNode.prototype.getChild = function (index)
- {
- if (index >= 0 && index < this.getChildrenLength())
- {
- return this.m_oChildren[index];
- }
- return null;
- };
- //take the passed node out of this node
- CTreeNode.prototype.removeChildren = function (childNodes)
- {
- //is it a node array?
- if (!childNodes || !childNodes.length || childNodes.length === 0)
- {
- return;
- }
- var oRef_map = new Object();
- var i = 0;
- for (i = 0; i < childNodes.length; i++)
- {
- if (childNodes[i].m_sId)
- {
- oRef_map[childNodes[i].m_sId] = childNodes[i];
- }
- }
- var oNewChildren = new Array();
- for (i = 0; i < this.getChildrenLength(); i++)
- {
- if (!oRef_map[this.m_oChildren[i].m_sId])
- {
- //this is saved from the bin
- oNewChildren.push(this.m_oChildren[i]);
- }
- }
- //replace the children with the filtered results
- this.m_oChildren = oNewChildren;
- //rejig the tree refs
- this.updateTreeRefs();
- };
- //remove this node from its parent
- CTreeNode.prototype.detach = function ()
- {
- this.getParent().removeChild(this);
- };
- CTreeNode.prototype.getSelectedChildrenCount = function ()
- {
- return this.m_iSelectedChildrenCount;
- };
- CTreeNode.prototype.setSelectedChildrenCount = function (count)
- {
- this.m_iSelectedChildrenCount = count;
- };
- CTreeNode.prototype.addSelectedChildrenCount = function ()
- {
- this.m_iSelectedChildrenCount = this.m_iSelectedChildrenCount + 1;
- };
- CTreeNode.prototype.removeSelectedChildrenCount = function ()
- {
- this.m_iSelectedChildrenCount = this.m_iSelectedChildrenCount - 1;
- };
- //return the current state of the node
- CTreeNode.prototype.getState = function ()
- {
- if (this.isSelected())
- {
- return NODE_SELECTED;
- }
- else if (this.hasSelectedChildren() == true)
- {
- if ((this.getTree().getSelectionMode() == CONTIGUOUS_TREE_SELECTION) &&
- (this.getSelectedChildrenCount() > 0) &&
- (this.getSelectedChildrenCount() == this.getChildrenLength()) &&
- this.getNodeTypeObject().getFullChildSelectable())
- {
- return NODE_SELECTED;
- }
- else
- {
- return NODE_PARTIAL;
- }
- }
- return NODE_UNSELECTED;
- };
- CTreeNode.prototype.setShowUI = function (showUI)
- {
- this.allowUIForChildren = showUI;
- };
- CTreeNode.prototype.getShowUI = function()
- {
- return this.allowUIForChildren;
- };
- CTreeNode.prototype.getResponseCacheKey = function(response){
- return this.getValue() + "_children";
- };
- //fetch the children of the node
- CTreeNode.prototype.fetchChildren = function (bForceFetch)
- {
- var v_oTree = this.getTree();
- if ( !v_oTree.nodesCanHaveChildren() && bForceFetch !== true)
- {
- return;
- }
- if (v_oTree.getPromptingTree() != false)
- {
- if ((typeof activeFetchingTreeNode == K_PRMT_sUNDEFINED || activeFetchingTreeNode == null) && (v_oTree.m_oDispatcher != null) && (this.getLoading() == false))
- {
- this.setLoading(true);
- v_oTree.setLoading(true);
- if (this.getShowUI())
- {
- this.setOpen(true);
- v_oTree.redrawNodeToggle(this, v_oTree.getName() + this.getTreeRef());
- v_oTree.drawLoading(this, v_oTree.getName() + this.getTreeRef());
- }
- activeFetchingTreeNode = this;
-
-
- var cachedResponse = SYSTEMPROPERTY_TREE_CACHE_IGNORE_PRIOR_RSVP_RESPONSES ? false : this.getTree().getCacheValue(this.getResponseCacheKey());
- if (cachedResponse && !this.bShouldFetchChildren){
- promptTreeCallback(cachedResponse);
- }else{
- this.sendFetchChildrenRequest();
- }
-
-
- }
- return true;
- }
- else if (typeof v_oTree.getLoadOnTheFly() == K_PRMT_sFUNCTION)
- {
- if (this.getLoading() == false)
- {
- this.setLoading(true);
- v_oTree.setLoading(true);
- if (this.getShowUI())
- {
- this.setOpen(true);
- v_oTree.redrawNodeToggle(this, v_oTree.getName() + this.getTreeRef());
- v_oTree.drawLoading(this, v_oTree.getName() + this.getTreeRef());
- }
- var theFunction = v_oTree.getLoadOnTheFly();
- theFunction(this);
- }
- return true;
- }
- else
- {
- this.setCanHaveChildren(false);
- if (this.getShowUI())
- {
- v_oTree.redrawNodeToggle(this, v_oTree.getName() + this.getTreeRef());
- }
- return false;
- }
- };
- // If the tracking information is not available call sendFetchChildrenRequest
- // after a delay of WAIT_FOR_TRACKING_TIMEOUT_MS. There is also a retry count
- // just in case the tracking information is always empty.
- var WAIT_FOR_TRACKING_TIMEOUT_MS = 100; // 100 milliseconds
- var TRACKING_RETRY_CNT_MAX = 500; // 500 * 100 ms = 50 seconds worth of trying
- CTreeNode.prototype.sendFetchChildrenRequest = function( v_oParams, v_iRetryCount )
- {
- // Call the XTS to load the prompting tree
- var cafContextId = K_PRMT_sEMPTY; // TODO
- var url = "b_action=xts.run&m=/prompting/promptTree.xts";
- // Pass the m_tracking node
- var tracking_info = this.getTree().getTracking();
- var sConversation = this.getTree().getConversation();
- var retries = TRACKING_RETRY_CNT_MAX;
- if ( typeof v_iRetryCount != "undefined" )
- {
- retries = v_iRetryCount;
- }
- if (tracking_info=="") {
- if ( retries > 0 )
- {
- var _self = this;
- setTimeout(
- function() {
- _self.sendFetchChildrenRequest(v_oParams, retries-1);
- }, WAIT_FOR_TRACKING_TIMEOUT_MS );
- return;
- }
- }
- if (cafContextId != K_PRMT_sEMPTY) {
- url += "&ui.cafcontextid=" + cafContextId;
- }
- if (this.getMoreData() == true)
- {
- url += "&skipValueCount=" + (this.getSkipValueCount() + this.getTree().getMaxValueCount());
- }
- else
- {
- url += "&skipValueCount=" + this.getSkipValueCount();
- }
- url += "&maximumValueCount=" + this.getTree().getMaxValueCount();
- url += "¶mName=" + encodeURIComponent(this.getTree().getPromptingTree());
- url += "&treeNodeName=" + this.getTree().getName() + this.getTreeRef();
- if (this.getNodeType() != TREE_ROOT)
- {
- url += "&useValue=" + encodeURIComponent(this.getValue());
- url += "&displayValue=" + encodeURIComponent(this.getName());
- }
- if ( v_oParams )
- {
- for( var v_sParamName in v_oParams )
- {
- if ( v_sParamName == "m_tracking" )
- {
- tracking_info = v_oParams[v_sParamName];
- }
- else if ( v_sParamName == "ui.conversation" )
- {
- sConversation = v_oParams[v_sParamName];
- }
- else
- {
- url += "&" + v_sParamName + "=" + encodeURIComponent( v_oParams[v_sParamName] );
- }
- }
- }
- url += "&m_tracking=" + tracking_info;
- url += "&ui.conversation=" + sConversation;
- var v_oRequest = this.getTree().m_oDispatcher.createRequest(this.getTree().getGateway(), url, promptTreeCallback);
- this.getTree().m_oDispatcher.setErrorHandlerFunction(treeErrorHandler);
- this.getTree().m_oDispatcher.dispatchRequest(v_oRequest);
- }
- CTreeNode.prototype.setLoading = function (val)
- {
- this.m_bIsLoading = val;
- };
- CTreeNode.prototype.getLoading = function ()
- {
- return this.m_bIsLoading;
- };
- CTreeNode.prototype.setMoreData = function (val)
- {
- this.m_bIsMoreData = val;
- };
- CTreeNode.prototype.getMoreData = function ()
- {
- return this.m_bIsMoreData;
- };
- CTreeNode.prototype.getIndex = function ()
- {
- if (this.getParent() != null)
- {
- var children = this.getParent().getChildren();
- for (var i = 0; i < children.length; i++)
- {
- if (children[i] == this) {
- return i;
- }
- }
- }
- else
- {
- return null;
- }
- };
- /*
- CTreeNode.prototype.findCommonParent = function (otherNode)
- {
- var i = this.getParent();
- var rootNode = this.getRootNode();
- while(i != rootNode)
- {
- var otheri = otherNode.getParent();
- while (otheri != rootNode)
- {
- if(otheri == i)
- return i;
- otheri = otheri.getParent();
- }
- if(otheri == i)
- return i;
- i = i.getParent();
- }
- return rootNode;
- }
- */
- CTreeNode.prototype.setIndicator = function(sIndicatorSrc)
- {
- // set the indicator value
- this.m_sIndicator = sIndicatorSrc;
- };
- CTreeNode.prototype.getIndicator = function()
- {
- // return the indicator value
- return this.m_sIndicator;
- };
- //definitions for the types of nodes
- function CTreeNodeType(iType, isContainer, sIconSrc, sIconOpenSrc)
- {
- this.m_iType = iType;
- this.m_isContainer = isContainer;
- this.m_sIconSrc = sIconSrc;
- this.m_sIconOpenSrc = sIconOpenSrc;
- this.m_sIconAltText = null;
- this.m_bSelectable = true;
- this.m_bRecursiveSelect = true;
- this.m_bFullChildSelect = true;
- }
- CTreeNodeType.prototype.setSelectable = function(val)
- {
- this.m_bSelectable = val;
- };
- CTreeNodeType.prototype.setAltText = function(altText)
- {
- this.m_sIconAltText = altText;
- };
- CTreeNodeType.prototype.getSelectable = function()
- {
- return this.m_bSelectable;
- };
- CTreeNodeType.prototype.setFullChildSelectable = function(val)
- {
- this.m_bFullChildSelect = val;
- };
- CTreeNodeType.prototype.getFullChildSelectable = function()
- {
- return this.m_bFullChildSelect;
- };
- CTreeNodeType.prototype.setRecursiveSelect = function(val)
- {
- this.m_bRecursiveSelect = val;
- };
- CTreeNodeType.prototype.getRecursiveSelect = function()
- {
- return this.m_bRecursiveSelect;
- };
- function handleWorking(response)
- {
- var responseArray = response.split('","');
- var url = "b_action=xts.run&m=/prompting/promptTree.xts";
- var cafContextId = K_PRMT_sEMPTY; // TODO
- if (cafContextId != K_PRMT_sEMPTY) {
- url += "&ui.cafcontextid=" + cafContextId;
- }
- var treeName = responseArray[1];
- url += "&treeNodeName=" + treeName;
- url += "&doWait=1&m_tracking=" + responseArray[2];
- //DO WE NEED TO GET PARAMETERS FROM SOMEWHERE??? Probably not
- // url += "&doWait=1&m_tracking=" + responseArray[2] + "¶meterValues=" + encodeURIComponent(cfgGet("parameterValues"));
- var treeNode = activeFetchingTreeNode;
- var request = treeNode.getTree().m_oDispatcher.createRequest(treeNode.getTree().getGateway(), url, promptTreeCallback);
- // alert("about to dispatch: [" + url + "]")
- treeNode.getTree().m_oDispatcher.dispatchRequest(request);
- }
- function cleanupActiveFetchingTreeNodeOnError()
- {
- var theNode = activeFetchingTreeNode;
- if (theNode) {
- var theTree = theNode.getTree();
- if (theNode.getShowUI())
- {
- theTree.removeLoading(theNode);
- }
- if (theNode.getChildren().length == 0)
- {
- theNode.setCanHaveChildren(false);
- }
- if (theNode.getShowUI())
- {
- var theNodeRef = theTree.getName() + theNode.getTreeRef();
- theTree.redrawNodeToggle(theNode, theNodeRef);
- theTree.updateSelections(theNode, false);
- theTree.redraw();
- theTree.checkData();
- }
- }
- activeFetchingTreeNode = null;
- }
- CTreeNode.prototype.createNewNode = function(treeNode, tntGeneric, name, value, isSelected)
- {
- new TreeNode(treeNode, tntGeneric, false, jsDecodeStr(name), jsDecodeStr(value), isSelected);
- };
- CTreeNode.prototype.setFetchChildrenFlag = function(bShouldFetch)
- {
- this.bShouldFetchChildren = bShouldFetch;
- };
- function promptTreeCallback(response, reRenderPage)
- {
- // web page(error, timeout, etc) or working response
- if (response != K_PRMT_sEMPTY && !PRMTTreeUtils.isChildrenInfo(response))
- {
- var responseArray = response.split('","');
- if (responseArray[0].substr(1) == "working") {
- setTimeout("handleWorking('" + response + "');", 100);
- } else {
- var v_oTree = activeFetchingTreeNode;
- if ( v_oTree ) { v_oTree = v_oTree.getTree(); }
- var v_oCV = ( v_oTree ? v_oTree.getCV() : null );
-
- if ( v_oCV && v_oCV.sSkin && typeof response == K_PRMT_sSTRING )
- {
- // add default CSS for this skin before the first <link> tag.
- response = response.replace("<link ", '<link type="text/css" rel="stylesheet" href="' + v_oCV.sSkin + '/portal/default.css">\n<link ');
- }
- response += '<script type="text/javascript">\nif (parent.CTree_setPromptAction){parent.CTree_setPromptAction(this);}\n</script>';
-
- var v_oIFrame = null;
- if (reRenderPage) {
- v_oIFrame = document.getElementById( 'CTree_IFramePOPUP' );
- v_oIFrame.setAttribute('reRender', true);
- } else {
- CTree_clearIFramePopup();
- v_oIFrame = document.createElement( 'iframe' );
- v_oIFrame.id = 'CTree_IFramePOPUP';
- v_oIFrame.src = "../common/blank.html";
- v_oIFrame.className = "clsPromptDialog";
- var d = ( document.body ? document.body : document.documentElement );
- d.appendChild( v_oIFrame );
- }
- var v_doc = (v_oIFrame && v_oIFrame.contentWindow ? v_oIFrame.contentWindow.document : null);
- if ( v_doc )
- {
- // Enable designMode to prevent issues with long lines and loading scripts in Internet Explorer
- if (window.ie) v_doc.designMode = "On";
- v_doc.open();
- v_doc.writeln( response );
- v_doc.close();
- // Disable designMode to re-enable javascript.
- if (window.ie) v_doc.designMode = "Off";
- }
- PRMTTreeUtils.setPopupFormTarget(v_oIFrame);
- }
- }
- else if (response != K_PRMT_sEMPTY) // children
- {
- var responseArray = response.split('","');
- var moreData = jsDecodeStr(responseArray[1]);
- var skipValueCount = parseInt(jsDecodeStr(responseArray[2]), 10);
- var maxValueCount = parseInt(jsDecodeStr(responseArray[3]), 10);
- var treeNode = activeFetchingTreeNode;
-
- // Cache the response if caching is enabled.
- treeNode.getTree().setCacheValue(treeNode.getResponseCacheKey() , response);
-
- if (treeNode && treeNode.createNewNode) {
- var preDataLength = 6; // because we have x values at the beginning that aren't part of any node
- if ( !(responseArray.length == preDataLength && (jsDecodeStr(responseArray[preDataLength - 1]).indexOf('"') > -1)) )
- {
- if ((responseArray.length - preDataLength) % 4 != 0) {
- return false;
- }
- for (var i = preDataLength; i < responseArray.length; i += 4)
- {
- var isSelected = false;
- if (jsDecodeStr(responseArray[i + 3]).charAt(0) == "t")
- {
- isSelected = true;
- }
- treeNode.createNewNode(treeNode, tntGeneric, responseArray[i + 1], responseArray[i + 2], isSelected);
- }
- }
- treeNode.setMoreData(moreData == "true");
- if(moreData == "true")
- {
- treeNode.setFetchChildrenFlag(true);
- }
- treeNode.setSkipValueCount(skipValueCount);
- treeNode.getTree().setMaxValueCount(maxValueCount);
- treeNode.getTree().childrenReadyForNode(treeNode);
- }
- activeFetchingTreeNode = null;
- }
- else
- {
- cleanupActiveFetchingTreeNodeOnError();
- }
- }
- function getMoreDataForTreeNode(evt)
- {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- // don't return when Enter, ArrowRight, ArrowUp or undefined keys are pressed
- if ((evt !== null) && (evt.keyCode != null) && (evt.keyCode != K_KEY_UP) && (evt.keyCode != K_KEY_RIGHT) && (evt.keyCode != K_KEY_ENTER) && (evt.keyCode !== 0) && (evt.keyCode != K_KEY_TAB || !evt.shiftKey))
- {
- return false;
- }
- //cancel any text selection
- clearSelection();
- //prevent the event from bubbling to other elements
- cancelBub(evt);
- //get UI Node
- var uiNode = null;
- if ( evt.target )
- {
- uiNode = evt.target;
- }
- else if ( evt.srcElement )
- {
- uiNode = evt.srcElement;
- }
- else
- {
- return false;
- }
- var uiNodeTreeRef = uiNode.getAttribute(gsCTREE_treeRef).toString();
- //get the tree object
- var tree = uiNode.getAttribute(gsCTREE_tree).toString();
- //get tree Node
- var node = getTreeNode(tree, uiNodeTreeRef);
- if (typeof activeFetchingTreeNode == K_PRMT_sUNDEFINED || activeFetchingTreeNode == null)
- {
- // expand the node when Enter or ArrowRight keys are pressed
- if (evt.keyCode == K_KEY_ENTER || evt.keyCode == K_KEY_RIGHT || evt.keyCode == 0 || evt.keyCode == null)
- {
- node.getTree().removeMoreData(node, node.getTree().getName() + node.getTreeRef());
- node.fetchChildren(true);
- }
- var v_oTree = node.getTree();
- if (v_oTree)
- {
- // if the pressed key is ArowUp then move the focus to the previous node which is the last sibling before More node
- // there will always be a previous node for a More node
- // do the same if the Shift+Tab keys are both pressed
-
- // otherwise, i.e. for ArrowRight, ArrowLeft, Enter, and undefined keys, move the focus to the parent node
- // there will always be a parent node for a More node
-
- // note that the user should be forced to collapse the parent node to navigate to its next sibling
- // the More link loses the focus but it should still be tab-able
- var moreDataNode = v_oTree.m_lastFocus;
- if (evt.keyCode == K_KEY_UP || (evt.keyCode == K_KEY_TAB && evt.shiftKey) || evt.keyCode == K_KEY_RIGHT || evt.keyCode == K_KEY_ENTER || evt.type == gsCTREE_click)
- {
- // the last child of 'node' is the node before More node
- v_oTree.f_moveFocus(null, node.getLastChild());
- }
- else
- {
- v_oTree.f_moveFocus(null, node);
- }
- // make the more data node tab-able
- moreDataNode.tabIndex = 0;
- }
- }
- }
- function treeErrorHandler(errorStoppedAt, e)
- {
- // alert("errorHandler broke at: [" + errorStoppedAt + "]\nwith message: [" + e.message + "]\nin file: [" + e.fileName + "]\nat line: [" + e.lineNumber + "]");
- }
- function CTree_clearIFramePopup()
- {
- var v_oIFrame = null;
- while( v_oIFrame = document.getElementById( 'CTree_IFramePOPUP' ) )
- {
- v_oIFrame.parentNode.removeChild( v_oIFrame );
- delete v_oIFrame;
- }
- G_CTREE_IFramePopupWindow = null;
- }
- function CTree_promptAction(sAction, sArg)
- {
- var v_oCV = PRMTTreeUtils.getCVObjectFromActiveTree();
- if ( v_oTree ) { v_oTree = v_oTree.getTree(); }
- var v_oCV = ( v_oTree ? v_oTree.getCV() : null );
- if ( sAction == K_ACTION_CANCEL )
- {
- // we use setTimeout to start a different thread for the request.
- // Otherwise, the request aborts in Firefox when this function ends.
- setTimeout( v_oCV.promptAction.bind( v_oCV, sAction, sArg ), 10 );
- }
- else
- {
- var aPreProcess = G_CTREE_IFramePopupWindow.getPreProcessControlArray();
- if (aPreProcess)
- {
- G_CTREE_IFramePopupWindow.preProcessForm(aPreProcess);
- var ar = aPreProcess;
- var kCount = ar.length;
- var k = 0;
- var sXML = K_PRMT_sEMPTY;
- var v_oParams = {};
- for (k=0; k<kCount; k++)
- {
- var v_oPC = G_CTREE_IFramePopupWindow.eval(ar[k]);
- v_oParams[ v_oPC.m_oSubmit.name ] = v_oPC.sGetValue();
- }
- if ( G_CTREE_IFramePopupWindow.PT_CONVERSATION_INFO ) {
- v_oParams[ "PT_CONVERSATION_INFO" ] = G_CTREE_IFramePopupWindow.PT_CONVERSATION_INFO;
- }
- if ( G_CTREE_IFramePopupWindow.PT_TRACKING ) {
- v_oParams[ "m_tracking" ] = G_CTREE_IFramePopupWindow.PT_TRACKING;
- }
- // we use setTimeout to start a different thread for the request.
- // Otherwise, the request aborts in Firefox when this function ends.
- setTimeout( activeFetchingTreeNode.sendFetchChildrenRequest.bind( activeFetchingTreeNode, v_oParams ), 10 );
- }
- }
- CTree_clearIFramePopup();
- }
- var PRMTTreeUtils =
- {
- f_addEvent: function( v_oElement, v_sType, v_oFct, v_bUseCapture ) {
- v_bUseCapture = !v_bUseCapture ? false : v_bUseCapture;
- if ( v_oElement )
- {
- if ( v_oElement.addEventListener )
- {
- v_oElement.addEventListener( v_sType, v_oFct, v_bUseCapture );
- }
- else
- {
- v_oElement.attachEvent('on' + v_sType, v_oFct );
- }
- }
- },
- isHTMLPage: function (sArg) {
- // html starts with '<!DOCTYPE html' or <html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">'
- var reHTML = new RegExp("^<(!DOCTYPE )?html", "i");
- var result = (sArg.match( reHTML )? true : false);
- return result;
- },
-
- isChildrenInfo: function (sArg) {
- // children info is in JSON format inside a minimal html wrapper, the json content starts 'var j="CTree'
- var reHTML = new RegExp("j=\\[\"CTree", "i");
- var result = (sArg.match( reHTML )? true : false);
- return result;
- },
-
- mergeChildrenInfo: function(sArg1, sArg2) {
- //helper function to merge two different sets of children info for the same tree node into one html wrapper
- //1. extract child information from html wrapper in sArg2
- //2. merge extracted child information with cached child info in sArg1
- var retVal = "";
- var parts = sArg1.split('","');
- var cachedSkipValueCount = parseInt(jsDecodeStr(parts[2]), 10);
-
- var extractedVal = '","';
- var childInfo = sArg2.split('","');
- var responseSkipValueCount = parseInt(jsDecodeStr(childInfo[2]), 10);
- var newSkipValueCount = cachedSkipValueCount + responseSkipValueCount;
- parts[2] = jsEncodeStr(newSkipValueCount.toString());
- retVal = parts.join('","');
-
- var indexOfClosingTag = childInfo[childInfo.length - 1].lastIndexOf("</script>");
- childInfo[childInfo.length - 1] = childInfo[childInfo.length - 1].substring(0, indexOfClosingTag);
-
- childInfo = childInfo.splice(6, childInfo.length);
-
- for (var i = 0; i < childInfo.length; i++)
- {
- extractedVal += childInfo[i];
- if(i != (childInfo.length - 1))
- {
- extractedVal += '","';
- }
- }
- retVal = retVal.replace("\"]</script>", extractedVal + "</script>");
-
- return retVal;
- },
-
- getCVObjectFromActiveTree: function () {
- var v_oTree = activeFetchingTreeNode;
- if ( v_oTree ) { v_oTree = v_oTree.getTree(); }
- var v_oCV = ( v_oTree ? v_oTree.getCV() : null );
- return v_oCV;
- },
- getIframeDoc: function (v_iFrame) {
- var v_oDoc = null;
- if (v_iFrame) {
- if (v_iFrame.contentDocument) {
- v_oDoc = v_iFrame.contentDocument;
- } else if (v_iFrame.contentWindow && v_iFrame.contentWindow.document) {
- v_oDoc = v_iFrame.contentWindow.document;
- } else if (v_iFrame.document) {
- v_oDoc = v_iFrame.document;
- }
- }
- return v_oDoc;
- },
- f_iFramePopupExists: function() {
- var v_oIFrame = null;
- var result = false;
- v_oIFrame = document.getElementById( 'CTree_IFramePOPUP' );
- if (v_oIFrame && v_oIFrame.reRender) {
- result = true;
- }
- return result;
- },
- f_createTargetIFrame: function () { // create/recycle target iframe
- var v_sIFrameId = 'CTree_IFramePOPUPTarget';
- //remove if exists
- var v_targetIframe = $(v_sIFrameId);
- if (v_targetIframe) { // and PRMTUtils.f_isDOMElem(v_alertDiv))
- PRMTUtils.f_removeElement(v_targetIframe.parent);
- }
- // create a new one
- var v_oEle = document.createElement('DIV');
- v_oEle.innerHTML = '<iframe style="display:none" src="about:blank" content="text/xml" id="'+v_sIFrameId+'" name="'+ v_sIFrameId + '"></iframe>';
- document.body.appendChild(v_oEle);
- var iFrame = document.getElementById(v_sIFrameId);
- PRMTUtils.f_addEvent(iFrame, "load", PRMTTreeUtils.f_popupSubmitCallback);
- return v_sIFrameId;
- },
- f_popupSubmitCallback: function () {
- var v_oIFrame = (window.ie?document.getElementById('CTree_IFramePOPUPTarget'):this);
- var v_oDoc = (v_oIFrame.contentDocument? v_oIFrame.contentDocument : (v_oIFrame.contentWindow? v_oIFrame.contentWindow.document : v_oIFrame.document) );
- if (v_oDoc && v_oDoc.location && v_oDoc.location.href != "about:blank") {
- // extract response string
- var responseString = null;
- if (v_oDoc.implementation && v_oDoc.implementation.createDocument) {
- var v_oSerializer = new XMLSerializer();
- responseString = v_oSerializer.serializeToString(v_oDoc);
- } else { // IE
- if (null != v_oDoc.body.parentNode.innerHTML) {
- responseString = v_oDoc.body.parentNode.innerHTML;
- } else {
- return;
- }
- }
- if (PRMTTreeUtils.isChildrenInfo(responseString)) {
- parent.CTree_clearIFramePopup();
- parent.promptTreeCallback(responseString);
- } else {
- // check to skip double submit
- if (!parent.PRMTTreeUtils.f_iFramePopupExists()) {
- parent.promptTreeCallback(responseString, true);
- }
- }
- }
- }
- };
- /**
- * Target the form in the popup iframe to a hidden iframe where we can parse the response
- */
- var K_PRMT_WAIT_FOR_POPUP_TIMEOUT_MS = 100; // 100 milliseconds
- var K_PRMT_POPUP_RETRY_CNT_MAX = 500; // 500 * 100 ms = 50 seconds worth of trying
- PRMTTreeUtils.setPopupFormTarget = function(iframe, v_iRetryCount) {
- var v_iframeDoc = null;
- var v_aForms = null;
- var v_targetIframeId = null;
- try {
- v_iframeDoc = PRMTTreeUtils.getIframeDoc(iframe);
- if (v_iframeDoc && v_iframeDoc.getElementsByTagName) {
- v_aForms = v_iframeDoc.getElementsByTagName('form');
- }
- var retries = K_PRMT_POPUP_RETRY_CNT_MAX;
- if ( typeof v_iRetryCount != "undefined" ) {
- retries = v_iRetryCount;
- }
- } catch(e) {
- // trace(e.message);
- }
- if ( v_aForms && v_aForms.length > 0 ) {
- v_targetIframeId = PRMTTreeUtils.f_createTargetIFrame();
- var v_oForm = v_aForms[0];
- v_oForm.setAttribute('target', v_targetIframeId);
- if (iframe.reRender) {
- iframe.removeAttribute('reRender');
- }
- } else {
- if ( retries > 0 ) {
- setTimeout( function() { PRMTTreeUtils.setPopupFormTarget(iframe, retries-1); }, K_PRMT_WAIT_FOR_POPUP_TIMEOUT_MS );
- return;
- }
- }
- };
- function CTree_setPromptAction( v_oWin )
- {
- var v_oCV = v_oWin.oCV;
- if ( v_oCV )
- {
- G_CTREE_IFramePopupWindow = v_oWin;
- v_oCV.promptAction = CTree_promptAction;
- }
- if ( v_oWin.doCancel )
- {
- v_oWin.doCancel = CTree_promptAction.bind( this, K_ACTION_CANCEL );
- }
- }
- //skin folder
- var PROMPT_SKIN = (typeof getPromptSkin != K_PRMT_sUNDEFINED ? getPromptSkin() : K_PRMT_sDEFAULTSKIN);
- var PROMT_IMAGES = PROMPT_SKIN + "/prompting/images/";
- //Constants
- var TREE_ROOT = 0;
- var TREE_FOLDER = 1;
- var TREE_ITEM = 2;
- //Selection Constants
- // Allow only a single node to be selected (default)
- var SINGLE_TREE_SELECTION = 0;
- // Allow multiple selections of visible nodes
- var DISCONTIGUOUS_TREE_SELECTION = 1;
- // Allow selection to span one vertical contiguous set of nodes
- var CONTIGUOUS_TREE_SELECTION = 2;
- //Tree Type Constant
- var NORMAL_TREE = "normalTree";
- var CHECKBOX_TREE = "checkboxTree";
- //Tree Classes
- var CLS_TREE_TEXT = "clsTreeText";
- var CLS_TREE_TEXT_LINK = "clsTreeText aLink";
- var CLS_TREE_TEXT_NO_LINK = "clsTreeText noLink";
- var CLS_TREE_LEVEL = "clsTreeLevel";
- var CLS_TREE_NODE_SELECTED = "clsTreeNode_selected";
- var CLS_TREE_NODE_PARTIAL = "clsTreeNode_partial";
- var CLS_TREE_NODE_UNSELECTED = "clsTreeNode_unselected";
- var CLS_TREE_NODE_HOVER = "clsTreeNode_hover";
- var CLS_TRE_EXPAND_COLLAPSE_HOVER = "clsExpandCollapseHover clsTextIconAlignFix";
- var CLS_TREE_TEXTICON_ALIGNFIX = "clsTextIconAlignFix";
- //tree node types
- var tntRoot = new CTreeNodeType(TREE_ROOT, true, PROMT_IMAGES + "icon_tree_folder_closed.gif", PROMT_IMAGES + "icon_tree_folder_open.gif");
- var tntFolder = new CTreeNodeType(TREE_FOLDER, true, PROMT_IMAGES + "icon_tree_folder_closed.gif", PROMT_IMAGES + "icon_tree_folder_open.gif");
- var tntLeaf = new CTreeNodeType(TREE_ITEM, false, PROMT_IMAGES + "icon_tree_leaf.gif", PROMT_IMAGES + "icon_tree_leaf.gif");
- //tri-state checkboxes have the following states:
- // node is selected
- // node is not selected
- // node has some or all children that are selected
- var CHECKBOX_UNSELECTED = PROMT_IMAGES + "checkbox_unchecked.gif";
- var CHECKBOX_PARTIAL = PROMT_IMAGES + "checkbox_mixed.gif";
- var CHECKBOX_SELECTED = PROMT_IMAGES + "checkbox_checked.gif";
- //Error state graphics
- var ERROR_TIMED_SMALL_OFF = PROMT_IMAGES + "error_timed_small_off.gif";
- var ERROR_TIMED_SMALL = PROMT_IMAGES + "error_timed_small.gif";
- var NODE_UNSELECTED = 0;
- var NODE_PARTIAL = 1;
- var NODE_SELECTED = 2;
- //line connector definitions
- var TREE_T_PLUS = PROMT_IMAGES + "icon_tree_Tplus.gif";
- var TREE_T_MINUS = PROMT_IMAGES + "icon_tree_Tminus.gif";
- var TREE_T_ONLY = PROMT_IMAGES + "icon_tree_T.gif";
- var TREE_L_PLUS = PROMT_IMAGES + "icon_tree_Lplus.gif";
- var TREE_L_MINUS = PROMT_IMAGES + "icon_tree_Lminus.gif";
- var TREE_L_ONLY = PROMT_IMAGES + "icon_tree_L.gif";
- var TREE_L_ONLY_RTL = PROMT_IMAGES + "icon_tree_L_rtl.gif";
- var TREE_I_ONLY = PROMT_IMAGES + "icon_tree_I.gif";
- var TREE_SPACE = PROMT_IMAGES + "icon_tree_white.gif";
- //loading icon
- var TREE_LOADING = PROMT_IMAGES + "loading_timed.gif";
- //more data icon
- var TREE_MORE_DATA = PROMT_IMAGES + "icon_more.gif";
- var G_CTREE_IFramePopupWindow = null;
- // Event Studio is not loading externsions.js so repeating browser id
- if (typeof window.ie === 'undefined') {
- if (!!window.MSInputMethodContext && !!document.documentMode && (document.documentMode == 11)) { window.ie = window.ie11 = true; }
- else if (document.childNodes && !document.all && !navigator.taintEnabled && !!window.StyleMedia) { window.ie = window.ie11 = window.edge = true; }
- else if (document.all && !!window.atob) { window.ie = window['ie10'] = true; }
- else if (document.all && !!document.addEventListener) { window.ie = window['ie9'] = true; }
- else if (document.all && !!document.querySelector) { window.ie = window['ie8'] = true; }
- else if (document.all && !!window.XMLHttpRequest) { window.ie = window['ie7'] = true; }
- else if (document.all && !!document.compatMode) { window.ie = window['ie6'] = true; }
- else if (document.all) { window.ie = window['ie5'] = true; }
- };
|