cvselection.js 144 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| IBM Cognos Products: Viewer
  5. *| (C) Copyright IBM Corp. 2017, 2019
  6. *|
  7. *| US Government Users Restricted Rights - Use, duplication or
  8. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. *|
  10. *+------------------------------------------------------------------------+
  11. */
  12. //
  13. // This class represents the basic representation of a selection object.
  14. //
  15. /*
  16. Constructor.
  17. Parameters:
  18. Returns:
  19. */
  20. function CSelectionObject()
  21. {
  22. this.initialize();
  23. }
  24. CSelectionObject.prototype.initialize = function()
  25. {
  26. this.m_oCellRef = {};
  27. this.m_sColumnRef = "";
  28. this.m_sColumnName = "";
  29. this.m_aDataItems = [];
  30. this.m_aUseValues = [];
  31. this.m_aDisplayValues = [];
  32. this.m_sCellTypeId = "";
  33. this.m_sLayoutType = "";
  34. this.m_sTag = "";
  35. this.m_aMuns = [];
  36. this.m_aRefQueries = [];
  37. this.m_aMetadataItems = [];
  38. this.m_aDrillOptions = [];
  39. this.m_selectionController = {};
  40. this.m_contextIds = [];
  41. this.m_ctxAttributeString = "";
  42. this.m_fetchedContextIds = false;
  43. this.m_selectedClass = [];
  44. this.m_cutClass=[];
  45. this.m_dataContainerType = "";
  46. this.m_oJsonContext = null;
  47. };
  48. CSelectionObject.prototype.isSelectionOnVizChart = function() { return false; };
  49. /*
  50. Parameters: none
  51. Returns: object reference to html <td> element
  52. */
  53. CSelectionObject.prototype.getCellRef = function()
  54. {
  55. return this.m_oCellRef;
  56. };
  57. /**
  58. * Get the original data item name (before renamed)
  59. * */
  60. CSelectionObject.prototype.getColumnRP_Name = function()
  61. {
  62. if(this.m_oCellRef != null){
  63. return this.m_oCellRef.getAttribute("rp_name");
  64. }
  65. };
  66. /*
  67. Parameters: none
  68. Returns: string
  69. */
  70. CSelectionObject.prototype.getColumnRef = function()
  71. {
  72. return this.m_sColumnRef;
  73. };
  74. /*
  75. Parameters: none
  76. Returns: string
  77. */
  78. CSelectionObject.prototype.getColumnName = function()
  79. {
  80. if (this.m_sColumnName == "")
  81. {
  82. if (this.m_selectionController.hasContextData() && this.m_contextIds.length)
  83. {
  84. this.m_sColumnName = this.m_selectionController.getRefDataItem(this.m_contextIds[0][0]);
  85. }
  86. }
  87. return this.m_sColumnName;
  88. };
  89. CSelectionObject.prototype.getDataItemDisplayValue = function(containerReportInfo) {
  90. var aDataItems = this.getDataItems();
  91. var item = "";
  92. if (aDataItems && aDataItems[0] && aDataItems[0][0]) {
  93. item = this.getDataItems()[0][0];
  94. if (containerReportInfo && containerReportInfo.itemInfo && containerReportInfo.itemInfo.length) {
  95. var itemInfo = containerReportInfo.itemInfo;
  96. for (var i=0; i < itemInfo.length; i++) {
  97. if (itemInfo[i].item === item && itemInfo[i].itemLabel) {
  98. return itemInfo[i].itemLabel;
  99. }
  100. }
  101. }
  102. }
  103. return item;
  104. };
  105. /*
  106. Parameters: none
  107. Returns: array of strings
  108. */
  109. CSelectionObject.prototype.getDataItems = function()
  110. {
  111. if (!this.m_aDataItems.length) {
  112. this.fetchContextIds();
  113. for (var i = 0; i < this.m_contextIds.length; ++i) {
  114. this.m_aDataItems[this.m_aDataItems.length] = [];
  115. for (var j = 0; j < this.m_contextIds[i].length; ++j) {
  116. var contextId = this.m_contextIds[i][j];
  117. this.m_aDataItems[this.m_aDataItems.length-1].push(this.m_selectionController.isContextId(contextId)? this.m_selectionController.getRefDataItem(contextId) : "");
  118. }
  119. }
  120. }
  121. return this.m_aDataItems;
  122. };
  123. /*
  124. Parameters: none
  125. Returns: array of strings
  126. */
  127. CSelectionObject.prototype.getUseValues = function()
  128. {
  129. if (!this.m_aUseValues.length) {
  130. this.fetchContextIds();
  131. for (var i = 0; i < this.m_contextIds.length; ++i) {
  132. this.m_aUseValues[this.m_aUseValues.length] = [];
  133. for (var j = 0; j < this.m_contextIds[i].length; ++j) {
  134. var contextId = this.m_contextIds[i][j];
  135. this.m_aUseValues[this.m_aUseValues.length-1].push(this.m_selectionController.isContextId(contextId) ? this.m_selectionController.getUseValue(contextId) : "");
  136. }
  137. }
  138. }
  139. return this.m_aUseValues;
  140. };
  141. /*
  142. Parameters: none
  143. Returns: string
  144. */
  145. CSelectionObject.prototype.getCellTypeId = function()
  146. {
  147. return this.m_sCellTypeId;
  148. };
  149. /*
  150. Parameters: none
  151. Returns: array of strings
  152. */
  153. CSelectionObject.prototype.getDisplayValues = function()
  154. {
  155. return this.m_aDisplayValues;
  156. };
  157. /*
  158. Parameters: none
  159. Returns: string
  160. */
  161. CSelectionObject.prototype.getLayoutType = function()
  162. {
  163. return this.m_sLayoutType;
  164. };
  165. /*
  166. Parameters: none
  167. Returns: string
  168. */
  169. CSelectionObject.prototype.getTag = function()
  170. {
  171. return this.m_sTag;
  172. };
  173. /*
  174. Parameters: none
  175. Returns: Array
  176. */
  177. CSelectionObject.prototype.getMuns = function()
  178. {
  179. if (!this.m_aMuns.length) {
  180. this.fetchContextIds();
  181. for (var i = 0; i < this.m_contextIds.length; ++i) {
  182. this.m_aMuns[this.m_aMuns.length] = [];
  183. for (var j = 0; j < this.m_contextIds[i].length; ++j) {
  184. var contextId = this.m_contextIds[i][j];
  185. this.m_aMuns[this.m_aMuns.length-1].push(this.m_selectionController.isContextId(contextId) ? this.m_selectionController.getMun(contextId) : "");
  186. }
  187. }
  188. }
  189. return this.m_aMuns;
  190. };
  191. /*
  192. Parameters: none
  193. Returns: Array
  194. */
  195. CSelectionObject.prototype.getRefQueries = function()
  196. {
  197. if (!this.m_aRefQueries.length) {
  198. this.fetchContextIds();
  199. for (var i = 0; i < this.m_contextIds.length; ++i) {
  200. this.m_aRefQueries[this.m_aRefQueries.length] = [];
  201. for (var j = 0; j < this.m_contextIds[i].length; ++j) {
  202. var contextId = this.m_contextIds[i][j];
  203. this.m_aRefQueries[this.m_aRefQueries.length-1].push(this.m_selectionController.isContextId(contextId) ? this.m_selectionController.getRefQuery(contextId) : "");
  204. }
  205. }
  206. }
  207. return this.m_aRefQueries;
  208. };
  209. CSelectionObject.prototype.getDimensionalItems = function(sType)
  210. {
  211. var aItems = [];
  212. this.fetchContextIds();
  213. for (var i = 0; i < this.m_contextIds.length; ++i) {
  214. aItems[aItems.length] = [];
  215. for (var j = 0; j < this.m_contextIds[i].length; ++j) {
  216. var contextId = this.m_contextIds[i][j];
  217. var sItem = "";
  218. if(this.m_selectionController.isContextId(contextId))
  219. {
  220. switch(sType)
  221. {
  222. case "hun":
  223. sItem = this.m_selectionController.getHun(contextId);
  224. break;
  225. case "lun":
  226. sItem = this.m_selectionController.getLun(contextId);
  227. break;
  228. case "dun":
  229. sItem = this.m_selectionController.getDun(contextId);
  230. break;
  231. }
  232. }
  233. aItems[aItems.length-1].push(sItem);
  234. }
  235. }
  236. return aItems;
  237. };
  238. /*
  239. Parameters: none
  240. Returns: Array
  241. */
  242. CSelectionObject.prototype.getMetadataItems = function()
  243. {
  244. if (!this.m_aMetadataItems.length) {
  245. this.fetchContextIds();
  246. for (var i = 0; i < this.m_contextIds.length; ++i) {
  247. this.m_aMetadataItems[this.m_aMetadataItems.length] = [];
  248. for (var j = 0; j < this.m_contextIds[i].length; ++j) {
  249. var contextId = this.m_contextIds[i][j];
  250. var sMetaDataItem="";
  251. if(this.m_selectionController.isContextId(contextId))
  252. {
  253. var sLun = this.m_selectionController.getLun(contextId);
  254. var sHun = this.m_selectionController.getHun(contextId);
  255. if(sLun && sLun != "")
  256. {
  257. sMetaDataItem = sLun;
  258. }
  259. else if(sHun && sHun != "")
  260. {
  261. sMetaDataItem = sHun;
  262. }
  263. else
  264. {
  265. sMetaDataItem = this.m_selectionController.getQueryModelId(contextId);
  266. }
  267. }
  268. this.m_aMetadataItems[this.m_aMetadataItems.length-1].push(sMetaDataItem);
  269. }
  270. }
  271. }
  272. return this.m_aMetadataItems;
  273. };
  274. /*
  275. Parameters: none
  276. Returns: Array
  277. */
  278. CSelectionObject.prototype.getDrillOptions = function()
  279. {
  280. if (!this.m_aDrillOptions.length) {
  281. this.fetchContextIds();
  282. for (var i = 0; i < this.m_contextIds.length; ++i) {
  283. this.m_aDrillOptions[this.m_aDrillOptions.length] = [];
  284. for (var j = 0; j < this.m_contextIds[i].length; ++j) {
  285. var contextId = this.m_contextIds[i][j];
  286. this.m_aDrillOptions[this.m_aDrillOptions.length-1].push(this.m_selectionController.isContextId(contextId) ? this.m_selectionController.getDrillFlag(contextId) : 0);
  287. }
  288. }
  289. }
  290. return this.m_aDrillOptions;
  291. };
  292. /*
  293. Parameters: none
  294. Returns: array
  295. */
  296. CSelectionObject.prototype.getSelectedContextIds = function()
  297. {
  298. return this.m_contextIds;
  299. };
  300. CSelectionObject.prototype.fetchContextIds = function()
  301. {
  302. if (!this.m_fetchedContextIds && this.m_contextIds.length && this.m_selectionController.hasContextData())
  303. {
  304. var fetchContextIds = [];
  305. for (var i = 0; i < this.m_contextIds.length; i++) {
  306. for (var j = 0; j < this.m_contextIds[i].length; j++) {
  307. fetchContextIds.push(this.m_contextIds[i][j]);
  308. }
  309. }
  310. this.m_selectionController.fetchContextData(fetchContextIds);
  311. this.m_fetchedContextIds = true;
  312. }
  313. };
  314. CSelectionObject.prototype.setSelectionController = function(sc) {
  315. if (sc) {
  316. this.m_selectionController = sc;
  317. }
  318. };
  319. CSelectionObject.prototype.getLayoutElementId = function() {
  320. return this.m_layoutElementId;
  321. };
  322. CSelectionObject.prototype.hasContextInformation = function() {
  323. for (var i=0; i < this.m_contextIds.length; i++)
  324. {
  325. for (var j=0; j < this.m_contextIds[i].length; j++)
  326. {
  327. if (this.m_contextIds[i][j].length > 0)
  328. {
  329. return true;
  330. }
  331. }
  332. }
  333. return false;
  334. };
  335. /**
  336. * Checks to see if the current selection is the home cell
  337. * @return true if the selection is on the home cell
  338. */
  339. CSelectionObject.prototype.isHomeCell = function() {
  340. var className = this.getCellRef().className;
  341. if (className && (className == "xm" || className.indexOf("xm ") != -1 || className.indexOf(" xm") != -1)) {
  342. return true;
  343. }
  344. return false;
  345. };
  346. CSelectionObject.prototype.getDataContainerType = function() {
  347. return this.m_dataContainerType;
  348. };
  349. /*
  350. * Returns an object with name/value pairs of the context ids of this object
  351. *
  352. * Refer this file for structure: http://c3/teams/BUX/Public%20Documents/Caspian/Design%20Documents/GenericWidgetContextEvents.xls
  353. */
  354. CSelectionObject.prototype.getContextJsonObject = function(oSelectionController, modelPath) {
  355. if (this.m_oJsonContext === null) {
  356. var nameValueObj = {};
  357. var aItemSpecValues = [];
  358. var selectedItemName = null;
  359. this.getDataItems(); //Invoke to populate data-items. AS report might not have them yet.
  360. this.getUseValues(); //Invoke to populate use-values
  361. if (this.m_contextIds.length == 0) {
  362. return null;
  363. }
  364. var i=0, j=0;
  365. var itemName = this._getBestPossibleItemName(this.m_aDataItems[i][j], this.m_contextIds[i][j], oSelectionController);
  366. selectedItemName = itemName;
  367. this._populateJsonContextObj(itemName, this.m_aUseValues[i][j], oSelectionController.getDisplayValue(this.m_contextIds[i][j]), oSelectionController.getMun(this.m_contextIds[i][j]), nameValueObj, aItemSpecValues);
  368. j++;
  369. for ( ; i < this.m_aDataItems.length; i++, j=0) {
  370. for ( ; j < this.m_aDataItems[i].length; j++) {
  371. itemName = this._getBestPossibleItemName(this.m_aDataItems[i][j], this.m_contextIds[i][j], oSelectionController);
  372. // this is only necessary for area map since the first context id is empty string.
  373. if( !selectedItemName ){ selectedItemName = itemName; }
  374. this._populateJsonContextObj(itemName, this.m_aUseValues[i][j], oSelectionController.getDisplayValue(this.m_contextIds[i][j]), oSelectionController.getMun(this.m_contextIds[i][j]), nameValueObj, aItemSpecValues);
  375. }
  376. }
  377. this.m_oJsonContext = this._createGenericPayloadStructureJson(selectedItemName, nameValueObj, aItemSpecValues, modelPath);
  378. }
  379. return this.m_oJsonContext;
  380. };
  381. CSelectionObject.prototype._getBestPossibleItemName = function(itemName, ctxId, oSelectionController) {
  382. var bestItemName = null;
  383. if (oSelectionController.isMeasure(ctxId)) {
  384. if (! oSelectionController.isValidColumnTitle(this.m_oCellRef) ) {
  385. if (! oSelectionController.isRelational([ctxId] )) {
  386. //Dimensional Measure
  387. bestItemName = oSelectionController.getCCDManager().GetBestPossibleDimensionMeasureName(ctxId);
  388. }
  389. return (bestItemName) ? bestItemName : itemName;
  390. }
  391. }
  392. bestItemName = oSelectionController.getCCDManager().GetBestPossibleItemName(ctxId);
  393. return (bestItemName) ? bestItemName : itemName;
  394. };
  395. CSelectionObject.prototype._isTypeColumnTitle = function() {
  396. //Check for getAttribute function's presence for a slice of chart because m_oCellRef is an empty object
  397. if (this.m_oCellRef && typeof this.m_oCellRef.getAttribute == 'function') {
  398. return (this.m_oCellRef.getAttribute('type') ==='columnTitle');
  399. }
  400. return false;
  401. };
  402. /*
  403. * Populates a property with itemName in the passed obj and detailObj.
  404. *
  405. * If itemName is already present in the obj, do not overwrite.
  406. * Use displayValue if present over useValue
  407. *
  408. */
  409. CSelectionObject.prototype._populateJsonContextObj = function(itemName, useValue, displayValue, mun, nameValueObj, aItemSpecValues) {
  410. if (nameValueObj && aItemSpecValues && itemName && typeof nameValueObj[itemName] == 'undefined') {
  411. var value = displayValue? displayValue: useValue;
  412. nameValueObj[itemName] = [value]; //should be array
  413. var detailObj = {};
  414. if (displayValue) {
  415. detailObj['caption'] = displayValue;
  416. }
  417. if (mun) {
  418. detailObj['mun'] = mun;
  419. }
  420. if (useValue) {
  421. detailObj['use'] = useValue;
  422. }
  423. aItemSpecValues.push(detailObj);
  424. }
  425. };
  426. CSelectionObject.prototype._createGenericPayloadStructureJson = function(selectedItemName, nameValueObject, aItemSpecValues, modelPath) {
  427. if (selectedItemName && nameValueObject && aItemSpecValues ) {
  428. var modelPathName = (modelPath)? modelPath : ".";
  429. var itemSpecObj = {};
  430. itemSpecObj[modelPathName] = {"values": aItemSpecValues};
  431. var obj = {
  432. "com.ibm.widget.context": {
  433. "values": nameValueObject
  434. },
  435. "com.ibm.widget.context.report.select": {
  436. "select": {
  437. "selectedItem": selectedItemName,
  438. "itemSpecification": itemSpecObj
  439. }
  440. }
  441. };
  442. return obj;
  443. }
  444. return null;
  445. };
  446. /*
  447. * For discrete data only, populate name/value pair and detail item spec into passed objects,
  448. *
  449. * @param nameValueObj - used in common part of generic payload
  450. * @param itemSpecObj - used in detail selection part of generic payload
  451. *
  452. */
  453. CSelectionObject.prototype.populateSelectionPayload = function(nameValueObj, itemSpecObj, bExcludeContext) {
  454. this.getDataItems(); //Invoke to populate data-items. AS report might not have them yet.
  455. this.getUseValues(); //Invoke to populate use-values
  456. if (this.m_contextIds.length == 0) {
  457. return false;
  458. }
  459. bExcludeContext = (( bExcludeContext === undefined ) ? false : bExcludeContext );
  460. var oSelectionController = this.m_selectionController;
  461. for (var i=0, j=0 ; i < this.m_aDataItems.length; i++, j=0)
  462. {
  463. var noOfDataItems = ( bExcludeContext ? 1 : this.m_aDataItems[i].length );
  464. for ( ; j < noOfDataItems; j++) {
  465. if (!oSelectionController.isMeasure(this.m_contextIds[i][j])) {
  466. var itemName = this.m_aDataItems[i][j];
  467. this._populateItemInSelectionPayload(itemName, this.m_aUseValues[i][j], oSelectionController.getDisplayValue(this.m_contextIds[i][j]), oSelectionController.getMun(this.m_contextIds[i][j]), nameValueObj, itemSpecObj);
  468. }
  469. }
  470. }
  471. return true;
  472. };
  473. /*
  474. * Populates discrete data of it into two objects, one used in common part of generic payload,
  475. * and another used in detail selection part of generic payload
  476. *
  477. * @param nameValueObj - used in common part of generic payload
  478. * @param itemSpecObj - used in detail selection part of generic payload
  479. *
  480. */
  481. CSelectionObject.prototype._populateItemInSelectionPayload = function(itemName, useValue, displayValue, mun, nameValueObj, itemSpecObj) {
  482. if (nameValueObj && itemName ) {
  483. var value = useValue? useValue : displayValue;
  484. if(nameValueObj[itemName]) {
  485. nameValueObj[itemName].push(value);
  486. } else {
  487. nameValueObj[itemName] = [value]; //should be array
  488. }
  489. var detailObj = {};
  490. detailObj['caption'] = value;
  491. if (mun) {
  492. detailObj['mun'] = mun;
  493. }
  494. var itemSpecValuesObj = itemSpecObj[itemName];
  495. if (!itemSpecValuesObj) {
  496. itemSpecValuesObj = {'values': []};
  497. itemSpecObj[itemName] = itemSpecValuesObj;
  498. }
  499. itemSpecValuesObj.values.push(detailObj);
  500. }
  501. };
  502. CSelectionObject.prototype.getCtxAttributeString = function() {
  503. return this.m_ctxAttributeString;
  504. };
  505. CSelectionObject.prototype.isDataValueOrChartElement = function(){
  506. return (this.m_sLayoutType === 'datavalue' || this.m_sLayoutType === 'chartElement' )
  507. };
  508. /*
  509. * Creates a JSON object with enough details so that could be re-maped to new set of cd and md if all attributes exists in new set
  510. */
  511. CSelectionObject.prototype.marshal = function(oSelectionController, sCVid) {
  512. if (!this.m_oJsonForMarshal) {
  513. var nameValueObj = {};
  514. var aItemSpecValues = [];
  515. var selectedItemName = null;
  516. this.getDataItems(); //Invoke to populate data-items. AS report might not have them yet.
  517. this.getUseValues(); //Invoke to populate use-values
  518. if (this.m_contextIds.length == 0) {
  519. return null;
  520. }
  521. var i=0, j=0;
  522. //ctx attribute could be [[""], ["22"], [""]]
  523. //make sure i,j are starting with not-empty
  524. if (this.m_contextIds[i][j].length == 0) {
  525. var foundValue = false;
  526. do {
  527. for ( ; j < this.m_contextIds[i].length; j++) {
  528. if (this.m_contextIds[i][j].length > 0 ) {
  529. foundValue = true;
  530. break;
  531. }
  532. }
  533. if (!foundValue) {
  534. j=0;
  535. i++;
  536. }
  537. } while (!foundValue)
  538. }
  539. var itemName = this._getBestPossibleItemName(this.m_aDataItems[i][j], this.m_contextIds[i][j], oSelectionController);
  540. var isMeasure = oSelectionController.isMeasure(this.m_contextIds[i][j]);
  541. var itemRef = this._getBestPossibleItemReference(this.m_contextIds[i][j], isMeasure, oSelectionController.getCCDManager());
  542. var queryName = oSelectionController.getCCDManager().GetQuery(this.m_contextIds[i][j]);
  543. var isDataValueOrChartElement = this.isDataValueOrChartElement();
  544. var oSelectedItem = this._populateJsonForMarshal(itemName, itemRef, isMeasure, this.m_aUseValues[i][j], oSelectionController.getDisplayValue(this.m_contextIds[i][j]), oSelectionController.getMun(this.m_contextIds[i][j]), isDataValueOrChartElement );
  545. j++;
  546. var aContext = [];
  547. for ( ; i < this.m_aDataItems.length; i++, j=0) {
  548. for ( ; j < this.m_aDataItems[i].length; j++) {
  549. itemName = this._getBestPossibleItemName(this.m_aDataItems[i][j], this.m_contextIds[i][j], oSelectionController);
  550. isMeasure = oSelectionController.isMeasure(this.m_contextIds[i][j]);
  551. itemRef = this._getBestPossibleItemReference(this.m_contextIds[i][j], isMeasure, oSelectionController.getCCDManager());
  552. var oContext = this._populateJsonForMarshal(itemName, itemRef, isMeasure, this.m_aUseValues[i][j], oSelectionController.getDisplayValue(this.m_contextIds[i][j]), oSelectionController.getMun(this.m_contextIds[i][j]));
  553. if (oContext) {
  554. aContext.push(oContext);
  555. }
  556. }
  557. }
  558. var lid = (typeof this.getArea == 'function') ? getImmediateLayoutContainerId(this.getArea()) : getImmediateLayoutContainerId(this.getCellRef());
  559. if (lid && lid.indexOf(sCVid)>0) {
  560. lid = lid.substring(0, lid.indexOf(sCVid)-1); //remove CV id
  561. }
  562. this.m_oJsonForMarshal = {
  563. 'lid': lid, //Do not use this - this.getLayoutElementId(),
  564. 'query': queryName,
  565. 'selectedItem': oSelectedItem,
  566. 'context': aContext
  567. };
  568. }
  569. return this.m_oJsonForMarshal;
  570. };
  571. CSelectionObject.prototype._populateJsonForMarshal = function(itemName, itemRefObj, isMeasure, useValue, displayValue, mun, isDataValueOrChartElement) {
  572. if (itemName) {
  573. var detailObj = {};
  574. detailObj['itemName'] = itemName;
  575. detailObj['isMeasure'] = isMeasure? 'true' : 'false'; //use string so that can be saved in itemset
  576. detailObj['mdProperty'] = itemRefObj.mdProperty;
  577. detailObj['mdValue'] = itemRefObj.mdValue;
  578. detailObj['isDataValueOrChartElement'] = isDataValueOrChartElement ? 'true' : 'false'
  579. /*if (displayValue) {
  580. detailObj['caption'] = displayValue;
  581. }*/
  582. if (mun) {
  583. detailObj['mun'] = mun;
  584. }
  585. if (useValue) {
  586. detailObj['use'] = useValue;
  587. }
  588. return detailObj;
  589. }
  590. return null;
  591. };
  592. CSelectionObject.prototype._getBestPossibleItemReference = function(ctxId, isMeasure, oCCDManager) {
  593. var bestItemRef = null;
  594. var property = null;
  595. if (isMeasure) {
  596. //Search in order of ["i", "m", "r"]
  597. property = "i";
  598. bestItemRef = oCCDManager.GetQMID(ctxId); /* i value */
  599. if(bestItemRef == null) {
  600. property = "m";
  601. bestItemRef = oCCDManager.GetMUN(ctxId); /* m value */
  602. }
  603. if(bestItemRef == null) {
  604. property = "r";
  605. bestItemRef = oCCDManager.GetRDIValue(ctxId); /* r value */
  606. }
  607. } else {
  608. //Search in order of ["l", "h", "i", "r"]
  609. property = "l";
  610. bestItemRef = oCCDManager.GetLUN(ctxId); /* l value */
  611. if(bestItemRef == null) {
  612. property = "h";
  613. bestItemRef = oCCDManager.GetHUN(ctxId); /* h value */
  614. }
  615. if(bestItemRef == null) {
  616. property = "i";
  617. bestItemRef = oCCDManager.GetQMID(ctxId); /* i value */
  618. }
  619. if(bestItemRef == null) {
  620. property = "r";
  621. bestItemRef = oCCDManager.GetRDIValue(ctxId); /* r value */
  622. }
  623. }
  624. return {'mdProperty': property, 'mdValue': bestItemRef};
  625. };
  626. //
  627. // This class represents the basic representation of a chart selection object.
  628. //
  629. /*
  630. Constructor.
  631. Parameters:
  632. Returns:
  633. */
  634. // set up the base class
  635. CSelectionChartObject.prototype = new CSelectionObject();
  636. CSelectionChartObject.prototype.constructor = CSelectionChartObject;
  637. CSelectionChartObject.baseclass = CSelectionObject.prototype;
  638. function CSelectionChartObject()
  639. {
  640. // initialize the base class
  641. CSelectionChartObject.baseclass.initialize.call(this);
  642. this.m_chartArea = null;
  643. this.m_context = "";
  644. this.m_chartCtxAreas = [];
  645. this.m_selectedVizChart = false;
  646. }
  647. CSelectionChartObject.prototype.isSelectionOnVizChart = function() {
  648. return this.m_selectedVizChart;
  649. };
  650. CSelectionChartObject.prototype.setSelectionOnVizChart = function(chartNode) {
  651. var imageNode = this.m_selectionController.getSelectedChartImageFromChartArea(chartNode);
  652. if (imageNode) {
  653. this.m_selectedVizChart = imageNode.parentNode.getAttribute("vizchart") == "true" ? true : false;
  654. }
  655. };
  656. CSelectionChartObject.prototype.getArea = function()
  657. {
  658. return this.m_chartArea;
  659. };
  660. CSelectionChartObject.prototype.getContext = function()
  661. {
  662. return this.m_context;
  663. };
  664. CSelectionChartObject.prototype.getCtxAreas = function()
  665. {
  666. return this.m_chartCtxAreas;
  667. };
  668. CSelectionChartObject.prototype.setCtxAreas = function(ctxAreas)
  669. {
  670. this.m_chartCtxAreas = ctxAreas;
  671. };
  672. CSelectionChartObject.prototype.getCtxAttributeString = function() {
  673. return this.m_context;
  674. };
  675. /**
  676. * This class contains the objects that help with chart selection
  677. * @param chartArea
  678. * @param cognosViewer
  679. * @returns {CChartHelper}
  680. */
  681. function CChartHelper(chartArea, selectionObjectFactory, cognosViewer){
  682. var imageMap = chartArea.parentNode;
  683. this.m_selectionObjectFactory = selectionObjectFactory;
  684. this.m_map = imageMap;
  685. cognosViewer.loadExtra();
  686. this.imageMapHighlighter = new CImageMapHighlight(imageMap, cognosViewer.sWebContentRoot);
  687. this.initialize();
  688. }
  689. CChartHelper.prototype.initialize = function() {
  690. this.buildMapCtxAreas();
  691. this.m_chartCtxNodes = {};
  692. };
  693. /**
  694. * Scan the map and build and object with all unique context as properties names, and an array of the
  695. * areas with that context as value
  696. */
  697. CChartHelper.prototype.buildMapCtxAreas = function() {
  698. var ctxAreas = {};
  699. var areas = this.m_map.childNodes;
  700. var areaCount = areas.length;
  701. var areaCtx = null;
  702. for (var i=0; i<areaCount; i++ ) {
  703. var a = areas[i];
  704. areaCtx = a.getAttribute("ctx");
  705. if (areaCtx) {
  706. if (ctxAreas[areaCtx]) {
  707. ctxAreas[areaCtx].push(a);
  708. } else {
  709. ctxAreas[areaCtx] = [a];
  710. }
  711. }
  712. }
  713. this.m_ctxAreas = ctxAreas;
  714. };
  715. CChartHelper.prototype.getChartNode = function(chartArea)
  716. {
  717. if (!this.isAreaInitialized(chartArea)) {
  718. var imageMap = chartArea.parentNode;
  719. this.m_map = imageMap;
  720. this.initialize();
  721. this.imageMapHighlighter.initialize(imageMap);
  722. }
  723. var areaCtx = chartArea.getAttribute("ctx");
  724. if (!this.m_chartCtxNodes[areaCtx]) {
  725. this.m_chartCtxNodes[areaCtx] = this.m_selectionObjectFactory.getSelectionChartObject(chartArea);
  726. this.m_chartCtxNodes[areaCtx].setCtxAreas(this.m_ctxAreas[areaCtx]);
  727. }
  728. return this.m_chartCtxNodes[areaCtx];
  729. };
  730. CChartHelper.prototype.isAreaInitialized = function(chartArea) {
  731. return this.imageMapHighlighter.isAreaInitialized(chartArea);
  732. };
  733. CChartHelper.prototype.getImageMapHighlighter = function() {
  734. return this.imageMapHighlighter;
  735. };
  736. //
  737. // This class creates a factory for selection objects.
  738. //
  739. /*
  740. Constructor.
  741. Parameters:
  742. Returns: selection object factory
  743. */
  744. function CSelectionObjectFactory(selectionController)
  745. {
  746. this.m_selectionController = selectionController;
  747. }
  748. CSelectionObjectFactory.prototype.getSelectionController = function()
  749. {
  750. return this.m_selectionController;
  751. };
  752. /*
  753. * Retrieves span tags from inside the target tag, but excluding any
  754. * inside a different layout element id.
  755. * Parameters: target, an HTML Element
  756. * Returns: an array of span HTML Elements
  757. */
  758. CSelectionObjectFactory.prototype.getChildSpans = function(target) {
  759. var toVisit = [];
  760. for(var i = 0; i < target.childNodes.length; i++) {
  761. var child = target.childNodes[i];
  762. if (!child.getAttribute || child.getAttribute("skipSelection") != "true") {
  763. toVisit.push(target.childNodes[i]);
  764. }
  765. }
  766. //Find the layout element id associated with target
  767. var targetParent = target;
  768. var targetLid = "";
  769. while(!targetLid && targetParent) {
  770. targetLid = targetParent.attributes ? targetParent.attributes["LID"] : "";
  771. targetParent = targetParent.parentNode;
  772. }
  773. targetLid = targetLid ? targetLid.value : "";
  774. //Get children
  775. var allChildren = [];
  776. while(toVisit.length > 0) {
  777. var child = toVisit.pop();
  778. var lid = child.attributes ? child.attributes["LID"] : "";
  779. lid = lid ? lid.value : "";
  780. //Omit children under a different layout element id
  781. if(!lid || lid == targetLid) {
  782. //Record all span tags
  783. if(child.nodeName.toLowerCase() == "span") {
  784. allChildren.push(child);
  785. }
  786. else {
  787. for(i = 0; i < child.childNodes.length; i++) {
  788. toVisit.push(child.childNodes[i]);
  789. }
  790. }
  791. }
  792. }
  793. return allChildren;
  794. };
  795. /*
  796. Parameters:
  797. cellRef - an HTML reference to a <td> element
  798. Returns: selection object
  799. */
  800. CSelectionObjectFactory.prototype.getSelectionObject = function(cellRef, matchOnCTX) {
  801. var newSelObj = new CSelectionObject();
  802. try{
  803. newSelObj.setSelectionController(this.getSelectionController());
  804. newSelObj.m_oCellRef = cellRef;
  805. newSelObj.m_sColumnRef = cellRef.getAttribute("cid");
  806. newSelObj.m_sCellTypeId = cellRef.getAttribute("uid");
  807. newSelObj.m_sLayoutType = cellRef.getAttribute("type");
  808. newSelObj.m_sTag = cellRef.getAttribute("tag");
  809. newSelObj.m_layoutElementId = this.getLayoutElementId(cellRef);
  810. newSelObj.m_dataContainerType = this.getContainerType(cellRef);
  811. //Query Studio specific code
  812. if (typeof cf != "undefined")
  813. {
  814. var miniQueryObj = cf.cfgGet("MiniQueryObj");
  815. if(miniQueryObj)
  816. {
  817. var tagElement = miniQueryObj.findChildWithAttribute("tag", newSelObj.m_sTag);
  818. if(tagElement && tagElement.getAttribute("id") != null)
  819. {
  820. newSelObj.m_sColumnName = tagElement.getAttribute("id");
  821. }
  822. }
  823. }
  824. //get all of the child textItem nodes which are not of a different layout id
  825. var allChildren = this.getChildSpans(cellRef);
  826. if (allChildren.length > 0)
  827. {
  828. for (var i = 0; i < allChildren.length; i++)
  829. {
  830. var oChild = allChildren[i];
  831. if (oChild.nodeType == 1 && oChild.nodeName.toLowerCase() == "span" && oChild.style.visibility != "hidden")
  832. {
  833. var contextNode = null;
  834. if (cellRef.getAttribute("ctx") != null && cellRef.getAttribute("ctx") != "") {
  835. contextNode = cellRef;
  836. }
  837. else if(oChild.getAttribute("ctx") != null && oChild.getAttribute("ctx") != "") {
  838. contextNode = oChild;
  839. }
  840. else if(oChild.getAttribute("dtTargets") && oChild.childNodes && oChild.childNodes.length) {
  841. for (var idxCN = 0; idxCN < oChild.childNodes.length; idxCN++)
  842. {
  843. if (oChild.childNodes[idxCN].nodeType == 1 && oChild.childNodes[idxCN].style.visibility != "hidden") {
  844. contextNode = oChild.childNodes[idxCN];
  845. }
  846. }
  847. } else {
  848. // for saved outputs with authored drill through we'll have a span within a span. The CTX attribute
  849. // will be on the inner span so go find it.
  850. for (var childIndex = 0; childIndex < oChild.childNodes.length; childIndex++) {
  851. var nestedChild = oChild.childNodes[childIndex];
  852. if(typeof nestedChild.getAttribute != "undefined" && nestedChild.getAttribute("ctx") != null && nestedChild.getAttribute("ctx") != "") {
  853. contextNode = nestedChild;
  854. break;
  855. }
  856. }
  857. }
  858. var context = "";
  859. if(contextNode && contextNode.getAttribute("ctx"))
  860. {
  861. context = contextNode.getAttribute("ctx");
  862. }
  863. newSelObj.m_aDisplayValues[newSelObj.m_aDisplayValues.length] = this.getSelectionController().getDisplayValue(context, cellRef.parentNode);
  864. // Check to see if we're explicity matching on a ctx id. If we are and we don't match, move on to the next node
  865. if(typeof matchOnCTX != "undefined" && matchOnCTX != context) {
  866. continue;
  867. }
  868. newSelObj = this.processCTX(newSelObj, context);
  869. }
  870. }
  871. }
  872. else if(cellRef.getAttribute("ctx") != null && cellRef.getAttribute("ctx") != "" && newSelObj.m_sLayoutType == "datavalue")
  873. {
  874. newSelObj = this.processCTX(newSelObj, cellRef.getAttribute("ctx"));
  875. }
  876. this.getSelectionController().processColumnTitleNode(newSelObj);
  877. }catch(ex) {
  878. // sometimes node may not be an HTML element (like a XUL element) and accessing nodeType/nodeName/className will generate an error.
  879. }
  880. return newSelObj;
  881. };
  882. /*
  883. Parameters:
  884. selObj - a CSelectionObject object
  885. context - the ctx attribute from the span or td
  886. Returns: selection object
  887. */
  888. CSelectionObjectFactory.prototype.processCTX = function(selObj, context)
  889. {
  890. if (typeof context != "string" || context.length == 0)
  891. {
  892. return selObj;
  893. }
  894. var ctx;
  895. // A:B::C:D::E becomes [[A,B],[C,D],[E]]
  896. if (typeof selObj.m_contextIds == "object" && selObj.m_contextIds !== null && selObj.m_contextIds.length > 0)
  897. {
  898. var tempContextIds = context.split("::");
  899. for(ctx = 0; ctx < selObj.m_contextIds.length; ++ctx)
  900. {
  901. try
  902. {
  903. if (tempContextIds[ctx])
  904. {
  905. selObj.m_contextIds[ctx] = selObj.m_contextIds[ctx].concat(tempContextIds[ctx].split(":"));
  906. }
  907. }
  908. catch (e)
  909. {
  910. }
  911. }
  912. }
  913. else
  914. {
  915. selObj.m_contextIds = this.m_selectionController.m_oCognosViewer.getReportContextHelper().processCtx(context);
  916. }
  917. selObj.m_ctxAttributeString = context;
  918. return selObj;
  919. };
  920. /*
  921. Parameters:
  922. tag - a reference to the column
  923. Returns: selection object
  924. */
  925. CSelectionObjectFactory.prototype.getSecondarySelectionObject = function(tag, layoutType, theDocument)
  926. {
  927. if (!theDocument) {
  928. theDocument = document;
  929. }
  930. var newSelObj = new CSelectionObject();
  931. newSelObj.setSelectionController(this.getSelectionController());
  932. // Non-default initialization
  933. newSelObj.m_oCellRef = null;
  934. newSelObj.m_sColumnRef = null;
  935. newSelObj.m_sCellTypeId = null;
  936. newSelObj.refQuery = "";
  937. var allTds = theDocument.getElementsByTagName("td");
  938. // Figure out from the secondary selection what needs to be selected
  939. for (var i = 0; i < allTds.length; i++)
  940. {
  941. var colTag = allTds[i].getAttribute("tag");
  942. if (colTag != null && colTag != "")
  943. {
  944. if (tag == colTag)
  945. {
  946. var colClass = allTds[i].className;
  947. if (colClass != null && colTag != "")
  948. {
  949. if ((layoutType == "columnTitle" && colClass == "lt") || (layoutType == "datavalue" && colClass == "lc"))
  950. {
  951. newSelObj.m_sColumnRef = allTds[i].getAttribute("cid");
  952. newSelObj.m_sCellTypeId = allTds[i].getAttribute("uid");
  953. break;
  954. }
  955. }
  956. }
  957. }
  958. }
  959. if (newSelObj.m_sCellTypeId == null) {
  960. return null;
  961. }
  962. return newSelObj;
  963. };
  964. CSelectionObjectFactory.prototype.getSelectionChartObject = function(chartNode)
  965. {
  966. var contextIds = "";
  967. if(chartNode.getAttribute("flashChart") != null)
  968. {
  969. if(typeof chartNode.getCtx != "undefined")
  970. {
  971. try
  972. {
  973. contextIds = chartNode.getCtx();
  974. }
  975. catch(e)
  976. {
  977. contextIds ="";
  978. }
  979. }
  980. }
  981. else
  982. {
  983. contextIds = chartNode.getAttribute("ctx");
  984. }
  985. var newSelObj = new CSelectionChartObject();
  986. newSelObj.setSelectionController(this.getSelectionController());
  987. if(contextIds != null)
  988. {
  989. newSelObj.m_contextIds = contextIds.split("::");
  990. for(var ctx = 0; ctx < newSelObj.m_contextIds.length; ++ctx)
  991. {
  992. newSelObj.m_contextIds[ctx] = newSelObj.m_contextIds[ctx].split(":");
  993. }
  994. }
  995. newSelObj.m_layoutElementId = this.getLayoutElementId(chartNode);
  996. newSelObj.m_sLayoutType = chartNode.getAttribute("type");
  997. newSelObj.m_chartArea = chartNode;
  998. newSelObj.m_context = contextIds;
  999. newSelObj.setSelectionOnVizChart(chartNode);
  1000. return newSelObj;
  1001. };
  1002. CSelectionObjectFactory.prototype.getContainerTypeFromClass = function(className)
  1003. {
  1004. var containerType = "";
  1005. switch(className)
  1006. {
  1007. case "ls":
  1008. containerType = "list";
  1009. break;
  1010. case "xt":
  1011. containerType = "crosstab";
  1012. break;
  1013. case "rt":
  1014. containerType = "repeaterTable";
  1015. break;
  1016. }
  1017. return containerType;
  1018. };
  1019. //get the container type
  1020. CSelectionObjectFactory.prototype.getContainerType = function(el) {
  1021. var type = "";
  1022. if (el) {
  1023. if (el.className) {
  1024. type = this.getContainerTypeFromClass(el.className);
  1025. }
  1026. if (!type) {
  1027. var parentNode = el.parentNode;
  1028. if (parentNode) {
  1029. type = this.getContainerType(parentNode);
  1030. }
  1031. }
  1032. }
  1033. return type;
  1034. };
  1035. //get the unique ID for the layout object.
  1036. CSelectionObjectFactory.prototype.getLayoutElementId = function(el) {
  1037. var id = "";
  1038. var viewerId = this.getSelectionController().getNamespace();
  1039. if (el) {
  1040. if (el.getAttribute && el.getAttribute("chartcontainer") == "true") {
  1041. for (var childIndex=0; childIndex < el.childNodes.length; childIndex++) {
  1042. var childNode = el.childNodes[childIndex];
  1043. if (childNode.nodeName.toLowerCase() == "img" && childNode.getAttribute("lid") != null) {
  1044. return childNode.getAttribute("lid");
  1045. }
  1046. }
  1047. }
  1048. id = (el.getAttribute && el.getAttribute("LID")) || "";
  1049. if (!id) {
  1050. var parentNode = el.parentNode;
  1051. if (parentNode) {
  1052. id = this.getLayoutElementId(parentNode);
  1053. }
  1054. } else if(el.tagName.toUpperCase() == "MAP") {
  1055. // temporary until we get rsvp to update v5ReportEngine.xsl
  1056. id = id.replace(viewerId, "");
  1057. id = viewerId + id;
  1058. // end of temp code
  1059. var imageMapName = "#" + id;
  1060. var imgNodes = getElementsByAttribute(el.parentNode, "IMG", "usemap", imageMapName);
  1061. if (imgNodes.length > 0)
  1062. {
  1063. id = imgNodes[0].getAttribute("LID");
  1064. }
  1065. }
  1066. }
  1067. return id;
  1068. };
  1069. //
  1070. // This class creates a controller for all of the selection objects.
  1071. //
  1072. /*
  1073. Constructor.
  1074. Parameters:
  1075. Returns: selection controller
  1076. */
  1077. function CSelectionController(sNamespace, oCognosViewer)
  1078. {
  1079. this.m_bSelectionBasedFeaturesEnabled = false;
  1080. this.m_bDrillUpDownEnabled = false;
  1081. this.m_bModelDrillThroughEnabled = false;
  1082. this.m_oCognosViewer = null;
  1083. this.m_bSavedSelections = false;
  1084. if (oCognosViewer) {
  1085. this.m_oCognosViewer = oCognosViewer;
  1086. }
  1087. this.initialize(sNamespace);
  1088. this.FILTER_SELECTION_STYLE = 0;
  1089. this.FILTER_SELECTION_CONTEXT_MENU_STYLE = 1;
  1090. }
  1091. CSelectionController.prototype.initialize = function(sNamespace)
  1092. {
  1093. this.m_sNamespace = sNamespace;
  1094. this.m_aCutColumns = [];
  1095. this.m_aSelectedObjects = [];
  1096. this.m_selectedClass = [];
  1097. this.m_cutClass = [];
  1098. this.m_oObserver = new CObserver(this);
  1099. this.m_bSelectionArraysSetup = false;
  1100. this.m_aSelectionHoverNodes = [];
  1101. //deprecated
  1102. this.m_bUsingCCDManager = false; //This bool can go when we switch to JSON format exclusively
  1103. this.m_aReportMetadataArray = [];
  1104. this.m_aReportContextDataArray = [];
  1105. //JSON
  1106. this.m_oCDManager = new CCDManager();
  1107. this.m_oSelectionObjectFactory = new CSelectionObjectFactory(this);
  1108. this.m_selectedChartArea = null;
  1109. this.m_selectedChartNodes = [];
  1110. this.m_selectionContainerMap = null;
  1111. this.m_chartHelpers = {};
  1112. if(this.m_oCognosViewer != null)
  1113. {
  1114. this.m_oCDManager.SetCognosViewer(this.m_oCognosViewer);
  1115. }
  1116. this.m_maxSecondarySelection = -1;
  1117. this.c_usageMeasure = '2';
  1118. this.m_ccl_dateTypes = { 59:'dateTime', 60:'interval' };
  1119. this.m_selectionStyles = new CSelectionDefaultStyles( this );
  1120. this.m_originalSelectionStyles = this.m_selectionStyles;
  1121. this.m_bAllowHorizontalDataValueSelection = false;
  1122. };
  1123. CSelectionController.prototype.secondarySelectionIsDisabled = function(){
  1124. return this.m_selectionStyles.secondarySelectionIsDisabled();
  1125. };
  1126. CSelectionController.prototype.getPrimarySelectionColor = function(){
  1127. return this.m_selectionStyles.getPrimarySelectionColor();
  1128. };
  1129. CSelectionController.prototype.getHighContrastBorderStyle = function(){
  1130. return this.m_selectionStyles.getHighContrastBorderStyle();
  1131. };
  1132. CSelectionController.prototype.getSecondarySelectionColor = function(){
  1133. return this.m_selectionStyles.getSecondarySelectionColor();
  1134. };
  1135. CSelectionController.prototype.resetSelectionStyles = function(){
  1136. this.setSelectionStyles();
  1137. };
  1138. CSelectionController.prototype.setSelectionStyles = function( styleType ){
  1139. switch( styleType )
  1140. {
  1141. //case "filter":
  1142. case this.FILTER_SELECTION_STYLE:
  1143. {
  1144. if( !this.m_selectionFilterStyles ){
  1145. this.m_selectionFilterStyles = new CSelectionFilterStyles( this );
  1146. }
  1147. this.m_selectionStyles = this.m_selectionFilterStyles;
  1148. break;
  1149. }
  1150. //case "filterContextMenu":
  1151. case this.FILTER_SELECTION_CONTEXT_MENU_STYLE:
  1152. {
  1153. if( !this.m_selectionFilterContextMenuStyles ){
  1154. this.m_selectionFilterContextMenuStyles = new CSelectionFilterContextMenuStyles( this );
  1155. }
  1156. this.m_selectionStyles = this.m_selectionFilterContextMenuStyles;
  1157. break;
  1158. }
  1159. default:
  1160. this.m_selectionStyles = this.m_originalSelectionStyles;
  1161. }
  1162. };
  1163. CSelectionController.prototype.resetAllowHorizontalDataValueSelection = function()
  1164. {
  1165. this.m_bAllowHorizontalDataValueSelection = false;
  1166. };
  1167. CSelectionController.prototype.setAllowHorizontalDataValueSelection = function( bAllow)
  1168. {
  1169. this.m_bAllowHorizontalDataValueSelection = bAllow;
  1170. };
  1171. CSelectionController.prototype.allowHorizontalDataValueSelection = function()
  1172. {
  1173. return this.m_bAllowHorizontalDataValueSelection;
  1174. };
  1175. /**
  1176. * Resets the selection, note this function will NOT update the UI, it
  1177. * simply resets the internal selection array.
  1178. */
  1179. CSelectionController.prototype.clearSelectionData = function()
  1180. {
  1181. this.m_aSelectedObjects = [];
  1182. this.m_selectedChartNodes = [];
  1183. this.m_oSelectedDrillThroughImage = null;
  1184. this.m_oSelectedDrillThroughSingleton = null;
  1185. };
  1186. CSelectionController.prototype.getCCDManager = function()
  1187. {
  1188. return this.m_oCDManager;
  1189. };
  1190. CSelectionController.prototype.getCtxIdFromDisplayValue = function(sDisplayValue)
  1191. {
  1192. if (!this.m_bUsingCCDManager) {
  1193. var contextDataArray = this.getReportContextDataArray();
  1194. var CD_DISPLAY_VALUE_IDX = 1;
  1195. for (var sCtxId in contextDataArray)
  1196. {
  1197. var contextItem = contextDataArray[sCtxId];
  1198. if(contextItem[CD_DISPLAY_VALUE_IDX] == sDisplayValue) {
  1199. return sCtxId;
  1200. }
  1201. }
  1202. return "";
  1203. } else {
  1204. var sId = this.m_oCDManager.GetContextIdForDisplayValue(sDisplayValue);
  1205. return (sId == null) ? "" : sId;
  1206. }
  1207. };
  1208. CSelectionController.prototype.getCtxIdFromMetaData = function(sLun, sHun, bIgnoreDrillFlag)
  1209. {
  1210. return this.m_oCDManager.getContextIdForMetaData(sLun, sHun, bIgnoreDrillFlag);
  1211. };
  1212. /**
  1213. *replace the namespace substring if the passed in LUN or HUN are from a different namespace (but
  1214. *the shared TM1 dimension) compared with the metadata held by data manager instance
  1215. **/
  1216. CSelectionController.prototype.replaceNamespaceForSharedTM1DimensionOnly = function(lun, hun, mun)
  1217. {
  1218. var sLun = lun;
  1219. var sHun = hun;
  1220. if(mun && mun.indexOf("->:[TM].") > 0){
  1221. sLun = this.m_oCDManager._replaceNamespaceForSharedTM1DimensionOnly(lun);
  1222. sHun = this.m_oCDManager._replaceNamespaceForSharedTM1DimensionOnly(hun);
  1223. }
  1224. return { "lun" : sLun, "hun" :sHun};
  1225. };
  1226. CSelectionController.prototype.getCtxIdFromMun = function(sMun)
  1227. {
  1228. if (!this.m_bUsingCCDManager) {
  1229. var metaDataArray = this.getReportMetadataArray();
  1230. var MD_USE_VALUE_IDX = 0;
  1231. for(var sKey in metaDataArray)
  1232. {
  1233. var metaDataItem = metaDataArray[sKey];
  1234. if(metaDataItem[MD_USE_VALUE_IDX] == sMun)
  1235. {
  1236. var CD_METADATA_KEY_IDX = 2;
  1237. var contextDataArray = this.getReportContextDataArray();
  1238. for(var sCtxId in contextDataArray)
  1239. {
  1240. var contextItem = contextDataArray[sCtxId];
  1241. if(contextItem[CD_METADATA_KEY_IDX] == sKey) {
  1242. return sCtxId;
  1243. }
  1244. }
  1245. }
  1246. }
  1247. return "";
  1248. } else {
  1249. var sId = this.m_oCDManager.GetContextIdForMUN(sMun);
  1250. return (sId == null) ? "" : sId;
  1251. }
  1252. };
  1253. CSelectionController.prototype.canDrillDown = function(sCtxId)
  1254. {
  1255. var drillFlag = this.getDrillFlagForMember(sCtxId);
  1256. return (drillFlag == 3 || drillFlag == 2);
  1257. };
  1258. CSelectionController.prototype.canDrillUp = function(sCtxId)
  1259. {
  1260. var drillFlag = this.getDrillFlagForMember(sCtxId);
  1261. return (drillFlag == 3 || drillFlag == 1);
  1262. };
  1263. CSelectionController.prototype.getQueryModelId = function(sCtxId)
  1264. {
  1265. var qmid = "";
  1266. if (!this.m_bUsingCCDManager) {
  1267. var contextObj = this.m_aReportContextDataArray[sCtxId];
  1268. if(contextObj && typeof contextObj[3] != "undefined"){
  1269. var queryModelItemRefId = contextObj[3];
  1270. var contextQueryModelItem = this.m_aReportMetadataArray[queryModelItemRefId];
  1271. if(typeof contextQueryModelItem != "undefined" && typeof contextQueryModelItem[1] != "undefined" && contextQueryModelItem[1] == "I")
  1272. {
  1273. qmid = contextQueryModelItem[0];
  1274. }
  1275. }
  1276. } else {
  1277. qmid = this.m_oCDManager.GetQMID(sCtxId);
  1278. }
  1279. return qmid;
  1280. };
  1281. CSelectionController.prototype.getRefQuery = function(sCtxId)
  1282. {
  1283. if (!this.m_bUsingCCDManager) {
  1284. return this.getMetaDataItemUseValue(4/*ref query item reference*/, sCtxId);
  1285. } else {
  1286. var sRefQuery = this.m_oCDManager.GetQuery(sCtxId);
  1287. return (sRefQuery == null) ? "" : sRefQuery;
  1288. }
  1289. };
  1290. /**
  1291. @deprecated Use CCognosViewer.getReportContextHelper().getRefDataItem() instead
  1292. */
  1293. CSelectionController.prototype.getRefDataItem = function(sCtxId)
  1294. {
  1295. return this.m_oCognosViewer.getReportContextHelper().getRefDataItem(sCtxId);
  1296. };
  1297. /**
  1298. @deprecated Use CCognosViewer.getReportContextHelper().getMun() instead
  1299. */
  1300. CSelectionController.prototype.getMun = function(sCtxId)
  1301. {
  1302. return this.m_oCognosViewer.getReportContextHelper().getMun(sCtxId);
  1303. };
  1304. CSelectionController.prototype.getHun = function(sCtxId)
  1305. {
  1306. if (!this.m_bUsingCCDManager) {
  1307. var sHun = null;
  1308. var aData = this.getRDI(sCtxId);
  1309. if (aData && aData.length > 4 && aData[1] == "R") {
  1310. var sRefDataItem = aData[4];
  1311. var aReportMetadataArray = this.getReportMetadataArray();
  1312. aData = aReportMetadataArray[sRefDataItem];
  1313. }
  1314. if (aData && aData.length > 1 && aData[1] == "H")
  1315. {
  1316. sHun = aData[0];
  1317. }
  1318. return sHun;
  1319. } else {
  1320. return this.m_oCDManager.GetHUN(sCtxId);
  1321. }
  1322. };
  1323. CSelectionController.prototype.fetchContextData = function(fetchContextIds, callback)
  1324. {
  1325. var numberOfItemsWithNoContext = 0;
  1326. if (this.m_bUsingCCDManager) {
  1327. numberOfItemsWithNoContext = this.m_oCDManager.FetchContextData(fetchContextIds, callback);
  1328. }
  1329. return numberOfItemsWithNoContext;
  1330. };
  1331. //////////////////
  1332. // These can go once we have moved to JSON objects
  1333. CSelectionController.prototype.getMetaDataItem = function(sKey)
  1334. {
  1335. var metaDataArray = this.getReportMetadataArray();
  1336. if(typeof metaDataArray[sKey] != "undefined")
  1337. {
  1338. return metaDataArray[sKey];
  1339. }
  1340. return null;
  1341. };
  1342. CSelectionController.prototype.getContextDataItem = function(sCtxId)
  1343. {
  1344. var contextDataArray = this.getReportContextDataArray();
  1345. if(typeof contextDataArray[sCtxId] != "undefined")
  1346. {
  1347. return contextDataArray[sCtxId];
  1348. }
  1349. return null;
  1350. };
  1351. CSelectionController.prototype.getMetaDataItemUseValue = function(iKeyIndex, sCtxId)
  1352. {
  1353. /**
  1354. * 0 == ref data item
  1355. * 2 == mun
  1356. * 3 == level or qmid
  1357. * 4 == query
  1358. */
  1359. var contextItem = this.getContextDataItem(sCtxId);
  1360. if(contextItem != null)
  1361. {
  1362. var metaDataQueryKey = contextItem[iKeyIndex];
  1363. if(metaDataQueryKey != "")
  1364. {
  1365. var metaDataItem = this.getMetaDataItem(metaDataQueryKey);
  1366. if(metaDataItem != null)
  1367. {
  1368. return metaDataItem[0/*use value index*/];
  1369. }
  1370. }
  1371. }
  1372. return "";
  1373. };
  1374. CSelectionController.prototype.getRDI = function(sCtxId) {
  1375. var contextItem = this.getContextDataItem(sCtxId);
  1376. if(contextItem != null)
  1377. {
  1378. var metaDataQueryKey = contextItem[0];
  1379. if(metaDataQueryKey != "")
  1380. {
  1381. var metaDataItem = this.getMetaDataItem(metaDataQueryKey);
  1382. if(metaDataItem != null)
  1383. {
  1384. return metaDataItem;
  1385. }
  1386. }
  1387. }
  1388. };
  1389. /////////////////////
  1390. CSelectionController.prototype.getNamespace = function()
  1391. {
  1392. return this.m_sNamespace;
  1393. };
  1394. CSelectionController.prototype.setSelectionBasedFeaturesEnabled = function(bValue)
  1395. {
  1396. this.m_bSelectionBasedFeaturesEnabled = bValue;
  1397. };
  1398. CSelectionController.prototype.getSelectionBasedFeaturesEnabled = function()
  1399. {
  1400. return this.m_bSelectionBasedFeaturesEnabled;
  1401. };
  1402. CSelectionController.prototype.setDrillUpDownEnabled = function(bValue)
  1403. {
  1404. this.m_bDrillUpDownEnabled = bValue;
  1405. };
  1406. CSelectionController.prototype.getDrillUpDownEnabled = function()
  1407. {
  1408. return this.m_bDrillUpDownEnabled;
  1409. };
  1410. CSelectionController.prototype.setModelDrillThroughEnabled = function(bValue)
  1411. {
  1412. this.m_bModelDrillThroughEnabled = bValue;
  1413. };
  1414. CSelectionController.prototype.getBookletItemForCurrentSelection = function() {
  1415. var selectedObjects = this.getAllSelectedObjects();
  1416. if (selectedObjects && selectedObjects.length > 0) {
  1417. var selectedObject = selectedObjects[0];
  1418. if (selectedObject.hasContextInformation()) {
  1419. var bookletItem = this.m_oCDManager.GetBIValue(selectedObject.m_contextIds[0][0]);
  1420. if (!bookletItem) {
  1421. return null;
  1422. }
  1423. return bookletItem;
  1424. }
  1425. }
  1426. return null;
  1427. };
  1428. CSelectionController.prototype.getModelPathForCurrentSelection = function() {
  1429. var modelPath = null;
  1430. var bookletItem = this.getBookletItemForCurrentSelection();
  1431. if (bookletItem) {
  1432. var modelPath = this.m_oCDManager.getModelPathFromBookletItem(bookletItem);
  1433. }
  1434. return modelPath;
  1435. }
  1436. CSelectionController.prototype.getModelDrillThroughEnabled = function()
  1437. {
  1438. // With booklets we can't simply use the global drill through flag.
  1439. // Dig into the metadata to see if drill through has been turned off for the referenced report
  1440. var bookletItem = this.getBookletItemForCurrentSelection();
  1441. if (bookletItem) {
  1442. var modleDrillThroughEnabled = this.m_oCDManager.GetBookletModelBasedDrillThru(bookletItem);
  1443. return modleDrillThroughEnabled == 1 ? true : false;
  1444. }
  1445. else {
  1446. return this.m_bModelDrillThroughEnabled;
  1447. }
  1448. };
  1449. /*
  1450. Parameters:
  1451. Returns: boolean
  1452. */
  1453. CSelectionController.prototype.clearSelectedObjects = function(theDocument)
  1454. {
  1455. try
  1456. {
  1457. if (!theDocument) {
  1458. theDocument = document;
  1459. }
  1460. this.updateUI(theDocument, this.getSelections(), true, false);
  1461. this.m_aSelectedObjects = [];
  1462. if (typeof this.onSelectionChange == "function")
  1463. {
  1464. this.onSelectionChange();
  1465. }
  1466. return true;
  1467. }
  1468. catch (e)
  1469. {
  1470. return false;
  1471. }
  1472. };
  1473. /*
  1474. Parameters:
  1475. Returns: boolean
  1476. */
  1477. CSelectionController.prototype.resetSelections = function(theDocument)
  1478. {
  1479. try
  1480. {
  1481. if (!theDocument) {
  1482. theDocument = document;
  1483. }
  1484. if (this.hasSelectedChartNodes()) { // and isBUX
  1485. this.resetChartSelections(theDocument);
  1486. }
  1487. this.m_oSelectedDrillThroughImage = null;
  1488. this.m_oSelectedDrillThroughSingleton = null;
  1489. if(this.getSelections()) {
  1490. this.updateUI(theDocument, this.getSelections(), true, false);
  1491. this.updateUI(theDocument, this.getCutColumns(), true, false);
  1492. this.m_aCutColumns = [];
  1493. this.m_aSelectedObjects = [];
  1494. this.m_selectedClass = [];
  1495. this.m_cutClass = [];
  1496. if (typeof this.onSelectionChange == "function")
  1497. {
  1498. this.onSelectionChange();
  1499. }
  1500. }
  1501. return true;
  1502. }
  1503. catch (e)
  1504. {
  1505. return false;
  1506. }
  1507. };
  1508. CSelectionController.prototype.resetChartSelections = function(theDocument)
  1509. {
  1510. var chartHelpers = this.m_chartHelpers;
  1511. for (var mapName in chartHelpers) {
  1512. if (chartHelpers[mapName]) {
  1513. var mapHighlighter = chartHelpers[mapName].getImageMapHighlighter();
  1514. if (mapHighlighter.hideAllAreas) {
  1515. mapHighlighter.hideAllAreas();
  1516. }
  1517. }
  1518. }
  1519. this.m_selectedChartNodes = [];
  1520. this.m_selectionContainerMap = null;
  1521. };
  1522. /*
  1523. Parameters:
  1524. Returns: boolean
  1525. */
  1526. CSelectionController.prototype.addSelectionObject = function(CSelectionObject, theDocument)
  1527. {
  1528. try
  1529. {
  1530. if (!theDocument) {
  1531. theDocument = document;
  1532. }
  1533. //test to see if this object is already selected
  1534. var theCell = CSelectionObject.getCellRef();
  1535. if (this.isCellSelected(theCell) !== true || (typeof theCell != "object" || theCell === null))
  1536. {
  1537. //test to see if this object is currently cut
  1538. /* TODO: Put this back in once Report Server starts to produce context data
  1539. if (this.isColumnCut(CSelectionObject.getColumnName()) !== true)
  1540. {
  1541. this.m_aSelectedObjects[this.m_aSelectedObjects.length] = CSelectionObject;
  1542. if (typeof this.onSelectionChange == "function")
  1543. this.onSelectionChange();
  1544. this.updateUI(theDocument, this.getSelections(), false, false);
  1545. }
  1546. /TODO */
  1547. /* TODO: Take this out once Report Server starts to produce context data */
  1548. if (this.isColumnCut(CSelectionObject.getTag()) !== true)
  1549. {
  1550. this.m_aSelectedObjects[this.m_aSelectedObjects.length] = CSelectionObject;
  1551. if (typeof this.onSelectionChange == "function")
  1552. {
  1553. this.onSelectionChange();
  1554. }
  1555. this.updateUI(theDocument, this.getSelections(), false, false);
  1556. }
  1557. /* /TODO */
  1558. }
  1559. return true;
  1560. }
  1561. catch (e)
  1562. {
  1563. return false;
  1564. }
  1565. };
  1566. /*
  1567. * Removes selected object from the selection and update the UI.
  1568. Parameters:
  1569. Returns: boolean
  1570. */
  1571. CSelectionController.prototype.removeSelectionObject = function(CSelectionObject, theDocument)
  1572. {
  1573. try
  1574. {
  1575. if (!theDocument) {
  1576. theDocument = document;
  1577. }
  1578. var removed = [];
  1579. var idxSelObjects;
  1580. for (idxSelObjects = 0; idxSelObjects < this.m_aSelectedObjects.length; idxSelObjects++)
  1581. {
  1582. var selObjCellRef = this.m_aSelectedObjects[idxSelObjects].getCellRef();
  1583. var cselObjCellRef = CSelectionObject.getCellRef();
  1584. if (typeof selObjCellRef == "object" && typeof cselObjCellRef == "object" && selObjCellRef !== null && cselObjCellRef !== null)
  1585. {
  1586. if (selObjCellRef == cselObjCellRef)
  1587. {
  1588. removed[removed.length] = idxSelObjects;
  1589. }
  1590. }
  1591. }
  1592. if (removed.length > 0)
  1593. {
  1594. this.updateUI(theDocument, this.getSelections(), true, false);
  1595. var newArr = [];
  1596. for (idxSelObjects = 0; idxSelObjects < this.m_aSelectedObjects.length; idxSelObjects++)
  1597. {
  1598. var addToNewArr = true;
  1599. for (var j = 0; j < removed.length; j++)
  1600. {
  1601. if (idxSelObjects == removed[j])
  1602. {
  1603. addToNewArr = false;
  1604. }
  1605. }
  1606. if (addToNewArr)
  1607. {
  1608. newArr[newArr.length] = this.m_aSelectedObjects[idxSelObjects];
  1609. }
  1610. }
  1611. this.m_aSelectedObjects = newArr;
  1612. this.updateUI(theDocument, this.getSelections(), false, false);
  1613. }
  1614. if (typeof this.onSelectionChange == "function")
  1615. {
  1616. this.onSelectionChange();
  1617. }
  1618. return true;
  1619. }
  1620. catch (e)
  1621. {
  1622. return false;
  1623. }
  1624. };
  1625. CSelectionController.prototype.isSavedCellSelected = function( cellNode )
  1626. {
  1627. return this.isCellSelectedHelper(cellNode, this.getSavedSelectedObjects() );
  1628. };
  1629. CSelectionController.prototype.isCellSelected = function( cellNode ){
  1630. return this.isCellSelectedHelper(cellNode, this.getSelections());
  1631. }
  1632. /*
  1633. Parameters:
  1634. Returns: boolean
  1635. */
  1636. CSelectionController.prototype.isCellSelectedHelper = function(cellNode, selectedObjects )
  1637. {
  1638. try
  1639. {
  1640. for (var i = 0; i < selectedObjects.length; i++)
  1641. {
  1642. var selObjCellRef = selectedObjects[i].getCellRef();
  1643. if (typeof selObjCellRef == "object" && selObjCellRef !== null)
  1644. {
  1645. if (selObjCellRef == cellNode)
  1646. {
  1647. return true;
  1648. }
  1649. }
  1650. }
  1651. }
  1652. catch (e)
  1653. {
  1654. }
  1655. return false;
  1656. };
  1657. /*
  1658. Parameters:
  1659. Returns: boolean
  1660. */
  1661. CSelectionController.prototype.isColumnSelected = function(columnName)
  1662. {
  1663. try
  1664. {
  1665. for (var i = 0; i < this.m_aSelectedObjects.length; i++)
  1666. {
  1667. /* TODO: Put this back in once Report Server starts to produce context data
  1668. if (this.m_aSelectedObjects[i].getColumnName() == columnName)
  1669. {
  1670. return true;
  1671. }
  1672. /TODO */
  1673. /* TODO: Take this out once Report Server starts to produce context data */
  1674. if (this.m_aSelectedObjects[i].getTag() == columnName)
  1675. {
  1676. return true;
  1677. }
  1678. /* /TODO */
  1679. }
  1680. }
  1681. catch (e)
  1682. {
  1683. }
  1684. return false;
  1685. };
  1686. /*
  1687. Parameters:
  1688. Returns: boolean
  1689. */
  1690. CSelectionController.prototype.isColumnCut = function(columnName)
  1691. {
  1692. try
  1693. {
  1694. for (var i = 0; i < this.m_aCutColumns.length; i++)
  1695. {
  1696. /* TODO: Put this back in once Report Server starts to produce context data
  1697. if (this.m_aCutColumns[i].getColumnName() == columnName)
  1698. {
  1699. return true;
  1700. }
  1701. /TODO */
  1702. /* TODO: Take this out once Report Server starts to produce context data */
  1703. if (this.m_aCutColumns[i].getTag() == columnName)
  1704. {
  1705. return true;
  1706. }
  1707. /* /TODO */
  1708. }
  1709. }
  1710. catch (e)
  1711. {
  1712. }
  1713. return false;
  1714. };
  1715. /*
  1716. Parameters:
  1717. Returns: array of selected objects
  1718. */
  1719. CSelectionController.prototype.getSelections = function()
  1720. {
  1721. return this.m_aSelectedObjects;
  1722. };
  1723. /*
  1724. Parameters: a dom node
  1725. Returns: nothing
  1726. */
  1727. CSelectionController.prototype.selectSingleDomNode = function(nNode)
  1728. {
  1729. this.clearSelectedObjects();
  1730. var oSelObject = this.getSelectionObjectFactory().getSelectionObject(nNode);
  1731. var oDocument = null;
  1732. if (isIE()) {
  1733. oDocument = nNode.document;
  1734. } else {
  1735. oDocument = nNode.ownerDocument;
  1736. }
  1737. this.addSelectionObject(oSelObject, oDocument);
  1738. };
  1739. /*
  1740. Parameters:
  1741. Returns: array of selected objects
  1742. */
  1743. CSelectionController.prototype.hasCutColumns = function()
  1744. {
  1745. if (this.m_aCutColumns.length === 0)
  1746. {
  1747. return false;
  1748. }
  1749. else
  1750. {
  1751. return true;
  1752. }
  1753. };
  1754. /*
  1755. Parameters:
  1756. Returns: boolean
  1757. */
  1758. CSelectionController.prototype.setCutColumns = function(cutValue, theDocument)
  1759. {
  1760. try
  1761. {
  1762. if (!theDocument) {
  1763. theDocument = document;
  1764. }
  1765. this.updateUI(theDocument, this.getSelections(), true, false);
  1766. this.updateUI(theDocument, this.getCutColumns(), true, 1);
  1767. this.m_aCutColumns = [];
  1768. //sets all currently selected columns to cutValue
  1769. if (cutValue === true)
  1770. {
  1771. for (var i = 0; i < this.m_aSelectedObjects.length; i++)
  1772. {
  1773. this.m_aCutColumns[i] = this.m_aSelectedObjects[i];
  1774. }
  1775. this.m_aSelectedObjects = [];
  1776. }
  1777. this.updateUI(theDocument, this.getCutColumns(), false, 2);
  1778. /* I don't know yet if we want to observe the cutting of columns, leave it out for now.
  1779. if (typeof this.onSelectionChange == "function")
  1780. {
  1781. this.onSelectionChange();
  1782. }
  1783. */
  1784. return true;
  1785. }
  1786. catch (e)
  1787. {
  1788. return false;
  1789. }
  1790. };
  1791. /*
  1792. Parameters:
  1793. Returns: array of cut columns
  1794. */
  1795. CSelectionController.prototype.getCutColumns = function()
  1796. {
  1797. return this.m_aCutColumns;
  1798. };
  1799. /*
  1800. Parameters:
  1801. Returns: reference to observer function
  1802. */
  1803. CSelectionController.prototype.getObservers = function()
  1804. {
  1805. return this.m_oObserver;
  1806. };
  1807. /*
  1808. Parameters:
  1809. Returns: void
  1810. */
  1811. CSelectionController.prototype.attachObserver = function(observer)
  1812. {
  1813. this.m_oObserver.attach(observer);
  1814. };
  1815. /*
  1816. This is called when a selection changes
  1817. Parameters:
  1818. Returns: void
  1819. */
  1820. CSelectionController.prototype.onSelectionChange = function()
  1821. {
  1822. this.getObservers().notify();
  1823. };
  1824. /*
  1825. Parameters:
  1826. Returns: array of columns to draw
  1827. */
  1828. CSelectionController.prototype.getSelectedColumns = function(allSelections)
  1829. {
  1830. var columnsToDraw = [];
  1831. if (typeof allSelections == "undefined")
  1832. {
  1833. allSelections = this.getSelections();
  1834. }
  1835. var allSelectionsLength = allSelections.length;
  1836. for (var i = 0; i < allSelectionsLength; i++)
  1837. {
  1838. var currentSelection = allSelections[i];
  1839. var addNewEntry = true;
  1840. for (var j = 0; j < columnsToDraw.length; j++)
  1841. {
  1842. if (columnsToDraw[j][0] == currentSelection.getColumnRef() && columnsToDraw[j][1] == currentSelection.getCellTypeId())
  1843. {
  1844. addNewEntry = false;
  1845. break;
  1846. }
  1847. }
  1848. if (addNewEntry)
  1849. {
  1850. columnsToDraw[columnsToDraw.length] = [
  1851. currentSelection.getColumnRef(),
  1852. currentSelection.getCellTypeId(),
  1853. currentSelection.getLayoutType(),
  1854. currentSelection.getTag(),
  1855. currentSelection.getColumnName()
  1856. ];
  1857. }
  1858. }
  1859. return columnsToDraw;
  1860. };
  1861. /*
  1862. * Returns an array of unique (ctx id) selected objects.
  1863. */
  1864. CSelectionController.prototype.getAllSelectedObjectsWithUniqueCTXIDs = function()
  1865. {
  1866. var uniqueSelectedItems = [];
  1867. var selectedObjects = this.getAllSelectedObjects();
  1868. for (var i=0; i < selectedObjects.length; i++) {
  1869. var found=false;
  1870. var selectionObject = selectedObjects[i];
  1871. for (var ii=0; ii < uniqueSelectedItems.length; ii++) {
  1872. // if the ctx id matches, then don't add it to the unique array
  1873. if (selectionObject.m_contextIds[0][0] == uniqueSelectedItems[ii].m_contextIds[0][0]) {
  1874. found = true;
  1875. break;
  1876. }
  1877. }
  1878. if (!found) {
  1879. uniqueSelectedItems.push(selectionObject);
  1880. }
  1881. }
  1882. return uniqueSelectedItems;
  1883. };
  1884. CSelectionController.prototype.getAllSelectedObjects = function()
  1885. {
  1886. var selectedItems = this.getSelections();
  1887. if(this.hasSelectedChartNodes()) {
  1888. selectedItems = selectedItems.concat(this.getSelectedChartNodes());
  1889. }
  1890. return selectedItems;
  1891. };
  1892. /*
  1893. Parameters:
  1894. Returns: array of column ids
  1895. */
  1896. CSelectionController.prototype.getSelectedColumnIds = function(aAllSelections)
  1897. {
  1898. var aColumnIds = [];
  1899. if (typeof aAllSelections == "undefined")
  1900. {
  1901. aAllSelections = this.getSelections();
  1902. }
  1903. var aSelectedColumns = this.getSelectedColumns(aAllSelections);
  1904. for (var idxSelCols = 0; idxSelCols < aSelectedColumns.length; idxSelCols++)
  1905. {
  1906. var addNewEntry = true;
  1907. for (var idxColIds = 0; idxColIds < aColumnIds.length; idxColIds++)
  1908. {
  1909. if (aColumnIds[idxColIds] == aSelectedColumns[idxSelCols][4])
  1910. {
  1911. addNewEntry = false;
  1912. break;
  1913. }
  1914. }
  1915. if (addNewEntry)
  1916. {
  1917. aColumnIds[aColumnIds.length] = aSelectedColumns[idxSelCols][4];
  1918. }
  1919. }
  1920. return aColumnIds;
  1921. };
  1922. var STYLE_SELECTION = {};
  1923. CSelectionController.prototype.selecting = function(c,style)
  1924. {
  1925. var sText = "." + c + style;
  1926. var doc = document;
  1927. var oIFrame = document.getElementById('CVIFrame' + this.m_sNamespace);
  1928. if (oIFrame)
  1929. {
  1930. doc = oIFrame.contentWindow.document;
  1931. }
  1932. var nStyle = doc.createElement('style');
  1933. nStyle.setAttribute("type", "text/css");
  1934. if (nStyle.styleSheet)
  1935. {
  1936. // IE
  1937. nStyle.styleSheet.cssText = sText;
  1938. }
  1939. else
  1940. {
  1941. // Mozilla & Firefox
  1942. nStyle.appendChild( doc.createTextNode(sText) );
  1943. }
  1944. doc.getElementsByTagName("head").item(0).appendChild(nStyle);
  1945. STYLE_SELECTION[ c ] = nStyle;
  1946. };
  1947. CSelectionController.prototype.deselecting = function(anArray)
  1948. {
  1949. for(var i = 0; i < anArray.length; ++i)
  1950. {
  1951. if ( STYLE_SELECTION[ anArray[i] ])
  1952. {
  1953. var node = STYLE_SELECTION[ anArray[i] ];
  1954. node.parentNode.removeChild( node );
  1955. STYLE_SELECTION[ anArray[i] ] = null;
  1956. }
  1957. }
  1958. if (isIE() && typeof this.m_oCognosViewer.m_viewerFragment != "undefined")
  1959. {
  1960. // force IE to repaint the div
  1961. var reportDiv = document.getElementById("CVReport" + this.m_oCognosViewer.getId());
  1962. if(reportDiv != null)
  1963. {
  1964. var display = reportDiv.style.display;
  1965. reportDiv.style.display = "none";
  1966. reportDiv.style.display = display;
  1967. }
  1968. }
  1969. };
  1970. CSelectionController.prototype.showViewerContextMenu = function()
  1971. {
  1972. if (this.hasSelectedChartNodes())
  1973. {
  1974. return true;
  1975. }
  1976. if (this.m_aSelectedObjects && this.m_aSelectedObjects.length > 0)
  1977. {
  1978. return true;
  1979. }
  1980. return false;
  1981. };
  1982. function getStyleFromClass(c)
  1983. {
  1984. for (var i = 0; i < document.styleSheets.length; i++)
  1985. {
  1986. var ss = document.styleSheets[i];
  1987. var _rules = (ss.cssRules ? ss.cssRules : ss.rules);
  1988. for (var j = 0; j < _rules.length; j++)
  1989. {
  1990. var cr = _rules[j];
  1991. var reClass = new RegExp('\\b' + c + '\\b', 'g');
  1992. if (cr.selectorText && cr.selectorText.match(reClass))
  1993. {
  1994. return cr;
  1995. }
  1996. }
  1997. }
  1998. return 0;
  1999. };
  2000. CSelectionController.prototype.canUpdateSelection = function( contextIds )
  2001. {
  2002. return this.m_selectionStyles.canApplyToSelection( contextIds );
  2003. };
  2004. CSelectionController.prototype.setStyleForSelection = function( contextIds )
  2005. {
  2006. return this.m_selectionStyles.setStyleForSelection( contextIds );
  2007. };
  2008. /*
  2009. Parameters:
  2010. Returns: boolean
  2011. */
  2012. CSelectionController.prototype.updateUI = function(theDocument, allSelections, deselectAll, isCut)
  2013. {
  2014. if (!theDocument) {
  2015. theDocument = document;
  2016. }
  2017. try
  2018. {
  2019. if (allSelections && allSelections.length > 0)
  2020. {
  2021. var allSelectionsLength, idxAllSelections, selectedTD;
  2022. if (isCut == 1 || isCut == 2)
  2023. {
  2024. if (deselectAll)
  2025. {
  2026. this.deselecting(this.m_cutClass);
  2027. }
  2028. else
  2029. {
  2030. var cS_color = getStyleFromClass("cutSelection").style.color;
  2031. var cS_backgroundColor = getStyleFromClass("cutSelection").style.backgroundColor;
  2032. allSelectionsLength = allSelections.length;
  2033. for (idxAllSelections = 0; idxAllSelections < allSelectionsLength; idxAllSelections++)
  2034. {
  2035. selectedTD = allSelections[idxAllSelections].getCellRef();
  2036. var selectedClass = "cutQS" + selectedTD.getAttribute("cid");
  2037. this.selecting(selectedClass,"\n{ background-color: "+cS_backgroundColor+"; color: "+cS_color+";}\n");
  2038. this.m_cutClass.push(selectedClass);
  2039. }
  2040. }
  2041. }
  2042. else
  2043. {
  2044. if(this.m_oCognosViewer)
  2045. {
  2046. this.findSelectionURLs();
  2047. selectedTD="";
  2048. allSelectionsLength = allSelections.length;
  2049. for (idxAllSelections = 0; idxAllSelections < allSelectionsLength; idxAllSelections++)
  2050. {
  2051. selectedTD = allSelections[idxAllSelections].getCellRef();
  2052. // if we have an oldClassName it means we were showing our hover class, reset it to the original
  2053. // class before doing the select
  2054. if (selectedTD.getAttribute("oldClassName") != null)
  2055. {
  2056. selectedTD.className = selectedTD.getAttribute("oldClassName");
  2057. selectedTD.removeAttribute("oldClassName");
  2058. }
  2059. this.setStyleForSelection( allSelections[idxAllSelections].m_contextIds );
  2060. // do the secondary selection first
  2061. if( !this.secondarySelectionIsDisabled() || deselectAll ){
  2062. var reportDiv = document.getElementById("CVReport" + this.getNamespace());
  2063. var secondarySelectedItems = getElementsByAttribute(reportDiv, ["td", "th"], "name", selectedTD.getAttribute("name"), this.m_maxSecondarySelection);
  2064. for (var cellIndex=0; cellIndex < secondarySelectedItems.length; cellIndex++)
  2065. {
  2066. var cell = secondarySelectedItems[cellIndex];
  2067. if (deselectAll)
  2068. {
  2069. this.restoreOldBackgroundImage(cell);
  2070. }
  2071. else if ( cell.getAttribute("oldBackgroundImageStyle") == null)
  2072. {
  2073. this.saveOldCellStyles(cell);
  2074. this.setSecondarySelectionStyles(cell);
  2075. }
  2076. }
  2077. }
  2078. // primary selection
  2079. this.saveOldCellStyles(selectedTD);
  2080. if (deselectAll)
  2081. {
  2082. this.restoreOldBackgroundImage(selectedTD);
  2083. if (this.m_oCognosViewer.isHighContrast())
  2084. {
  2085. this.restoreOldBorder(selectedTD);
  2086. this.restoreOldPadding(selectedTD);
  2087. }
  2088. }
  2089. else
  2090. {
  2091. this.setPrimarySelectionStyles(selectedTD);
  2092. if (this.m_oCognosViewer.isHighContrast())
  2093. {
  2094. var size = getBoxInfo(selectedTD, true);
  2095. this.saveOldBorder(selectedTD);
  2096. this.saveOldPadding(selectedTD, size);
  2097. var borderWidth = 3;
  2098. var topSize = size.borderTopWidth + size.paddingTop - borderWidth;
  2099. var bottomSize = size.borderBottomWidth + size.paddingBottom - borderWidth;
  2100. var leftSize = size.borderLeftWidth + size.paddingLeft - borderWidth;
  2101. var rightSize = size.borderRightWidth + size.paddingRight - borderWidth;
  2102. selectedTD.style.border = borderWidth + "px " + this.getHighContrastBorderStyle() + " black";
  2103. selectedTD.style.padding = topSize + "px " + rightSize + "px " + bottomSize + "px " + leftSize + "px";
  2104. }
  2105. }
  2106. }
  2107. }
  2108. }
  2109. }
  2110. return true;
  2111. }
  2112. catch (e)
  2113. {
  2114. //alert("error selecting column -- please contact your administrator!");
  2115. return false;
  2116. }
  2117. };
  2118. CSelectionController.prototype.findSelectionURLs = function() {
  2119. if ( !(this.sS_backgroundImageURL && this.pS_backgroundImageURL) ) {
  2120. if(this.m_oCognosViewer.isBux || isSafari() || this.m_oCognosViewer.isMobile()) {
  2121. // BUX doesn't have the same CSS classes, Safari & Mobile needs relative paths
  2122. // We are using relative paths (relative to the current folger, ie. <gateway>/cgi-bin/)
  2123. this.pS_backgroundImageURL = "url(../common/images/selection_primary.png)";
  2124. this.sS_backgroundImageURL = "url(../common/images/selection_secondary.png)";
  2125. }
  2126. else {
  2127. this.pS_backgroundImageURL = this.getBackgroundImage(getStyleFromClass("primarySelection"));
  2128. this.sS_backgroundImageURL = this.getBackgroundImage(getStyleFromClass("secondarySelection"));
  2129. }
  2130. }
  2131. };
  2132. // make sure the item we are selecting is a rsvp chart image
  2133. CSelectionController.prototype.setSelectedChartImgArea = function(chartArea)
  2134. {
  2135. var isAreaValidSelection = true;
  2136. var isRSVPChart = chartArea.getAttribute("rsvpChart");
  2137. var inChartContainer = chartArea.parentNode.getAttribute("chartContainer");
  2138. if (isRSVPChart != "true" && inChartContainer != "true") {
  2139. this.m_selectedChartNodes = [];
  2140. isAreaValidSelection = false;
  2141. }
  2142. else {
  2143. var selectedChartNode = this.getSelectionObjectFactory().getSelectionChartObject(chartArea);
  2144. this.m_selectedChartNodes = [selectedChartNode];
  2145. }
  2146. return isAreaValidSelection;
  2147. };
  2148. CSelectionController.prototype.setSelectedChartArea = function(chartArea, e )
  2149. {
  2150. var isBUX = typeof this.m_oCognosViewer.isBux !== "undefined";
  2151. var isAreaValidSelection = false;
  2152. if (chartArea !== null) {
  2153. // make sure the item we are selecting is a rsvp chart image
  2154. if (chartArea.tagName == "IMG") {
  2155. isAreaValidSelection = this.setSelectedChartImgArea(chartArea);
  2156. }
  2157. else
  2158. if (chartArea.nodeName == 'AREA' && chartArea.attributes["ctx"]) {
  2159. isAreaValidSelection = true;
  2160. if (isBUX) {
  2161. this.setBuxSelectedChartArea(chartArea, e );
  2162. } else {
  2163. this.m_selectedChartNodes = [this.getSelectionObjectFactory().getSelectionChartObject(chartArea)];
  2164. }
  2165. }
  2166. if (isAreaValidSelection) {
  2167. this.getObservers().notify();
  2168. }
  2169. }
  2170. return isAreaValidSelection;
  2171. };
  2172. CSelectionController.prototype.setBuxSelectedChartArea = function(chartArea, e) {
  2173. var mapHelper = this.getChartHelper(chartArea);
  2174. var selectedChartNode = mapHelper.getChartNode(chartArea);
  2175. this.setStyleForSelection(selectedChartNode.m_contextIds );
  2176. var imageMapHighlighter = mapHelper.getImageMapHighlighter();
  2177. imageMapHighlighter.setFillColour( this.getPrimarySelectionColor());
  2178. imageMapHighlighter.setStrokeColour( this.getPrimarySelectionColor());
  2179. if (typeof e == "undefined") {
  2180. e = {};
  2181. }
  2182. if (this.ctrlKeyPressed(e) || this.shiftKeyPressed(e)) {
  2183. // multiple selection
  2184. if (imageMapHighlighter.isAreaHighlighted(chartArea)) {
  2185. // remove chart node from selection
  2186. imageMapHighlighter.hideAreas(selectedChartNode.getCtxAreas());
  2187. var chartAreaCtx = chartArea.getAttribute("ctx");
  2188. var selectedNodesCount = this.m_selectedChartNodes.length;
  2189. for (var i = 0; i < selectedNodesCount; i++) {
  2190. var selChartNode = this.m_selectedChartNodes[i];
  2191. if (chartAreaCtx == selChartNode.getContext()) {
  2192. this.m_selectedChartNodes.splice(i, 1);
  2193. break;
  2194. }
  2195. }
  2196. }
  2197. else {
  2198. // add chart node to selection
  2199. this.updateSelectionContainer(chartArea);
  2200. imageMapHighlighter.highlightAreas(selectedChartNode.getCtxAreas(), true);
  2201. this.m_selectedChartNodes.push(selectedChartNode);
  2202. }
  2203. }
  2204. else { // single selection
  2205. if( this.hasSavedSelectedChartNodes()){
  2206. var noOfSavedChartNodes = this.m_savedSelectedChartNodes.length;
  2207. var savedChartNodes = this.m_savedSelectedChartNodes;
  2208. for( var i = 0; i < noOfSavedChartNodes; i++){
  2209. var area = savedChartNodes[i].getArea();
  2210. var chartHelper = this.getSavedChartHelper( area );
  2211. var mapHighlighter = chartHelper.getImageMapHighlighter();
  2212. var areaId = mapHighlighter.getAreaId( area )
  2213. if( imageMapHighlighter.getAreaId(chartArea) === areaId){
  2214. mapHighlighter.hideAreaById( areaId + this.m_savedPrimarySelectionColor );
  2215. break;
  2216. }
  2217. }
  2218. }
  2219. this.updateSelectionContainer(chartArea);
  2220. imageMapHighlighter.highlightAreas(selectedChartNode.getCtxAreas());
  2221. this.m_selectedChartNodes = [selectedChartNode];
  2222. }
  2223. };
  2224. CSelectionController.prototype.updateSelectionContainer = function(chartArea)
  2225. {
  2226. var imageMap = chartArea.parentNode;
  2227. if (this.m_selectionContainerMap && this.m_selectionContainerMap.name != imageMap.name) {
  2228. var imageMapHighlighter = this.getChartHelper(chartArea).getImageMapHighlighter();
  2229. imageMapHighlighter.hideAllAreas();
  2230. }
  2231. this.m_selectionContainerMap = imageMap;
  2232. };
  2233. CSelectionController.prototype.getChartHelper = function(chartArea) {
  2234. var imageMap = chartArea.parentNode;
  2235. var mapName = imageMap.name;
  2236. if (!this.m_chartHelpers[mapName]) {
  2237. this.m_chartHelpers[mapName] = new CChartHelper(chartArea, this.getSelectionObjectFactory(), this.m_oCognosViewer);
  2238. }
  2239. return this.m_chartHelpers[mapName];
  2240. };
  2241. CSelectionController.prototype.getSavedChartHelper = function(chartArea) {
  2242. var imageMap = chartArea.parentNode;
  2243. var mapName = imageMap.name;
  2244. return this.m_savedChartHelpers[mapName];
  2245. };
  2246. CSelectionController.prototype.getSelectedChartArea = function()
  2247. {
  2248. return this.m_selectedChartArea;
  2249. };
  2250. CSelectionController.prototype.getSelectedChartNodes = function()
  2251. {
  2252. return this.m_selectedChartNodes ;
  2253. };
  2254. CSelectionController.prototype.hasSelectedChartNodes = function()
  2255. {
  2256. return this.m_selectedChartNodes && this.m_selectedChartNodes.length && this.m_selectedChartNodes.length > 0;
  2257. };
  2258. CSelectionController.prototype.getSelectedChartImage = function()
  2259. {
  2260. var selectedChartArea = null;
  2261. if(this.hasSelectedChartNodes())
  2262. {
  2263. var selectedChartNode = this.m_selectedChartNodes[0];
  2264. selectedChartArea = selectedChartNode.getArea();
  2265. }
  2266. if (selectedChartArea === null)
  2267. {
  2268. return null;
  2269. }
  2270. if (selectedChartArea.tagName == "IMG")
  2271. {
  2272. return selectedChartArea;
  2273. }
  2274. return this.getSelectedChartImageFromChartArea(selectedChartArea);
  2275. };
  2276. CSelectionController.prototype.getSelectedChartImageFromChartArea = function(oChartArea){
  2277. var imageMap = oChartArea.parentNode;
  2278. var imageMapName = "#" + imageMap.getAttribute("name");
  2279. return this.checkChildrenForChart(imageMap.parentNode, imageMapName);
  2280. };
  2281. CSelectionController.prototype.checkChildrenForChart = function(parent, imageMapName) {
  2282. var child = parent.firstChild;
  2283. while (child !== null)
  2284. {
  2285. if (!child.tagName) {
  2286. return null;
  2287. }
  2288. else if (child.tagName == "IMG" && child.getAttribute("usemap") == imageMapName)
  2289. {
  2290. return child;
  2291. }
  2292. // if we have a div or span always look through its children
  2293. else if (child.tagName === "DIV" || child.tagName === "SPAN") {
  2294. var result = this.checkChildrenForChart(child, imageMapName);
  2295. if (result) {
  2296. return result;
  2297. }
  2298. }
  2299. child = child.nextSibling;
  2300. }
  2301. return null;
  2302. };
  2303. CSelectionController.prototype.downloadSelectedChartImage = function(sCVID)
  2304. {
  2305. var chartImage = this.getSelectedChartImage();
  2306. if (chartImage !== null)
  2307. {
  2308. var theDocument = this.getDocumentFromImage(chartImage);
  2309. var imageURL = chartImage.name.replace(".", "_");
  2310. var imageName = imageURL.substr(5);
  2311. var theURL = '?m_name=';
  2312. theURL += imageName;
  2313. theURL += '&format=png&b_action=xts.run&m=portal/download.xts&m_obj=';
  2314. if (isIE()) {
  2315. imageURL = theDocument.parentWindow.eval("graphicSrc" + imageName);
  2316. }
  2317. else {
  2318. imageURL = theDocument.defaultView.eval("graphicSrc" + imageName);
  2319. }
  2320. var encodedPrams = "";
  2321. if (typeof imageURL != "undefined" && imageURL !== null)
  2322. {
  2323. var urlArray = imageURL.split('&');
  2324. if (urlArray.length === 0)
  2325. {
  2326. return;
  2327. }
  2328. if (imageURL.indexOf("/repository/") < 0)
  2329. {
  2330. for (var i = 0; i < urlArray.length; ++i)
  2331. {
  2332. var urlParam = urlArray[i];
  2333. var equalPos = urlParam.indexOf('=');
  2334. if (equalPos != -1) {
  2335. var urlParamName = urlParam.substr(0,equalPos);
  2336. var urlParamValue = urlParam.slice(equalPos+1);
  2337. if (urlParamName == 'search')
  2338. {
  2339. encodedPrams += urlParamValue;
  2340. break;
  2341. }
  2342. }
  2343. }
  2344. }
  2345. // if we didn't find a searchPath then the chart must be saved on the file system. Use
  2346. // the img src for the URL to use - it'll call the dispatcher
  2347. if (encodedPrams == "") {
  2348. theURL = chartImage.getAttribute("src");
  2349. if (theURL.indexOf('?') != -1) {
  2350. theURL += "&download=true";
  2351. }
  2352. else {
  2353. theURL += "?download=true";
  2354. }
  2355. }
  2356. if (typeof getConfigFrame == "function")
  2357. {
  2358. theURL += encodedPrams;
  2359. theURL = getConfigFrame().constructGETRequestParamsString(theURL);
  2360. window.open(theURL, "_blank", "width=0,height=0");
  2361. }
  2362. else
  2363. {
  2364. theURL = constructGETRequestParamsString(theURL);
  2365. theURL += encodedPrams;
  2366. var gateway = this.m_oCognosViewer.getGateway();
  2367. var oIFrame = document.getElementById('CVIFrame' + this.m_sNamespace);
  2368. if (oIFrame) {
  2369. var iframe_src = oIFrame.src;
  2370. if (iframe_src.indexOf("repository") >= 0 && theURL.indexOf("repository") < 0) {
  2371. //viewer uses CM's rest API
  2372. var indOfContent = iframe_src.indexOf("content");
  2373. theURL = iframe_src.substring(0, indOfContent) + theURL;
  2374. }
  2375. }
  2376. // if the image is saved on the file system then the URL already has the gateway
  2377. if (theURL.indexOf(gateway) == -1) {
  2378. var formWarpRequest = document.forms["formWarpRequest" + sCVID];
  2379. theURL = formWarpRequest.action + theURL;
  2380. }
  2381. // Remove onBeforeUnLoad for this submission but set it back after.
  2382. if (typeof window.detachLeavingRV == "function") {
  2383. window.detachLeavingRV();
  2384. }
  2385. location.href = theURL;
  2386. if (typeof window.attachLeavingRV == "function") {
  2387. setTimeout(window.attachLeavingRV, 100);
  2388. }
  2389. }
  2390. }
  2391. }
  2392. };
  2393. CSelectionController.prototype.getDocumentFromImage = function(image) {
  2394. var imageDocument = null;
  2395. if (image.ownerDocument) {
  2396. imageDocument = image.ownerDocument;
  2397. }
  2398. else {
  2399. imageDocument = image.document;
  2400. }
  2401. return imageDocument;
  2402. };
  2403. //Determine whether pageClicked should be invoked on on the mouseDown or the mouseUp.
  2404. CSelectionController.prototype.shouldExecutePageClickedOnMouseDown = function(e) {
  2405. //Special case where deselecting should be postponed until mouse up because
  2406. //another event could cancel deselecting:
  2407. //1. More than one column must be selected
  2408. var selections = this.getSelections();
  2409. if (selections.length > 1) {
  2410. //2. Must be a live report
  2411. if(this.m_oCognosViewer.envParams["ui.action"] !== 'view') {
  2412. //3. Must be in a list
  2413. //Get non-text ancestor node
  2414. var node = getNodeFromEvent(e);
  2415. try {
  2416. while (node && (node.nodeType == 3 || (node.getAttribute && node.getAttribute("uid") === null))) {
  2417. node = node.parentNode;
  2418. }
  2419. }
  2420. catch(ex) {
  2421. // sometimes node may not be an HTML element (like a XUL element) and accessing nodeType/nodeName/className will generate an error.
  2422. }
  2423. var container = this.getSelectionObjectFactory().getContainerType(node);
  2424. if(container === "list") {
  2425. //4. Must already be selected
  2426. for (var i = 0; i < selections.length; i++) {
  2427. if(selections[i].m_oCellRef == node) {
  2428. //All conditions met - postpone to mouse up
  2429. return false;
  2430. }
  2431. }
  2432. }
  2433. }
  2434. }
  2435. //Default case: execute select action on mouse down
  2436. return true;
  2437. };
  2438. /**
  2439. * Get the container type for the currently selected node
  2440. * Used for mobile
  2441. */
  2442. CSelectionController.prototype.getContainerType = function() {
  2443. var containerType = "";
  2444. if (this.hasSelectedChartNodes()) {
  2445. containerType = "chart";
  2446. }
  2447. else if (this.getDataContainerType() === "list") {
  2448. containerType = "list";
  2449. }
  2450. else {
  2451. containerType = "crosstab";
  2452. }
  2453. return containerType;
  2454. };
  2455. /**
  2456. * Build up an object for the display values of all the defining cells
  2457. * Used for mobile
  2458. */
  2459. CSelectionController.prototype.getDisplayValues = function() {
  2460. var displayValues = {};
  2461. var oSelection = this.getAllSelectedObjects()[0];
  2462. if (oSelection) {
  2463. var ctxIds = oSelection.getSelectedContextIds();
  2464. if (ctxIds) {
  2465. for (var axis=0; axis < ctxIds.length; axis++) {
  2466. var axisDisplayValues = [];
  2467. var axisIds = ctxIds[axis];
  2468. for (var nestingLevel=0; nestingLevel < axisIds.length; nestingLevel++) {
  2469. var cellId = axisIds[nestingLevel];
  2470. var displayValue = this.getDisplayValue(cellId);
  2471. axisDisplayValues.push(displayValue);
  2472. // Mobile doesn't want any of the defining cells for the primary selection so break out of the loop
  2473. if (axis === 0) {
  2474. break;
  2475. }
  2476. }
  2477. var sAxis = "";
  2478. switch(axis) {
  2479. case 0:
  2480. sAxis = "selected";
  2481. break;
  2482. case 1:
  2483. sAxis = "rows";
  2484. break;
  2485. default:
  2486. sAxis = "columns";
  2487. }
  2488. displayValues[sAxis] = axisDisplayValues;
  2489. }
  2490. }
  2491. }
  2492. return displayValues;
  2493. };
  2494. /**
  2495. * Get the tooltip from the map for chart selections
  2496. */
  2497. CSelectionController.prototype.getChartTooltip = function() {
  2498. var oSelection = this.getAllSelectedObjects()[0];
  2499. if (oSelection) {
  2500. var area = oSelection.getArea();
  2501. if (area) {
  2502. var title = area.getAttribute("title");
  2503. if (title && title.length > 0) {
  2504. return area.getAttribute("title");
  2505. }
  2506. }
  2507. }
  2508. return "";
  2509. };
  2510. /**
  2511. * used for when we're in mobile. Retruns true if a node was selected
  2512. */
  2513. CSelectionController.prototype.pageClickedForMobile = function(e)
  2514. {
  2515. this.pageClicked(e);
  2516. var selectionLength = this.getAllSelectedObjects().length;
  2517. // Special case for mobile when there's a drill through on an image. Since they want to show a menu instead of doing the drill through
  2518. // and clicking on an image doesn't create a selection object, add the image to the selection controller so that it gets
  2519. // detected when looking for drill information
  2520. if (selectionLength == 0) {
  2521. var node = getNodeFromEvent(e, true);
  2522. if ( !node ){
  2523. return false;
  2524. }
  2525. if ( node.nodeName.toLowerCase() == "img" && node.getAttribute("dttargets")) {
  2526. this.selectDrillThroughImage(node);
  2527. return true;
  2528. } else if( node.getAttribute("dttargets") ){
  2529. this.selectDrillThroughSingleton( node );
  2530. return true;
  2531. } else if ( node.parentNode && node.parentNode.getAttribute( "dttargets") ){
  2532. this.selectDrillThroughSingleton( node.parentNode );
  2533. return true;
  2534. }
  2535. return false;
  2536. }
  2537. return true;
  2538. };
  2539. CSelectionController.prototype.clearSavedSelections = function()
  2540. {
  2541. this.m_bSavedSelections = false;
  2542. if( this.hasSavedSelectedObjects() ){
  2543. this.updateUI( null, this.getSavedSelectedObjects(), true, false );
  2544. delete( this.m_aSavedSelectedObjects );
  2545. }
  2546. if( this.hasSavedSelectedChartNodes() ){
  2547. var chartHelpers = this.m_savedChartHelpers;
  2548. for( var mapName in chartHelpers){
  2549. if( chartHelpers[mapName]){
  2550. var mapHighlighter = chartHelpers[mapName].getImageMapHighlighter();
  2551. if (mapHighlighter.hideAllAreas) {
  2552. mapHighlighter.hideAllAreas();
  2553. }
  2554. }
  2555. }
  2556. delete this.m_savedChartHelpers;
  2557. delete this.m_savedSelectedChartNodes;
  2558. }
  2559. };
  2560. CSelectionController.prototype.hasSavedSelectedChartNodes = function(){
  2561. return ( this.m_savedSelectedChartNodes && this.m_savedSelectedChartNodes.length > 0 );
  2562. };
  2563. CSelectionController.prototype.getSavedSelectedChartNodes = function(){
  2564. return this.m_savedSelectedChartNodes;
  2565. };
  2566. /**
  2567. * This function saves the previous selections and the primary selection colour
  2568. */
  2569. CSelectionController.prototype.saveSelections = function()
  2570. {
  2571. this.m_savedSelectionStyles = this.m_selectionStyles;
  2572. if( this.m_aSelectedObjects.length > 0 )
  2573. {
  2574. this.m_aSavedSelectedObjects = [];
  2575. var noOfSelectedObjects = this.m_aSelectedObjects.length;
  2576. var temp = [];
  2577. for( var i=0; i < noOfSelectedObjects; i++ ){
  2578. if( this.isMeasure( this.m_aSelectedObjects[i].m_contextIds[0][0] ) ){
  2579. temp.push( this.m_aSelectedObjects[i] );
  2580. } else {
  2581. this.m_aSavedSelectedObjects.push( this.m_aSelectedObjects[i] );
  2582. }
  2583. }
  2584. this.m_aSelectedObjects = temp;
  2585. }
  2586. if(this.hasSelectedChartNodes()){
  2587. this.m_savedChartHelpers = this.m_chartHelpers;
  2588. this.m_chartHelpers = {};
  2589. this.m_savedSelectedChartNodes = [];
  2590. var noOfSelectedChartNodes = this.m_selectedChartNodes.length;
  2591. var temp = [];
  2592. for( var i=0; i < noOfSelectedChartNodes; i++ )
  2593. {
  2594. if( this.isMeasure( this.m_selectedChartNodes[i].m_contextIds[0][0] ) )
  2595. {
  2596. var chartArea = this.m_selectedChartNodes[i].getArea();
  2597. var mapName = this.getImageMapName(chartArea);
  2598. this.m_chartHelpers[mapName] = this.m_savedChartHelpers[mapName];
  2599. delete this.m_savedChartHelpers[mapName];
  2600. temp.push( this.m_selectedChartNodes[i]);
  2601. } else {
  2602. this.m_savedSelectedChartNodes.push( this.m_selectedChartNodes[i]);
  2603. }
  2604. }
  2605. this.m_selectedChartNodes = temp;
  2606. }
  2607. this.m_bSavedSelections = true;
  2608. };
  2609. CSelectionController.prototype.hasSavedSelections = function()
  2610. {
  2611. return this.m_bSavedSelections;
  2612. }
  2613. CSelectionController.prototype.hasSavedSelectedObjects = function()
  2614. {
  2615. return ( this.m_aSavedSelectedObjects && this.m_aSavedSelectedObjects.length > 0 ) || this.hasSavedSelectedChartNodes();
  2616. }
  2617. CSelectionController.prototype.getSavedSelectedObjects = function()
  2618. {
  2619. return this.m_aSavedSelectedObjects;
  2620. };
  2621. CSelectionController.prototype.getImageMapName = function(chartArea){
  2622. var imageMap = chartArea.parentNode;
  2623. return imageMap.name;
  2624. };
  2625. /**
  2626. * Fix up the chart helpers - for saved nodes, use the saved chart helper
  2627. */
  2628. CSelectionController.prototype.repaintBUXSelectedChartArea = function( chartNodes, bUseSavedChartHelpers, bExcludeMeasuresOnly ) {
  2629. var chartHelperUsed = {};
  2630. var noOfChartNodes = chartNodes.length;
  2631. for( var i = 0; i < noOfChartNodes; i++){
  2632. var chartArea = chartNodes[i].getArea();
  2633. var mapName = this.getImageMapName(chartArea);
  2634. var chartHelper;
  2635. if( !chartHelperUsed[ mapName] ){
  2636. chartHelper = (bUseSavedChartHelpers) ? this.getSavedChartHelper( chartArea ) : this.getChartHelper( chartArea );
  2637. chartHelperUsed[ mapName ] = chartHelper;
  2638. var imageMapHighlighter = chartHelper.getImageMapHighlighter();
  2639. imageMapHighlighter.hideAllAreas();
  2640. imageMapHighlighter.setFillColour( this.getPrimarySelectionColor() );
  2641. imageMapHighlighter.setStrokeColour( this.getPrimarySelectionColor());
  2642. } else {
  2643. chartHelper = chartHelperUsed[ mapName];
  2644. }
  2645. var contextIds = chartNodes[i].m_contextIds;
  2646. if( bExcludeMeasuresOnly && contextIds.length === 1 && contextIds[0].length === 1 && this.isMeasure(contextIds[0][0])){
  2647. continue;
  2648. }
  2649. imageMapHighlighter.highlightAreas( chartNodes[i].getCtxAreas(), 1 );
  2650. }
  2651. }
  2652. CSelectionController.prototype.repaintSavedSelections = function()
  2653. {
  2654. var tempStyle = this.m_selectionStyles;
  2655. this.m_selectionStyles = this.m_savedSelectionStyles;
  2656. var selections = this.getSavedSelectedChartNodes();
  2657. var bIsChartSelection = false;
  2658. if( selections && selections.length > 0 ){
  2659. bIsChart = true;
  2660. } else {
  2661. selections = this.getSavedSelectedObjects();
  2662. }
  2663. this.repaintSelectionsHelper( selections, true /*bRepaintSavedSelections*/, bIsChartSelection );
  2664. this.resetSelectionStyles();
  2665. this.m_selectionStyles = tempStyle;
  2666. };
  2667. CSelectionController.prototype.repaintSelections = function()
  2668. {
  2669. var selections = this.getSelectedChartNodes();
  2670. var bIsChartSelection = false;
  2671. if( selections && selections.length > 0 ){
  2672. bIsChartSelection = true;
  2673. } else {
  2674. selections = this.getSelections();
  2675. }
  2676. this.repaintSelectionsHelper( selections, false /*bRepaintSavedSelections*/, bIsChartSelection );
  2677. };
  2678. CSelectionController.prototype.repaintSelectionsHelper = function( selections, bRepaintSavedSelections, bIsChartSelection )
  2679. {
  2680. try
  2681. {
  2682. if( bIsChartSelection ){
  2683. this.repaintBUXSelectedChartArea( selections, bRepaintSavedSelections );
  2684. } else {
  2685. /**
  2686. * For crosstab and list
  2687. */
  2688. // remove current selections UI
  2689. this.updateUI(document, selections, true /*deselect*/, false /*isCut*/);
  2690. // update with new selections UI
  2691. this.updateUI(document, selections, false /*deselect*/, false /*isCut*/ );
  2692. }
  2693. }
  2694. catch (e)
  2695. {
  2696. //alert("error selecting column -- please contact your administrator!");
  2697. return false;
  2698. }
  2699. }
  2700. CSelectionController.prototype.resetAll = function()
  2701. {
  2702. this.resetSelectionStyles();
  2703. this.clearSavedSelections();
  2704. this.resetSelections();
  2705. this.resetAllowHorizontalDataValueSelection();
  2706. };
  2707. CSelectionController.prototype.pageClicked = function(e )
  2708. {
  2709. try{
  2710. var node = getNodeFromEvent(e);
  2711. // make sure we don't reselect a node that's already selected (performance)
  2712. if (this.m_aSelectedObjects.length > 0 && !this.shiftKeyPressed(e) && !this.ctrlKeyPressed(e)) {
  2713. var tempNode = node;
  2714. // need to find the node with 'uid' since it's that node that's part of the selection object
  2715. if (!tempNode.getAttribute("uid")) {
  2716. var parentNode = tempNode.parentNode;
  2717. if (parentNode && parentNode.nodeType == 1 && typeof parentNode.getAttribute != "undefined" && parentNode.getAttribute("uid") != null) {
  2718. tempNode = parentNode;
  2719. }
  2720. }
  2721. if (this.isCellSelected(tempNode)) {
  2722. if( typeof this.m_oCognosViewer.isBux !== "undefined" ){
  2723. this.repaintSelections();
  2724. }
  2725. // If the user right clicks on a cell without pressing ctrl or shift don't change the selection,
  2726. // he's looking to open the context menu with the currently selected cells
  2727. if (e.button !== 0) {
  2728. return false;
  2729. }
  2730. }
  2731. }
  2732. if (node.tagName && node.tagName.toUpperCase() == "INPUT") {
  2733. //This key was for a text input entry, allow the event to bubble
  2734. return true;
  2735. }
  2736. if ((e.keyCode != null) && (e.keyCode != 13) && (e.keyCode != 32) && (e.keyCode != 27) && (e.keyCode != 0) && (e.keyCode != 121) && (e.keyCode != 93)) {
  2737. return false;
  2738. }
  2739. var nodeDocument = getDocumentFromEvent(e);
  2740. if (!this.hasContextData() || !this.hasMetadata())
  2741. {
  2742. // Update anyway- necessary for updating context menu for authored drill
  2743. // when there is no selection when context data is absent
  2744. if(node.nodeName == 'AREA' || node.nodeName == 'IMG' || (typeof node.getAttribute == "function" && node.getAttribute("flashChart") != null))
  2745. {
  2746. this.setSelectedChartArea(node, e);
  2747. }
  2748. this.getObservers().notify();
  2749. return false;
  2750. }
  2751. if(typeof node.selectedCell != "undefined")
  2752. {
  2753. var divRegion = node;
  2754. node = node.selectedCell;
  2755. divRegion.removeAttribute("selectedCell");
  2756. }
  2757. if (typeof cf != "undefined" && typeof cf.hidePickers == "function")
  2758. {
  2759. cf.hidePickers();
  2760. }
  2761. if (e.keyCode == 27)
  2762. {
  2763. if (typeof g_reportSelectionController != "undefined")
  2764. {
  2765. g_reportSelectionController.clearSelections();
  2766. }
  2767. this.resetSelections(nodeDocument);
  2768. }
  2769. else if(node.nodeName == 'AREA' || node.nodeName == 'IMG' || (typeof node.getAttribute != "undefined" && node.getAttribute("flashChart") != null))
  2770. {
  2771. if (e.button !== 2 || this.getAllSelectedObjects().length <= 1 || typeof this.m_oCognosViewer.isBux === "undefined") {
  2772. this.selectNode(node, e);
  2773. this.setSelectedChartArea(node, e );
  2774. }
  2775. }
  2776. //Do not select a blank crosstab corner cell
  2777. else if (!(node.firstChild == null && node.cellIndex == 0 && node.parentNode.rowIndex == 0 && node.getAttribute("cid") == null))
  2778. {
  2779. //Prevent a right-click in BUX from changing the selection only when there are already multiple selections
  2780. //This enables the context menu actions which require multiple select, like calculations
  2781. var widget = this.m_oCognosViewer.getViewerWidget();
  2782. this.selectNode(node, e);
  2783. }
  2784. if (window.gViewerLogger) {
  2785. window.gViewerLogger.addContextInfo(this);
  2786. }
  2787. }
  2788. catch (e) {
  2789. // sometimes node may not be an HTML element (like a XUL element) and accessing nodeType/nodeName/className will generate an error.
  2790. }
  2791. };
  2792. CSelectionController.prototype.getSelectionObjectFactory = function()
  2793. {
  2794. return this.m_oSelectionObjectFactory;
  2795. };
  2796. CSelectionController.prototype.isDrillLinkOnCrosstabCell = function(node)
  2797. {
  2798. return (node.getAttribute("ctx") == null && node.parentNode.getAttribute("dtTargets") != null);
  2799. };
  2800. CSelectionController.prototype.selectObject = function(sMun, sLun, sHun, bIgnoreDrillFlag)
  2801. {
  2802. var ctxId = this.getCtxIdFromMun(sMun);
  2803. if(ctxId == "")
  2804. {
  2805. ctxId = this.getCtxIdFromMetaData(sLun, sHun, bIgnoreDrillFlag);
  2806. }
  2807. if(ctxId != null && this.m_oCDManager.GetUsage(ctxId) != "2") // check that it's not a measure
  2808. {
  2809. var reportTable = document.getElementById("rt" + this.getNamespace());
  2810. if(reportTable != null)
  2811. {
  2812. var cellRef = getElementsByAttribute(reportTable, "*", "ctx", ctxId);
  2813. if( cellRef && cellRef.length === 0 )
  2814. {
  2815. var attributeValueExp = new RegExp("(^|:)" + ctxId + "(:|$)", "i");
  2816. cellRef = getElementsByAttribute( reportTable, "*", "ctx", ctxId, -1, attributeValueExp);
  2817. }
  2818. var selectionObject = null;
  2819. if(cellRef != null && cellRef.length > 0)
  2820. {
  2821. selectionObject = new CSelectionObject();
  2822. selectionObject.setSelectionController(this);
  2823. selectionObject.m_sColumnRef = cellRef[0].getAttribute("cid");
  2824. selectionObject.m_sCellTypeId = cellRef[0].getAttribute("uid");
  2825. selectionObject.m_sLayoutType = cellRef[0].getAttribute("type");
  2826. selectionObject.m_sTag = cellRef[0].getAttribute("tag");
  2827. selectionObject.m_layoutElementId = this.m_oSelectionObjectFactory.getLayoutElementId(cellRef[0]);
  2828. selectionObject.m_dataContainerType = this.m_oSelectionObjectFactory.getContainerType(cellRef[0]);
  2829. selectionObject.m_contextIds = [[ctxId]];
  2830. this.m_aSelectedObjects[this.m_aSelectedObjects.length] = selectionObject;
  2831. }
  2832. else
  2833. {
  2834. var flashCharts = getElementsByAttribute(reportTable, "*", "flashChart", "true");
  2835. if(flashCharts != null)
  2836. {
  2837. for(var index = 0; index < flashCharts.length; ++index)
  2838. {
  2839. var ldx = flashCharts[index].getLDX();
  2840. if(ldx.indexOf("<ctx>" + ctxId + "</ctx>") != -1)
  2841. {
  2842. selectionObject = new CSelectionObject();
  2843. selectionObject.setSelectionController(this);
  2844. var lid = flashCharts[index].getAttribute("lid");
  2845. selectionObject.m_layoutElementId = lid.replace(this.m_oCognosViewer.getId(), "");
  2846. selectionObject.m_dataContainerType = "chart";
  2847. selectionObject.m_contextIds = [[ctxId]];
  2848. this.m_aSelectedObjects[this.m_aSelectedObjects.length] = selectionObject;
  2849. }
  2850. }
  2851. }
  2852. }
  2853. }
  2854. }
  2855. };
  2856. CSelectionController.prototype.buildSelectionObject = function(node, e)
  2857. {
  2858. var SelObj = null;
  2859. try {
  2860. while (node.nodeType == 3) { // test to see if this is a text node
  2861. node = node.parentNode;
  2862. }
  2863. // crosstab cell check on a drill link. RSVP does not output ctx values on a crosstab cell, so we need to have special handling for drill link on a xtab cell.
  2864. if(this.isDrillLinkOnCrosstabCell(node))
  2865. {
  2866. node = node.parentNode;
  2867. }
  2868. var ctx = node.getAttribute("ctx");
  2869. var uid = node.getAttribute("uid");
  2870. if ((uid == null) && ((ctx != null) || (node.parentNode && node.parentNode.nodeType == 1 && typeof node.parentNode.getAttribute != "undefined" && node.parentNode.getAttribute("uid") != null))) // this is a textitem or chart img
  2871. {
  2872. //Test to see if we're clicking on a chart in a sectioned report
  2873. if (node.nodeName == "IMG" && (node.src.indexOf("SM=") > -1 || (isIE() > -1 && node.src.indexOf("space.gif") > -1))) {
  2874. return null;
  2875. }
  2876. node = node.parentNode;
  2877. // special case for Bug#498910. Analysis Studio is adding a members attributes within the same td, broken up by divs.
  2878. // If the parent node is a DIV and the class is "BLOCK", move up one level higher in the DOM
  2879. if((node.className.toUpperCase() == "BLOCK" && node.nodeName.toUpperCase() == "DIV") || (node.getAttribute("dtTargets") != null))
  2880. {
  2881. node = node.parentNode;
  2882. }
  2883. uid = node.getAttribute("uid");
  2884. }
  2885. if (uid != null) // this is a valid column element
  2886. {
  2887. var nodeChildren = node.childNodes;
  2888. for (var i = 0; i < nodeChildren.length; i++)
  2889. {
  2890. if (nodeChildren[i].nodeName.toUpperCase() == "TABLE" && (nodeChildren[i].className == "ls" || nodeChildren[i].className=="xt"))
  2891. {
  2892. //Note that we can't purely match on the "ls" or "xt" classes for a table because they could be user assigned in RS, we must dig further
  2893. var trs = nodeChildren[i].rows;
  2894. for (var j = 0; j < trs.length; j++)
  2895. {
  2896. var tds = trs[j].cells;
  2897. for (var k = 0; k < tds.length; k++)
  2898. {
  2899. if (tds[k].getAttribute("uid") != null)
  2900. {
  2901. //We've found a nested list or crosstab, therefore we don't want to select the outer list cell
  2902. return null;
  2903. }
  2904. }
  2905. }
  2906. }
  2907. }
  2908. if(node.className.toUpperCase() == "REPEATERTABLECELL" && ctx != null)
  2909. {
  2910. SelObj = this.getSelectionObjectFactory().getSelectionObject(node, ctx);
  2911. }
  2912. else
  2913. {
  2914. SelObj = this.getSelectionObjectFactory().getSelectionObject(node);
  2915. }
  2916. }
  2917. }catch (e) {
  2918. // sometimes node may not be an HTML element (like a XUL element) and accessing nodeType/nodeName/className will generate an error.
  2919. }
  2920. return SelObj;
  2921. };
  2922. /**
  2923. * Helper function to figure out if the shift key was pressed. Needed since there's
  2924. * a bug in safari where the event from a right mouse click will ALWAYS have shiftKey set
  2925. * to true. So if we're in Safari and the event is from the right mouse, we'll pretend the shift key
  2926. * wasn't clicked. This is a small change in behavior, but only for safari users and there's no
  2927. * way around it
  2928. * @param {Object} e
  2929. */
  2930. CSelectionController.prototype.shiftKeyPressed = function(e) {
  2931. if (e.keyCode == "121") {
  2932. // context menu is Shift + F10, so if the key is F10 pretend the shift isn't
  2933. // pressed or we'll do multiple selection
  2934. return false;
  2935. }
  2936. if (isSafari()) {
  2937. if (e.button != 2) {
  2938. return e.shiftKey ? e.shiftKey : false;
  2939. }
  2940. else {
  2941. return false;
  2942. }
  2943. }
  2944. return e.shiftKey ? e.shiftKey : false;
  2945. };
  2946. /**
  2947. * Helper function to figure out if the ctrl key was pressed. Needed since there's
  2948. * a bug in safari where the event from a right mouse click will ALWAYS have ctrl set
  2949. * to true. So if we're in Safari and the event is from the right mouse, we'll pretend the ctrl key
  2950. * wasn't clicked. This is a small change in behavior, but only for safari users and there's no
  2951. * way around it
  2952. * @param {Object} e
  2953. */
  2954. CSelectionController.prototype.ctrlKeyPressed = function(e) {
  2955. if (isSafari()) {
  2956. if (e.button != 2) {
  2957. return e.ctrlKey ? e.ctrlKey : false;
  2958. }
  2959. else {
  2960. return false;
  2961. }
  2962. }
  2963. return e.ctrlKey ? e.ctrlKey : false;
  2964. };
  2965. CSelectionController.prototype.isSelectionsPreviouslySaved = function( selections )
  2966. {
  2967. var bIsPreviousSelectedObjectAFilter = false;
  2968. if( !this.m_aSavedSelectedObjects || !this.m_aSavedSelectedObjects.length || !selections || !selections.length )
  2969. {
  2970. return false;
  2971. }
  2972. for( var i = 0; i < selections.length; i++ ){
  2973. if( this.isSavedCellSelected( selections[i].getCellRef() ) ){
  2974. return true;
  2975. }
  2976. }
  2977. return false;
  2978. };
  2979. CSelectionController.prototype.selectNode = function(node, e)
  2980. {
  2981. try{
  2982. while (node.nodeType == 3) { // test to see if this is a text node
  2983. node = node.parentNode;
  2984. }
  2985. // crosstab cell check on a drill link. RSVP does not output ctx values on a crosstab cell, so we need to have special handling for drill link on a xtab cell.
  2986. if(this.isDrillLinkOnCrosstabCell(node))
  2987. {
  2988. node = node.parentNode;
  2989. }
  2990. var nodeDocument = null;
  2991. if (isIE()) {
  2992. nodeDocument = node.document;
  2993. }
  2994. else {
  2995. nodeDocument = node.ownerDocument;
  2996. }
  2997. var ctx = node.getAttribute("ctx");
  2998. var uid = node.getAttribute("uid");
  2999. var callRefresh = false;
  3000. if (typeof e == "undefined") {
  3001. e = {};
  3002. }
  3003. var reportElementNode = false;
  3004. if (typeof g_reportSelectionController != "undefined")
  3005. {
  3006. reportElementNode = this.checkForReportElementNode(node);
  3007. }
  3008. if ((ctx == null && uid == null && node.parentNode.nodeType == 1 && node.parentNode.getAttribute("uid") == null && reportElementNode == false) || (!this.ctrlKeyPressed(e) && !this.shiftKeyPressed(e))) //if didn't use ctrl or shift click, deselect the other selections
  3009. {
  3010. if (this.getSelections().length > 0) {
  3011. callRefresh = true;
  3012. }
  3013. if (this.hasCutColumns() == true) {
  3014. this.clearSelectedObjects(nodeDocument);
  3015. }
  3016. else
  3017. {
  3018. this.resetSelections( nodeDocument);
  3019. //make sure to repaint saved selections
  3020. this.repaintSavedSelections();
  3021. //TODO this needs to be removed
  3022. //This will remove all selection objects from the list of selected columns in Query Studio
  3023. if (typeof cf != "undefined" && typeof cf.removeAllSelectionsFromCfgVariables == "function") {
  3024. cf.removeAllSelectionsFromCfgVariables();
  3025. }
  3026. this.m_oCognosViewer.setCurrentNodeFocus(null);
  3027. }
  3028. if (this.ctrlKeyPressed(e) || this.shiftKeyPressed(e)) {
  3029. clearTextSelection(nodeDocument);
  3030. }
  3031. if (typeof g_reportSelectionController != "undefined" && reportElementNode == false)
  3032. {
  3033. if (g_reportSelectionController.getSelections().length > 0) {
  3034. callRefresh = true;
  3035. }
  3036. g_reportSelectionController.clearSelections();
  3037. }
  3038. }
  3039. var dtTargetsNode = node.getAttribute("dtTargets") ? node : null;
  3040. var areaNodeSelected = (node.nodeName.toLowerCase()==="area");
  3041. if ((uid == null) && ((ctx != null) || (node.parentNode && node.parentNode.nodeType == 1 && typeof node.parentNode.getAttribute != "undefined"))) // this is a textitem or chart img
  3042. {
  3043. //Test to see if we're clicking on a chart in a sectioned report
  3044. if (node.nodeName == "IMG" && (node.src.indexOf("SM=") > -1 || (isIE() > -1 && node.src.indexOf("space.gif") > -1))) {
  3045. return false;
  3046. }
  3047. // Old logic plus testing shows that we must go up 1 level in the DOM, then if the parent
  3048. // node is a DIV or SPAN, we have to go up a maximum of 2 more levels until we find the UID attribute.
  3049. // Scenarios :
  3050. // Saved HTML outputs
  3051. // 498910: Analysis Studio is adding a members attributes within the same td, broken up by divs.
  3052. // 195442: PI86860 USING DRILL THROUGH IN A CONDITIONAL BLOCK, WHEN YOU RIGHT CLICKINSTEAD OF SHOWING THE DRILL TRU MENU, IT SHOWS THE BROWSER MENU
  3053. var nodeName;
  3054. var maxIters = 3;
  3055. do {
  3056. node = node.parentNode;
  3057. if (node) {
  3058. dtTargetsNode = (!dtTargetsNode && typeof node.getAttribute != "undefined" && node.getAttribute("dtTargets")) ? node : dtTargetsNode;
  3059. uid = (typeof node.getAttribute != "undefined") ? node.getAttribute("uid") : null;
  3060. nodeName = node.nodeName.toLowerCase();
  3061. }
  3062. } while ((uid == null) && node && (--maxIters > 0) && (nodeName == "span" || nodeName == "div"));
  3063. }
  3064. if (uid != null) // this is a valid column element
  3065. {
  3066. var nodeChildren = node.childNodes;
  3067. for (var i = 0; i < nodeChildren.length; i++)
  3068. {
  3069. if (nodeChildren[i].nodeName.toUpperCase() == "TABLE" && (nodeChildren[i].className == "ls" || nodeChildren[i].className=="xt"))
  3070. {
  3071. //Note that we can't purely match on the "ls" or "xt" classes for a table because they could be user assigned in RS, we must dig further
  3072. var trs = nodeChildren[i].rows;
  3073. for (var j = 0; j < trs.length; j++)
  3074. {
  3075. var tds = trs[j].cells;
  3076. for (var k = 0; k < tds.length; k++)
  3077. {
  3078. if (tds[k].getAttribute("uid") != null)
  3079. {
  3080. //We've found a nested list or crosstab, therefore we don't want to select the outer list cell
  3081. return false;
  3082. }
  3083. }
  3084. }
  3085. }
  3086. }
  3087. var SelObj;
  3088. if(node.className.toUpperCase() == "REPEATERTABLECELL" && ctx != null)
  3089. {
  3090. SelObj = this.getSelectionObjectFactory().getSelectionObject(node, ctx);
  3091. }
  3092. else
  3093. {
  3094. SelObj = this.getSelectionObjectFactory().getSelectionObject(node);
  3095. }
  3096. // Determine if this column is already selected (if so, unselect it if CTRL or SHIFT clicked)
  3097. if (this.isCellSelected(node) == false)
  3098. { // If the cell is not selected, select it
  3099. if (this.shiftKeyPressed(e))
  3100. {
  3101. var allSelections = this.getSelections();
  3102. if (allSelections.length > 0)
  3103. {
  3104. var lastSelection = allSelections[allSelections.length - 1];
  3105. //Make sure both selections have the same layout and they are in the same table
  3106. if (lastSelection.getLayoutType() == SelObj.getLayoutType() && (lastSelection.getCellRef().parentNode.parentNode == SelObj.getCellRef().parentNode.parentNode))
  3107. {
  3108. //Check if we want to multi-select rows or columns
  3109. if(this.cellsAreInSameColumn(lastSelection.getCellRef(), SelObj.getCellRef()))
  3110. {
  3111. this.selectVertical(lastSelection, SelObj, nodeDocument);
  3112. }
  3113. //Shift-selection on the same row
  3114. else if(lastSelection.getCellRef().parentNode.rowIndex == SelObj.getCellRef().parentNode.rowIndex)
  3115. {
  3116. this.selectHorizontal(lastSelection, SelObj, nodeDocument);
  3117. }
  3118. }
  3119. }
  3120. clearTextSelection(nodeDocument);
  3121. }
  3122. else if (this.ctrlKeyPressed(e)) {
  3123. clearTextSelection(nodeDocument);
  3124. }
  3125. this.addSelectionObject(SelObj, nodeDocument);
  3126. // This will add the selection object to the list of selected columns in Query Studio
  3127. if (typeof cf != "undefined" && typeof cf.addSelectionToCfgVariables == "function") {
  3128. cf.addSelectionToCfgVariables(SelObj.getColumnName());
  3129. }
  3130. this.m_oCognosViewer.setCurrentNodeFocus(node);
  3131. }
  3132. else
  3133. {
  3134. if (this.ctrlKeyPressed(e))
  3135. { // Otherwise the cell is selected, and this is a CTRL click, so unselect it
  3136. this.removeSelectionObject(SelObj, nodeDocument);
  3137. // This will remove the selection of the specified column if it's the only selection in that column in Query Studio
  3138. if (typeof cf != "undefined" && typeof cf.removeSelectionFromCfgVariables == "function")
  3139. {
  3140. /* TODO: Put this back in once Report Server starts to produce context data
  3141. if (!this.isColumnSelected(SelObj.getColumnName()))
  3142. cf.removeSelectionFromCfgVariables(SelObj.getTag());
  3143. /TODO */
  3144. /* TODO: Take this out once Report Server starts to produce context data */
  3145. if (!this.isColumnSelected(SelObj.getTag())) {
  3146. cf.removeSelectionFromCfgVariables(SelObj.getTag());
  3147. }
  3148. /* /TODO */
  3149. }
  3150. clearTextSelection(nodeDocument);
  3151. }
  3152. else if (this.shiftKeyPressed(e)) {
  3153. clearTextSelection(nodeDocument);
  3154. }
  3155. }
  3156. callRefresh = true;
  3157. }
  3158. else if (reportElementNode)
  3159. {
  3160. var style = null;
  3161. while ((typeof node.id == "undefined" || node.id == null || node.id == "") && node.parentNode != null) {
  3162. node = node.parentNode;
  3163. }
  3164. if (node.id == "reportTitle") {
  3165. style = 'TitleStyle';
  3166. }
  3167. else if (node.id == "reportSubtitle") {
  3168. style = 'SubtitleStyle';
  3169. }
  3170. else if (node.id.indexOf("reportFilter") == 0) {
  3171. style = 'FilterStyle';
  3172. }
  3173. if (style != null)
  3174. {
  3175. selectReportElement(e,node.id,style);
  3176. callRefresh = true;
  3177. }
  3178. }
  3179. // special case where we need to select a drill through node that has no UI for Mobile
  3180. else if (dtTargetsNode != null && this.m_oCognosViewer && this.m_oCognosViewer.isMobile() && !areaNodeSelected) {
  3181. var SelObj = this.getSelectionObjectFactory().getSelectionObject(dtTargetsNode);
  3182. this.addSelectionObject(SelObj, nodeDocument );
  3183. }
  3184. //This will refresh the dialogs with a new list of selected columns in Query Studio
  3185. if (callRefresh == true && (typeof cf != "undefined" && typeof cf.refreshDialog == "function")) {
  3186. cf.refreshDialog();
  3187. }
  3188. }
  3189. catch(ex) {
  3190. // sometimes node may not be an HTML element (like a XUL element) and accessing nodeType/nodeName/className will generate an error.
  3191. }
  3192. };
  3193. CSelectionController.prototype.selectDrillThroughImage = function(node) {
  3194. this.m_oSelectedDrillThroughImage = node;
  3195. };
  3196. CSelectionController.prototype.getSelectedDrillThroughImage = function() {
  3197. return this.m_oSelectedDrillThroughImage ? this.m_oSelectedDrillThroughImage : null;
  3198. };
  3199. CSelectionController.prototype.selectDrillThroughSingleton = function(node) {
  3200. this.m_oSelectedDrillThroughSingleton = node;
  3201. }
  3202. CSelectionController.prototype.getSelectDrillThroughSingleton = function() {
  3203. return this.m_oSelectedDrillThroughSingleton ? this.m_oSelectedDrillThroughSingleton : null;
  3204. };
  3205. //Deprecated way
  3206. CSelectionController.prototype.getReportContextDataArray = function()
  3207. {
  3208. return this.m_aReportContextDataArray;
  3209. };
  3210. CSelectionController.prototype.getReportMetadataArray = function()
  3211. {
  3212. return this.m_aReportMetadataArray;
  3213. };
  3214. CSelectionController.prototype.setupContextDataArray = function(contextDataArray)
  3215. {
  3216. this.m_aReportContextDataArray = contextDataArray;
  3217. };
  3218. CSelectionController.prototype.setupMetaDataArray = function(metaDataArray)
  3219. {
  3220. this.m_aReportMetadataArray = metaDataArray;
  3221. };
  3222. //JSON Way
  3223. CSelectionController.prototype.addContextData = function(contextDataJSONSpec) {
  3224. this.m_aSelectedObjects = [];
  3225. this.m_oCDManager.SetContextData(contextDataJSONSpec);
  3226. if (!this.m_bUsingCCDManager) {
  3227. this.m_bUsingCCDManager = true;
  3228. }
  3229. for(var i = 0; i < this.m_selectedClass.length; ++i) {
  3230. this.deselecting(this.m_selectedClass);
  3231. }
  3232. };
  3233. CSelectionController.prototype.addMetaData = function(metaDataJSONSpec) {
  3234. this.m_aSelectedObjects = [];
  3235. this.m_oCDManager.SetMetadata(metaDataJSONSpec);
  3236. if (!this.m_bUsingCCDManager) {
  3237. this.m_bUsingCCDManager = true;
  3238. }
  3239. };
  3240. // Y Valve Deprecated and Old ways
  3241. CSelectionController.prototype.getDrillFlag = function(contextId) {
  3242. var drill = "";
  3243. if (!this.m_bUsingCCDManager) {
  3244. var contextObj = this.m_aReportContextDataArray[contextId];
  3245. var dataItemRefId = contextObj[0];
  3246. var contextDataItem = this.m_aReportMetadataArray[dataItemRefId];
  3247. if(typeof contextDataItem != "undefined" && typeof contextDataItem[3] != "undefined")
  3248. {
  3249. drill = contextDataItem[3];
  3250. }
  3251. } else {
  3252. drill = this.m_oCDManager.GetDrillFlag(contextId);
  3253. }
  3254. return drill;
  3255. };
  3256. CSelectionController.prototype.getDrillFlagForMember = function(sCtxId)
  3257. {
  3258. var drillFlag = "0";
  3259. if (!this.m_bUsingCCDManager) {
  3260. var contextItem = this.getContextDataItem(sCtxId);
  3261. if(contextItem != null)
  3262. {
  3263. // check to see that this is a "member"
  3264. var metaDataRefMunKey = contextItem[2]; //Mun reference key
  3265. if(metaDataRefMunKey != "")
  3266. {
  3267. var metaDataRefDataItemKey = contextItem[0]; //data item reference key
  3268. var metaDataItem = this.getMetaDataItem(metaDataRefDataItemKey);
  3269. if(metaDataItem != null)
  3270. {
  3271. drillFlag = metaDataItem[3]; //drill flag index
  3272. }
  3273. }
  3274. }
  3275. } else {
  3276. drillFlag = this.m_oCDManager.GetDrillFlagForMember(sCtxId);
  3277. }
  3278. return (drillFlag == null) ? 0 : drillFlag;
  3279. };
  3280. CSelectionController.prototype.getDataType = function(contextId) {
  3281. var dtype = null;
  3282. if (!this.m_bUsingCCDManager) {
  3283. var aData = this.getRDI(contextId);
  3284. if (aData && aData.length > 2)
  3285. {
  3286. dtype = parseInt(aData[2],10);
  3287. }
  3288. } else {
  3289. dtype = parseInt(this.m_oCDManager.GetDataType(contextId),10);
  3290. }
  3291. return dtype;
  3292. };
  3293. CSelectionController.prototype.getUsageInfo = function(contextId) {
  3294. if (this.m_bUsingCCDManager) {
  3295. return this.m_oCDManager.GetUsage(contextId);
  3296. }
  3297. };
  3298. CSelectionController.prototype.isMeasure = function(contextId) {
  3299. return (this.getUsageInfo(contextId) == this.c_usageMeasure);
  3300. };
  3301. CSelectionController.prototype.getDepth = function(contextId) {
  3302. var sLevel = null;
  3303. if (!this.m_bUsingCCDManager) {
  3304. var aData = this.getRDI(contextId);
  3305. if (aData && aData.length > 5 && aData[1] == "R") {
  3306. sLevel = aData[5];
  3307. }
  3308. } else {
  3309. sLevel = this.m_oCDManager.GetDepth(contextId);
  3310. }
  3311. return sLevel;
  3312. };
  3313. CSelectionController.prototype.getUseValue = function(contextId)
  3314. {
  3315. var value = "";
  3316. if (!this.m_bUsingCCDManager) {
  3317. var contextObj = this.m_aReportContextDataArray[contextId];
  3318. if(typeof contextObj[1] != "undefined")
  3319. {
  3320. value = contextObj[1];
  3321. }
  3322. } else {
  3323. value = this.m_oCDManager.GetDisplayValue(contextId);
  3324. }
  3325. return value;
  3326. };
  3327. CSelectionController.prototype.getTextValue = function(aSpans) {
  3328. var value = null;
  3329. // need to find the span that has a ctx attribute equal or starts with
  3330. // the contextId passed in
  3331. for (var iIndex=0; iIndex < aSpans.length; iIndex++)
  3332. {
  3333. if (aSpans[iIndex].style.visisbility != "hidden")
  3334. {
  3335. if(isIE())
  3336. {
  3337. value = aSpans[iIndex].innerText;
  3338. }
  3339. else
  3340. {
  3341. value = aSpans[iIndex].textContent;
  3342. }
  3343. // need to check if there are any other spans with the same ctx. RSVP sometimes
  3344. // uses multiple spans when generting one label
  3345. var sibling = aSpans[iIndex].nextSibling;
  3346. while (sibling != null)
  3347. {
  3348. if (sibling.nodeName.toUpperCase() == "SPAN" && sibling.style.visibility != "hidden")
  3349. {
  3350. if(isIE())
  3351. {
  3352. value += sibling.innerText;
  3353. }
  3354. else
  3355. {
  3356. value += sibling.textContent;
  3357. }
  3358. }
  3359. sibling = sibling.nextSibling;
  3360. }
  3361. break;
  3362. }
  3363. }
  3364. return value;
  3365. };
  3366. CSelectionController.prototype.getDisplayValueFromDOM = function(contextId, srcNode) {
  3367. var value = null;
  3368. var htmlNodes;
  3369. var ctxRegex = new RegExp("(^|\\s)" + contextId + "(\\s|$|:)", "i");
  3370. if (typeof srcNode != "undefined")
  3371. {
  3372. htmlNodes = getElementsByAttribute(srcNode, ["span", "td", "th"], "ctx", contextId, 1, ctxRegex);
  3373. }
  3374. else
  3375. {
  3376. var oIFrame = document.getElementById('CVIFrame' + this.m_sNamespace);
  3377. if (typeof oIFrame == "undefined" || oIFrame == null)
  3378. {
  3379. var oRVContent = document.getElementById('RVContent' + this.m_sNamespace);
  3380. if (typeof oRVContent == "undefined" || oRVContent == null)
  3381. {
  3382. htmlNodes = getElementsByAttribute(document.body, ["span", "td", "th"], "ctx", contextId, 1, ctxRegex);
  3383. }
  3384. else
  3385. {
  3386. htmlNodes = getElementsByAttribute(oRVContent, ["span", "td", "th"], "ctx", contextId, 1, ctxRegex);
  3387. }
  3388. }
  3389. else
  3390. {
  3391. htmlNodes = getElementsByAttribute(oIFrame.contentWindow.document.body, ["span", "td", "th"], "ctx", contextId, 1, ctxRegex);
  3392. }
  3393. }
  3394. var aSpans;
  3395. if(htmlNodes.length > 0 && (htmlNodes[0].nodeName.toUpperCase() == "TD" || htmlNodes[0].nodeName.toUpperCase() == "TH"))
  3396. {
  3397. aSpans = htmlNodes[0].childNodes;
  3398. }
  3399. else
  3400. {
  3401. aSpans = htmlNodes;
  3402. }
  3403. // For Annotations/Comments get the value through getUseValue().
  3404. if (aSpans.length == 0 ||
  3405. (aSpans[0].className.indexOf("chart_area")==-1 && aSpans[0].className.indexOf("bux-comment")==-1))
  3406. {
  3407. value = this.getTextValue(aSpans);
  3408. }
  3409. return value;
  3410. };
  3411. CSelectionController.prototype.getDisplayValue = function(contextId, srcNode) {
  3412. var value = this.getDisplayValueFromDOM(contextId, srcNode);
  3413. if (value == null)
  3414. {
  3415. value = this.getUseValue(contextId);
  3416. }
  3417. return value;
  3418. };
  3419. CSelectionController.prototype.getDun = function(contextId)
  3420. {
  3421. if (this.m_bUsingCCDManager)
  3422. {
  3423. return this.m_oCDManager.GetDUN(contextId);
  3424. }
  3425. else
  3426. {
  3427. var contextObj = this.m_aReportContextDataArray[contextId];
  3428. if(contextObj && typeof contextObj[5] != "undefined"){
  3429. var dimensionRefId = contextObj[5];
  3430. var contextDimension = this.m_aReportMetadataArray[dimensionRefId];
  3431. if(typeof contextDimension != "undefined" && typeof contextDimension[1] != "undefined" && contextDimension[1] == "D")
  3432. {
  3433. return contextDimension[0];
  3434. }
  3435. }
  3436. }
  3437. };
  3438. CSelectionController.prototype.getPun = function(contextId) {
  3439. if (this.m_bUsingCCDManager) {
  3440. return this.m_oCDManager.GetPUN(contextId);
  3441. }
  3442. };
  3443. CSelectionController.prototype.getLun = function(contextId) {
  3444. var lun = "";
  3445. if (!this.m_bUsingCCDManager) {
  3446. var contextObj = this.m_aReportContextDataArray[contextId];
  3447. if(contextObj && typeof contextObj[3] != "undefined"){
  3448. var queryModelItemRefId = contextObj[3];
  3449. var contextQueryModelItem = this.m_aReportMetadataArray[queryModelItemRefId];
  3450. if(typeof contextQueryModelItem != "undefined" && typeof contextQueryModelItem[1] != "undefined" && contextQueryModelItem[1] == "L")
  3451. {
  3452. lun = contextQueryModelItem[0];
  3453. }
  3454. }
  3455. } else {
  3456. lun = this.m_oCDManager.GetLUN(contextId);
  3457. }
  3458. return lun;
  3459. };
  3460. CSelectionController.prototype.isContextId = function(contextId) {
  3461. var isContext = false;
  3462. if (!this.m_bUsingCCDManager) {
  3463. var contextObj = this.m_aReportContextDataArray[contextId];
  3464. isContext = (typeof contextObj == "object");
  3465. } else {
  3466. this.m_oCDManager.FetchContextData([contextId]);
  3467. isContext = this.m_oCDManager.ContextIdExists(contextId);
  3468. }
  3469. return isContext;
  3470. };
  3471. CSelectionController.prototype.hasContextData = function() {
  3472. var hasContextData = false;
  3473. if (!this.m_bUsingCCDManager) {
  3474. if (this.m_aReportContextDataArray && this.m_aReportContextDataArray.length && this.m_aReportContextDataArray.length() > 0) {
  3475. return true;
  3476. }
  3477. } else {
  3478. hasContextData = this.m_oCDManager.HasContextData();
  3479. }
  3480. return hasContextData;
  3481. };
  3482. CSelectionController.prototype.hasMetadata = function() {
  3483. var hasMetadata = false;
  3484. if (!this.m_bUsingCCDManager) {
  3485. if (this.m_aReportMetadataArray && this.m_aReportMetadataArray.length && this.m_aReportMetadataArray.length() > 0) {
  3486. return true;
  3487. }
  3488. } else {
  3489. hasMetadata = this.m_oCDManager.HasMetadata();
  3490. }
  3491. return hasMetadata;
  3492. };
  3493. /*** Gets a new index value of a cell after all the groups/non-datavalues are added or removed (depends on indexType) ***/
  3494. CSelectionController.prototype.getDifferentCellIndex = function(cellRow, cellIndex, indexType)
  3495. {
  3496. //Go through each cell in the current row
  3497. for(var i = 0; i < cellRow.cells.length; i++)
  3498. {
  3499. //If we see a cell of type "datavalue", stop and return the new cellindex value
  3500. if (this.getSelectionObjectFactory().getSelectionObject(cellRow.cells[i]).getLayoutType() == "datavalue")
  3501. {
  3502. break;
  3503. }
  3504. }
  3505. if (indexType == "relative")
  3506. {
  3507. return (cellIndex - i);
  3508. }
  3509. else if(indexType == "actual")
  3510. {
  3511. return (cellIndex + i);
  3512. }
  3513. };
  3514. /*** Checks if two given cells are in the same column ***/
  3515. CSelectionController.prototype.cellsAreInSameColumn = function(cellOneRef, cellTwoRef)
  3516. {
  3517. //If both selections are on the same row, they are obviously not in the same column
  3518. if (cellOneRef.parentNode.rowIndex == cellTwoRef.parentNode.rowIndex)
  3519. {
  3520. return false;
  3521. }
  3522. //If it's a crosstab...
  3523. if (cellOneRef.getAttribute("cid") === null)
  3524. {
  3525. //Compare the UIDs
  3526. if (cellOneRef.getAttribute("uid") === cellTwoRef.getAttribute("uid"))
  3527. {
  3528. //If the UIDs match and the selections are column titles, they are in the same column
  3529. if (cellOneRef.getAttribute("type") != "datavalue") {
  3530. return true;
  3531. }
  3532. //if they are datavalues, see if both belong to the same column
  3533. else if(this.getDifferentCellIndex(cellOneRef.parentNode,cellOneRef.cellIndex, "relative") == this.getDifferentCellIndex(cellTwoRef.parentNode,cellTwoRef.cellIndex, "relative")) {
  3534. return true;
  3535. }
  3536. }
  3537. else
  3538. {
  3539. return false;
  3540. }
  3541. }
  3542. //If it's a list and the headers of both selections are same, then they are in the same column
  3543. else if (cellOneRef.getAttribute("cid") === cellTwoRef.getAttribute("cid"))
  3544. {
  3545. return true;
  3546. }
  3547. else
  3548. {
  3549. return false;
  3550. }
  3551. };
  3552. /*** Selects all the required cells between two selections in a certain column ***/
  3553. CSelectionController.prototype.selectVertical = function(sourceObj, targetObj, theDocument)
  3554. {
  3555. if (!theDocument) {
  3556. theDocument = document;
  3557. }
  3558. var currentRow = sourceObj.getCellRef().parentNode;
  3559. var tempSelObj, i;
  3560. var bGoDown = (sourceObj.getCellRef().parentNode.rowIndex < targetObj.getCellRef().parentNode.rowIndex);
  3561. var lengthOfNonDataValueCells = (sourceObj.getCellRef().parentNode.cells.length - sourceObj.getCellRef().cellIndex);
  3562. //Loop through all the rows (starting from the source cell's row)
  3563. //Do until we reach the target object
  3564. while (currentRow.rowIndex != targetObj.getCellRef().parentNode.rowIndex)
  3565. {
  3566. if(bGoDown) {
  3567. //source objects's row comes before the target object's row in the table, so go forward from the source
  3568. currentRow = currentRow.nextSibling;
  3569. }
  3570. else {
  3571. //source objects's row comes after the target object's row in the table, so go backward from the source
  3572. currentRow = currentRow.previousSibling;
  3573. }
  3574. if (currentRow == null)
  3575. {
  3576. break; //There are no more rows (start or end of table)
  3577. }
  3578. //If the current row has the same number of cells or more than the row which had source object, go through individual cells
  3579. if (currentRow.cells.length >= lengthOfNonDataValueCells)
  3580. {
  3581. for(i = 0; i < currentRow.cells.length; i++)
  3582. {
  3583. //Make sure both are in the same column and have the same layout
  3584. if ((currentRow.cells[i].getAttribute("type") == sourceObj.getLayoutType()) && this.cellsAreInSameColumn(sourceObj.getCellRef(), currentRow.cells[i]))
  3585. {
  3586. //Get the cell that's anywhere below the source object's cell but only if they are in the same column
  3587. tempSelObj = this.getSelectionObjectFactory().getSelectionObject(currentRow.cells[i]);
  3588. //Add the selection if it's not already selected
  3589. if(this.addSelectionObject(tempSelObj, theDocument))
  3590. {
  3591. // This will add the selection object to the list of selected columns in Query Studio
  3592. if (typeof cf != "undefined" && typeof cf.addSelectionToCfgVariables == "function")
  3593. {
  3594. cf.addSelectionToCfgVariables(tempSelObj.getColumnName());
  3595. }
  3596. }
  3597. break;
  3598. }
  3599. }
  3600. }
  3601. }
  3602. };
  3603. /**** Selects all the required cells between two selections on a certain row ***/
  3604. CSelectionController.prototype.selectHorizontal = function(sourceObj, targetObj, theDocument)
  3605. {
  3606. var compareUID = "";
  3607. //If it's a crosstab, and the UIDs of the selections don't match, exit this function
  3608. if (sourceObj.getColumnRef() == null)
  3609. {
  3610. if (sourceObj.getCellRef().getAttribute("uid") == targetObj.getCellRef().getAttribute("uid")) {
  3611. //crosstab, and same UIDs
  3612. compareUID = sourceObj.getCellRef().getAttribute("uid");
  3613. }
  3614. else {
  3615. return;
  3616. }
  3617. }
  3618. //Set up start and end points of our loop
  3619. var minNodeCellIndex, maxNodeCellIndex;
  3620. var nodeParent = targetObj.getCellRef().parentNode; // A <tr> element
  3621. var tempSelObj;
  3622. if (targetObj.getCellRef().cellIndex < sourceObj.getCellRef().cellIndex)
  3623. {
  3624. minNodeCellIndex = targetObj.getCellRef().cellIndex;
  3625. maxNodeCellIndex = sourceObj.getCellRef().cellIndex;
  3626. }
  3627. else
  3628. {
  3629. maxNodeCellIndex = targetObj.getCellRef().cellIndex;
  3630. minNodeCellIndex = sourceObj.getCellRef().cellIndex;
  3631. }
  3632. //Go through each cell
  3633. for (var i = minNodeCellIndex + 1; i < maxNodeCellIndex; i++)
  3634. {
  3635. //Select the cell if the layouts match and it's not a datavalue <----------if it's a list
  3636. if (((sourceObj.getColumnRef() != null) && (sourceObj.getLayoutType() == targetObj.getLayoutType()) && (sourceObj.getLayoutType() != "datavalue") || this.allowHorizontalDataValueSelection() ) ||
  3637. //Select the cell if the UIDs match <----- if it's a crosstab
  3638. ((sourceObj.getColumnRef() == null) && (nodeParent.cells[i].getAttribute("uid") == compareUID)))
  3639. {
  3640. tempSelObj = this.getSelectionObjectFactory().getSelectionObject(nodeParent.cells[i]);
  3641. //Add the selection if it's not already selected
  3642. if(this.addSelectionObject(tempSelObj, theDocument))
  3643. {
  3644. // This will add the selection object to the list of selected columns in Query Studio
  3645. if (typeof cf != "undefined" && typeof cf.addSelectionToCfgVariables == "function") {
  3646. cf.addSelectionToCfgVariables(tempSelObj.getColumnName());
  3647. }
  3648. }
  3649. }
  3650. }
  3651. };
  3652. CSelectionController.prototype.pageDoubleClicked = function(e) {
  3653. try{
  3654. var node = getNodeFromEvent(e);
  3655. if(typeof node.selectedCell != "undefined")
  3656. {
  3657. var divRegion = node;
  3658. node = node.selectedCell;
  3659. divRegion.removeAttribute("selectedCell");
  3660. }
  3661. while (node.nodeType == 3)
  3662. { // test to see if this is a text node
  3663. node = node.parentNode;
  3664. }
  3665. var ctx = node.getAttribute("ctx");
  3666. var uid = node.getAttribute("uid");
  3667. if ((ctx != null) || (node.parentNode.nodeType == 1 && node.parentNode.getAttribute("uid") != null)) // this is a textitem
  3668. {
  3669. node = node.parentNode;
  3670. // special case for Bug#498910. Analysis Studio is adding a members attributes within the same td, broken up by divs.
  3671. // If the parent node is a DIV and the class is "BLOCK", move up one level higher in the DOM
  3672. if(node.className.toUpperCase() == "BLOCK" && node.nodeName.toUpperCase() == "DIV") {
  3673. node = node.parentNode;
  3674. }
  3675. uid = node.getAttribute("uid");
  3676. }
  3677. if (uid != null && node.firstChild != null && (node.getAttribute("type") == "columnTitle" || node.getAttribute("type") == "section")) // this is a valid column title element
  3678. {
  3679. if (typeof goWindowManager != "undefined" && goWindowManager && typeof goWindowManager.getApplicationFrame == "function")
  3680. {
  3681. goWindowManager.getFeatureManager().launchFeature('Rename');
  3682. }
  3683. }
  3684. if (typeof g_reportSelectionController != "undefined") {
  3685. g_reportSelectionController.clearSelections();
  3686. }
  3687. }
  3688. catch(ex) {
  3689. // sometimes node may not be an HTML element (like a XUL element) and accessing nodeType/nodeName/className will generate an error.
  3690. }
  3691. };
  3692. CSelectionController.prototype.getSelectionHoverNodes = function()
  3693. {
  3694. return this.m_aSelectionHoverNodes;
  3695. };
  3696. CSelectionController.prototype.setSelectionHoverNodes = function(selectionHoverNodes)
  3697. {
  3698. this.m_aSelectionHoverNodes = selectionHoverNodes;
  3699. };
  3700. CSelectionController.prototype.addSelectionHoverNode = function(node)
  3701. {
  3702. this.m_aSelectionHoverNodes[this.m_aSelectionHoverNodes.length] = node;
  3703. };
  3704. CSelectionController.prototype.pageHover = function(e) {
  3705. try {
  3706. var node = getNodeFromEvent(e);
  3707. while (node.nodeType == 3) { // test to see if this is a text node
  3708. node = node.parentNode;
  3709. }
  3710. if ((node.getAttribute("ctx") != null) || (node.parentNode.nodeType == 1 && node.parentNode.getAttribute("uid") != null)) // this is a textitem
  3711. {
  3712. if (node.parentNode.nodeName.toLowerCase() != "tr") {
  3713. node = node.parentNode;
  3714. }
  3715. }
  3716. var aSelectionHoverNodes = this.getSelectionHoverNodes();
  3717. var selectionCount = this.getAllSelectedObjects().length;
  3718. if (!(aSelectionHoverNodes.length == 1 && aSelectionHoverNodes[0] == node))
  3719. {
  3720. for (var i = 0; i < aSelectionHoverNodes.length; i++)
  3721. {
  3722. this.sortIconHover(aSelectionHoverNodes[i], true);
  3723. if (selectionCount == 0)
  3724. {
  3725. this.pageChangeHover(aSelectionHoverNodes[i], true);
  3726. }
  3727. }
  3728. this.setSelectionHoverNodes([]);
  3729. if (selectionCount == 0)
  3730. {
  3731. this.sortIconHover(node, false);
  3732. if (this.pageChangeHover(node, false))
  3733. {
  3734. this.addSelectionHoverNode(node);
  3735. }
  3736. }
  3737. else
  3738. {
  3739. if (this.sortIconHover(node, false))
  3740. {
  3741. this.addSelectionHoverNode(node);
  3742. }
  3743. }
  3744. }
  3745. }
  3746. catch(ex) {
  3747. // sometimes node may not be an HTML element (like a XUL element) and accessing nodeType/nodeName/className will generate an error.
  3748. }
  3749. };
  3750. CSelectionController.prototype.sortIconHover = function(node, hoverOff)
  3751. {
  3752. if (!this.isValidColumnTitle(node))
  3753. {
  3754. return false;
  3755. }
  3756. var sortImgNode = this.getSortImgNode(node);
  3757. if(sortImgNode != null && sortImgNode != "undefined")
  3758. {
  3759. if(sortImgNode.getAttribute( 'sortOrder' ) === 'nosort')
  3760. {
  3761. if (hoverOff)
  3762. {
  3763. sortImgNode.style.visibility = "hidden";
  3764. }
  3765. else
  3766. {
  3767. sortImgNode.style.visibility = 'visible';
  3768. }
  3769. }
  3770. return true;
  3771. }
  3772. return false;
  3773. };
  3774. CSelectionController.prototype.isValidColumnTitle = function(node)
  3775. {
  3776. if (node && node.parentNode)
  3777. {
  3778. var uid = node.getAttribute("uid");
  3779. if (uid != null && (!(node.firstChild == null && node.cellIndex == 0 && node.parentNode.rowIndex == 0 && node.getAttribute("cid") == null)) && (node.getAttribute("type") == "columnTitle" || node.getAttribute("type") == "section"))
  3780. {
  3781. return true;
  3782. }
  3783. }
  3784. return false;
  3785. };
  3786. CSelectionController.prototype.pageChangeHover = function(node, hoverOff) {
  3787. try {
  3788. if ((node.getAttribute("ctx") != null) || (node.parentNode && node.parentNode.nodeType == 1 && node.parentNode.getAttribute("uid") != null)) // this is a textitem
  3789. {
  3790. if (node.parentNode.nodeName.toLowerCase() != "tr") {
  3791. node = node.parentNode;
  3792. }
  3793. }
  3794. if (this.isValidColumnTitle(node)) // this is a valid column title element
  3795. {
  3796. /* TODO: Put this back in once Report Server starts to produce context data
  3797. var columnSelected = this.isColumnSelected(aReportMetadataArray[cid]);
  3798. /TODO */
  3799. /* TODO: Take this out once Report Server starts to produce context data */
  3800. var columnSelected = this.isColumnSelected(node.getAttribute("tag"));
  3801. /* /TODO */
  3802. if (!columnSelected)
  3803. {
  3804. /* TODO: Put this back in once Report Server starts to produce context data
  3805. columnSelected = this.isColumnCut(aReportMetadataArray[cid]);
  3806. /TODO */
  3807. /* TODO: Take this out once Report Server starts to produce context data */
  3808. columnSelected = this.isColumnCut(node.getAttribute("tag"));
  3809. /* /TODO */
  3810. }
  3811. if (!columnSelected)
  3812. {
  3813. if (hoverOff)
  3814. {
  3815. if (node.getAttribute("oldClassName") != null)
  3816. {
  3817. node.className = node.getAttribute("oldClassName");
  3818. node.removeAttribute("oldClassName");
  3819. }
  3820. this.restoreOldBackgroundImage(node);
  3821. }
  3822. else
  3823. {
  3824. if (node.getAttribute("oldClassName") != null) {
  3825. node.className = node.getAttribute("oldClassName");
  3826. }
  3827. else {
  3828. node.setAttribute("oldClassName", node.className);
  3829. }
  3830. if (node.getAttribute("oldBackgroundImageStyle") != null) {
  3831. node.style.backgroundImage = node.getAttribute("oldBackgroundImageStyle");
  3832. }
  3833. else {
  3834. this.saveOldCellStyles(node);
  3835. }
  3836. node.className += " hoverSelection";
  3837. return true;
  3838. }
  3839. }
  3840. }
  3841. }
  3842. catch(ex) {
  3843. // sometimes node may not be an HTML element (like a XUL element) and accessing nodeType/nodeName/className will generate an error.
  3844. }
  3845. return false;
  3846. };
  3847. //helper function to get the span node containing the sort image
  3848. CSelectionController.prototype.getSortImgNode = function( node)
  3849. {
  3850. var elements = node.getElementsByTagName("img");
  3851. for( var i = 0; i < elements.length ; i++)
  3852. {
  3853. var sId = elements[i].id.toString();
  3854. if( sId != null && sId.length > 0 && sId.indexOf("sortimg") >= 0 )
  3855. {
  3856. node = elements[i];
  3857. return node;
  3858. }
  3859. }
  3860. return null;
  3861. };
  3862. CSelectionController.prototype.restoreOldPadding = function(node)
  3863. {
  3864. if (node && node.style && node.getAttribute("oldPaddingStyle") != null)
  3865. {
  3866. if (node.getAttribute("oldPaddingStyle").length > 0)
  3867. {
  3868. node.style.padding = node.getAttribute("oldPaddingStyle");
  3869. }
  3870. node.removeAttribute("oldPaddingStyle");
  3871. }
  3872. };
  3873. CSelectionController.prototype.saveOldPadding = function(node, size)
  3874. {
  3875. if (node && node.getAttribute("oldPaddingStyle") == null)
  3876. {
  3877. node.setAttribute("oldPaddingStyle", size.paddingTop + "px " + size.paddingRight + "px " + size.paddingBottom + "px " + size.paddingLeft + "px");
  3878. }
  3879. };
  3880. CSelectionController.prototype.saveOldBorder = function(node)
  3881. {
  3882. if (node && node.getAttribute("oldBorderStyle") == null)
  3883. {
  3884. node.setAttribute("oldBorderStyle", node.style.border);
  3885. }
  3886. };
  3887. CSelectionController.prototype.restoreOldBorder = function(node)
  3888. {
  3889. if (node && node.style && node.getAttribute("oldBorderStyle") != null)
  3890. {
  3891. if (node.getAttribute("oldBorderStyle").length > 0)
  3892. {
  3893. node.style.border = node.getAttribute("oldBorderStyle");
  3894. }
  3895. else
  3896. {
  3897. node.style.borderColor = node.style.borderWidth = node.style.borderStyle = "";
  3898. }
  3899. node.removeAttribute("oldBorderStyle");
  3900. }
  3901. };
  3902. CSelectionController.prototype.setPrimarySelectionStyles = function(cell) {
  3903. if (this.getPrimarySelectionColor()) {
  3904. cell.style.backgroundColor = this.getPrimarySelectionColor();
  3905. }
  3906. else {
  3907. cell.style.backgroundImage = this.pS_backgroundImageURL;
  3908. cell.style.backgroundRepeat = "repeat";
  3909. }
  3910. };
  3911. CSelectionController.prototype.setSecondarySelectionStyles = function(cell) {
  3912. if (this.getSecondarySelectionColor()) {
  3913. cell.style.backgroundColor = this.getSecondarySelectionColor();
  3914. }
  3915. else {
  3916. cell.style.backgroundImage = this.sS_backgroundImageURL;
  3917. cell.style.backgroundRepeat = "repeat";
  3918. }
  3919. };
  3920. CSelectionController.prototype.saveOldCellStyles = function(node)
  3921. {
  3922. if (node && node.getAttribute("oldBackgroundImageStyle") == null)
  3923. {
  3924. node.setAttribute("oldBackgroundColor", this.getStyleProperty(node, "backgroundColor"));
  3925. node.setAttribute("oldBackgroundImageStyle", this.getBackgroundImage(node));
  3926. node.setAttribute("oldBackgroundRepeat", this.getStyleProperty(node, "backgroundRepeat"));
  3927. node.style.backgroundImage = "";
  3928. node.style.backgroundRepeat = "";
  3929. }
  3930. };
  3931. CSelectionController.prototype.restoreOldBackgroundImage = function(node)
  3932. {
  3933. if (node && node.style && node.getAttribute("oldBackgroundImageStyle") != null)
  3934. {
  3935. node.style.backgroundImage = node.getAttribute("oldBackgroundImageStyle");
  3936. node.removeAttribute("oldBackgroundImageStyle");
  3937. node.style.backgroundRepeat = node.getAttribute("oldBackgroundRepeat");
  3938. node.removeAttribute("oldBackgroundRepeat");
  3939. node.style.backgroundColor = node.getAttribute("oldBackgroundColor");
  3940. node.removeAttribute("oldBackgroundColor");
  3941. }
  3942. };
  3943. CSelectionController.prototype.getStyleProperty = function(node, property)
  3944. {
  3945. if(node && node.style && node.style[property])
  3946. {
  3947. return node.style[property];
  3948. }
  3949. return "";
  3950. };
  3951. CSelectionController.prototype.getBackgroundImage = function(node)
  3952. {
  3953. if(node && node.style)
  3954. {
  3955. return node.style.backgroundImage;
  3956. }
  3957. return "";
  3958. };
  3959. CSelectionController.prototype.pageContextClicked = function(e)
  3960. {
  3961. var node = getNodeFromEvent(e);
  3962. if(typeof node.selectedCell != "undefined")
  3963. {
  3964. var divRegion = node;
  3965. node = node.selectedCell;
  3966. divRegion.removeAttribute("selectedCell");
  3967. }
  3968. while (node != null && node.tagName != "TD")
  3969. {
  3970. node = node.parentNode;
  3971. }
  3972. if (node != null)
  3973. {
  3974. var nodeBackgroundImage = this.getBackgroundImage(node);
  3975. this.findSelectionURLs();
  3976. if (this.getSelections().length == 0 || nodeBackgroundImage != this.pS_backgroundImageURL )
  3977. {
  3978. this.pageClicked(e);
  3979. }
  3980. }
  3981. if (typeof populateContextMenu != "undefined")
  3982. {
  3983. populateContextMenu();
  3984. moveContextMenu(e);
  3985. }
  3986. var bReturn = false;
  3987. if (this.showViewerContextMenu())
  3988. {
  3989. //NS6 specific
  3990. if (typeof e.preventDefault == "function")
  3991. {
  3992. e.preventDefault();
  3993. }
  3994. bReturn = true;
  3995. }
  3996. return bReturn;
  3997. };
  3998. CSelectionController.prototype.chartContextMenu = function(e)
  3999. {
  4000. if(!this.hasSelectedChartNodes())
  4001. {
  4002. return;
  4003. }
  4004. if (typeof populateContextMenu != "undefined")
  4005. {
  4006. populateContextMenu();
  4007. moveContextMenu(e);
  4008. }
  4009. //NS6 specific
  4010. if (typeof e.preventDefault == "function")
  4011. {
  4012. e.preventDefault();
  4013. }
  4014. return false;
  4015. };
  4016. CSelectionController.prototype.titleAreaContextMenu = function(e, sType, sId)
  4017. {
  4018. if (typeof populateContextMenu != "undefined")
  4019. {
  4020. goWindowManager.getApplicationFrame().cfgSet("contextMenuType", sType);
  4021. goWindowManager.getApplicationFrame().cfgSet("contextMenuId", sId);
  4022. populateContextMenu(sType.toUpperCase());
  4023. moveContextMenu(e, sType.toUpperCase());
  4024. }
  4025. //NS6 specific
  4026. if (typeof e.preventDefault == "function")
  4027. {
  4028. e.preventDefault();
  4029. }
  4030. return false;
  4031. };
  4032. CSelectionController.prototype.selectionsAreAllSameType = function()
  4033. {
  4034. var allSelections = this.getSelections();
  4035. if (allSelections.length > 0)
  4036. {
  4037. var layoutType = allSelections[0].getLayoutType();
  4038. for (var i = 1; i < allSelections.length; i++)
  4039. {
  4040. if (layoutType != allSelections[i].getLayoutType()) {
  4041. return 0; // They aren't all the same type
  4042. }
  4043. }
  4044. return 1; // They are all the same type
  4045. }
  4046. return -1; // There are no selections
  4047. };
  4048. CSelectionController.prototype.selectionsAreAllOnSameColumn = function()
  4049. {
  4050. var allSelections = this.getSelections();
  4051. var i = 0;
  4052. if (allSelections.length > 0)
  4053. {
  4054. var colRef = allSelections[0].getColumnRef();
  4055. if (colRef != null && colRef != "")
  4056. {
  4057. for (i = 1; i < allSelections.length; i++)
  4058. {
  4059. if (colRef != allSelections[i].getColumnRef()) {
  4060. return false; // They aren't all on the same column
  4061. }
  4062. }
  4063. }
  4064. else
  4065. {
  4066. var cellTypeId = allSelections[0].getCellTypeId();
  4067. for (i = 1; i < allSelections.length; i++)
  4068. {
  4069. if (cellTypeId != allSelections[i].getCellTypeId()) {
  4070. return false; // They aren't all on the same column
  4071. }
  4072. }
  4073. }
  4074. return true; // They are all on the same column
  4075. }
  4076. return false; // There are no selections
  4077. };
  4078. CSelectionController.prototype.checkForReportElementNode = function(node)
  4079. {
  4080. if (typeof node != "undefined" && node != null && typeof node.className != "undefined" && node.className != null)
  4081. {
  4082. if (node.className == "tt")
  4083. {
  4084. // Check to see if this is the report title or subtitle
  4085. if (typeof node.parentNode != "undefined" && node.parentNode != null && typeof node.parentNode.parentNode != "undefined" && node.parentNode.parentNode != null && (node.parentNode.className == "reportSubtitleStyle" || node.parentNode.id == "reportTitleLink")) {
  4086. node = node.parentNode.parentNode;
  4087. }
  4088. else {
  4089. return false;
  4090. }
  4091. }
  4092. /*
  4093. else if (node.className == "textItem")
  4094. {
  4095. // Handle page footer here
  4096. if (typeof node.parentNode != "undefined" && node.parentNode != null && node.parentNode.className == "tableCell"
  4097. && typeof node.parentNode.parentNode != "undefined" && node.parentNode.parentNode != null && node.parentNode.parentNode.className == "tableRow"
  4098. && typeof node.parentNode.parentNode.parentNode != "undefined" && node.parentNode.parentNode.parentNode != null && node.parentNode.parentNode.className == "tb"
  4099. && typeof node.parentNode.parentNode.parentNode.parentNode != "undefined" && node.parentNode.parentNode.parentNode.parentNode != null && node.parentNode.parentNode.parentNode.className == "pf"
  4100. )
  4101. node = node.parentNode;
  4102. else
  4103. return false;
  4104. }
  4105. */
  4106. else if (typeof node.parentNode != "undefined" && node.parentNode != null)
  4107. {
  4108. // Check to see if this is the report filter area
  4109. var parentNode = node.parentNode;
  4110. while (typeof parentNode != "undefined" && parentNode != null)
  4111. {
  4112. if (typeof parentNode.className != "undefined" && parentNode.className != null && parentNode.className.substr(0, 2) == "ft")
  4113. {
  4114. node = parentNode;
  4115. break;
  4116. }
  4117. else {
  4118. parentNode = parentNode.parentNode;
  4119. }
  4120. }
  4121. }
  4122. else {
  4123. return false;
  4124. }
  4125. var nodeCN = node.className.substr(0, 2);
  4126. if (nodeCN == "ta" || nodeCN == "ts" || nodeCN == "ft") {
  4127. return true;
  4128. }
  4129. }
  4130. return false;
  4131. };
  4132. CSelectionController.prototype.chartClicked = function(htmlElement)
  4133. {
  4134. this.setSelectedChartArea(htmlElement);
  4135. };
  4136. /**
  4137. * A workaround for a RSVP bug: when a list column is renamed, the column title loses its ctx.
  4138. * this function pick the the ctx of the first row in the same column and set it to the column title node.
  4139. */
  4140. CSelectionController.prototype.processColumnTitleNode = function(selectedObject)
  4141. {
  4142. if (!selectedObject || !this.m_oCognosViewer.isBux) {
  4143. return;
  4144. }
  4145. var oCell = selectedObject.getCellRef();
  4146. // quick check to make sure we're dealing with a column title and that we
  4147. // haven't already tried to process it once
  4148. if ( oCell.getAttribute("contextAugmented") == "true" || "list" != selectedObject.getDataContainerType() || "columnTitle" != selectedObject.getLayoutType()) {
  4149. return;
  4150. }
  4151. var selectedContextIds = selectedObject.getSelectedContextIds();
  4152. var missingQueryModelId = false;
  4153. if (typeof selectedContextIds == "object" && selectedContextIds != null && selectedContextIds.length > 0) {
  4154. // special case where relational list headers have context but are missing a query model id
  4155. if (this.isRelational(selectedContextIds) && this.getQueryModelId(selectedContextIds[0][0]) == null) {
  4156. missingQueryModelId = true;
  4157. } else {
  4158. return;
  4159. }
  4160. }
  4161. var lid = oCell.parentNode.parentNode.parentNode.getAttribute("lid"); //lid on table node.
  4162. var parentNode = oCell.parentNode.nextSibling; //get to the next tr node.
  4163. var aCells = getChildElementsByAttribute(parentNode, "td", "cid", oCell.getAttribute("cid"));
  4164. var ctxValue = null;
  4165. var canSort = true;
  4166. var spanElements;
  4167. if (aCells.length > 0) {
  4168. var tdCell = aCells[0];
  4169. var childNodesLength = tdCell.childNodes.length;
  4170. // we need to loop through the TD's child elements one by one to make sure
  4171. // we don't start looking for span's inside an embeded list or crosstab
  4172. for (var tdChildIndex=0; tdChildIndex < childNodesLength; tdChildIndex++) {
  4173. var childNode = tdCell.childNodes[tdChildIndex];
  4174. // found an embeded list/crosstab/chart, don't bother looking at the span's in them.
  4175. if ( childNode.getAttribute &&
  4176. ((childNode.nodeName.toLowerCase() == "table" && typeof childNode.getAttribute("lid") == "string")
  4177. || childNode.nodeName.toLowerCase() == 'map' || childNode.nodeName.toLowerCase() == "img" || childNode.getAttribute("chartcontainer") == "true") ) {
  4178. // if the first item in the column content is another list or crosstab, then disable sort
  4179. if (tdChildIndex == 0) {
  4180. canSort = false;
  4181. }
  4182. } else {
  4183. spanElements = [];
  4184. if (childNode.nodeName.toLowerCase() == "span") {
  4185. spanElements.push(childNode);
  4186. }
  4187. // the case where we have nested span elements
  4188. var nestedSpanElements = childNode.getElementsByTagName ? childNode.getElementsByTagName("span"): [];
  4189. for (var nestedSpanIndex = 0; nestedSpanIndex < nestedSpanElements.length; ++nestedSpanIndex)
  4190. {
  4191. if (lid == getImmediateLayoutContainerId(nestedSpanElements[nestedSpanIndex]))
  4192. {
  4193. spanElements.push(nestedSpanElements[nestedSpanIndex]);
  4194. }
  4195. }
  4196. for (var spanIndex = 0; spanIndex < spanElements.length; ++spanIndex) {
  4197. var oChild = spanElements[spanIndex];
  4198. if (oChild.nodeType == 1 && oChild.nodeName.toLowerCase() == "span" && oChild.style.visibility != "hidden") {
  4199. if(oChild.getAttribute("ctx") != null && oChild.getAttribute("ctx") != "") {
  4200. ctxValue = oChild.getAttribute("ctx");
  4201. break;
  4202. }
  4203. }
  4204. }
  4205. }
  4206. }
  4207. }
  4208. if (ctxValue != null) {
  4209. var ctxId = ctxValue.split("::")[0].split(":")[0];
  4210. // if we're not here because of a missing query model id, then we must be missing
  4211. // the entire context
  4212. if (!missingQueryModelId) {
  4213. //set the ctx for the column header node to speed up subsequent runs
  4214. spanElements = oCell.getElementsByTagName("span");
  4215. if (spanElements.length != 0)
  4216. {
  4217. var contextObject = this.m_oCDManager.m_cd[ctxId];
  4218. var textValue = this.getTextValue(spanElements);
  4219. var newContextObject = {"u": textValue === null ? "" : textValue};
  4220. if(typeof contextObject != "undefined")
  4221. {
  4222. if(typeof contextObject["r"] != "undefined") { newContextObject.r = contextObject["r"]; }
  4223. if(typeof contextObject["q"] != "undefined") { newContextObject.q = contextObject["q"]; }
  4224. if(typeof contextObject["i"] != "undefined") { newContextObject.i = contextObject["i"]; }
  4225. }
  4226. var clonedCtxId = "cloned" + ctxId;
  4227. this.m_oCDManager.m_cd[clonedCtxId] = newContextObject;
  4228. spanElements[0].setAttribute("ctx", clonedCtxId);
  4229. selectedObject = this.getSelectionObjectFactory().processCTX(selectedObject, clonedCtxId);
  4230. }
  4231. } else {
  4232. // we were only missing the query model id, if we found one then set it in the context data
  4233. var qmid = this.getQueryModelId(ctxId);
  4234. if (qmid == null) {
  4235. // for calculated columns, none of the cells in the column will have a query model item
  4236. }
  4237. if (qmid != null) {
  4238. var oriCtxId = selectedContextIds[0][0];
  4239. this.m_oCDManager.m_cd[oriCtxId].i = this.m_oCDManager.m_cd[ctxId].i;
  4240. return false;
  4241. }
  4242. }
  4243. }
  4244. else
  4245. {
  4246. canSort = false; //not sortable with the absense of ctx.
  4247. }
  4248. if (!canSort) {
  4249. oCell.setAttribute("canSort", "false");
  4250. }
  4251. oCell.setAttribute("contextAugmented", "true");
  4252. };
  4253. /**
  4254. * Goes through all the selections to make sure they're in the same
  4255. * data container
  4256. */
  4257. CSelectionController.prototype.selectionsInSameDataContainer = function() {
  4258. try {
  4259. var aSelectedObjects = this.getAllSelectedObjects();
  4260. var sLayoutElementId = aSelectedObjects[0].getLayoutElementId();
  4261. for (var index=1; index<aSelectedObjects.length; index++) {
  4262. if (sLayoutElementId != aSelectedObjects[index].getLayoutElementId()) {
  4263. return false;
  4264. }
  4265. }
  4266. } catch (e) {
  4267. return false;
  4268. }
  4269. return true;
  4270. };
  4271. /**
  4272. * Goes through all the selections to make sure they're from the same data item
  4273. */
  4274. CSelectionController.prototype.selectionsFromSameDataItem = function() {
  4275. try {
  4276. var aSelectedObjects = this.getAllSelectedObjects();
  4277. var refDataItem = aSelectedObjects[0].getDataItems()[0][0];
  4278. for (var index=1; index<aSelectedObjects.length; index++) {
  4279. if (refDataItem != aSelectedObjects[index].getDataItems()[0][0]) {
  4280. return false;
  4281. }
  4282. }
  4283. } catch (e) {
  4284. return false;
  4285. }
  4286. return true;
  4287. };
  4288. /**
  4289. * Checks to see if the first selection is on relational data.
  4290. * @return false if OLAP data, true otherwise
  4291. */
  4292. CSelectionController.prototype.isRelational = function(aCtxs) {
  4293. try {
  4294. if (!aCtxs) {
  4295. var selection = this.getAllSelectedObjects()[0];
  4296. aCtxs = selection.getSelectedContextIds();
  4297. }
  4298. for (var axisIndex=0; axisIndex < aCtxs.length; axisIndex++) {
  4299. for (var nestIndex=0; nestIndex < aCtxs[axisIndex].length; nestIndex++) {
  4300. var ctx = aCtxs[axisIndex][nestIndex];
  4301. var mun = this.getMun(ctx);
  4302. var lun = this.getLun(ctx);
  4303. var hun = this.getHun(ctx);
  4304. if (mun != null && typeof mun != "undefined" && mun.length > 0) {
  4305. return false;
  4306. }
  4307. if (lun != null && typeof lun != "undefined" && lun.length > 0) {
  4308. return false;
  4309. }
  4310. if (hun != null && typeof hun != "undefined" && hun.length > 0) {
  4311. return false;
  4312. }
  4313. }
  4314. }
  4315. return true;
  4316. } catch (e) {
  4317. return true;
  4318. }
  4319. return true;
  4320. };
  4321. /**
  4322. * Gets the type of the data container in which the selections are
  4323. * @return 'list', 'crosstab' or an empty string if there was an error finding the container type
  4324. */
  4325. CSelectionController.prototype.getDataContainerType = function() {
  4326. try {
  4327. if( !this.getAllSelectedObjects()[0] ){
  4328. return "";
  4329. }
  4330. return this.getAllSelectedObjects()[0].m_dataContainerType;
  4331. } catch (e) {
  4332. return "";
  4333. }
  4334. };
  4335. /**
  4336. * Looks to make sure that the selected cells are either columns or rows
  4337. * @return true if the selected cells are either columns or rows
  4338. */
  4339. CSelectionController.prototype.areSelectionsColumnRowTitles = function() {
  4340. try {
  4341. var aSelectedObjects = this.getAllSelectedObjects();
  4342. for (var index=0; index < aSelectedObjects.length; index++) {
  4343. var selectedObject = aSelectedObjects[index];
  4344. if (selectedObject.getLayoutType() != "columnTitle" || selectedObject.isHomeCell()) {
  4345. return false;
  4346. }
  4347. }
  4348. } catch (e) {
  4349. return false;
  4350. }
  4351. return true;
  4352. };
  4353. /**
  4354. * Checks to see if all the current selections are measures
  4355. * @return true if all the current selections are measures, false otherwise
  4356. */
  4357. CSelectionController.prototype.selectionsAreMeasures = function() {
  4358. try {
  4359. var aSelectedObjects = this.getAllSelectedObjects();
  4360. for (var index=0; index < aSelectedObjects.length; index++) {
  4361. var selectedObject = aSelectedObjects[index];
  4362. if (this.getUsageInfo(selectedObject.getSelectedContextIds()[0][0]) != this.c_usageMeasure) {
  4363. return false;
  4364. }
  4365. }
  4366. } catch (e) {
  4367. return false;
  4368. }
  4369. return true;
  4370. };
  4371. /**
  4372. * @return true if the current selections have muns and aren't measures
  4373. */
  4374. CSelectionController.prototype.selectionsNonMeasureWithMUN = function() {
  4375. var aSelectedObjects = this.getAllSelectedObjects();
  4376. if (aSelectedObjects.length == 0) {
  4377. return false;
  4378. }
  4379. for (var index=0; index < aSelectedObjects.length; index++) {
  4380. var selectedObject = aSelectedObjects[0];
  4381. if (selectedObject.getSelectedContextIds().length == 0) {
  4382. return false;
  4383. }
  4384. var contextId = selectedObject.getSelectedContextIds()[0][0];
  4385. var mun = this.getMun(contextId);
  4386. var sUsage = this.getUsageInfo(contextId);
  4387. if (mun == null || typeof mun == "undefined" || mun.length == 0 || sUsage == this.c_usageMeasure) {
  4388. return false;
  4389. }
  4390. }
  4391. return true;
  4392. };
  4393. /**
  4394. * @return true if the current selections are all measure or calculation
  4395. */
  4396. CSelectionController.prototype.areSelectionsMeasureOrCalculation = function() {
  4397. var aSelectedObjects = this.getAllSelectedObjects();
  4398. if (aSelectedObjects.length == 0) {
  4399. return false;
  4400. }
  4401. var bHaveCalcMetaData = this.selectionsHaveCalculationMetadata();
  4402. for (var index=0; index < aSelectedObjects.length; index++) {
  4403. var selectedObject = aSelectedObjects[index];
  4404. var contextId = selectedObject.getSelectedContextIds()[0][0];
  4405. if( !this.isCalculationOrMeasure(contextId, bHaveCalcMetaData) ){
  4406. return false;
  4407. }
  4408. }
  4409. return true;
  4410. };
  4411. /**
  4412. * @return true if the metadata is appropriate for calculations.
  4413. * Measure OR (Relational: no model item, Dimensional: no MUN)
  4414. */
  4415. CSelectionController.prototype.selectionsHaveCalculationMetadata = function() {
  4416. try {
  4417. var containerType = this.getDataContainerType();
  4418. var aSelectedObjects = this.getAllSelectedObjects();
  4419. for (var index=0; index < aSelectedObjects.length; index++) {
  4420. var selectedObject = aSelectedObjects[index];
  4421. var contextIds = selectedObject.getSelectedContextIds();
  4422. var contextId = contextIds[0][0];
  4423. var sHun = this.getHun(contextId);
  4424. if( !this.hasCalculationMetadata( contextId, contextIds, containerType) ){
  4425. return false;
  4426. }
  4427. }
  4428. } catch (e) {
  4429. return false;
  4430. }
  4431. return true;
  4432. };
  4433. CSelectionController.prototype.isCalculationOrMeasure = function( contextId, bHaveCalcMetaData ){
  4434. var mun = this.getMun(contextId);
  4435. var sUsage = this.getUsageInfo(contextId);
  4436. if (!(( (mun == null || typeof mun == "undefined" || mun.length == 0) && bHaveCalcMetaData) ||
  4437. sUsage == this.c_usageMeasure)) {
  4438. return false;
  4439. }
  4440. return true;
  4441. };
  4442. /**
  4443. * @return true if the metadata is appropriate for calculations.
  4444. * Measure OR (Relational: no model item, Dimensional: no MUN)
  4445. */
  4446. CSelectionController.prototype.hasCalculationMetadata = function( contextId, contextIds, containerType ){
  4447. var sHun = this.getHun(contextId);
  4448. if (this.getUsageInfo(contextId) != this.c_usageMeasure) {
  4449. if ((this.isRelational(contextIds) && this.getQueryModelId(contextId) != null)
  4450. || (!this.isRelational(contextIds) && containerType == "list" && (sHun && sHun != "")))
  4451. {
  4452. return false;
  4453. }
  4454. }
  4455. return true;
  4456. };
  4457. CSelectionController.prototype.selectionsAreDateTime = function() {
  4458. try {
  4459. var aSelectedObjects = this.getAllSelectedObjects();
  4460. for (var index=0; index < aSelectedObjects.length; index++) {
  4461. var selectedObject = aSelectedObjects[index];
  4462. var contextIds = selectedObject.getSelectedContextIds();
  4463. var contextId = contextIds[0][0];
  4464. var dType = this.getDataType(contextId);
  4465. if (dType && typeof this.m_ccl_dateTypes[dType]!=="undefined") {
  4466. return true;
  4467. }
  4468. }
  4469. } catch (e) {
  4470. return false;
  4471. }
  4472. return false;
  4473. };
  4474. /*
  4475. * @return array of json object which contains the context of each selected object
  4476. */
  4477. CSelectionController.prototype.getSelectedObjectsJsonContext = function() {
  4478. try {
  4479. var aSelectedObjects = this.getAllSelectedObjects();
  4480. if ( aSelectedObjects=== null || aSelectedObjects.length <=0 ) {
  4481. return null;
  4482. }
  4483. var modelPath = this.m_oCognosViewer.getModelPath();
  4484. var aJsonObjects = [];
  4485. for (var i=0; i < aSelectedObjects.length; i++) {
  4486. var obj = aSelectedObjects[i].getContextJsonObject(this, modelPath);
  4487. aJsonObjects.push(obj);
  4488. }
  4489. return aJsonObjects;
  4490. } catch (e) {
  4491. //ignore
  4492. }
  4493. };
  4494. CSelectionController.prototype.destroy = function()
  4495. {
  4496. delete this.m_oCognosViewer;
  4497. delete this.m_aCutColumns;
  4498. delete this.m_aSelectedObjects;
  4499. delete this.m_selectedClass;
  4500. delete this.m_cutClass;
  4501. if (this.m_oObserver && this.m_oObserver.destroy) {
  4502. this.m_oObserver.destroy();
  4503. }
  4504. delete this.m_oObserver;
  4505. delete this.m_aReportMetadataArray;
  4506. delete this.m_aReportContextDataArray;
  4507. if (this.m_oCDManager && this.m_oCDManager.destroy) {
  4508. this.m_oCDManager.destroy();
  4509. }
  4510. delete this.m_oCDManager;
  4511. if(this.m_oSelectionObjectFactory && this.m_oSelectionObjectFactory.destroy) {
  4512. this.m_oSelectionObjectFactory.destroy();
  4513. }
  4514. delete this.m_oSelectionObjectFactory;
  4515. delete this.m_selectedChartArea;
  4516. delete this.m_selectedChartNodes;
  4517. delete this.m_selectionContainerMap;
  4518. delete this.m_chartHelpers;
  4519. delete this.m_oJsonForMarshal;
  4520. if( this.hasSavedSelections() ){
  4521. this.clearSavedSelections();
  4522. }
  4523. }
  4524. function clearTextSelection(theDocument)
  4525. {
  4526. if (!theDocument) {
  4527. theDocument = document;
  4528. }
  4529. try
  4530. {
  4531. if (typeof theDocument.selection == "object" && theDocument.selection !== null)
  4532. {
  4533. theDocument.selection.empty();
  4534. }
  4535. else if (typeof window.getSelection == "function" && typeof window.getSelection() == "object" && window.getSelection() !== null)
  4536. {
  4537. //NS6 specific
  4538. window.getSelection().removeAllRanges();
  4539. }
  4540. }
  4541. catch(e)
  4542. {
  4543. }
  4544. }