1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278 |
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: Viewer
- *| (C) Copyright IBM Corp. 2017, 2019
- *|
- *| US Government Users Restricted Rights - Use, duplication or
- *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- *|
- *+------------------------------------------------------------------------+
- */
- //
- // This class represents the basic representation of a selection object.
- //
- /*
- Constructor.
- Parameters:
- Returns:
- */
- function CSelectionObject()
- {
- this.initialize();
- }
- CSelectionObject.prototype.initialize = function()
- {
- this.m_oCellRef = {};
- this.m_sColumnRef = "";
- this.m_sColumnName = "";
- this.m_aDataItems = [];
- this.m_aUseValues = [];
- this.m_aDisplayValues = [];
- this.m_sCellTypeId = "";
- this.m_sLayoutType = "";
- this.m_sTag = "";
- this.m_aMuns = [];
- this.m_aRefQueries = [];
- this.m_aMetadataItems = [];
- this.m_aDrillOptions = [];
- this.m_selectionController = {};
- this.m_contextIds = [];
- this.m_ctxAttributeString = "";
- this.m_fetchedContextIds = false;
- this.m_selectedClass = [];
- this.m_cutClass=[];
- this.m_dataContainerType = "";
- this.m_oJsonContext = null;
- };
- CSelectionObject.prototype.isSelectionOnVizChart = function() { return false; };
- /*
- Parameters: none
- Returns: object reference to html <td> element
- */
- CSelectionObject.prototype.getCellRef = function()
- {
- return this.m_oCellRef;
- };
- /**
- * Get the original data item name (before renamed)
- * */
- CSelectionObject.prototype.getColumnRP_Name = function()
- {
- if(this.m_oCellRef != null){
- return this.m_oCellRef.getAttribute("rp_name");
- }
- };
- /*
- Parameters: none
- Returns: string
- */
- CSelectionObject.prototype.getColumnRef = function()
- {
- return this.m_sColumnRef;
- };
- /*
- Parameters: none
- Returns: string
- */
- CSelectionObject.prototype.getColumnName = function()
- {
- if (this.m_sColumnName == "")
- {
- if (this.m_selectionController.hasContextData() && this.m_contextIds.length)
- {
- this.m_sColumnName = this.m_selectionController.getRefDataItem(this.m_contextIds[0][0]);
- }
- }
- return this.m_sColumnName;
- };
- CSelectionObject.prototype.getDataItemDisplayValue = function(containerReportInfo) {
- var aDataItems = this.getDataItems();
- var item = "";
- if (aDataItems && aDataItems[0] && aDataItems[0][0]) {
- item = this.getDataItems()[0][0];
- if (containerReportInfo && containerReportInfo.itemInfo && containerReportInfo.itemInfo.length) {
- var itemInfo = containerReportInfo.itemInfo;
- for (var i=0; i < itemInfo.length; i++) {
- if (itemInfo[i].item === item && itemInfo[i].itemLabel) {
- return itemInfo[i].itemLabel;
- }
- }
- }
- }
- return item;
- };
- /*
- Parameters: none
- Returns: array of strings
- */
- CSelectionObject.prototype.getDataItems = function()
- {
- if (!this.m_aDataItems.length) {
- this.fetchContextIds();
- for (var i = 0; i < this.m_contextIds.length; ++i) {
- this.m_aDataItems[this.m_aDataItems.length] = [];
- for (var j = 0; j < this.m_contextIds[i].length; ++j) {
- var contextId = this.m_contextIds[i][j];
- this.m_aDataItems[this.m_aDataItems.length-1].push(this.m_selectionController.isContextId(contextId)? this.m_selectionController.getRefDataItem(contextId) : "");
- }
- }
- }
- return this.m_aDataItems;
- };
- /*
- Parameters: none
- Returns: array of strings
- */
- CSelectionObject.prototype.getUseValues = function()
- {
- if (!this.m_aUseValues.length) {
- this.fetchContextIds();
- for (var i = 0; i < this.m_contextIds.length; ++i) {
- this.m_aUseValues[this.m_aUseValues.length] = [];
- for (var j = 0; j < this.m_contextIds[i].length; ++j) {
- var contextId = this.m_contextIds[i][j];
- this.m_aUseValues[this.m_aUseValues.length-1].push(this.m_selectionController.isContextId(contextId) ? this.m_selectionController.getUseValue(contextId) : "");
- }
- }
- }
- return this.m_aUseValues;
- };
- /*
- Parameters: none
- Returns: string
- */
- CSelectionObject.prototype.getCellTypeId = function()
- {
- return this.m_sCellTypeId;
- };
- /*
- Parameters: none
- Returns: array of strings
- */
- CSelectionObject.prototype.getDisplayValues = function()
- {
- return this.m_aDisplayValues;
- };
- /*
- Parameters: none
- Returns: string
- */
- CSelectionObject.prototype.getLayoutType = function()
- {
- return this.m_sLayoutType;
- };
- /*
- Parameters: none
- Returns: string
- */
- CSelectionObject.prototype.getTag = function()
- {
- return this.m_sTag;
- };
- /*
- Parameters: none
- Returns: Array
- */
- CSelectionObject.prototype.getMuns = function()
- {
- if (!this.m_aMuns.length) {
- this.fetchContextIds();
- for (var i = 0; i < this.m_contextIds.length; ++i) {
- this.m_aMuns[this.m_aMuns.length] = [];
- for (var j = 0; j < this.m_contextIds[i].length; ++j) {
- var contextId = this.m_contextIds[i][j];
- this.m_aMuns[this.m_aMuns.length-1].push(this.m_selectionController.isContextId(contextId) ? this.m_selectionController.getMun(contextId) : "");
- }
- }
- }
- return this.m_aMuns;
- };
- /*
- Parameters: none
- Returns: Array
- */
- CSelectionObject.prototype.getRefQueries = function()
- {
- if (!this.m_aRefQueries.length) {
- this.fetchContextIds();
- for (var i = 0; i < this.m_contextIds.length; ++i) {
- this.m_aRefQueries[this.m_aRefQueries.length] = [];
- for (var j = 0; j < this.m_contextIds[i].length; ++j) {
- var contextId = this.m_contextIds[i][j];
- this.m_aRefQueries[this.m_aRefQueries.length-1].push(this.m_selectionController.isContextId(contextId) ? this.m_selectionController.getRefQuery(contextId) : "");
- }
- }
- }
- return this.m_aRefQueries;
- };
- CSelectionObject.prototype.getDimensionalItems = function(sType)
- {
- var aItems = [];
- this.fetchContextIds();
- for (var i = 0; i < this.m_contextIds.length; ++i) {
- aItems[aItems.length] = [];
- for (var j = 0; j < this.m_contextIds[i].length; ++j) {
- var contextId = this.m_contextIds[i][j];
- var sItem = "";
- if(this.m_selectionController.isContextId(contextId))
- {
- switch(sType)
- {
- case "hun":
- sItem = this.m_selectionController.getHun(contextId);
- break;
- case "lun":
- sItem = this.m_selectionController.getLun(contextId);
- break;
- case "dun":
- sItem = this.m_selectionController.getDun(contextId);
- break;
- }
- }
- aItems[aItems.length-1].push(sItem);
- }
- }
- return aItems;
- };
- /*
- Parameters: none
- Returns: Array
- */
- CSelectionObject.prototype.getMetadataItems = function()
- {
- if (!this.m_aMetadataItems.length) {
- this.fetchContextIds();
- for (var i = 0; i < this.m_contextIds.length; ++i) {
- this.m_aMetadataItems[this.m_aMetadataItems.length] = [];
- for (var j = 0; j < this.m_contextIds[i].length; ++j) {
- var contextId = this.m_contextIds[i][j];
- var sMetaDataItem="";
- if(this.m_selectionController.isContextId(contextId))
- {
- var sLun = this.m_selectionController.getLun(contextId);
- var sHun = this.m_selectionController.getHun(contextId);
- if(sLun && sLun != "")
- {
- sMetaDataItem = sLun;
- }
- else if(sHun && sHun != "")
- {
- sMetaDataItem = sHun;
- }
- else
- {
- sMetaDataItem = this.m_selectionController.getQueryModelId(contextId);
- }
- }
- this.m_aMetadataItems[this.m_aMetadataItems.length-1].push(sMetaDataItem);
- }
- }
- }
- return this.m_aMetadataItems;
- };
- /*
- Parameters: none
- Returns: Array
- */
- CSelectionObject.prototype.getDrillOptions = function()
- {
- if (!this.m_aDrillOptions.length) {
- this.fetchContextIds();
- for (var i = 0; i < this.m_contextIds.length; ++i) {
- this.m_aDrillOptions[this.m_aDrillOptions.length] = [];
- for (var j = 0; j < this.m_contextIds[i].length; ++j) {
- var contextId = this.m_contextIds[i][j];
- this.m_aDrillOptions[this.m_aDrillOptions.length-1].push(this.m_selectionController.isContextId(contextId) ? this.m_selectionController.getDrillFlag(contextId) : 0);
- }
- }
- }
- return this.m_aDrillOptions;
- };
- /*
- Parameters: none
- Returns: array
- */
- CSelectionObject.prototype.getSelectedContextIds = function()
- {
- return this.m_contextIds;
- };
- CSelectionObject.prototype.fetchContextIds = function()
- {
- if (!this.m_fetchedContextIds && this.m_contextIds.length && this.m_selectionController.hasContextData())
- {
- var fetchContextIds = [];
- for (var i = 0; i < this.m_contextIds.length; i++) {
- for (var j = 0; j < this.m_contextIds[i].length; j++) {
- fetchContextIds.push(this.m_contextIds[i][j]);
- }
- }
- this.m_selectionController.fetchContextData(fetchContextIds);
- this.m_fetchedContextIds = true;
- }
- };
- CSelectionObject.prototype.setSelectionController = function(sc) {
- if (sc) {
- this.m_selectionController = sc;
- }
- };
- CSelectionObject.prototype.getLayoutElementId = function() {
- return this.m_layoutElementId;
- };
- CSelectionObject.prototype.hasContextInformation = function() {
- for (var i=0; i < this.m_contextIds.length; i++)
- {
- for (var j=0; j < this.m_contextIds[i].length; j++)
- {
- if (this.m_contextIds[i][j].length > 0)
- {
- return true;
- }
- }
- }
- return false;
- };
- /**
- * Checks to see if the current selection is the home cell
- * @return true if the selection is on the home cell
- */
- CSelectionObject.prototype.isHomeCell = function() {
- var className = this.getCellRef().className;
- if (className && (className == "xm" || className.indexOf("xm ") != -1 || className.indexOf(" xm") != -1)) {
- return true;
- }
- return false;
- };
- CSelectionObject.prototype.getDataContainerType = function() {
- return this.m_dataContainerType;
- };
- /*
- * Returns an object with name/value pairs of the context ids of this object
- *
- * Refer this file for structure: http://c3/teams/BUX/Public%20Documents/Caspian/Design%20Documents/GenericWidgetContextEvents.xls
- */
- CSelectionObject.prototype.getContextJsonObject = function(oSelectionController, modelPath) {
- if (this.m_oJsonContext === null) {
- var nameValueObj = {};
- var aItemSpecValues = [];
- var selectedItemName = null;
- this.getDataItems(); //Invoke to populate data-items. AS report might not have them yet.
- this.getUseValues(); //Invoke to populate use-values
- if (this.m_contextIds.length == 0) {
- return null;
- }
- var i=0, j=0;
- var itemName = this._getBestPossibleItemName(this.m_aDataItems[i][j], this.m_contextIds[i][j], oSelectionController);
- selectedItemName = itemName;
- this._populateJsonContextObj(itemName, this.m_aUseValues[i][j], oSelectionController.getDisplayValue(this.m_contextIds[i][j]), oSelectionController.getMun(this.m_contextIds[i][j]), nameValueObj, aItemSpecValues);
- j++;
- for ( ; i < this.m_aDataItems.length; i++, j=0) {
- for ( ; j < this.m_aDataItems[i].length; j++) {
- itemName = this._getBestPossibleItemName(this.m_aDataItems[i][j], this.m_contextIds[i][j], oSelectionController);
- // this is only necessary for area map since the first context id is empty string.
- if( !selectedItemName ){ selectedItemName = itemName; }
- this._populateJsonContextObj(itemName, this.m_aUseValues[i][j], oSelectionController.getDisplayValue(this.m_contextIds[i][j]), oSelectionController.getMun(this.m_contextIds[i][j]), nameValueObj, aItemSpecValues);
- }
- }
- this.m_oJsonContext = this._createGenericPayloadStructureJson(selectedItemName, nameValueObj, aItemSpecValues, modelPath);
- }
- return this.m_oJsonContext;
- };
- CSelectionObject.prototype._getBestPossibleItemName = function(itemName, ctxId, oSelectionController) {
- var bestItemName = null;
- if (oSelectionController.isMeasure(ctxId)) {
- if (! oSelectionController.isValidColumnTitle(this.m_oCellRef) ) {
- if (! oSelectionController.isRelational([ctxId] )) {
- //Dimensional Measure
- bestItemName = oSelectionController.getCCDManager().GetBestPossibleDimensionMeasureName(ctxId);
- }
- return (bestItemName) ? bestItemName : itemName;
- }
- }
- bestItemName = oSelectionController.getCCDManager().GetBestPossibleItemName(ctxId);
- return (bestItemName) ? bestItemName : itemName;
- };
- CSelectionObject.prototype._isTypeColumnTitle = function() {
- //Check for getAttribute function's presence for a slice of chart because m_oCellRef is an empty object
- if (this.m_oCellRef && typeof this.m_oCellRef.getAttribute == 'function') {
- return (this.m_oCellRef.getAttribute('type') ==='columnTitle');
- }
- return false;
- };
- /*
- * Populates a property with itemName in the passed obj and detailObj.
- *
- * If itemName is already present in the obj, do not overwrite.
- * Use displayValue if present over useValue
- *
- */
- CSelectionObject.prototype._populateJsonContextObj = function(itemName, useValue, displayValue, mun, nameValueObj, aItemSpecValues) {
- if (nameValueObj && aItemSpecValues && itemName && typeof nameValueObj[itemName] == 'undefined') {
- var value = displayValue? displayValue: useValue;
- nameValueObj[itemName] = [value]; //should be array
- var detailObj = {};
- if (displayValue) {
- detailObj['caption'] = displayValue;
- }
- if (mun) {
- detailObj['mun'] = mun;
- }
- if (useValue) {
- detailObj['use'] = useValue;
- }
- aItemSpecValues.push(detailObj);
- }
- };
- CSelectionObject.prototype._createGenericPayloadStructureJson = function(selectedItemName, nameValueObject, aItemSpecValues, modelPath) {
- if (selectedItemName && nameValueObject && aItemSpecValues ) {
- var modelPathName = (modelPath)? modelPath : ".";
- var itemSpecObj = {};
- itemSpecObj[modelPathName] = {"values": aItemSpecValues};
- var obj = {
- "com.ibm.widget.context": {
- "values": nameValueObject
- },
- "com.ibm.widget.context.report.select": {
- "select": {
- "selectedItem": selectedItemName,
- "itemSpecification": itemSpecObj
- }
- }
- };
- return obj;
- }
- return null;
- };
- /*
- * For discrete data only, populate name/value pair and detail item spec into passed objects,
- *
- * @param nameValueObj - used in common part of generic payload
- * @param itemSpecObj - used in detail selection part of generic payload
- *
- */
- CSelectionObject.prototype.populateSelectionPayload = function(nameValueObj, itemSpecObj, bExcludeContext) {
- this.getDataItems(); //Invoke to populate data-items. AS report might not have them yet.
- this.getUseValues(); //Invoke to populate use-values
- if (this.m_contextIds.length == 0) {
- return false;
- }
-
- bExcludeContext = (( bExcludeContext === undefined ) ? false : bExcludeContext );
- var oSelectionController = this.m_selectionController;
- for (var i=0, j=0 ; i < this.m_aDataItems.length; i++, j=0)
- {
- var noOfDataItems = ( bExcludeContext ? 1 : this.m_aDataItems[i].length );
- for ( ; j < noOfDataItems; j++) {
- if (!oSelectionController.isMeasure(this.m_contextIds[i][j])) {
- var itemName = this.m_aDataItems[i][j];
- this._populateItemInSelectionPayload(itemName, this.m_aUseValues[i][j], oSelectionController.getDisplayValue(this.m_contextIds[i][j]), oSelectionController.getMun(this.m_contextIds[i][j]), nameValueObj, itemSpecObj);
- }
- }
- }
- return true;
- };
- /*
- * Populates discrete data of it into two objects, one used in common part of generic payload,
- * and another used in detail selection part of generic payload
- *
- * @param nameValueObj - used in common part of generic payload
- * @param itemSpecObj - used in detail selection part of generic payload
- *
- */
- CSelectionObject.prototype._populateItemInSelectionPayload = function(itemName, useValue, displayValue, mun, nameValueObj, itemSpecObj) {
- if (nameValueObj && itemName ) {
- var value = useValue? useValue : displayValue;
- if(nameValueObj[itemName]) {
- nameValueObj[itemName].push(value);
- } else {
- nameValueObj[itemName] = [value]; //should be array
- }
- var detailObj = {};
-
- detailObj['caption'] = value;
- if (mun) {
- detailObj['mun'] = mun;
- }
-
- var itemSpecValuesObj = itemSpecObj[itemName];
- if (!itemSpecValuesObj) {
- itemSpecValuesObj = {'values': []};
- itemSpecObj[itemName] = itemSpecValuesObj;
- }
- itemSpecValuesObj.values.push(detailObj);
- }
- };
- CSelectionObject.prototype.getCtxAttributeString = function() {
- return this.m_ctxAttributeString;
- };
- CSelectionObject.prototype.isDataValueOrChartElement = function(){
- return (this.m_sLayoutType === 'datavalue' || this.m_sLayoutType === 'chartElement' )
- };
- /*
- * 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
- */
- CSelectionObject.prototype.marshal = function(oSelectionController, sCVid) {
- if (!this.m_oJsonForMarshal) {
- var nameValueObj = {};
- var aItemSpecValues = [];
- var selectedItemName = null;
- this.getDataItems(); //Invoke to populate data-items. AS report might not have them yet.
- this.getUseValues(); //Invoke to populate use-values
- if (this.m_contextIds.length == 0) {
- return null;
- }
- var i=0, j=0;
-
- //ctx attribute could be [[""], ["22"], [""]]
- //make sure i,j are starting with not-empty
- if (this.m_contextIds[i][j].length == 0) {
- var foundValue = false;
- do {
- for ( ; j < this.m_contextIds[i].length; j++) {
- if (this.m_contextIds[i][j].length > 0 ) {
- foundValue = true;
- break;
- }
- }
- if (!foundValue) {
- j=0;
- i++;
- }
- } while (!foundValue)
- }
-
-
- var itemName = this._getBestPossibleItemName(this.m_aDataItems[i][j], this.m_contextIds[i][j], oSelectionController);
- var isMeasure = oSelectionController.isMeasure(this.m_contextIds[i][j]);
- var itemRef = this._getBestPossibleItemReference(this.m_contextIds[i][j], isMeasure, oSelectionController.getCCDManager());
- var queryName = oSelectionController.getCCDManager().GetQuery(this.m_contextIds[i][j]);
- var isDataValueOrChartElement = this.isDataValueOrChartElement();
-
- 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 );
- j++;
- var aContext = [];
- for ( ; i < this.m_aDataItems.length; i++, j=0) {
- for ( ; j < this.m_aDataItems[i].length; j++) {
- itemName = this._getBestPossibleItemName(this.m_aDataItems[i][j], this.m_contextIds[i][j], oSelectionController);
- isMeasure = oSelectionController.isMeasure(this.m_contextIds[i][j]);
- itemRef = this._getBestPossibleItemReference(this.m_contextIds[i][j], isMeasure, oSelectionController.getCCDManager());
-
- 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]));
- if (oContext) {
- aContext.push(oContext);
- }
- }
- }
- var lid = (typeof this.getArea == 'function') ? getImmediateLayoutContainerId(this.getArea()) : getImmediateLayoutContainerId(this.getCellRef());
- if (lid && lid.indexOf(sCVid)>0) {
- lid = lid.substring(0, lid.indexOf(sCVid)-1); //remove CV id
- }
- this.m_oJsonForMarshal = {
- 'lid': lid, //Do not use this - this.getLayoutElementId(),
- 'query': queryName,
- 'selectedItem': oSelectedItem,
- 'context': aContext
- };
- }
-
- return this.m_oJsonForMarshal;
- };
- CSelectionObject.prototype._populateJsonForMarshal = function(itemName, itemRefObj, isMeasure, useValue, displayValue, mun, isDataValueOrChartElement) {
- if (itemName) {
- var detailObj = {};
-
- detailObj['itemName'] = itemName;
- detailObj['isMeasure'] = isMeasure? 'true' : 'false'; //use string so that can be saved in itemset
- detailObj['mdProperty'] = itemRefObj.mdProperty;
- detailObj['mdValue'] = itemRefObj.mdValue;
- detailObj['isDataValueOrChartElement'] = isDataValueOrChartElement ? 'true' : 'false'
- /*if (displayValue) {
- detailObj['caption'] = displayValue;
- }*/
- if (mun) {
- detailObj['mun'] = mun;
- }
- if (useValue) {
- detailObj['use'] = useValue;
- }
- return detailObj;
- }
- return null;
- };
- CSelectionObject.prototype._getBestPossibleItemReference = function(ctxId, isMeasure, oCCDManager) {
- var bestItemRef = null;
- var property = null;
- if (isMeasure) {
- //Search in order of ["i", "m", "r"]
-
- property = "i";
- bestItemRef = oCCDManager.GetQMID(ctxId); /* i value */
- if(bestItemRef == null) {
- property = "m";
- bestItemRef = oCCDManager.GetMUN(ctxId); /* m value */
- }
- if(bestItemRef == null) {
- property = "r";
- bestItemRef = oCCDManager.GetRDIValue(ctxId); /* r value */
- }
- } else {
- //Search in order of ["l", "h", "i", "r"]
-
- property = "l";
- bestItemRef = oCCDManager.GetLUN(ctxId); /* l value */
- if(bestItemRef == null) {
- property = "h";
- bestItemRef = oCCDManager.GetHUN(ctxId); /* h value */
- }
- if(bestItemRef == null) {
- property = "i";
- bestItemRef = oCCDManager.GetQMID(ctxId); /* i value */
- }
- if(bestItemRef == null) {
- property = "r";
- bestItemRef = oCCDManager.GetRDIValue(ctxId); /* r value */
- }
- }
-
- return {'mdProperty': property, 'mdValue': bestItemRef};
- };
- //
- // This class represents the basic representation of a chart selection object.
- //
- /*
- Constructor.
- Parameters:
- Returns:
- */
- // set up the base class
- CSelectionChartObject.prototype = new CSelectionObject();
- CSelectionChartObject.prototype.constructor = CSelectionChartObject;
- CSelectionChartObject.baseclass = CSelectionObject.prototype;
- function CSelectionChartObject()
- {
- // initialize the base class
- CSelectionChartObject.baseclass.initialize.call(this);
- this.m_chartArea = null;
- this.m_context = "";
- this.m_chartCtxAreas = [];
- this.m_selectedVizChart = false;
- }
- CSelectionChartObject.prototype.isSelectionOnVizChart = function() {
- return this.m_selectedVizChart;
- };
- CSelectionChartObject.prototype.setSelectionOnVizChart = function(chartNode) {
- var imageNode = this.m_selectionController.getSelectedChartImageFromChartArea(chartNode);
- if (imageNode) {
- this.m_selectedVizChart = imageNode.parentNode.getAttribute("vizchart") == "true" ? true : false;
- }
- };
- CSelectionChartObject.prototype.getArea = function()
- {
- return this.m_chartArea;
- };
- CSelectionChartObject.prototype.getContext = function()
- {
- return this.m_context;
- };
- CSelectionChartObject.prototype.getCtxAreas = function()
- {
- return this.m_chartCtxAreas;
- };
- CSelectionChartObject.prototype.setCtxAreas = function(ctxAreas)
- {
- this.m_chartCtxAreas = ctxAreas;
- };
- CSelectionChartObject.prototype.getCtxAttributeString = function() {
- return this.m_context;
- };
- /**
- * This class contains the objects that help with chart selection
- * @param chartArea
- * @param cognosViewer
- * @returns {CChartHelper}
- */
- function CChartHelper(chartArea, selectionObjectFactory, cognosViewer){
- var imageMap = chartArea.parentNode;
- this.m_selectionObjectFactory = selectionObjectFactory;
- this.m_map = imageMap;
- cognosViewer.loadExtra();
- this.imageMapHighlighter = new CImageMapHighlight(imageMap, cognosViewer.sWebContentRoot);
- this.initialize();
- }
- CChartHelper.prototype.initialize = function() {
- this.buildMapCtxAreas();
- this.m_chartCtxNodes = {};
- };
- /**
- * Scan the map and build and object with all unique context as properties names, and an array of the
- * areas with that context as value
- */
- CChartHelper.prototype.buildMapCtxAreas = function() {
- var ctxAreas = {};
- var areas = this.m_map.childNodes;
- var areaCount = areas.length;
- var areaCtx = null;
- for (var i=0; i<areaCount; i++ ) {
- var a = areas[i];
- areaCtx = a.getAttribute("ctx");
- if (areaCtx) {
- if (ctxAreas[areaCtx]) {
- ctxAreas[areaCtx].push(a);
- } else {
- ctxAreas[areaCtx] = [a];
- }
- }
- }
- this.m_ctxAreas = ctxAreas;
- };
- CChartHelper.prototype.getChartNode = function(chartArea)
- {
- if (!this.isAreaInitialized(chartArea)) {
- var imageMap = chartArea.parentNode;
- this.m_map = imageMap;
- this.initialize();
- this.imageMapHighlighter.initialize(imageMap);
- }
- var areaCtx = chartArea.getAttribute("ctx");
- if (!this.m_chartCtxNodes[areaCtx]) {
- this.m_chartCtxNodes[areaCtx] = this.m_selectionObjectFactory.getSelectionChartObject(chartArea);
- this.m_chartCtxNodes[areaCtx].setCtxAreas(this.m_ctxAreas[areaCtx]);
- }
- return this.m_chartCtxNodes[areaCtx];
- };
- CChartHelper.prototype.isAreaInitialized = function(chartArea) {
- return this.imageMapHighlighter.isAreaInitialized(chartArea);
- };
- CChartHelper.prototype.getImageMapHighlighter = function() {
- return this.imageMapHighlighter;
- };
- //
- // This class creates a factory for selection objects.
- //
- /*
- Constructor.
- Parameters:
- Returns: selection object factory
- */
- function CSelectionObjectFactory(selectionController)
- {
- this.m_selectionController = selectionController;
- }
- CSelectionObjectFactory.prototype.getSelectionController = function()
- {
- return this.m_selectionController;
- };
- /*
- * Retrieves span tags from inside the target tag, but excluding any
- * inside a different layout element id.
- * Parameters: target, an HTML Element
- * Returns: an array of span HTML Elements
- */
- CSelectionObjectFactory.prototype.getChildSpans = function(target) {
- var toVisit = [];
- for(var i = 0; i < target.childNodes.length; i++) {
- var child = target.childNodes[i];
- if (!child.getAttribute || child.getAttribute("skipSelection") != "true") {
- toVisit.push(target.childNodes[i]);
- }
- }
- //Find the layout element id associated with target
- var targetParent = target;
- var targetLid = "";
- while(!targetLid && targetParent) {
- targetLid = targetParent.attributes ? targetParent.attributes["LID"] : "";
- targetParent = targetParent.parentNode;
- }
- targetLid = targetLid ? targetLid.value : "";
- //Get children
- var allChildren = [];
- while(toVisit.length > 0) {
- var child = toVisit.pop();
- var lid = child.attributes ? child.attributes["LID"] : "";
- lid = lid ? lid.value : "";
- //Omit children under a different layout element id
- if(!lid || lid == targetLid) {
- //Record all span tags
- if(child.nodeName.toLowerCase() == "span") {
- allChildren.push(child);
- }
- else {
- for(i = 0; i < child.childNodes.length; i++) {
- toVisit.push(child.childNodes[i]);
- }
- }
- }
- }
- return allChildren;
- };
- /*
- Parameters:
- cellRef - an HTML reference to a <td> element
- Returns: selection object
- */
- CSelectionObjectFactory.prototype.getSelectionObject = function(cellRef, matchOnCTX) {
- var newSelObj = new CSelectionObject();
- try{
- newSelObj.setSelectionController(this.getSelectionController());
- newSelObj.m_oCellRef = cellRef;
- newSelObj.m_sColumnRef = cellRef.getAttribute("cid");
- newSelObj.m_sCellTypeId = cellRef.getAttribute("uid");
- newSelObj.m_sLayoutType = cellRef.getAttribute("type");
- newSelObj.m_sTag = cellRef.getAttribute("tag");
- newSelObj.m_layoutElementId = this.getLayoutElementId(cellRef);
- newSelObj.m_dataContainerType = this.getContainerType(cellRef);
- //Query Studio specific code
- if (typeof cf != "undefined")
- {
- var miniQueryObj = cf.cfgGet("MiniQueryObj");
- if(miniQueryObj)
- {
- var tagElement = miniQueryObj.findChildWithAttribute("tag", newSelObj.m_sTag);
- if(tagElement && tagElement.getAttribute("id") != null)
- {
- newSelObj.m_sColumnName = tagElement.getAttribute("id");
- }
- }
- }
- //get all of the child textItem nodes which are not of a different layout id
- var allChildren = this.getChildSpans(cellRef);
- if (allChildren.length > 0)
- {
- for (var i = 0; i < allChildren.length; i++)
- {
- var oChild = allChildren[i];
- if (oChild.nodeType == 1 && oChild.nodeName.toLowerCase() == "span" && oChild.style.visibility != "hidden")
- {
- var contextNode = null;
- if (cellRef.getAttribute("ctx") != null && cellRef.getAttribute("ctx") != "") {
- contextNode = cellRef;
- }
- else if(oChild.getAttribute("ctx") != null && oChild.getAttribute("ctx") != "") {
- contextNode = oChild;
- }
- else if(oChild.getAttribute("dtTargets") && oChild.childNodes && oChild.childNodes.length) {
- for (var idxCN = 0; idxCN < oChild.childNodes.length; idxCN++)
- {
- if (oChild.childNodes[idxCN].nodeType == 1 && oChild.childNodes[idxCN].style.visibility != "hidden") {
- contextNode = oChild.childNodes[idxCN];
- }
- }
- } else {
- // for saved outputs with authored drill through we'll have a span within a span. The CTX attribute
- // will be on the inner span so go find it.
- for (var childIndex = 0; childIndex < oChild.childNodes.length; childIndex++) {
- var nestedChild = oChild.childNodes[childIndex];
- if(typeof nestedChild.getAttribute != "undefined" && nestedChild.getAttribute("ctx") != null && nestedChild.getAttribute("ctx") != "") {
- contextNode = nestedChild;
- break;
- }
- }
- }
- var context = "";
- if(contextNode && contextNode.getAttribute("ctx"))
- {
- context = contextNode.getAttribute("ctx");
- }
- newSelObj.m_aDisplayValues[newSelObj.m_aDisplayValues.length] = this.getSelectionController().getDisplayValue(context, cellRef.parentNode);
- // 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
- if(typeof matchOnCTX != "undefined" && matchOnCTX != context) {
- continue;
- }
- newSelObj = this.processCTX(newSelObj, context);
- }
- }
- }
- else if(cellRef.getAttribute("ctx") != null && cellRef.getAttribute("ctx") != "" && newSelObj.m_sLayoutType == "datavalue")
- {
- newSelObj = this.processCTX(newSelObj, cellRef.getAttribute("ctx"));
- }
- this.getSelectionController().processColumnTitleNode(newSelObj);
- }catch(ex) {
- // sometimes node may not be an HTML element (like a XUL element) and accessing nodeType/nodeName/className will generate an error.
- }
- return newSelObj;
- };
- /*
- Parameters:
- selObj - a CSelectionObject object
- context - the ctx attribute from the span or td
- Returns: selection object
- */
- CSelectionObjectFactory.prototype.processCTX = function(selObj, context)
- {
- if (typeof context != "string" || context.length == 0)
- {
- return selObj;
- }
- var ctx;
- // A:B::C:D::E becomes [[A,B],[C,D],[E]]
- if (typeof selObj.m_contextIds == "object" && selObj.m_contextIds !== null && selObj.m_contextIds.length > 0)
- {
- var tempContextIds = context.split("::");
- for(ctx = 0; ctx < selObj.m_contextIds.length; ++ctx)
- {
- try
- {
- if (tempContextIds[ctx])
- {
- selObj.m_contextIds[ctx] = selObj.m_contextIds[ctx].concat(tempContextIds[ctx].split(":"));
- }
- }
- catch (e)
- {
- }
- }
- }
- else
- {
- selObj.m_contextIds = this.m_selectionController.m_oCognosViewer.getReportContextHelper().processCtx(context);
- }
- selObj.m_ctxAttributeString = context;
- return selObj;
- };
- /*
- Parameters:
- tag - a reference to the column
- Returns: selection object
- */
- CSelectionObjectFactory.prototype.getSecondarySelectionObject = function(tag, layoutType, theDocument)
- {
- if (!theDocument) {
- theDocument = document;
- }
- var newSelObj = new CSelectionObject();
- newSelObj.setSelectionController(this.getSelectionController());
- // Non-default initialization
- newSelObj.m_oCellRef = null;
- newSelObj.m_sColumnRef = null;
- newSelObj.m_sCellTypeId = null;
- newSelObj.refQuery = "";
- var allTds = theDocument.getElementsByTagName("td");
- // Figure out from the secondary selection what needs to be selected
- for (var i = 0; i < allTds.length; i++)
- {
- var colTag = allTds[i].getAttribute("tag");
- if (colTag != null && colTag != "")
- {
- if (tag == colTag)
- {
- var colClass = allTds[i].className;
- if (colClass != null && colTag != "")
- {
- if ((layoutType == "columnTitle" && colClass == "lt") || (layoutType == "datavalue" && colClass == "lc"))
- {
- newSelObj.m_sColumnRef = allTds[i].getAttribute("cid");
- newSelObj.m_sCellTypeId = allTds[i].getAttribute("uid");
- break;
- }
- }
- }
- }
- }
- if (newSelObj.m_sCellTypeId == null) {
- return null;
- }
- return newSelObj;
- };
- CSelectionObjectFactory.prototype.getSelectionChartObject = function(chartNode)
- {
- var contextIds = "";
- if(chartNode.getAttribute("flashChart") != null)
- {
- if(typeof chartNode.getCtx != "undefined")
- {
- try
- {
- contextIds = chartNode.getCtx();
- }
- catch(e)
- {
- contextIds ="";
- }
- }
- }
- else
- {
- contextIds = chartNode.getAttribute("ctx");
- }
- var newSelObj = new CSelectionChartObject();
- newSelObj.setSelectionController(this.getSelectionController());
- if(contextIds != null)
- {
- newSelObj.m_contextIds = contextIds.split("::");
- for(var ctx = 0; ctx < newSelObj.m_contextIds.length; ++ctx)
- {
- newSelObj.m_contextIds[ctx] = newSelObj.m_contextIds[ctx].split(":");
- }
- }
- newSelObj.m_layoutElementId = this.getLayoutElementId(chartNode);
- newSelObj.m_sLayoutType = chartNode.getAttribute("type");
- newSelObj.m_chartArea = chartNode;
- newSelObj.m_context = contextIds;
- newSelObj.setSelectionOnVizChart(chartNode);
- return newSelObj;
- };
- CSelectionObjectFactory.prototype.getContainerTypeFromClass = function(className)
- {
- var containerType = "";
- switch(className)
- {
- case "ls":
- containerType = "list";
- break;
- case "xt":
- containerType = "crosstab";
- break;
- case "rt":
- containerType = "repeaterTable";
- break;
- }
- return containerType;
- };
- //get the container type
- CSelectionObjectFactory.prototype.getContainerType = function(el) {
- var type = "";
- if (el) {
- if (el.className) {
- type = this.getContainerTypeFromClass(el.className);
- }
- if (!type) {
- var parentNode = el.parentNode;
- if (parentNode) {
- type = this.getContainerType(parentNode);
- }
- }
- }
- return type;
- };
- //get the unique ID for the layout object.
- CSelectionObjectFactory.prototype.getLayoutElementId = function(el) {
- var id = "";
- var viewerId = this.getSelectionController().getNamespace();
- if (el) {
- if (el.getAttribute && el.getAttribute("chartcontainer") == "true") {
- for (var childIndex=0; childIndex < el.childNodes.length; childIndex++) {
- var childNode = el.childNodes[childIndex];
- if (childNode.nodeName.toLowerCase() == "img" && childNode.getAttribute("lid") != null) {
- return childNode.getAttribute("lid");
- }
- }
- }
- id = (el.getAttribute && el.getAttribute("LID")) || "";
- if (!id) {
- var parentNode = el.parentNode;
- if (parentNode) {
- id = this.getLayoutElementId(parentNode);
- }
- } else if(el.tagName.toUpperCase() == "MAP") {
- // temporary until we get rsvp to update v5ReportEngine.xsl
- id = id.replace(viewerId, "");
- id = viewerId + id;
- // end of temp code
- var imageMapName = "#" + id;
- var imgNodes = getElementsByAttribute(el.parentNode, "IMG", "usemap", imageMapName);
- if (imgNodes.length > 0)
- {
- id = imgNodes[0].getAttribute("LID");
- }
- }
- }
- return id;
- };
- //
- // This class creates a controller for all of the selection objects.
- //
- /*
- Constructor.
- Parameters:
- Returns: selection controller
- */
- function CSelectionController(sNamespace, oCognosViewer)
- {
- this.m_bSelectionBasedFeaturesEnabled = false;
- this.m_bDrillUpDownEnabled = false;
- this.m_bModelDrillThroughEnabled = false;
- this.m_oCognosViewer = null;
- this.m_bSavedSelections = false;
- if (oCognosViewer) {
- this.m_oCognosViewer = oCognosViewer;
- }
- this.initialize(sNamespace);
- this.FILTER_SELECTION_STYLE = 0;
- this.FILTER_SELECTION_CONTEXT_MENU_STYLE = 1;
- }
- CSelectionController.prototype.initialize = function(sNamespace)
- {
- this.m_sNamespace = sNamespace;
- this.m_aCutColumns = [];
- this.m_aSelectedObjects = [];
- this.m_selectedClass = [];
- this.m_cutClass = [];
- this.m_oObserver = new CObserver(this);
- this.m_bSelectionArraysSetup = false;
- this.m_aSelectionHoverNodes = [];
- //deprecated
- this.m_bUsingCCDManager = false; //This bool can go when we switch to JSON format exclusively
- this.m_aReportMetadataArray = [];
- this.m_aReportContextDataArray = [];
- //JSON
- this.m_oCDManager = new CCDManager();
- this.m_oSelectionObjectFactory = new CSelectionObjectFactory(this);
- this.m_selectedChartArea = null;
- this.m_selectedChartNodes = [];
- this.m_selectionContainerMap = null;
- this.m_chartHelpers = {};
- if(this.m_oCognosViewer != null)
- {
- this.m_oCDManager.SetCognosViewer(this.m_oCognosViewer);
- }
- this.m_maxSecondarySelection = -1;
- this.c_usageMeasure = '2';
- this.m_ccl_dateTypes = { 59:'dateTime', 60:'interval' };
-
- this.m_selectionStyles = new CSelectionDefaultStyles( this );
- this.m_originalSelectionStyles = this.m_selectionStyles;
- this.m_bAllowHorizontalDataValueSelection = false;
-
- };
- CSelectionController.prototype.secondarySelectionIsDisabled = function(){
- return this.m_selectionStyles.secondarySelectionIsDisabled();
- };
- CSelectionController.prototype.getPrimarySelectionColor = function(){
- return this.m_selectionStyles.getPrimarySelectionColor();
- };
- CSelectionController.prototype.getHighContrastBorderStyle = function(){
- return this.m_selectionStyles.getHighContrastBorderStyle();
- };
- CSelectionController.prototype.getSecondarySelectionColor = function(){
- return this.m_selectionStyles.getSecondarySelectionColor();
- };
- CSelectionController.prototype.resetSelectionStyles = function(){
- this.setSelectionStyles();
- };
- CSelectionController.prototype.setSelectionStyles = function( styleType ){
- switch( styleType )
- {
- //case "filter":
- case this.FILTER_SELECTION_STYLE:
- {
- if( !this.m_selectionFilterStyles ){
- this.m_selectionFilterStyles = new CSelectionFilterStyles( this );
- }
-
- this.m_selectionStyles = this.m_selectionFilterStyles;
- break;
- }
-
- //case "filterContextMenu":
- case this.FILTER_SELECTION_CONTEXT_MENU_STYLE:
- {
- if( !this.m_selectionFilterContextMenuStyles ){
- this.m_selectionFilterContextMenuStyles = new CSelectionFilterContextMenuStyles( this );
- }
-
- this.m_selectionStyles = this.m_selectionFilterContextMenuStyles;
- break;
- }
-
- default:
- this.m_selectionStyles = this.m_originalSelectionStyles;
- }
- };
- CSelectionController.prototype.resetAllowHorizontalDataValueSelection = function()
- {
- this.m_bAllowHorizontalDataValueSelection = false;
- };
- CSelectionController.prototype.setAllowHorizontalDataValueSelection = function( bAllow)
- {
- this.m_bAllowHorizontalDataValueSelection = bAllow;
- };
- CSelectionController.prototype.allowHorizontalDataValueSelection = function()
- {
- return this.m_bAllowHorizontalDataValueSelection;
- };
- /**
- * Resets the selection, note this function will NOT update the UI, it
- * simply resets the internal selection array.
- */
- CSelectionController.prototype.clearSelectionData = function()
- {
- this.m_aSelectedObjects = [];
- this.m_selectedChartNodes = [];
- this.m_oSelectedDrillThroughImage = null;
- this.m_oSelectedDrillThroughSingleton = null;
- };
- CSelectionController.prototype.getCCDManager = function()
- {
- return this.m_oCDManager;
- };
- CSelectionController.prototype.getCtxIdFromDisplayValue = function(sDisplayValue)
- {
- if (!this.m_bUsingCCDManager) {
- var contextDataArray = this.getReportContextDataArray();
- var CD_DISPLAY_VALUE_IDX = 1;
- for (var sCtxId in contextDataArray)
- {
- var contextItem = contextDataArray[sCtxId];
- if(contextItem[CD_DISPLAY_VALUE_IDX] == sDisplayValue) {
- return sCtxId;
- }
- }
- return "";
- } else {
- var sId = this.m_oCDManager.GetContextIdForDisplayValue(sDisplayValue);
- return (sId == null) ? "" : sId;
- }
- };
- CSelectionController.prototype.getCtxIdFromMetaData = function(sLun, sHun, bIgnoreDrillFlag)
- {
- return this.m_oCDManager.getContextIdForMetaData(sLun, sHun, bIgnoreDrillFlag);
- };
- /**
- *replace the namespace substring if the passed in LUN or HUN are from a different namespace (but
- *the shared TM1 dimension) compared with the metadata held by data manager instance
- **/
- CSelectionController.prototype.replaceNamespaceForSharedTM1DimensionOnly = function(lun, hun, mun)
- {
- var sLun = lun;
- var sHun = hun;
- if(mun && mun.indexOf("->:[TM].") > 0){
- sLun = this.m_oCDManager._replaceNamespaceForSharedTM1DimensionOnly(lun);
- sHun = this.m_oCDManager._replaceNamespaceForSharedTM1DimensionOnly(hun);
- }
- return { "lun" : sLun, "hun" :sHun};
- };
- CSelectionController.prototype.getCtxIdFromMun = function(sMun)
- {
- if (!this.m_bUsingCCDManager) {
- var metaDataArray = this.getReportMetadataArray();
- var MD_USE_VALUE_IDX = 0;
- for(var sKey in metaDataArray)
- {
- var metaDataItem = metaDataArray[sKey];
- if(metaDataItem[MD_USE_VALUE_IDX] == sMun)
- {
- var CD_METADATA_KEY_IDX = 2;
- var contextDataArray = this.getReportContextDataArray();
- for(var sCtxId in contextDataArray)
- {
- var contextItem = contextDataArray[sCtxId];
- if(contextItem[CD_METADATA_KEY_IDX] == sKey) {
- return sCtxId;
- }
- }
- }
- }
- return "";
- } else {
- var sId = this.m_oCDManager.GetContextIdForMUN(sMun);
- return (sId == null) ? "" : sId;
- }
- };
- CSelectionController.prototype.canDrillDown = function(sCtxId)
- {
- var drillFlag = this.getDrillFlagForMember(sCtxId);
- return (drillFlag == 3 || drillFlag == 2);
- };
- CSelectionController.prototype.canDrillUp = function(sCtxId)
- {
- var drillFlag = this.getDrillFlagForMember(sCtxId);
- return (drillFlag == 3 || drillFlag == 1);
- };
- CSelectionController.prototype.getQueryModelId = function(sCtxId)
- {
- var qmid = "";
- if (!this.m_bUsingCCDManager) {
- var contextObj = this.m_aReportContextDataArray[sCtxId];
- if(contextObj && typeof contextObj[3] != "undefined"){
- var queryModelItemRefId = contextObj[3];
- var contextQueryModelItem = this.m_aReportMetadataArray[queryModelItemRefId];
- if(typeof contextQueryModelItem != "undefined" && typeof contextQueryModelItem[1] != "undefined" && contextQueryModelItem[1] == "I")
- {
- qmid = contextQueryModelItem[0];
- }
- }
- } else {
- qmid = this.m_oCDManager.GetQMID(sCtxId);
- }
- return qmid;
- };
- CSelectionController.prototype.getRefQuery = function(sCtxId)
- {
- if (!this.m_bUsingCCDManager) {
- return this.getMetaDataItemUseValue(4/*ref query item reference*/, sCtxId);
- } else {
- var sRefQuery = this.m_oCDManager.GetQuery(sCtxId);
- return (sRefQuery == null) ? "" : sRefQuery;
- }
- };
- /**
- @deprecated Use CCognosViewer.getReportContextHelper().getRefDataItem() instead
- */
- CSelectionController.prototype.getRefDataItem = function(sCtxId)
- {
- return this.m_oCognosViewer.getReportContextHelper().getRefDataItem(sCtxId);
- };
- /**
- @deprecated Use CCognosViewer.getReportContextHelper().getMun() instead
- */
- CSelectionController.prototype.getMun = function(sCtxId)
- {
- return this.m_oCognosViewer.getReportContextHelper().getMun(sCtxId);
- };
- CSelectionController.prototype.getHun = function(sCtxId)
- {
- if (!this.m_bUsingCCDManager) {
- var sHun = null;
- var aData = this.getRDI(sCtxId);
- if (aData && aData.length > 4 && aData[1] == "R") {
- var sRefDataItem = aData[4];
- var aReportMetadataArray = this.getReportMetadataArray();
- aData = aReportMetadataArray[sRefDataItem];
- }
- if (aData && aData.length > 1 && aData[1] == "H")
- {
- sHun = aData[0];
- }
- return sHun;
- } else {
- return this.m_oCDManager.GetHUN(sCtxId);
- }
- };
- CSelectionController.prototype.fetchContextData = function(fetchContextIds, callback)
- {
- var numberOfItemsWithNoContext = 0;
- if (this.m_bUsingCCDManager) {
- numberOfItemsWithNoContext = this.m_oCDManager.FetchContextData(fetchContextIds, callback);
- }
- return numberOfItemsWithNoContext;
- };
- //////////////////
- // These can go once we have moved to JSON objects
- CSelectionController.prototype.getMetaDataItem = function(sKey)
- {
- var metaDataArray = this.getReportMetadataArray();
- if(typeof metaDataArray[sKey] != "undefined")
- {
- return metaDataArray[sKey];
- }
- return null;
- };
- CSelectionController.prototype.getContextDataItem = function(sCtxId)
- {
- var contextDataArray = this.getReportContextDataArray();
- if(typeof contextDataArray[sCtxId] != "undefined")
- {
- return contextDataArray[sCtxId];
- }
- return null;
- };
- CSelectionController.prototype.getMetaDataItemUseValue = function(iKeyIndex, sCtxId)
- {
- /**
- * 0 == ref data item
- * 2 == mun
- * 3 == level or qmid
- * 4 == query
- */
- var contextItem = this.getContextDataItem(sCtxId);
- if(contextItem != null)
- {
- var metaDataQueryKey = contextItem[iKeyIndex];
- if(metaDataQueryKey != "")
- {
- var metaDataItem = this.getMetaDataItem(metaDataQueryKey);
- if(metaDataItem != null)
- {
- return metaDataItem[0/*use value index*/];
- }
- }
- }
- return "";
- };
- CSelectionController.prototype.getRDI = function(sCtxId) {
- var contextItem = this.getContextDataItem(sCtxId);
- if(contextItem != null)
- {
- var metaDataQueryKey = contextItem[0];
- if(metaDataQueryKey != "")
- {
- var metaDataItem = this.getMetaDataItem(metaDataQueryKey);
- if(metaDataItem != null)
- {
- return metaDataItem;
- }
- }
- }
- };
- /////////////////////
- CSelectionController.prototype.getNamespace = function()
- {
- return this.m_sNamespace;
- };
- CSelectionController.prototype.setSelectionBasedFeaturesEnabled = function(bValue)
- {
- this.m_bSelectionBasedFeaturesEnabled = bValue;
- };
- CSelectionController.prototype.getSelectionBasedFeaturesEnabled = function()
- {
- return this.m_bSelectionBasedFeaturesEnabled;
- };
- CSelectionController.prototype.setDrillUpDownEnabled = function(bValue)
- {
- this.m_bDrillUpDownEnabled = bValue;
- };
- CSelectionController.prototype.getDrillUpDownEnabled = function()
- {
- return this.m_bDrillUpDownEnabled;
- };
- CSelectionController.prototype.setModelDrillThroughEnabled = function(bValue)
- {
- this.m_bModelDrillThroughEnabled = bValue;
- };
- CSelectionController.prototype.getBookletItemForCurrentSelection = function() {
- var selectedObjects = this.getAllSelectedObjects();
-
- if (selectedObjects && selectedObjects.length > 0) {
- var selectedObject = selectedObjects[0];
- if (selectedObject.hasContextInformation()) {
- var bookletItem = this.m_oCDManager.GetBIValue(selectedObject.m_contextIds[0][0]);
- if (!bookletItem) {
- return null;
- }
-
- return bookletItem;
- }
- }
-
- return null;
- };
- CSelectionController.prototype.getModelPathForCurrentSelection = function() {
- var modelPath = null;
- var bookletItem = this.getBookletItemForCurrentSelection();
- if (bookletItem) {
- var modelPath = this.m_oCDManager.getModelPathFromBookletItem(bookletItem);
- }
-
- return modelPath;
- }
- CSelectionController.prototype.getModelDrillThroughEnabled = function()
- {
- // With booklets we can't simply use the global drill through flag.
- // Dig into the metadata to see if drill through has been turned off for the referenced report
- var bookletItem = this.getBookletItemForCurrentSelection();
- if (bookletItem) {
- var modleDrillThroughEnabled = this.m_oCDManager.GetBookletModelBasedDrillThru(bookletItem);
- return modleDrillThroughEnabled == 1 ? true : false;
- }
- else {
- return this.m_bModelDrillThroughEnabled;
- }
- };
- /*
- Parameters:
- Returns: boolean
- */
- CSelectionController.prototype.clearSelectedObjects = function(theDocument)
- {
- try
- {
- if (!theDocument) {
- theDocument = document;
- }
- this.updateUI(theDocument, this.getSelections(), true, false);
- this.m_aSelectedObjects = [];
- if (typeof this.onSelectionChange == "function")
- {
- this.onSelectionChange();
- }
- return true;
- }
- catch (e)
- {
- return false;
- }
- };
- /*
- Parameters:
- Returns: boolean
- */
- CSelectionController.prototype.resetSelections = function(theDocument)
- {
- try
- {
- if (!theDocument) {
- theDocument = document;
- }
- if (this.hasSelectedChartNodes()) { // and isBUX
- this.resetChartSelections(theDocument);
- }
- this.m_oSelectedDrillThroughImage = null;
- this.m_oSelectedDrillThroughSingleton = null;
- if(this.getSelections()) {
- this.updateUI(theDocument, this.getSelections(), true, false);
- this.updateUI(theDocument, this.getCutColumns(), true, false);
- this.m_aCutColumns = [];
- this.m_aSelectedObjects = [];
- this.m_selectedClass = [];
- this.m_cutClass = [];
- if (typeof this.onSelectionChange == "function")
- {
- this.onSelectionChange();
- }
- }
- return true;
- }
- catch (e)
- {
- return false;
- }
- };
- CSelectionController.prototype.resetChartSelections = function(theDocument)
- {
- var chartHelpers = this.m_chartHelpers;
- for (var mapName in chartHelpers) {
- if (chartHelpers[mapName]) {
- var mapHighlighter = chartHelpers[mapName].getImageMapHighlighter();
- if (mapHighlighter.hideAllAreas) {
- mapHighlighter.hideAllAreas();
- }
- }
- }
- this.m_selectedChartNodes = [];
- this.m_selectionContainerMap = null;
- };
- /*
- Parameters:
- Returns: boolean
- */
- CSelectionController.prototype.addSelectionObject = function(CSelectionObject, theDocument)
- {
- try
- {
- if (!theDocument) {
- theDocument = document;
- }
- //test to see if this object is already selected
- var theCell = CSelectionObject.getCellRef();
- if (this.isCellSelected(theCell) !== true || (typeof theCell != "object" || theCell === null))
- {
- //test to see if this object is currently cut
- /* TODO: Put this back in once Report Server starts to produce context data
- if (this.isColumnCut(CSelectionObject.getColumnName()) !== true)
- {
- this.m_aSelectedObjects[this.m_aSelectedObjects.length] = CSelectionObject;
- if (typeof this.onSelectionChange == "function")
- this.onSelectionChange();
- this.updateUI(theDocument, this.getSelections(), false, false);
- }
- /TODO */
- /* TODO: Take this out once Report Server starts to produce context data */
- if (this.isColumnCut(CSelectionObject.getTag()) !== true)
- {
- this.m_aSelectedObjects[this.m_aSelectedObjects.length] = CSelectionObject;
- if (typeof this.onSelectionChange == "function")
- {
- this.onSelectionChange();
- }
- this.updateUI(theDocument, this.getSelections(), false, false);
- }
- /* /TODO */
- }
- return true;
- }
- catch (e)
- {
- return false;
- }
- };
- /*
- * Removes selected object from the selection and update the UI.
- Parameters:
- Returns: boolean
- */
- CSelectionController.prototype.removeSelectionObject = function(CSelectionObject, theDocument)
- {
- try
- {
- if (!theDocument) {
- theDocument = document;
- }
- var removed = [];
- var idxSelObjects;
- for (idxSelObjects = 0; idxSelObjects < this.m_aSelectedObjects.length; idxSelObjects++)
- {
- var selObjCellRef = this.m_aSelectedObjects[idxSelObjects].getCellRef();
- var cselObjCellRef = CSelectionObject.getCellRef();
- if (typeof selObjCellRef == "object" && typeof cselObjCellRef == "object" && selObjCellRef !== null && cselObjCellRef !== null)
- {
- if (selObjCellRef == cselObjCellRef)
- {
- removed[removed.length] = idxSelObjects;
- }
- }
- }
- if (removed.length > 0)
- {
- this.updateUI(theDocument, this.getSelections(), true, false);
- var newArr = [];
- for (idxSelObjects = 0; idxSelObjects < this.m_aSelectedObjects.length; idxSelObjects++)
- {
- var addToNewArr = true;
- for (var j = 0; j < removed.length; j++)
- {
- if (idxSelObjects == removed[j])
- {
- addToNewArr = false;
- }
- }
- if (addToNewArr)
- {
- newArr[newArr.length] = this.m_aSelectedObjects[idxSelObjects];
- }
- }
- this.m_aSelectedObjects = newArr;
- this.updateUI(theDocument, this.getSelections(), false, false);
- }
- if (typeof this.onSelectionChange == "function")
- {
- this.onSelectionChange();
- }
- return true;
- }
- catch (e)
- {
- return false;
- }
- };
- CSelectionController.prototype.isSavedCellSelected = function( cellNode )
- {
- return this.isCellSelectedHelper(cellNode, this.getSavedSelectedObjects() );
- };
- CSelectionController.prototype.isCellSelected = function( cellNode ){
- return this.isCellSelectedHelper(cellNode, this.getSelections());
- }
- /*
- Parameters:
- Returns: boolean
- */
- CSelectionController.prototype.isCellSelectedHelper = function(cellNode, selectedObjects )
- {
- try
- {
- for (var i = 0; i < selectedObjects.length; i++)
- {
- var selObjCellRef = selectedObjects[i].getCellRef();
- if (typeof selObjCellRef == "object" && selObjCellRef !== null)
- {
- if (selObjCellRef == cellNode)
- {
- return true;
- }
- }
- }
- }
- catch (e)
- {
- }
- return false;
- };
- /*
- Parameters:
- Returns: boolean
- */
- CSelectionController.prototype.isColumnSelected = function(columnName)
- {
- try
- {
- for (var i = 0; i < this.m_aSelectedObjects.length; i++)
- {
- /* TODO: Put this back in once Report Server starts to produce context data
- if (this.m_aSelectedObjects[i].getColumnName() == columnName)
- {
- return true;
- }
- /TODO */
- /* TODO: Take this out once Report Server starts to produce context data */
- if (this.m_aSelectedObjects[i].getTag() == columnName)
- {
- return true;
- }
- /* /TODO */
- }
- }
- catch (e)
- {
- }
- return false;
- };
- /*
- Parameters:
- Returns: boolean
- */
- CSelectionController.prototype.isColumnCut = function(columnName)
- {
- try
- {
- for (var i = 0; i < this.m_aCutColumns.length; i++)
- {
- /* TODO: Put this back in once Report Server starts to produce context data
- if (this.m_aCutColumns[i].getColumnName() == columnName)
- {
- return true;
- }
- /TODO */
- /* TODO: Take this out once Report Server starts to produce context data */
- if (this.m_aCutColumns[i].getTag() == columnName)
- {
- return true;
- }
- /* /TODO */
- }
- }
- catch (e)
- {
- }
- return false;
- };
- /*
- Parameters:
- Returns: array of selected objects
- */
- CSelectionController.prototype.getSelections = function()
- {
- return this.m_aSelectedObjects;
- };
- /*
- Parameters: a dom node
- Returns: nothing
- */
- CSelectionController.prototype.selectSingleDomNode = function(nNode)
- {
- this.clearSelectedObjects();
- var oSelObject = this.getSelectionObjectFactory().getSelectionObject(nNode);
- var oDocument = null;
- if (isIE()) {
- oDocument = nNode.document;
- } else {
- oDocument = nNode.ownerDocument;
- }
- this.addSelectionObject(oSelObject, oDocument);
- };
- /*
- Parameters:
- Returns: array of selected objects
- */
- CSelectionController.prototype.hasCutColumns = function()
- {
- if (this.m_aCutColumns.length === 0)
- {
- return false;
- }
- else
- {
- return true;
- }
- };
- /*
- Parameters:
- Returns: boolean
- */
- CSelectionController.prototype.setCutColumns = function(cutValue, theDocument)
- {
- try
- {
- if (!theDocument) {
- theDocument = document;
- }
- this.updateUI(theDocument, this.getSelections(), true, false);
- this.updateUI(theDocument, this.getCutColumns(), true, 1);
- this.m_aCutColumns = [];
- //sets all currently selected columns to cutValue
- if (cutValue === true)
- {
- for (var i = 0; i < this.m_aSelectedObjects.length; i++)
- {
- this.m_aCutColumns[i] = this.m_aSelectedObjects[i];
- }
- this.m_aSelectedObjects = [];
- }
- this.updateUI(theDocument, this.getCutColumns(), false, 2);
- /* I don't know yet if we want to observe the cutting of columns, leave it out for now.
- if (typeof this.onSelectionChange == "function")
- {
- this.onSelectionChange();
- }
- */
- return true;
- }
- catch (e)
- {
- return false;
- }
- };
- /*
- Parameters:
- Returns: array of cut columns
- */
- CSelectionController.prototype.getCutColumns = function()
- {
- return this.m_aCutColumns;
- };
- /*
- Parameters:
- Returns: reference to observer function
- */
- CSelectionController.prototype.getObservers = function()
- {
- return this.m_oObserver;
- };
- /*
- Parameters:
- Returns: void
- */
- CSelectionController.prototype.attachObserver = function(observer)
- {
- this.m_oObserver.attach(observer);
- };
- /*
- This is called when a selection changes
- Parameters:
- Returns: void
- */
- CSelectionController.prototype.onSelectionChange = function()
- {
- this.getObservers().notify();
- };
- /*
- Parameters:
- Returns: array of columns to draw
- */
- CSelectionController.prototype.getSelectedColumns = function(allSelections)
- {
- var columnsToDraw = [];
- if (typeof allSelections == "undefined")
- {
- allSelections = this.getSelections();
- }
- var allSelectionsLength = allSelections.length;
- for (var i = 0; i < allSelectionsLength; i++)
- {
- var currentSelection = allSelections[i];
- var addNewEntry = true;
- for (var j = 0; j < columnsToDraw.length; j++)
- {
- if (columnsToDraw[j][0] == currentSelection.getColumnRef() && columnsToDraw[j][1] == currentSelection.getCellTypeId())
- {
- addNewEntry = false;
- break;
- }
- }
- if (addNewEntry)
- {
- columnsToDraw[columnsToDraw.length] = [
- currentSelection.getColumnRef(),
- currentSelection.getCellTypeId(),
- currentSelection.getLayoutType(),
- currentSelection.getTag(),
- currentSelection.getColumnName()
- ];
- }
- }
- return columnsToDraw;
- };
- /*
- * Returns an array of unique (ctx id) selected objects.
- */
- CSelectionController.prototype.getAllSelectedObjectsWithUniqueCTXIDs = function()
- {
- var uniqueSelectedItems = [];
- var selectedObjects = this.getAllSelectedObjects();
- for (var i=0; i < selectedObjects.length; i++) {
- var found=false;
- var selectionObject = selectedObjects[i];
- for (var ii=0; ii < uniqueSelectedItems.length; ii++) {
- // if the ctx id matches, then don't add it to the unique array
- if (selectionObject.m_contextIds[0][0] == uniqueSelectedItems[ii].m_contextIds[0][0]) {
- found = true;
- break;
- }
- }
- if (!found) {
- uniqueSelectedItems.push(selectionObject);
- }
- }
- return uniqueSelectedItems;
- };
- CSelectionController.prototype.getAllSelectedObjects = function()
- {
- var selectedItems = this.getSelections();
- if(this.hasSelectedChartNodes()) {
- selectedItems = selectedItems.concat(this.getSelectedChartNodes());
- }
- return selectedItems;
- };
- /*
- Parameters:
- Returns: array of column ids
- */
- CSelectionController.prototype.getSelectedColumnIds = function(aAllSelections)
- {
- var aColumnIds = [];
- if (typeof aAllSelections == "undefined")
- {
- aAllSelections = this.getSelections();
- }
- var aSelectedColumns = this.getSelectedColumns(aAllSelections);
- for (var idxSelCols = 0; idxSelCols < aSelectedColumns.length; idxSelCols++)
- {
- var addNewEntry = true;
- for (var idxColIds = 0; idxColIds < aColumnIds.length; idxColIds++)
- {
- if (aColumnIds[idxColIds] == aSelectedColumns[idxSelCols][4])
- {
- addNewEntry = false;
- break;
- }
- }
- if (addNewEntry)
- {
- aColumnIds[aColumnIds.length] = aSelectedColumns[idxSelCols][4];
- }
- }
- return aColumnIds;
- };
- var STYLE_SELECTION = {};
- CSelectionController.prototype.selecting = function(c,style)
- {
- var sText = "." + c + style;
- var doc = document;
- var oIFrame = document.getElementById('CVIFrame' + this.m_sNamespace);
- if (oIFrame)
- {
- doc = oIFrame.contentWindow.document;
- }
- var nStyle = doc.createElement('style');
- nStyle.setAttribute("type", "text/css");
- if (nStyle.styleSheet)
- {
- // IE
- nStyle.styleSheet.cssText = sText;
- }
- else
- {
- // Mozilla & Firefox
- nStyle.appendChild( doc.createTextNode(sText) );
- }
- doc.getElementsByTagName("head").item(0).appendChild(nStyle);
- STYLE_SELECTION[ c ] = nStyle;
- };
- CSelectionController.prototype.deselecting = function(anArray)
- {
- for(var i = 0; i < anArray.length; ++i)
- {
- if ( STYLE_SELECTION[ anArray[i] ])
- {
- var node = STYLE_SELECTION[ anArray[i] ];
- node.parentNode.removeChild( node );
- STYLE_SELECTION[ anArray[i] ] = null;
- }
- }
- if (isIE() && typeof this.m_oCognosViewer.m_viewerFragment != "undefined")
- {
- // force IE to repaint the div
- var reportDiv = document.getElementById("CVReport" + this.m_oCognosViewer.getId());
- if(reportDiv != null)
- {
- var display = reportDiv.style.display;
- reportDiv.style.display = "none";
- reportDiv.style.display = display;
- }
- }
- };
- CSelectionController.prototype.showViewerContextMenu = function()
- {
- if (this.hasSelectedChartNodes())
- {
- return true;
- }
- if (this.m_aSelectedObjects && this.m_aSelectedObjects.length > 0)
- {
- return true;
- }
- return false;
- };
- function getStyleFromClass(c)
- {
- for (var i = 0; i < document.styleSheets.length; i++)
- {
- var ss = document.styleSheets[i];
- var _rules = (ss.cssRules ? ss.cssRules : ss.rules);
- for (var j = 0; j < _rules.length; j++)
- {
- var cr = _rules[j];
- var reClass = new RegExp('\\b' + c + '\\b', 'g');
- if (cr.selectorText && cr.selectorText.match(reClass))
- {
- return cr;
- }
- }
- }
- return 0;
- };
- CSelectionController.prototype.canUpdateSelection = function( contextIds )
- {
- return this.m_selectionStyles.canApplyToSelection( contextIds );
-
- };
- CSelectionController.prototype.setStyleForSelection = function( contextIds )
- {
- return this.m_selectionStyles.setStyleForSelection( contextIds );
-
- };
- /*
- Parameters:
- Returns: boolean
- */
- CSelectionController.prototype.updateUI = function(theDocument, allSelections, deselectAll, isCut)
- {
- if (!theDocument) {
- theDocument = document;
- }
- try
- {
- if (allSelections && allSelections.length > 0)
- {
- var allSelectionsLength, idxAllSelections, selectedTD;
- if (isCut == 1 || isCut == 2)
- {
- if (deselectAll)
- {
- this.deselecting(this.m_cutClass);
- }
- else
- {
- var cS_color = getStyleFromClass("cutSelection").style.color;
- var cS_backgroundColor = getStyleFromClass("cutSelection").style.backgroundColor;
- allSelectionsLength = allSelections.length;
- for (idxAllSelections = 0; idxAllSelections < allSelectionsLength; idxAllSelections++)
- {
- selectedTD = allSelections[idxAllSelections].getCellRef();
- var selectedClass = "cutQS" + selectedTD.getAttribute("cid");
- this.selecting(selectedClass,"\n{ background-color: "+cS_backgroundColor+"; color: "+cS_color+";}\n");
- this.m_cutClass.push(selectedClass);
- }
- }
- }
- else
- {
- if(this.m_oCognosViewer)
- {
- this.findSelectionURLs();
- selectedTD="";
- allSelectionsLength = allSelections.length;
- for (idxAllSelections = 0; idxAllSelections < allSelectionsLength; idxAllSelections++)
- {
- selectedTD = allSelections[idxAllSelections].getCellRef();
- // if we have an oldClassName it means we were showing our hover class, reset it to the original
- // class before doing the select
- if (selectedTD.getAttribute("oldClassName") != null)
- {
- selectedTD.className = selectedTD.getAttribute("oldClassName");
- selectedTD.removeAttribute("oldClassName");
- }
-
- this.setStyleForSelection( allSelections[idxAllSelections].m_contextIds );
-
- // do the secondary selection first
- if( !this.secondarySelectionIsDisabled() || deselectAll ){
- var reportDiv = document.getElementById("CVReport" + this.getNamespace());
- var secondarySelectedItems = getElementsByAttribute(reportDiv, ["td", "th"], "name", selectedTD.getAttribute("name"), this.m_maxSecondarySelection);
-
- for (var cellIndex=0; cellIndex < secondarySelectedItems.length; cellIndex++)
- {
- var cell = secondarySelectedItems[cellIndex];
- if (deselectAll)
- {
- this.restoreOldBackgroundImage(cell);
- }
- else if ( cell.getAttribute("oldBackgroundImageStyle") == null)
- {
- this.saveOldCellStyles(cell);
- this.setSecondarySelectionStyles(cell);
- }
- }
- }
- // primary selection
- this.saveOldCellStyles(selectedTD);
- if (deselectAll)
- {
- this.restoreOldBackgroundImage(selectedTD);
- if (this.m_oCognosViewer.isHighContrast())
- {
- this.restoreOldBorder(selectedTD);
- this.restoreOldPadding(selectedTD);
- }
- }
- else
- {
- this.setPrimarySelectionStyles(selectedTD);
- if (this.m_oCognosViewer.isHighContrast())
- {
- var size = getBoxInfo(selectedTD, true);
- this.saveOldBorder(selectedTD);
- this.saveOldPadding(selectedTD, size);
- var borderWidth = 3;
- var topSize = size.borderTopWidth + size.paddingTop - borderWidth;
- var bottomSize = size.borderBottomWidth + size.paddingBottom - borderWidth;
- var leftSize = size.borderLeftWidth + size.paddingLeft - borderWidth;
- var rightSize = size.borderRightWidth + size.paddingRight - borderWidth;
- selectedTD.style.border = borderWidth + "px " + this.getHighContrastBorderStyle() + " black";
- selectedTD.style.padding = topSize + "px " + rightSize + "px " + bottomSize + "px " + leftSize + "px";
- }
- }
- }
- }
- }
- }
- return true;
- }
- catch (e)
- {
- //alert("error selecting column -- please contact your administrator!");
- return false;
- }
- };
- CSelectionController.prototype.findSelectionURLs = function() {
- if ( !(this.sS_backgroundImageURL && this.pS_backgroundImageURL) ) {
- if(this.m_oCognosViewer.isBux || isSafari() || this.m_oCognosViewer.isMobile()) {
- // BUX doesn't have the same CSS classes, Safari & Mobile needs relative paths
- // We are using relative paths (relative to the current folger, ie. <gateway>/cgi-bin/)
- this.pS_backgroundImageURL = "url(../common/images/selection_primary.png)";
- this.sS_backgroundImageURL = "url(../common/images/selection_secondary.png)";
- }
- else {
- this.pS_backgroundImageURL = this.getBackgroundImage(getStyleFromClass("primarySelection"));
- this.sS_backgroundImageURL = this.getBackgroundImage(getStyleFromClass("secondarySelection"));
- }
- }
- };
- // make sure the item we are selecting is a rsvp chart image
- CSelectionController.prototype.setSelectedChartImgArea = function(chartArea)
- {
- var isAreaValidSelection = true;
- var isRSVPChart = chartArea.getAttribute("rsvpChart");
- var inChartContainer = chartArea.parentNode.getAttribute("chartContainer");
- if (isRSVPChart != "true" && inChartContainer != "true") {
- this.m_selectedChartNodes = [];
- isAreaValidSelection = false;
- }
- else {
- var selectedChartNode = this.getSelectionObjectFactory().getSelectionChartObject(chartArea);
- this.m_selectedChartNodes = [selectedChartNode];
- }
- return isAreaValidSelection;
- };
- CSelectionController.prototype.setSelectedChartArea = function(chartArea, e )
- {
- var isBUX = typeof this.m_oCognosViewer.isBux !== "undefined";
- var isAreaValidSelection = false;
- if (chartArea !== null) {
- // make sure the item we are selecting is a rsvp chart image
- if (chartArea.tagName == "IMG") {
- isAreaValidSelection = this.setSelectedChartImgArea(chartArea);
- }
- else
- if (chartArea.nodeName == 'AREA' && chartArea.attributes["ctx"]) {
- isAreaValidSelection = true;
- if (isBUX) {
- this.setBuxSelectedChartArea(chartArea, e );
- } else {
- this.m_selectedChartNodes = [this.getSelectionObjectFactory().getSelectionChartObject(chartArea)];
- }
- }
- if (isAreaValidSelection) {
- this.getObservers().notify();
- }
- }
- return isAreaValidSelection;
- };
- CSelectionController.prototype.setBuxSelectedChartArea = function(chartArea, e) {
- var mapHelper = this.getChartHelper(chartArea);
- var selectedChartNode = mapHelper.getChartNode(chartArea);
- this.setStyleForSelection(selectedChartNode.m_contextIds );
- var imageMapHighlighter = mapHelper.getImageMapHighlighter();
- imageMapHighlighter.setFillColour( this.getPrimarySelectionColor());
- imageMapHighlighter.setStrokeColour( this.getPrimarySelectionColor());
- if (typeof e == "undefined") {
- e = {};
- }
- if (this.ctrlKeyPressed(e) || this.shiftKeyPressed(e)) {
- // multiple selection
- if (imageMapHighlighter.isAreaHighlighted(chartArea)) {
- // remove chart node from selection
- imageMapHighlighter.hideAreas(selectedChartNode.getCtxAreas());
- var chartAreaCtx = chartArea.getAttribute("ctx");
- var selectedNodesCount = this.m_selectedChartNodes.length;
- for (var i = 0; i < selectedNodesCount; i++) {
- var selChartNode = this.m_selectedChartNodes[i];
- if (chartAreaCtx == selChartNode.getContext()) {
- this.m_selectedChartNodes.splice(i, 1);
- break;
- }
- }
- }
- else {
- // add chart node to selection
- this.updateSelectionContainer(chartArea);
- imageMapHighlighter.highlightAreas(selectedChartNode.getCtxAreas(), true);
- this.m_selectedChartNodes.push(selectedChartNode);
- }
- }
- else { // single selection
- if( this.hasSavedSelectedChartNodes()){
- var noOfSavedChartNodes = this.m_savedSelectedChartNodes.length;
- var savedChartNodes = this.m_savedSelectedChartNodes;
- for( var i = 0; i < noOfSavedChartNodes; i++){
- var area = savedChartNodes[i].getArea();
- var chartHelper = this.getSavedChartHelper( area );
- var mapHighlighter = chartHelper.getImageMapHighlighter();
- var areaId = mapHighlighter.getAreaId( area )
- if( imageMapHighlighter.getAreaId(chartArea) === areaId){
- mapHighlighter.hideAreaById( areaId + this.m_savedPrimarySelectionColor );
- break;
- }
- }
- }
- this.updateSelectionContainer(chartArea);
- imageMapHighlighter.highlightAreas(selectedChartNode.getCtxAreas());
- this.m_selectedChartNodes = [selectedChartNode];
- }
- };
- CSelectionController.prototype.updateSelectionContainer = function(chartArea)
- {
- var imageMap = chartArea.parentNode;
- if (this.m_selectionContainerMap && this.m_selectionContainerMap.name != imageMap.name) {
- var imageMapHighlighter = this.getChartHelper(chartArea).getImageMapHighlighter();
- imageMapHighlighter.hideAllAreas();
- }
- this.m_selectionContainerMap = imageMap;
- };
- CSelectionController.prototype.getChartHelper = function(chartArea) {
- var imageMap = chartArea.parentNode;
- var mapName = imageMap.name;
- if (!this.m_chartHelpers[mapName]) {
- this.m_chartHelpers[mapName] = new CChartHelper(chartArea, this.getSelectionObjectFactory(), this.m_oCognosViewer);
- }
- return this.m_chartHelpers[mapName];
- };
- CSelectionController.prototype.getSavedChartHelper = function(chartArea) {
- var imageMap = chartArea.parentNode;
- var mapName = imageMap.name;
- return this.m_savedChartHelpers[mapName];
- };
- CSelectionController.prototype.getSelectedChartArea = function()
- {
- return this.m_selectedChartArea;
- };
- CSelectionController.prototype.getSelectedChartNodes = function()
- {
- return this.m_selectedChartNodes ;
- };
- CSelectionController.prototype.hasSelectedChartNodes = function()
- {
- return this.m_selectedChartNodes && this.m_selectedChartNodes.length && this.m_selectedChartNodes.length > 0;
- };
- CSelectionController.prototype.getSelectedChartImage = function()
- {
- var selectedChartArea = null;
- if(this.hasSelectedChartNodes())
- {
- var selectedChartNode = this.m_selectedChartNodes[0];
- selectedChartArea = selectedChartNode.getArea();
- }
- if (selectedChartArea === null)
- {
- return null;
- }
- if (selectedChartArea.tagName == "IMG")
- {
- return selectedChartArea;
- }
- return this.getSelectedChartImageFromChartArea(selectedChartArea);
- };
- CSelectionController.prototype.getSelectedChartImageFromChartArea = function(oChartArea){
- var imageMap = oChartArea.parentNode;
- var imageMapName = "#" + imageMap.getAttribute("name");
- return this.checkChildrenForChart(imageMap.parentNode, imageMapName);
- };
- CSelectionController.prototype.checkChildrenForChart = function(parent, imageMapName) {
- var child = parent.firstChild;
- while (child !== null)
- {
- if (!child.tagName) {
- return null;
- }
- else if (child.tagName == "IMG" && child.getAttribute("usemap") == imageMapName)
- {
- return child;
- }
- // if we have a div or span always look through its children
- else if (child.tagName === "DIV" || child.tagName === "SPAN") {
- var result = this.checkChildrenForChart(child, imageMapName);
- if (result) {
- return result;
- }
- }
- child = child.nextSibling;
- }
- return null;
- };
- CSelectionController.prototype.downloadSelectedChartImage = function(sCVID)
- {
- var chartImage = this.getSelectedChartImage();
- if (chartImage !== null)
- {
- var theDocument = this.getDocumentFromImage(chartImage);
- var imageURL = chartImage.name.replace(".", "_");
- var imageName = imageURL.substr(5);
- var theURL = '?m_name=';
- theURL += imageName;
- theURL += '&format=png&b_action=xts.run&m=portal/download.xts&m_obj=';
- if (isIE()) {
- imageURL = theDocument.parentWindow.eval("graphicSrc" + imageName);
- }
- else {
- imageURL = theDocument.defaultView.eval("graphicSrc" + imageName);
- }
- var encodedPrams = "";
- if (typeof imageURL != "undefined" && imageURL !== null)
- {
- var urlArray = imageURL.split('&');
- if (urlArray.length === 0)
- {
- return;
- }
- if (imageURL.indexOf("/repository/") < 0)
- {
- for (var i = 0; i < urlArray.length; ++i)
- {
- var urlParam = urlArray[i];
- var equalPos = urlParam.indexOf('=');
- if (equalPos != -1) {
- var urlParamName = urlParam.substr(0,equalPos);
- var urlParamValue = urlParam.slice(equalPos+1);
- if (urlParamName == 'search')
- {
- encodedPrams += urlParamValue;
- break;
- }
- }
- }
- }
- // if we didn't find a searchPath then the chart must be saved on the file system. Use
- // the img src for the URL to use - it'll call the dispatcher
- if (encodedPrams == "") {
- theURL = chartImage.getAttribute("src");
- if (theURL.indexOf('?') != -1) {
- theURL += "&download=true";
- }
- else {
- theURL += "?download=true";
- }
- }
- if (typeof getConfigFrame == "function")
- {
- theURL += encodedPrams;
- theURL = getConfigFrame().constructGETRequestParamsString(theURL);
- window.open(theURL, "_blank", "width=0,height=0");
- }
- else
- {
- theURL = constructGETRequestParamsString(theURL);
- theURL += encodedPrams;
- var gateway = this.m_oCognosViewer.getGateway();
- var oIFrame = document.getElementById('CVIFrame' + this.m_sNamespace);
- if (oIFrame) {
- var iframe_src = oIFrame.src;
- if (iframe_src.indexOf("repository") >= 0 && theURL.indexOf("repository") < 0) {
- //viewer uses CM's rest API
- var indOfContent = iframe_src.indexOf("content");
- theURL = iframe_src.substring(0, indOfContent) + theURL;
- }
- }
- // if the image is saved on the file system then the URL already has the gateway
- if (theURL.indexOf(gateway) == -1) {
- var formWarpRequest = document.forms["formWarpRequest" + sCVID];
- theURL = formWarpRequest.action + theURL;
- }
- // Remove onBeforeUnLoad for this submission but set it back after.
- if (typeof window.detachLeavingRV == "function") {
- window.detachLeavingRV();
- }
- location.href = theURL;
- if (typeof window.attachLeavingRV == "function") {
- setTimeout(window.attachLeavingRV, 100);
- }
- }
- }
- }
- };
- CSelectionController.prototype.getDocumentFromImage = function(image) {
- var imageDocument = null;
- if (image.ownerDocument) {
- imageDocument = image.ownerDocument;
- }
- else {
- imageDocument = image.document;
- }
- return imageDocument;
- };
- //Determine whether pageClicked should be invoked on on the mouseDown or the mouseUp.
- CSelectionController.prototype.shouldExecutePageClickedOnMouseDown = function(e) {
- //Special case where deselecting should be postponed until mouse up because
- //another event could cancel deselecting:
- //1. More than one column must be selected
- var selections = this.getSelections();
- if (selections.length > 1) {
- //2. Must be a live report
- if(this.m_oCognosViewer.envParams["ui.action"] !== 'view') {
- //3. Must be in a list
- //Get non-text ancestor node
- var node = getNodeFromEvent(e);
- try {
- while (node && (node.nodeType == 3 || (node.getAttribute && node.getAttribute("uid") === null))) {
- node = node.parentNode;
- }
- }
- catch(ex) {
- // sometimes node may not be an HTML element (like a XUL element) and accessing nodeType/nodeName/className will generate an error.
- }
- var container = this.getSelectionObjectFactory().getContainerType(node);
- if(container === "list") {
- //4. Must already be selected
- for (var i = 0; i < selections.length; i++) {
- if(selections[i].m_oCellRef == node) {
- //All conditions met - postpone to mouse up
- return false;
- }
- }
- }
- }
- }
- //Default case: execute select action on mouse down
- return true;
- };
- /**
- * Get the container type for the currently selected node
- * Used for mobile
- */
- CSelectionController.prototype.getContainerType = function() {
- var containerType = "";
- if (this.hasSelectedChartNodes()) {
- containerType = "chart";
- }
- else if (this.getDataContainerType() === "list") {
- containerType = "list";
- }
- else {
- containerType = "crosstab";
- }
- return containerType;
- };
- /**
- * Build up an object for the display values of all the defining cells
- * Used for mobile
- */
- CSelectionController.prototype.getDisplayValues = function() {
- var displayValues = {};
- var oSelection = this.getAllSelectedObjects()[0];
- if (oSelection) {
- var ctxIds = oSelection.getSelectedContextIds();
- if (ctxIds) {
- for (var axis=0; axis < ctxIds.length; axis++) {
- var axisDisplayValues = [];
- var axisIds = ctxIds[axis];
- for (var nestingLevel=0; nestingLevel < axisIds.length; nestingLevel++) {
- var cellId = axisIds[nestingLevel];
- var displayValue = this.getDisplayValue(cellId);
- axisDisplayValues.push(displayValue);
- // Mobile doesn't want any of the defining cells for the primary selection so break out of the loop
- if (axis === 0) {
- break;
- }
- }
- var sAxis = "";
- switch(axis) {
- case 0:
- sAxis = "selected";
- break;
- case 1:
- sAxis = "rows";
- break;
- default:
- sAxis = "columns";
- }
- displayValues[sAxis] = axisDisplayValues;
- }
- }
- }
- return displayValues;
- };
- /**
- * Get the tooltip from the map for chart selections
- */
- CSelectionController.prototype.getChartTooltip = function() {
- var oSelection = this.getAllSelectedObjects()[0];
- if (oSelection) {
- var area = oSelection.getArea();
- if (area) {
- var title = area.getAttribute("title");
- if (title && title.length > 0) {
- return area.getAttribute("title");
- }
- }
- }
- return "";
- };
- /**
- * used for when we're in mobile. Retruns true if a node was selected
- */
- CSelectionController.prototype.pageClickedForMobile = function(e)
- {
- this.pageClicked(e);
- var selectionLength = this.getAllSelectedObjects().length;
- // 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
- // and clicking on an image doesn't create a selection object, add the image to the selection controller so that it gets
- // detected when looking for drill information
- if (selectionLength == 0) {
- var node = getNodeFromEvent(e, true);
- if ( !node ){
- return false;
- }
-
- if ( node.nodeName.toLowerCase() == "img" && node.getAttribute("dttargets")) {
- this.selectDrillThroughImage(node);
- return true;
- } else if( node.getAttribute("dttargets") ){
- this.selectDrillThroughSingleton( node );
- return true;
- } else if ( node.parentNode && node.parentNode.getAttribute( "dttargets") ){
- this.selectDrillThroughSingleton( node.parentNode );
- return true;
- }
-
- return false;
- }
- return true;
- };
- CSelectionController.prototype.clearSavedSelections = function()
- {
- this.m_bSavedSelections = false;
-
- if( this.hasSavedSelectedObjects() ){
- this.updateUI( null, this.getSavedSelectedObjects(), true, false );
- delete( this.m_aSavedSelectedObjects );
- }
-
- if( this.hasSavedSelectedChartNodes() ){
- var chartHelpers = this.m_savedChartHelpers;
- for( var mapName in chartHelpers){
- if( chartHelpers[mapName]){
- var mapHighlighter = chartHelpers[mapName].getImageMapHighlighter();
- if (mapHighlighter.hideAllAreas) {
- mapHighlighter.hideAllAreas();
- }
- }
- }
-
- delete this.m_savedChartHelpers;
-
- delete this.m_savedSelectedChartNodes;
- }
- };
- CSelectionController.prototype.hasSavedSelectedChartNodes = function(){
- return ( this.m_savedSelectedChartNodes && this.m_savedSelectedChartNodes.length > 0 );
- };
- CSelectionController.prototype.getSavedSelectedChartNodes = function(){
- return this.m_savedSelectedChartNodes;
- };
- /**
- * This function saves the previous selections and the primary selection colour
- */
- CSelectionController.prototype.saveSelections = function()
- {
- this.m_savedSelectionStyles = this.m_selectionStyles;
-
- if( this.m_aSelectedObjects.length > 0 )
- {
- this.m_aSavedSelectedObjects = [];
-
- var noOfSelectedObjects = this.m_aSelectedObjects.length;
- var temp = [];
- for( var i=0; i < noOfSelectedObjects; i++ ){
- if( this.isMeasure( this.m_aSelectedObjects[i].m_contextIds[0][0] ) ){
- temp.push( this.m_aSelectedObjects[i] );
- } else {
- this.m_aSavedSelectedObjects.push( this.m_aSelectedObjects[i] );
- }
- }
-
- this.m_aSelectedObjects = temp;
- }
-
- if(this.hasSelectedChartNodes()){
- this.m_savedChartHelpers = this.m_chartHelpers;
- this.m_chartHelpers = {};
-
- this.m_savedSelectedChartNodes = [];
- var noOfSelectedChartNodes = this.m_selectedChartNodes.length;
- var temp = [];
- for( var i=0; i < noOfSelectedChartNodes; i++ )
- {
- if( this.isMeasure( this.m_selectedChartNodes[i].m_contextIds[0][0] ) )
- {
- var chartArea = this.m_selectedChartNodes[i].getArea();
- var mapName = this.getImageMapName(chartArea);
- this.m_chartHelpers[mapName] = this.m_savedChartHelpers[mapName];
- delete this.m_savedChartHelpers[mapName];
- temp.push( this.m_selectedChartNodes[i]);
- } else {
- this.m_savedSelectedChartNodes.push( this.m_selectedChartNodes[i]);
- }
- }
- this.m_selectedChartNodes = temp;
- }
-
- this.m_bSavedSelections = true;
- };
- CSelectionController.prototype.hasSavedSelections = function()
- {
- return this.m_bSavedSelections;
- }
- CSelectionController.prototype.hasSavedSelectedObjects = function()
- {
- return ( this.m_aSavedSelectedObjects && this.m_aSavedSelectedObjects.length > 0 ) || this.hasSavedSelectedChartNodes();
- }
- CSelectionController.prototype.getSavedSelectedObjects = function()
- {
- return this.m_aSavedSelectedObjects;
- };
- CSelectionController.prototype.getImageMapName = function(chartArea){
- var imageMap = chartArea.parentNode;
- return imageMap.name;
- };
- /**
- * Fix up the chart helpers - for saved nodes, use the saved chart helper
- */
- CSelectionController.prototype.repaintBUXSelectedChartArea = function( chartNodes, bUseSavedChartHelpers, bExcludeMeasuresOnly ) {
- var chartHelperUsed = {};
- var noOfChartNodes = chartNodes.length;
-
- for( var i = 0; i < noOfChartNodes; i++){
- var chartArea = chartNodes[i].getArea();
- var mapName = this.getImageMapName(chartArea);
- var chartHelper;
- if( !chartHelperUsed[ mapName] ){
- chartHelper = (bUseSavedChartHelpers) ? this.getSavedChartHelper( chartArea ) : this.getChartHelper( chartArea );
- chartHelperUsed[ mapName ] = chartHelper;
- var imageMapHighlighter = chartHelper.getImageMapHighlighter();
- imageMapHighlighter.hideAllAreas();
- imageMapHighlighter.setFillColour( this.getPrimarySelectionColor() );
- imageMapHighlighter.setStrokeColour( this.getPrimarySelectionColor());
- } else {
- chartHelper = chartHelperUsed[ mapName];
- }
-
-
- var contextIds = chartNodes[i].m_contextIds;
- if( bExcludeMeasuresOnly && contextIds.length === 1 && contextIds[0].length === 1 && this.isMeasure(contextIds[0][0])){
- continue;
- }
-
- imageMapHighlighter.highlightAreas( chartNodes[i].getCtxAreas(), 1 );
- }
- }
- CSelectionController.prototype.repaintSavedSelections = function()
- {
- var tempStyle = this.m_selectionStyles;
- this.m_selectionStyles = this.m_savedSelectionStyles;
- var selections = this.getSavedSelectedChartNodes();
- var bIsChartSelection = false;
- if( selections && selections.length > 0 ){
- bIsChart = true;
- } else {
- selections = this.getSavedSelectedObjects();
- }
- this.repaintSelectionsHelper( selections, true /*bRepaintSavedSelections*/, bIsChartSelection );
- this.resetSelectionStyles();
-
- this.m_selectionStyles = tempStyle;
- };
- CSelectionController.prototype.repaintSelections = function()
- {
- var selections = this.getSelectedChartNodes();
- var bIsChartSelection = false;
- if( selections && selections.length > 0 ){
- bIsChartSelection = true;
- } else {
- selections = this.getSelections();
- }
- this.repaintSelectionsHelper( selections, false /*bRepaintSavedSelections*/, bIsChartSelection );
- };
- CSelectionController.prototype.repaintSelectionsHelper = function( selections, bRepaintSavedSelections, bIsChartSelection )
- {
- try
- {
- if( bIsChartSelection ){
- this.repaintBUXSelectedChartArea( selections, bRepaintSavedSelections );
- } else {
- /**
- * For crosstab and list
- */
- // remove current selections UI
- this.updateUI(document, selections, true /*deselect*/, false /*isCut*/);
- // update with new selections UI
- this.updateUI(document, selections, false /*deselect*/, false /*isCut*/ );
- }
- }
- catch (e)
- {
- //alert("error selecting column -- please contact your administrator!");
- return false;
- }
- }
- CSelectionController.prototype.resetAll = function()
- {
- this.resetSelectionStyles();
- this.clearSavedSelections();
- this.resetSelections();
- this.resetAllowHorizontalDataValueSelection();
- };
- CSelectionController.prototype.pageClicked = function(e )
- {
- try{
- var node = getNodeFromEvent(e);
- // make sure we don't reselect a node that's already selected (performance)
- if (this.m_aSelectedObjects.length > 0 && !this.shiftKeyPressed(e) && !this.ctrlKeyPressed(e)) {
- var tempNode = node;
- // need to find the node with 'uid' since it's that node that's part of the selection object
- if (!tempNode.getAttribute("uid")) {
- var parentNode = tempNode.parentNode;
- if (parentNode && parentNode.nodeType == 1 && typeof parentNode.getAttribute != "undefined" && parentNode.getAttribute("uid") != null) {
- tempNode = parentNode;
- }
- }
- if (this.isCellSelected(tempNode)) {
- if( typeof this.m_oCognosViewer.isBux !== "undefined" ){
- this.repaintSelections();
- }
-
- // If the user right clicks on a cell without pressing ctrl or shift don't change the selection,
- // he's looking to open the context menu with the currently selected cells
- if (e.button !== 0) {
- return false;
- }
- }
- }
- if (node.tagName && node.tagName.toUpperCase() == "INPUT") {
- //This key was for a text input entry, allow the event to bubble
- return true;
- }
- if ((e.keyCode != null) && (e.keyCode != 13) && (e.keyCode != 32) && (e.keyCode != 27) && (e.keyCode != 0) && (e.keyCode != 121) && (e.keyCode != 93)) {
- return false;
- }
- var nodeDocument = getDocumentFromEvent(e);
- if (!this.hasContextData() || !this.hasMetadata())
- {
- // Update anyway- necessary for updating context menu for authored drill
- // when there is no selection when context data is absent
- if(node.nodeName == 'AREA' || node.nodeName == 'IMG' || (typeof node.getAttribute == "function" && node.getAttribute("flashChart") != null))
- {
- this.setSelectedChartArea(node, e);
- }
- this.getObservers().notify();
- return false;
- }
- if(typeof node.selectedCell != "undefined")
- {
- var divRegion = node;
- node = node.selectedCell;
- divRegion.removeAttribute("selectedCell");
- }
- if (typeof cf != "undefined" && typeof cf.hidePickers == "function")
- {
- cf.hidePickers();
- }
- if (e.keyCode == 27)
- {
- if (typeof g_reportSelectionController != "undefined")
- {
- g_reportSelectionController.clearSelections();
- }
- this.resetSelections(nodeDocument);
- }
- else if(node.nodeName == 'AREA' || node.nodeName == 'IMG' || (typeof node.getAttribute != "undefined" && node.getAttribute("flashChart") != null))
- {
- if (e.button !== 2 || this.getAllSelectedObjects().length <= 1 || typeof this.m_oCognosViewer.isBux === "undefined") {
- this.selectNode(node, e);
- this.setSelectedChartArea(node, e );
- }
- }
- //Do not select a blank crosstab corner cell
- else if (!(node.firstChild == null && node.cellIndex == 0 && node.parentNode.rowIndex == 0 && node.getAttribute("cid") == null))
- {
- //Prevent a right-click in BUX from changing the selection only when there are already multiple selections
- //This enables the context menu actions which require multiple select, like calculations
- var widget = this.m_oCognosViewer.getViewerWidget();
-
- this.selectNode(node, e);
- }
- if (window.gViewerLogger) {
- window.gViewerLogger.addContextInfo(this);
- }
- }
- catch (e) {
- // sometimes node may not be an HTML element (like a XUL element) and accessing nodeType/nodeName/className will generate an error.
- }
- };
- CSelectionController.prototype.getSelectionObjectFactory = function()
- {
- return this.m_oSelectionObjectFactory;
- };
- CSelectionController.prototype.isDrillLinkOnCrosstabCell = function(node)
- {
- return (node.getAttribute("ctx") == null && node.parentNode.getAttribute("dtTargets") != null);
- };
- CSelectionController.prototype.selectObject = function(sMun, sLun, sHun, bIgnoreDrillFlag)
- {
- var ctxId = this.getCtxIdFromMun(sMun);
- if(ctxId == "")
- {
- ctxId = this.getCtxIdFromMetaData(sLun, sHun, bIgnoreDrillFlag);
- }
- if(ctxId != null && this.m_oCDManager.GetUsage(ctxId) != "2") // check that it's not a measure
- {
- var reportTable = document.getElementById("rt" + this.getNamespace());
- if(reportTable != null)
- {
- var cellRef = getElementsByAttribute(reportTable, "*", "ctx", ctxId);
- if( cellRef && cellRef.length === 0 )
- {
- var attributeValueExp = new RegExp("(^|:)" + ctxId + "(:|$)", "i");
- cellRef = getElementsByAttribute( reportTable, "*", "ctx", ctxId, -1, attributeValueExp);
- }
- var selectionObject = null;
- if(cellRef != null && cellRef.length > 0)
- {
- selectionObject = new CSelectionObject();
- selectionObject.setSelectionController(this);
- selectionObject.m_sColumnRef = cellRef[0].getAttribute("cid");
- selectionObject.m_sCellTypeId = cellRef[0].getAttribute("uid");
- selectionObject.m_sLayoutType = cellRef[0].getAttribute("type");
- selectionObject.m_sTag = cellRef[0].getAttribute("tag");
- selectionObject.m_layoutElementId = this.m_oSelectionObjectFactory.getLayoutElementId(cellRef[0]);
- selectionObject.m_dataContainerType = this.m_oSelectionObjectFactory.getContainerType(cellRef[0]);
- selectionObject.m_contextIds = [[ctxId]];
- this.m_aSelectedObjects[this.m_aSelectedObjects.length] = selectionObject;
- }
- else
- {
- var flashCharts = getElementsByAttribute(reportTable, "*", "flashChart", "true");
- if(flashCharts != null)
- {
- for(var index = 0; index < flashCharts.length; ++index)
- {
- var ldx = flashCharts[index].getLDX();
- if(ldx.indexOf("<ctx>" + ctxId + "</ctx>") != -1)
- {
- selectionObject = new CSelectionObject();
- selectionObject.setSelectionController(this);
- var lid = flashCharts[index].getAttribute("lid");
- selectionObject.m_layoutElementId = lid.replace(this.m_oCognosViewer.getId(), "");
- selectionObject.m_dataContainerType = "chart";
- selectionObject.m_contextIds = [[ctxId]];
- this.m_aSelectedObjects[this.m_aSelectedObjects.length] = selectionObject;
- }
- }
- }
- }
- }
- }
- };
- CSelectionController.prototype.buildSelectionObject = function(node, e)
- {
- var SelObj = null;
- try {
- while (node.nodeType == 3) { // test to see if this is a text node
- node = node.parentNode;
- }
- // 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.
- if(this.isDrillLinkOnCrosstabCell(node))
- {
- node = node.parentNode;
- }
- var ctx = node.getAttribute("ctx");
- var uid = node.getAttribute("uid");
- 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
- {
- //Test to see if we're clicking on a chart in a sectioned report
- if (node.nodeName == "IMG" && (node.src.indexOf("SM=") > -1 || (isIE() > -1 && node.src.indexOf("space.gif") > -1))) {
- return null;
- }
- node = node.parentNode;
- // special case for Bug#498910. Analysis Studio is adding a members attributes within the same td, broken up by divs.
- // If the parent node is a DIV and the class is "BLOCK", move up one level higher in the DOM
- if((node.className.toUpperCase() == "BLOCK" && node.nodeName.toUpperCase() == "DIV") || (node.getAttribute("dtTargets") != null))
- {
- node = node.parentNode;
- }
- uid = node.getAttribute("uid");
- }
- if (uid != null) // this is a valid column element
- {
- var nodeChildren = node.childNodes;
- for (var i = 0; i < nodeChildren.length; i++)
- {
- if (nodeChildren[i].nodeName.toUpperCase() == "TABLE" && (nodeChildren[i].className == "ls" || nodeChildren[i].className=="xt"))
- {
- //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
- var trs = nodeChildren[i].rows;
- for (var j = 0; j < trs.length; j++)
- {
- var tds = trs[j].cells;
- for (var k = 0; k < tds.length; k++)
- {
- if (tds[k].getAttribute("uid") != null)
- {
- //We've found a nested list or crosstab, therefore we don't want to select the outer list cell
- return null;
- }
- }
- }
- }
- }
- if(node.className.toUpperCase() == "REPEATERTABLECELL" && ctx != null)
- {
- SelObj = this.getSelectionObjectFactory().getSelectionObject(node, ctx);
- }
- else
- {
- SelObj = this.getSelectionObjectFactory().getSelectionObject(node);
- }
- }
- }catch (e) {
- // sometimes node may not be an HTML element (like a XUL element) and accessing nodeType/nodeName/className will generate an error.
- }
- return SelObj;
- };
- /**
- * Helper function to figure out if the shift key was pressed. Needed since there's
- * a bug in safari where the event from a right mouse click will ALWAYS have shiftKey set
- * to true. So if we're in Safari and the event is from the right mouse, we'll pretend the shift key
- * wasn't clicked. This is a small change in behavior, but only for safari users and there's no
- * way around it
- * @param {Object} e
- */
- CSelectionController.prototype.shiftKeyPressed = function(e) {
- if (e.keyCode == "121") {
- // context menu is Shift + F10, so if the key is F10 pretend the shift isn't
- // pressed or we'll do multiple selection
- return false;
- }
- if (isSafari()) {
- if (e.button != 2) {
- return e.shiftKey ? e.shiftKey : false;
- }
- else {
- return false;
- }
- }
- return e.shiftKey ? e.shiftKey : false;
- };
- /**
- * Helper function to figure out if the ctrl key was pressed. Needed since there's
- * a bug in safari where the event from a right mouse click will ALWAYS have ctrl set
- * to true. So if we're in Safari and the event is from the right mouse, we'll pretend the ctrl key
- * wasn't clicked. This is a small change in behavior, but only for safari users and there's no
- * way around it
- * @param {Object} e
- */
- CSelectionController.prototype.ctrlKeyPressed = function(e) {
- if (isSafari()) {
- if (e.button != 2) {
- return e.ctrlKey ? e.ctrlKey : false;
- }
- else {
- return false;
- }
- }
- return e.ctrlKey ? e.ctrlKey : false;
- };
- CSelectionController.prototype.isSelectionsPreviouslySaved = function( selections )
- {
- var bIsPreviousSelectedObjectAFilter = false;
- if( !this.m_aSavedSelectedObjects || !this.m_aSavedSelectedObjects.length || !selections || !selections.length )
- {
- return false;
- }
-
- for( var i = 0; i < selections.length; i++ ){
- if( this.isSavedCellSelected( selections[i].getCellRef() ) ){
- return true;
- }
- }
-
- return false;
-
- };
- CSelectionController.prototype.selectNode = function(node, e)
- {
- try{
- while (node.nodeType == 3) { // test to see if this is a text node
- node = node.parentNode;
- }
- // 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.
- if(this.isDrillLinkOnCrosstabCell(node))
- {
- node = node.parentNode;
- }
- var nodeDocument = null;
- if (isIE()) {
- nodeDocument = node.document;
- }
- else {
- nodeDocument = node.ownerDocument;
- }
- var ctx = node.getAttribute("ctx");
- var uid = node.getAttribute("uid");
- var callRefresh = false;
- if (typeof e == "undefined") {
- e = {};
- }
- var reportElementNode = false;
- if (typeof g_reportSelectionController != "undefined")
- {
- reportElementNode = this.checkForReportElementNode(node);
- }
- 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
- {
- if (this.getSelections().length > 0) {
- callRefresh = true;
- }
- if (this.hasCutColumns() == true) {
- this.clearSelectedObjects(nodeDocument);
- }
- else
- {
- this.resetSelections( nodeDocument);
-
- //make sure to repaint saved selections
- this.repaintSavedSelections();
-
- //TODO this needs to be removed
- //This will remove all selection objects from the list of selected columns in Query Studio
- if (typeof cf != "undefined" && typeof cf.removeAllSelectionsFromCfgVariables == "function") {
- cf.removeAllSelectionsFromCfgVariables();
- }
- this.m_oCognosViewer.setCurrentNodeFocus(null);
- }
- if (this.ctrlKeyPressed(e) || this.shiftKeyPressed(e)) {
- clearTextSelection(nodeDocument);
- }
- if (typeof g_reportSelectionController != "undefined" && reportElementNode == false)
- {
- if (g_reportSelectionController.getSelections().length > 0) {
- callRefresh = true;
- }
- g_reportSelectionController.clearSelections();
- }
- }
- var dtTargetsNode = node.getAttribute("dtTargets") ? node : null;
- var areaNodeSelected = (node.nodeName.toLowerCase()==="area");
- if ((uid == null) && ((ctx != null) || (node.parentNode && node.parentNode.nodeType == 1 && typeof node.parentNode.getAttribute != "undefined"))) // this is a textitem or chart img
- {
- //Test to see if we're clicking on a chart in a sectioned report
- if (node.nodeName == "IMG" && (node.src.indexOf("SM=") > -1 || (isIE() > -1 && node.src.indexOf("space.gif") > -1))) {
- return false;
- }
- // Old logic plus testing shows that we must go up 1 level in the DOM, then if the parent
- // node is a DIV or SPAN, we have to go up a maximum of 2 more levels until we find the UID attribute.
- // Scenarios :
- // Saved HTML outputs
- // 498910: Analysis Studio is adding a members attributes within the same td, broken up by divs.
- // 195442: PI86860 USING DRILL THROUGH IN A CONDITIONAL BLOCK, WHEN YOU RIGHT CLICKINSTEAD OF SHOWING THE DRILL TRU MENU, IT SHOWS THE BROWSER MENU
- var nodeName;
- var maxIters = 3;
- do {
- node = node.parentNode;
- if (node) {
- dtTargetsNode = (!dtTargetsNode && typeof node.getAttribute != "undefined" && node.getAttribute("dtTargets")) ? node : dtTargetsNode;
- uid = (typeof node.getAttribute != "undefined") ? node.getAttribute("uid") : null;
- nodeName = node.nodeName.toLowerCase();
- }
- } while ((uid == null) && node && (--maxIters > 0) && (nodeName == "span" || nodeName == "div"));
- }
- if (uid != null) // this is a valid column element
- {
- var nodeChildren = node.childNodes;
- for (var i = 0; i < nodeChildren.length; i++)
- {
- if (nodeChildren[i].nodeName.toUpperCase() == "TABLE" && (nodeChildren[i].className == "ls" || nodeChildren[i].className=="xt"))
- {
- //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
- var trs = nodeChildren[i].rows;
- for (var j = 0; j < trs.length; j++)
- {
- var tds = trs[j].cells;
- for (var k = 0; k < tds.length; k++)
- {
- if (tds[k].getAttribute("uid") != null)
- {
- //We've found a nested list or crosstab, therefore we don't want to select the outer list cell
- return false;
- }
- }
- }
- }
- }
- var SelObj;
- if(node.className.toUpperCase() == "REPEATERTABLECELL" && ctx != null)
- {
- SelObj = this.getSelectionObjectFactory().getSelectionObject(node, ctx);
- }
- else
- {
- SelObj = this.getSelectionObjectFactory().getSelectionObject(node);
- }
- // Determine if this column is already selected (if so, unselect it if CTRL or SHIFT clicked)
- if (this.isCellSelected(node) == false)
- { // If the cell is not selected, select it
- if (this.shiftKeyPressed(e))
- {
- var allSelections = this.getSelections();
- if (allSelections.length > 0)
- {
- var lastSelection = allSelections[allSelections.length - 1];
- //Make sure both selections have the same layout and they are in the same table
- if (lastSelection.getLayoutType() == SelObj.getLayoutType() && (lastSelection.getCellRef().parentNode.parentNode == SelObj.getCellRef().parentNode.parentNode))
- {
- //Check if we want to multi-select rows or columns
- if(this.cellsAreInSameColumn(lastSelection.getCellRef(), SelObj.getCellRef()))
- {
- this.selectVertical(lastSelection, SelObj, nodeDocument);
- }
- //Shift-selection on the same row
- else if(lastSelection.getCellRef().parentNode.rowIndex == SelObj.getCellRef().parentNode.rowIndex)
- {
- this.selectHorizontal(lastSelection, SelObj, nodeDocument);
- }
- }
- }
- clearTextSelection(nodeDocument);
- }
- else if (this.ctrlKeyPressed(e)) {
- clearTextSelection(nodeDocument);
- }
- this.addSelectionObject(SelObj, nodeDocument);
- // This will add the selection object to the list of selected columns in Query Studio
- if (typeof cf != "undefined" && typeof cf.addSelectionToCfgVariables == "function") {
- cf.addSelectionToCfgVariables(SelObj.getColumnName());
- }
- this.m_oCognosViewer.setCurrentNodeFocus(node);
- }
- else
- {
- if (this.ctrlKeyPressed(e))
- { // Otherwise the cell is selected, and this is a CTRL click, so unselect it
- this.removeSelectionObject(SelObj, nodeDocument);
- // This will remove the selection of the specified column if it's the only selection in that column in Query Studio
- if (typeof cf != "undefined" && typeof cf.removeSelectionFromCfgVariables == "function")
- {
- /* TODO: Put this back in once Report Server starts to produce context data
- if (!this.isColumnSelected(SelObj.getColumnName()))
- cf.removeSelectionFromCfgVariables(SelObj.getTag());
- /TODO */
- /* TODO: Take this out once Report Server starts to produce context data */
- if (!this.isColumnSelected(SelObj.getTag())) {
- cf.removeSelectionFromCfgVariables(SelObj.getTag());
- }
- /* /TODO */
- }
- clearTextSelection(nodeDocument);
- }
- else if (this.shiftKeyPressed(e)) {
- clearTextSelection(nodeDocument);
- }
- }
- callRefresh = true;
- }
- else if (reportElementNode)
- {
- var style = null;
- while ((typeof node.id == "undefined" || node.id == null || node.id == "") && node.parentNode != null) {
- node = node.parentNode;
- }
- if (node.id == "reportTitle") {
- style = 'TitleStyle';
- }
- else if (node.id == "reportSubtitle") {
- style = 'SubtitleStyle';
- }
- else if (node.id.indexOf("reportFilter") == 0) {
- style = 'FilterStyle';
- }
- if (style != null)
- {
- selectReportElement(e,node.id,style);
- callRefresh = true;
- }
- }
- // special case where we need to select a drill through node that has no UI for Mobile
- else if (dtTargetsNode != null && this.m_oCognosViewer && this.m_oCognosViewer.isMobile() && !areaNodeSelected) {
- var SelObj = this.getSelectionObjectFactory().getSelectionObject(dtTargetsNode);
- this.addSelectionObject(SelObj, nodeDocument );
- }
- //This will refresh the dialogs with a new list of selected columns in Query Studio
- if (callRefresh == true && (typeof cf != "undefined" && typeof cf.refreshDialog == "function")) {
- cf.refreshDialog();
- }
-
- }
- catch(ex) {
- // sometimes node may not be an HTML element (like a XUL element) and accessing nodeType/nodeName/className will generate an error.
- }
- };
- CSelectionController.prototype.selectDrillThroughImage = function(node) {
- this.m_oSelectedDrillThroughImage = node;
- };
- CSelectionController.prototype.getSelectedDrillThroughImage = function() {
- return this.m_oSelectedDrillThroughImage ? this.m_oSelectedDrillThroughImage : null;
- };
- CSelectionController.prototype.selectDrillThroughSingleton = function(node) {
- this.m_oSelectedDrillThroughSingleton = node;
- }
- CSelectionController.prototype.getSelectDrillThroughSingleton = function() {
- return this.m_oSelectedDrillThroughSingleton ? this.m_oSelectedDrillThroughSingleton : null;
- };
- //Deprecated way
- CSelectionController.prototype.getReportContextDataArray = function()
- {
- return this.m_aReportContextDataArray;
- };
- CSelectionController.prototype.getReportMetadataArray = function()
- {
- return this.m_aReportMetadataArray;
- };
- CSelectionController.prototype.setupContextDataArray = function(contextDataArray)
- {
- this.m_aReportContextDataArray = contextDataArray;
- };
- CSelectionController.prototype.setupMetaDataArray = function(metaDataArray)
- {
- this.m_aReportMetadataArray = metaDataArray;
- };
- //JSON Way
- CSelectionController.prototype.addContextData = function(contextDataJSONSpec) {
- this.m_aSelectedObjects = [];
- this.m_oCDManager.SetContextData(contextDataJSONSpec);
- if (!this.m_bUsingCCDManager) {
- this.m_bUsingCCDManager = true;
- }
- for(var i = 0; i < this.m_selectedClass.length; ++i) {
- this.deselecting(this.m_selectedClass);
- }
- };
- CSelectionController.prototype.addMetaData = function(metaDataJSONSpec) {
- this.m_aSelectedObjects = [];
- this.m_oCDManager.SetMetadata(metaDataJSONSpec);
- if (!this.m_bUsingCCDManager) {
- this.m_bUsingCCDManager = true;
- }
- };
- // Y Valve Deprecated and Old ways
- CSelectionController.prototype.getDrillFlag = function(contextId) {
- var drill = "";
- if (!this.m_bUsingCCDManager) {
- var contextObj = this.m_aReportContextDataArray[contextId];
- var dataItemRefId = contextObj[0];
- var contextDataItem = this.m_aReportMetadataArray[dataItemRefId];
- if(typeof contextDataItem != "undefined" && typeof contextDataItem[3] != "undefined")
- {
- drill = contextDataItem[3];
- }
- } else {
- drill = this.m_oCDManager.GetDrillFlag(contextId);
- }
- return drill;
- };
- CSelectionController.prototype.getDrillFlagForMember = function(sCtxId)
- {
- var drillFlag = "0";
- if (!this.m_bUsingCCDManager) {
- var contextItem = this.getContextDataItem(sCtxId);
- if(contextItem != null)
- {
- // check to see that this is a "member"
- var metaDataRefMunKey = contextItem[2]; //Mun reference key
- if(metaDataRefMunKey != "")
- {
- var metaDataRefDataItemKey = contextItem[0]; //data item reference key
- var metaDataItem = this.getMetaDataItem(metaDataRefDataItemKey);
- if(metaDataItem != null)
- {
- drillFlag = metaDataItem[3]; //drill flag index
- }
- }
- }
- } else {
- drillFlag = this.m_oCDManager.GetDrillFlagForMember(sCtxId);
- }
- return (drillFlag == null) ? 0 : drillFlag;
- };
- CSelectionController.prototype.getDataType = function(contextId) {
- var dtype = null;
- if (!this.m_bUsingCCDManager) {
- var aData = this.getRDI(contextId);
- if (aData && aData.length > 2)
- {
- dtype = parseInt(aData[2],10);
- }
- } else {
- dtype = parseInt(this.m_oCDManager.GetDataType(contextId),10);
- }
- return dtype;
- };
- CSelectionController.prototype.getUsageInfo = function(contextId) {
- if (this.m_bUsingCCDManager) {
- return this.m_oCDManager.GetUsage(contextId);
- }
- };
- CSelectionController.prototype.isMeasure = function(contextId) {
- return (this.getUsageInfo(contextId) == this.c_usageMeasure);
- };
- CSelectionController.prototype.getDepth = function(contextId) {
- var sLevel = null;
- if (!this.m_bUsingCCDManager) {
- var aData = this.getRDI(contextId);
- if (aData && aData.length > 5 && aData[1] == "R") {
- sLevel = aData[5];
- }
- } else {
- sLevel = this.m_oCDManager.GetDepth(contextId);
- }
- return sLevel;
- };
- CSelectionController.prototype.getUseValue = function(contextId)
- {
- var value = "";
- if (!this.m_bUsingCCDManager) {
- var contextObj = this.m_aReportContextDataArray[contextId];
- if(typeof contextObj[1] != "undefined")
- {
- value = contextObj[1];
- }
- } else {
- value = this.m_oCDManager.GetDisplayValue(contextId);
- }
- return value;
- };
- CSelectionController.prototype.getTextValue = function(aSpans) {
- var value = null;
- // need to find the span that has a ctx attribute equal or starts with
- // the contextId passed in
- for (var iIndex=0; iIndex < aSpans.length; iIndex++)
- {
- if (aSpans[iIndex].style.visisbility != "hidden")
- {
- if(isIE())
- {
- value = aSpans[iIndex].innerText;
- }
- else
- {
- value = aSpans[iIndex].textContent;
- }
- // need to check if there are any other spans with the same ctx. RSVP sometimes
- // uses multiple spans when generting one label
- var sibling = aSpans[iIndex].nextSibling;
- while (sibling != null)
- {
- if (sibling.nodeName.toUpperCase() == "SPAN" && sibling.style.visibility != "hidden")
- {
- if(isIE())
- {
- value += sibling.innerText;
- }
- else
- {
- value += sibling.textContent;
- }
- }
- sibling = sibling.nextSibling;
- }
- break;
- }
- }
- return value;
- };
- CSelectionController.prototype.getDisplayValueFromDOM = function(contextId, srcNode) {
- var value = null;
- var htmlNodes;
- var ctxRegex = new RegExp("(^|\\s)" + contextId + "(\\s|$|:)", "i");
- if (typeof srcNode != "undefined")
- {
- htmlNodes = getElementsByAttribute(srcNode, ["span", "td", "th"], "ctx", contextId, 1, ctxRegex);
- }
- else
- {
- var oIFrame = document.getElementById('CVIFrame' + this.m_sNamespace);
- if (typeof oIFrame == "undefined" || oIFrame == null)
- {
- var oRVContent = document.getElementById('RVContent' + this.m_sNamespace);
- if (typeof oRVContent == "undefined" || oRVContent == null)
- {
- htmlNodes = getElementsByAttribute(document.body, ["span", "td", "th"], "ctx", contextId, 1, ctxRegex);
- }
- else
- {
- htmlNodes = getElementsByAttribute(oRVContent, ["span", "td", "th"], "ctx", contextId, 1, ctxRegex);
- }
- }
- else
- {
- htmlNodes = getElementsByAttribute(oIFrame.contentWindow.document.body, ["span", "td", "th"], "ctx", contextId, 1, ctxRegex);
- }
- }
- var aSpans;
- if(htmlNodes.length > 0 && (htmlNodes[0].nodeName.toUpperCase() == "TD" || htmlNodes[0].nodeName.toUpperCase() == "TH"))
- {
- aSpans = htmlNodes[0].childNodes;
- }
- else
- {
- aSpans = htmlNodes;
- }
- // For Annotations/Comments get the value through getUseValue().
- if (aSpans.length == 0 ||
- (aSpans[0].className.indexOf("chart_area")==-1 && aSpans[0].className.indexOf("bux-comment")==-1))
- {
- value = this.getTextValue(aSpans);
- }
- return value;
- };
- CSelectionController.prototype.getDisplayValue = function(contextId, srcNode) {
- var value = this.getDisplayValueFromDOM(contextId, srcNode);
- if (value == null)
- {
- value = this.getUseValue(contextId);
- }
- return value;
- };
- CSelectionController.prototype.getDun = function(contextId)
- {
- if (this.m_bUsingCCDManager)
- {
- return this.m_oCDManager.GetDUN(contextId);
- }
- else
- {
- var contextObj = this.m_aReportContextDataArray[contextId];
- if(contextObj && typeof contextObj[5] != "undefined"){
- var dimensionRefId = contextObj[5];
- var contextDimension = this.m_aReportMetadataArray[dimensionRefId];
- if(typeof contextDimension != "undefined" && typeof contextDimension[1] != "undefined" && contextDimension[1] == "D")
- {
- return contextDimension[0];
- }
- }
- }
- };
- CSelectionController.prototype.getPun = function(contextId) {
- if (this.m_bUsingCCDManager) {
- return this.m_oCDManager.GetPUN(contextId);
- }
- };
- CSelectionController.prototype.getLun = function(contextId) {
- var lun = "";
- if (!this.m_bUsingCCDManager) {
- var contextObj = this.m_aReportContextDataArray[contextId];
- if(contextObj && typeof contextObj[3] != "undefined"){
- var queryModelItemRefId = contextObj[3];
- var contextQueryModelItem = this.m_aReportMetadataArray[queryModelItemRefId];
- if(typeof contextQueryModelItem != "undefined" && typeof contextQueryModelItem[1] != "undefined" && contextQueryModelItem[1] == "L")
- {
- lun = contextQueryModelItem[0];
- }
- }
- } else {
- lun = this.m_oCDManager.GetLUN(contextId);
- }
- return lun;
- };
- CSelectionController.prototype.isContextId = function(contextId) {
- var isContext = false;
- if (!this.m_bUsingCCDManager) {
- var contextObj = this.m_aReportContextDataArray[contextId];
- isContext = (typeof contextObj == "object");
- } else {
- this.m_oCDManager.FetchContextData([contextId]);
- isContext = this.m_oCDManager.ContextIdExists(contextId);
- }
- return isContext;
- };
- CSelectionController.prototype.hasContextData = function() {
- var hasContextData = false;
- if (!this.m_bUsingCCDManager) {
- if (this.m_aReportContextDataArray && this.m_aReportContextDataArray.length && this.m_aReportContextDataArray.length() > 0) {
- return true;
- }
- } else {
- hasContextData = this.m_oCDManager.HasContextData();
- }
- return hasContextData;
- };
- CSelectionController.prototype.hasMetadata = function() {
- var hasMetadata = false;
- if (!this.m_bUsingCCDManager) {
- if (this.m_aReportMetadataArray && this.m_aReportMetadataArray.length && this.m_aReportMetadataArray.length() > 0) {
- return true;
- }
- } else {
- hasMetadata = this.m_oCDManager.HasMetadata();
- }
- return hasMetadata;
- };
- /*** Gets a new index value of a cell after all the groups/non-datavalues are added or removed (depends on indexType) ***/
- CSelectionController.prototype.getDifferentCellIndex = function(cellRow, cellIndex, indexType)
- {
- //Go through each cell in the current row
- for(var i = 0; i < cellRow.cells.length; i++)
- {
- //If we see a cell of type "datavalue", stop and return the new cellindex value
- if (this.getSelectionObjectFactory().getSelectionObject(cellRow.cells[i]).getLayoutType() == "datavalue")
- {
- break;
- }
- }
- if (indexType == "relative")
- {
- return (cellIndex - i);
- }
- else if(indexType == "actual")
- {
- return (cellIndex + i);
- }
- };
- /*** Checks if two given cells are in the same column ***/
- CSelectionController.prototype.cellsAreInSameColumn = function(cellOneRef, cellTwoRef)
- {
- //If both selections are on the same row, they are obviously not in the same column
- if (cellOneRef.parentNode.rowIndex == cellTwoRef.parentNode.rowIndex)
- {
- return false;
- }
- //If it's a crosstab...
- if (cellOneRef.getAttribute("cid") === null)
- {
- //Compare the UIDs
- if (cellOneRef.getAttribute("uid") === cellTwoRef.getAttribute("uid"))
- {
- //If the UIDs match and the selections are column titles, they are in the same column
- if (cellOneRef.getAttribute("type") != "datavalue") {
- return true;
- }
- //if they are datavalues, see if both belong to the same column
- else if(this.getDifferentCellIndex(cellOneRef.parentNode,cellOneRef.cellIndex, "relative") == this.getDifferentCellIndex(cellTwoRef.parentNode,cellTwoRef.cellIndex, "relative")) {
- return true;
- }
- }
- else
- {
- return false;
- }
- }
- //If it's a list and the headers of both selections are same, then they are in the same column
- else if (cellOneRef.getAttribute("cid") === cellTwoRef.getAttribute("cid"))
- {
- return true;
- }
- else
- {
- return false;
- }
- };
- /*** Selects all the required cells between two selections in a certain column ***/
- CSelectionController.prototype.selectVertical = function(sourceObj, targetObj, theDocument)
- {
- if (!theDocument) {
- theDocument = document;
- }
- var currentRow = sourceObj.getCellRef().parentNode;
- var tempSelObj, i;
- var bGoDown = (sourceObj.getCellRef().parentNode.rowIndex < targetObj.getCellRef().parentNode.rowIndex);
- var lengthOfNonDataValueCells = (sourceObj.getCellRef().parentNode.cells.length - sourceObj.getCellRef().cellIndex);
- //Loop through all the rows (starting from the source cell's row)
- //Do until we reach the target object
- while (currentRow.rowIndex != targetObj.getCellRef().parentNode.rowIndex)
- {
- if(bGoDown) {
- //source objects's row comes before the target object's row in the table, so go forward from the source
- currentRow = currentRow.nextSibling;
- }
- else {
- //source objects's row comes after the target object's row in the table, so go backward from the source
- currentRow = currentRow.previousSibling;
- }
- if (currentRow == null)
- {
- break; //There are no more rows (start or end of table)
- }
- //If the current row has the same number of cells or more than the row which had source object, go through individual cells
- if (currentRow.cells.length >= lengthOfNonDataValueCells)
- {
- for(i = 0; i < currentRow.cells.length; i++)
- {
- //Make sure both are in the same column and have the same layout
- if ((currentRow.cells[i].getAttribute("type") == sourceObj.getLayoutType()) && this.cellsAreInSameColumn(sourceObj.getCellRef(), currentRow.cells[i]))
- {
- //Get the cell that's anywhere below the source object's cell but only if they are in the same column
- tempSelObj = this.getSelectionObjectFactory().getSelectionObject(currentRow.cells[i]);
- //Add the selection if it's not already selected
- if(this.addSelectionObject(tempSelObj, theDocument))
- {
- // This will add the selection object to the list of selected columns in Query Studio
- if (typeof cf != "undefined" && typeof cf.addSelectionToCfgVariables == "function")
- {
- cf.addSelectionToCfgVariables(tempSelObj.getColumnName());
- }
- }
- break;
- }
- }
- }
- }
- };
- /**** Selects all the required cells between two selections on a certain row ***/
- CSelectionController.prototype.selectHorizontal = function(sourceObj, targetObj, theDocument)
- {
- var compareUID = "";
- //If it's a crosstab, and the UIDs of the selections don't match, exit this function
- if (sourceObj.getColumnRef() == null)
- {
- if (sourceObj.getCellRef().getAttribute("uid") == targetObj.getCellRef().getAttribute("uid")) {
- //crosstab, and same UIDs
- compareUID = sourceObj.getCellRef().getAttribute("uid");
- }
- else {
- return;
- }
- }
- //Set up start and end points of our loop
- var minNodeCellIndex, maxNodeCellIndex;
- var nodeParent = targetObj.getCellRef().parentNode; // A <tr> element
- var tempSelObj;
- if (targetObj.getCellRef().cellIndex < sourceObj.getCellRef().cellIndex)
- {
- minNodeCellIndex = targetObj.getCellRef().cellIndex;
- maxNodeCellIndex = sourceObj.getCellRef().cellIndex;
- }
- else
- {
- maxNodeCellIndex = targetObj.getCellRef().cellIndex;
- minNodeCellIndex = sourceObj.getCellRef().cellIndex;
- }
- //Go through each cell
- for (var i = minNodeCellIndex + 1; i < maxNodeCellIndex; i++)
- {
- //Select the cell if the layouts match and it's not a datavalue <----------if it's a list
- if (((sourceObj.getColumnRef() != null) && (sourceObj.getLayoutType() == targetObj.getLayoutType()) && (sourceObj.getLayoutType() != "datavalue") || this.allowHorizontalDataValueSelection() ) ||
- //Select the cell if the UIDs match <----- if it's a crosstab
- ((sourceObj.getColumnRef() == null) && (nodeParent.cells[i].getAttribute("uid") == compareUID)))
- {
- tempSelObj = this.getSelectionObjectFactory().getSelectionObject(nodeParent.cells[i]);
- //Add the selection if it's not already selected
- if(this.addSelectionObject(tempSelObj, theDocument))
- {
- // This will add the selection object to the list of selected columns in Query Studio
- if (typeof cf != "undefined" && typeof cf.addSelectionToCfgVariables == "function") {
- cf.addSelectionToCfgVariables(tempSelObj.getColumnName());
- }
- }
- }
- }
- };
- CSelectionController.prototype.pageDoubleClicked = function(e) {
- try{
- var node = getNodeFromEvent(e);
- if(typeof node.selectedCell != "undefined")
- {
- var divRegion = node;
- node = node.selectedCell;
- divRegion.removeAttribute("selectedCell");
- }
- while (node.nodeType == 3)
- { // test to see if this is a text node
- node = node.parentNode;
- }
- var ctx = node.getAttribute("ctx");
- var uid = node.getAttribute("uid");
- if ((ctx != null) || (node.parentNode.nodeType == 1 && node.parentNode.getAttribute("uid") != null)) // this is a textitem
- {
- node = node.parentNode;
- // special case for Bug#498910. Analysis Studio is adding a members attributes within the same td, broken up by divs.
- // If the parent node is a DIV and the class is "BLOCK", move up one level higher in the DOM
- if(node.className.toUpperCase() == "BLOCK" && node.nodeName.toUpperCase() == "DIV") {
- node = node.parentNode;
- }
- uid = node.getAttribute("uid");
- }
- if (uid != null && node.firstChild != null && (node.getAttribute("type") == "columnTitle" || node.getAttribute("type") == "section")) // this is a valid column title element
- {
- if (typeof goWindowManager != "undefined" && goWindowManager && typeof goWindowManager.getApplicationFrame == "function")
- {
- goWindowManager.getFeatureManager().launchFeature('Rename');
- }
- }
- if (typeof g_reportSelectionController != "undefined") {
- g_reportSelectionController.clearSelections();
- }
- }
- catch(ex) {
- // sometimes node may not be an HTML element (like a XUL element) and accessing nodeType/nodeName/className will generate an error.
- }
- };
- CSelectionController.prototype.getSelectionHoverNodes = function()
- {
- return this.m_aSelectionHoverNodes;
- };
- CSelectionController.prototype.setSelectionHoverNodes = function(selectionHoverNodes)
- {
- this.m_aSelectionHoverNodes = selectionHoverNodes;
- };
- CSelectionController.prototype.addSelectionHoverNode = function(node)
- {
- this.m_aSelectionHoverNodes[this.m_aSelectionHoverNodes.length] = node;
- };
- CSelectionController.prototype.pageHover = function(e) {
- try {
- var node = getNodeFromEvent(e);
- while (node.nodeType == 3) { // test to see if this is a text node
- node = node.parentNode;
- }
- if ((node.getAttribute("ctx") != null) || (node.parentNode.nodeType == 1 && node.parentNode.getAttribute("uid") != null)) // this is a textitem
- {
- if (node.parentNode.nodeName.toLowerCase() != "tr") {
- node = node.parentNode;
- }
- }
- var aSelectionHoverNodes = this.getSelectionHoverNodes();
- var selectionCount = this.getAllSelectedObjects().length;
- if (!(aSelectionHoverNodes.length == 1 && aSelectionHoverNodes[0] == node))
- {
- for (var i = 0; i < aSelectionHoverNodes.length; i++)
- {
- this.sortIconHover(aSelectionHoverNodes[i], true);
- if (selectionCount == 0)
- {
- this.pageChangeHover(aSelectionHoverNodes[i], true);
- }
- }
- this.setSelectionHoverNodes([]);
- if (selectionCount == 0)
- {
- this.sortIconHover(node, false);
- if (this.pageChangeHover(node, false))
- {
- this.addSelectionHoverNode(node);
- }
- }
- else
- {
- if (this.sortIconHover(node, false))
- {
- this.addSelectionHoverNode(node);
- }
- }
- }
- }
- catch(ex) {
- // sometimes node may not be an HTML element (like a XUL element) and accessing nodeType/nodeName/className will generate an error.
- }
- };
- CSelectionController.prototype.sortIconHover = function(node, hoverOff)
- {
- if (!this.isValidColumnTitle(node))
- {
- return false;
- }
- var sortImgNode = this.getSortImgNode(node);
- if(sortImgNode != null && sortImgNode != "undefined")
- {
- if(sortImgNode.getAttribute( 'sortOrder' ) === 'nosort')
- {
- if (hoverOff)
- {
- sortImgNode.style.visibility = "hidden";
- }
- else
- {
- sortImgNode.style.visibility = 'visible';
- }
- }
- return true;
- }
- return false;
- };
- CSelectionController.prototype.isValidColumnTitle = function(node)
- {
- if (node && node.parentNode)
- {
- var uid = node.getAttribute("uid");
- 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"))
- {
- return true;
- }
- }
- return false;
- };
- CSelectionController.prototype.pageChangeHover = function(node, hoverOff) {
- try {
- if ((node.getAttribute("ctx") != null) || (node.parentNode && node.parentNode.nodeType == 1 && node.parentNode.getAttribute("uid") != null)) // this is a textitem
- {
- if (node.parentNode.nodeName.toLowerCase() != "tr") {
- node = node.parentNode;
- }
- }
- if (this.isValidColumnTitle(node)) // this is a valid column title element
- {
- /* TODO: Put this back in once Report Server starts to produce context data
- var columnSelected = this.isColumnSelected(aReportMetadataArray[cid]);
- /TODO */
- /* TODO: Take this out once Report Server starts to produce context data */
- var columnSelected = this.isColumnSelected(node.getAttribute("tag"));
- /* /TODO */
- if (!columnSelected)
- {
- /* TODO: Put this back in once Report Server starts to produce context data
- columnSelected = this.isColumnCut(aReportMetadataArray[cid]);
- /TODO */
- /* TODO: Take this out once Report Server starts to produce context data */
- columnSelected = this.isColumnCut(node.getAttribute("tag"));
- /* /TODO */
- }
- if (!columnSelected)
- {
- if (hoverOff)
- {
- if (node.getAttribute("oldClassName") != null)
- {
- node.className = node.getAttribute("oldClassName");
- node.removeAttribute("oldClassName");
- }
- this.restoreOldBackgroundImage(node);
- }
- else
- {
- if (node.getAttribute("oldClassName") != null) {
- node.className = node.getAttribute("oldClassName");
- }
- else {
- node.setAttribute("oldClassName", node.className);
- }
- if (node.getAttribute("oldBackgroundImageStyle") != null) {
- node.style.backgroundImage = node.getAttribute("oldBackgroundImageStyle");
- }
- else {
- this.saveOldCellStyles(node);
- }
- node.className += " hoverSelection";
- return true;
- }
- }
- }
- }
- catch(ex) {
- // sometimes node may not be an HTML element (like a XUL element) and accessing nodeType/nodeName/className will generate an error.
- }
- return false;
- };
- //helper function to get the span node containing the sort image
- CSelectionController.prototype.getSortImgNode = function( node)
- {
- var elements = node.getElementsByTagName("img");
- for( var i = 0; i < elements.length ; i++)
- {
- var sId = elements[i].id.toString();
- if( sId != null && sId.length > 0 && sId.indexOf("sortimg") >= 0 )
- {
- node = elements[i];
- return node;
- }
- }
- return null;
- };
- CSelectionController.prototype.restoreOldPadding = function(node)
- {
- if (node && node.style && node.getAttribute("oldPaddingStyle") != null)
- {
- if (node.getAttribute("oldPaddingStyle").length > 0)
- {
- node.style.padding = node.getAttribute("oldPaddingStyle");
- }
- node.removeAttribute("oldPaddingStyle");
- }
- };
- CSelectionController.prototype.saveOldPadding = function(node, size)
- {
- if (node && node.getAttribute("oldPaddingStyle") == null)
- {
- node.setAttribute("oldPaddingStyle", size.paddingTop + "px " + size.paddingRight + "px " + size.paddingBottom + "px " + size.paddingLeft + "px");
- }
- };
- CSelectionController.prototype.saveOldBorder = function(node)
- {
- if (node && node.getAttribute("oldBorderStyle") == null)
- {
- node.setAttribute("oldBorderStyle", node.style.border);
- }
- };
- CSelectionController.prototype.restoreOldBorder = function(node)
- {
- if (node && node.style && node.getAttribute("oldBorderStyle") != null)
- {
- if (node.getAttribute("oldBorderStyle").length > 0)
- {
- node.style.border = node.getAttribute("oldBorderStyle");
- }
- else
- {
- node.style.borderColor = node.style.borderWidth = node.style.borderStyle = "";
- }
- node.removeAttribute("oldBorderStyle");
- }
- };
- CSelectionController.prototype.setPrimarySelectionStyles = function(cell) {
- if (this.getPrimarySelectionColor()) {
- cell.style.backgroundColor = this.getPrimarySelectionColor();
- }
- else {
- cell.style.backgroundImage = this.pS_backgroundImageURL;
- cell.style.backgroundRepeat = "repeat";
- }
- };
- CSelectionController.prototype.setSecondarySelectionStyles = function(cell) {
- if (this.getSecondarySelectionColor()) {
- cell.style.backgroundColor = this.getSecondarySelectionColor();
- }
- else {
- cell.style.backgroundImage = this.sS_backgroundImageURL;
- cell.style.backgroundRepeat = "repeat";
- }
- };
- CSelectionController.prototype.saveOldCellStyles = function(node)
- {
- if (node && node.getAttribute("oldBackgroundImageStyle") == null)
- {
- node.setAttribute("oldBackgroundColor", this.getStyleProperty(node, "backgroundColor"));
- node.setAttribute("oldBackgroundImageStyle", this.getBackgroundImage(node));
- node.setAttribute("oldBackgroundRepeat", this.getStyleProperty(node, "backgroundRepeat"));
- node.style.backgroundImage = "";
- node.style.backgroundRepeat = "";
- }
- };
- CSelectionController.prototype.restoreOldBackgroundImage = function(node)
- {
- if (node && node.style && node.getAttribute("oldBackgroundImageStyle") != null)
- {
- node.style.backgroundImage = node.getAttribute("oldBackgroundImageStyle");
- node.removeAttribute("oldBackgroundImageStyle");
- node.style.backgroundRepeat = node.getAttribute("oldBackgroundRepeat");
- node.removeAttribute("oldBackgroundRepeat");
- node.style.backgroundColor = node.getAttribute("oldBackgroundColor");
- node.removeAttribute("oldBackgroundColor");
- }
- };
- CSelectionController.prototype.getStyleProperty = function(node, property)
- {
- if(node && node.style && node.style[property])
- {
- return node.style[property];
- }
- return "";
- };
- CSelectionController.prototype.getBackgroundImage = function(node)
- {
- if(node && node.style)
- {
- return node.style.backgroundImage;
- }
- return "";
- };
- CSelectionController.prototype.pageContextClicked = function(e)
- {
- var node = getNodeFromEvent(e);
- if(typeof node.selectedCell != "undefined")
- {
- var divRegion = node;
- node = node.selectedCell;
- divRegion.removeAttribute("selectedCell");
- }
- while (node != null && node.tagName != "TD")
- {
- node = node.parentNode;
- }
- if (node != null)
- {
- var nodeBackgroundImage = this.getBackgroundImage(node);
- this.findSelectionURLs();
- if (this.getSelections().length == 0 || nodeBackgroundImage != this.pS_backgroundImageURL )
- {
- this.pageClicked(e);
- }
- }
- if (typeof populateContextMenu != "undefined")
- {
- populateContextMenu();
- moveContextMenu(e);
- }
- var bReturn = false;
- if (this.showViewerContextMenu())
- {
- //NS6 specific
- if (typeof e.preventDefault == "function")
- {
- e.preventDefault();
- }
- bReturn = true;
- }
- return bReturn;
- };
- CSelectionController.prototype.chartContextMenu = function(e)
- {
- if(!this.hasSelectedChartNodes())
- {
- return;
- }
- if (typeof populateContextMenu != "undefined")
- {
- populateContextMenu();
- moveContextMenu(e);
- }
- //NS6 specific
- if (typeof e.preventDefault == "function")
- {
- e.preventDefault();
- }
- return false;
- };
- CSelectionController.prototype.titleAreaContextMenu = function(e, sType, sId)
- {
- if (typeof populateContextMenu != "undefined")
- {
- goWindowManager.getApplicationFrame().cfgSet("contextMenuType", sType);
- goWindowManager.getApplicationFrame().cfgSet("contextMenuId", sId);
- populateContextMenu(sType.toUpperCase());
- moveContextMenu(e, sType.toUpperCase());
- }
- //NS6 specific
- if (typeof e.preventDefault == "function")
- {
- e.preventDefault();
- }
- return false;
- };
- CSelectionController.prototype.selectionsAreAllSameType = function()
- {
- var allSelections = this.getSelections();
- if (allSelections.length > 0)
- {
- var layoutType = allSelections[0].getLayoutType();
- for (var i = 1; i < allSelections.length; i++)
- {
- if (layoutType != allSelections[i].getLayoutType()) {
- return 0; // They aren't all the same type
- }
- }
- return 1; // They are all the same type
- }
- return -1; // There are no selections
- };
- CSelectionController.prototype.selectionsAreAllOnSameColumn = function()
- {
- var allSelections = this.getSelections();
- var i = 0;
- if (allSelections.length > 0)
- {
- var colRef = allSelections[0].getColumnRef();
- if (colRef != null && colRef != "")
- {
- for (i = 1; i < allSelections.length; i++)
- {
- if (colRef != allSelections[i].getColumnRef()) {
- return false; // They aren't all on the same column
- }
- }
- }
- else
- {
- var cellTypeId = allSelections[0].getCellTypeId();
- for (i = 1; i < allSelections.length; i++)
- {
- if (cellTypeId != allSelections[i].getCellTypeId()) {
- return false; // They aren't all on the same column
- }
- }
- }
- return true; // They are all on the same column
- }
- return false; // There are no selections
- };
- CSelectionController.prototype.checkForReportElementNode = function(node)
- {
- if (typeof node != "undefined" && node != null && typeof node.className != "undefined" && node.className != null)
- {
- if (node.className == "tt")
- {
- // Check to see if this is the report title or subtitle
- 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")) {
- node = node.parentNode.parentNode;
- }
- else {
- return false;
- }
- }
- /*
- else if (node.className == "textItem")
- {
- // Handle page footer here
- if (typeof node.parentNode != "undefined" && node.parentNode != null && node.parentNode.className == "tableCell"
- && typeof node.parentNode.parentNode != "undefined" && node.parentNode.parentNode != null && node.parentNode.parentNode.className == "tableRow"
- && typeof node.parentNode.parentNode.parentNode != "undefined" && node.parentNode.parentNode.parentNode != null && node.parentNode.parentNode.className == "tb"
- && typeof node.parentNode.parentNode.parentNode.parentNode != "undefined" && node.parentNode.parentNode.parentNode.parentNode != null && node.parentNode.parentNode.parentNode.className == "pf"
- )
- node = node.parentNode;
- else
- return false;
- }
- */
- else if (typeof node.parentNode != "undefined" && node.parentNode != null)
- {
- // Check to see if this is the report filter area
- var parentNode = node.parentNode;
- while (typeof parentNode != "undefined" && parentNode != null)
- {
- if (typeof parentNode.className != "undefined" && parentNode.className != null && parentNode.className.substr(0, 2) == "ft")
- {
- node = parentNode;
- break;
- }
- else {
- parentNode = parentNode.parentNode;
- }
- }
- }
- else {
- return false;
- }
- var nodeCN = node.className.substr(0, 2);
- if (nodeCN == "ta" || nodeCN == "ts" || nodeCN == "ft") {
- return true;
- }
- }
- return false;
- };
- CSelectionController.prototype.chartClicked = function(htmlElement)
- {
- this.setSelectedChartArea(htmlElement);
- };
- /**
- * A workaround for a RSVP bug: when a list column is renamed, the column title loses its ctx.
- * this function pick the the ctx of the first row in the same column and set it to the column title node.
- */
- CSelectionController.prototype.processColumnTitleNode = function(selectedObject)
- {
- if (!selectedObject || !this.m_oCognosViewer.isBux) {
- return;
- }
- var oCell = selectedObject.getCellRef();
- // quick check to make sure we're dealing with a column title and that we
- // haven't already tried to process it once
- if ( oCell.getAttribute("contextAugmented") == "true" || "list" != selectedObject.getDataContainerType() || "columnTitle" != selectedObject.getLayoutType()) {
- return;
- }
- var selectedContextIds = selectedObject.getSelectedContextIds();
- var missingQueryModelId = false;
- if (typeof selectedContextIds == "object" && selectedContextIds != null && selectedContextIds.length > 0) {
- // special case where relational list headers have context but are missing a query model id
- if (this.isRelational(selectedContextIds) && this.getQueryModelId(selectedContextIds[0][0]) == null) {
- missingQueryModelId = true;
- } else {
- return;
- }
- }
- var lid = oCell.parentNode.parentNode.parentNode.getAttribute("lid"); //lid on table node.
- var parentNode = oCell.parentNode.nextSibling; //get to the next tr node.
- var aCells = getChildElementsByAttribute(parentNode, "td", "cid", oCell.getAttribute("cid"));
- var ctxValue = null;
- var canSort = true;
- var spanElements;
- if (aCells.length > 0) {
- var tdCell = aCells[0];
- var childNodesLength = tdCell.childNodes.length;
- // we need to loop through the TD's child elements one by one to make sure
- // we don't start looking for span's inside an embeded list or crosstab
- for (var tdChildIndex=0; tdChildIndex < childNodesLength; tdChildIndex++) {
- var childNode = tdCell.childNodes[tdChildIndex];
- // found an embeded list/crosstab/chart, don't bother looking at the span's in them.
- if ( childNode.getAttribute &&
- ((childNode.nodeName.toLowerCase() == "table" && typeof childNode.getAttribute("lid") == "string")
- || childNode.nodeName.toLowerCase() == 'map' || childNode.nodeName.toLowerCase() == "img" || childNode.getAttribute("chartcontainer") == "true") ) {
- // if the first item in the column content is another list or crosstab, then disable sort
- if (tdChildIndex == 0) {
- canSort = false;
- }
- } else {
- spanElements = [];
- if (childNode.nodeName.toLowerCase() == "span") {
- spanElements.push(childNode);
- }
- // the case where we have nested span elements
- var nestedSpanElements = childNode.getElementsByTagName ? childNode.getElementsByTagName("span"): [];
- for (var nestedSpanIndex = 0; nestedSpanIndex < nestedSpanElements.length; ++nestedSpanIndex)
- {
- if (lid == getImmediateLayoutContainerId(nestedSpanElements[nestedSpanIndex]))
- {
- spanElements.push(nestedSpanElements[nestedSpanIndex]);
- }
- }
- for (var spanIndex = 0; spanIndex < spanElements.length; ++spanIndex) {
- var oChild = spanElements[spanIndex];
- if (oChild.nodeType == 1 && oChild.nodeName.toLowerCase() == "span" && oChild.style.visibility != "hidden") {
- if(oChild.getAttribute("ctx") != null && oChild.getAttribute("ctx") != "") {
- ctxValue = oChild.getAttribute("ctx");
- break;
- }
- }
- }
- }
- }
- }
- if (ctxValue != null) {
- var ctxId = ctxValue.split("::")[0].split(":")[0];
- // if we're not here because of a missing query model id, then we must be missing
- // the entire context
- if (!missingQueryModelId) {
- //set the ctx for the column header node to speed up subsequent runs
- spanElements = oCell.getElementsByTagName("span");
- if (spanElements.length != 0)
- {
- var contextObject = this.m_oCDManager.m_cd[ctxId];
- var textValue = this.getTextValue(spanElements);
- var newContextObject = {"u": textValue === null ? "" : textValue};
- if(typeof contextObject != "undefined")
- {
- if(typeof contextObject["r"] != "undefined") { newContextObject.r = contextObject["r"]; }
- if(typeof contextObject["q"] != "undefined") { newContextObject.q = contextObject["q"]; }
- if(typeof contextObject["i"] != "undefined") { newContextObject.i = contextObject["i"]; }
- }
- var clonedCtxId = "cloned" + ctxId;
- this.m_oCDManager.m_cd[clonedCtxId] = newContextObject;
- spanElements[0].setAttribute("ctx", clonedCtxId);
- selectedObject = this.getSelectionObjectFactory().processCTX(selectedObject, clonedCtxId);
- }
- } else {
- // we were only missing the query model id, if we found one then set it in the context data
- var qmid = this.getQueryModelId(ctxId);
- if (qmid == null) {
- // for calculated columns, none of the cells in the column will have a query model item
- }
- if (qmid != null) {
- var oriCtxId = selectedContextIds[0][0];
- this.m_oCDManager.m_cd[oriCtxId].i = this.m_oCDManager.m_cd[ctxId].i;
- return false;
- }
- }
- }
- else
- {
- canSort = false; //not sortable with the absense of ctx.
- }
- if (!canSort) {
- oCell.setAttribute("canSort", "false");
- }
- oCell.setAttribute("contextAugmented", "true");
- };
- /**
- * Goes through all the selections to make sure they're in the same
- * data container
- */
- CSelectionController.prototype.selectionsInSameDataContainer = function() {
- try {
- var aSelectedObjects = this.getAllSelectedObjects();
- var sLayoutElementId = aSelectedObjects[0].getLayoutElementId();
- for (var index=1; index<aSelectedObjects.length; index++) {
- if (sLayoutElementId != aSelectedObjects[index].getLayoutElementId()) {
- return false;
- }
- }
- } catch (e) {
- return false;
- }
- return true;
- };
- /**
- * Goes through all the selections to make sure they're from the same data item
- */
- CSelectionController.prototype.selectionsFromSameDataItem = function() {
- try {
- var aSelectedObjects = this.getAllSelectedObjects();
- var refDataItem = aSelectedObjects[0].getDataItems()[0][0];
- for (var index=1; index<aSelectedObjects.length; index++) {
- if (refDataItem != aSelectedObjects[index].getDataItems()[0][0]) {
- return false;
- }
- }
- } catch (e) {
- return false;
- }
- return true;
- };
- /**
- * Checks to see if the first selection is on relational data.
- * @return false if OLAP data, true otherwise
- */
- CSelectionController.prototype.isRelational = function(aCtxs) {
- try {
- if (!aCtxs) {
- var selection = this.getAllSelectedObjects()[0];
- aCtxs = selection.getSelectedContextIds();
- }
- for (var axisIndex=0; axisIndex < aCtxs.length; axisIndex++) {
- for (var nestIndex=0; nestIndex < aCtxs[axisIndex].length; nestIndex++) {
- var ctx = aCtxs[axisIndex][nestIndex];
- var mun = this.getMun(ctx);
- var lun = this.getLun(ctx);
- var hun = this.getHun(ctx);
- if (mun != null && typeof mun != "undefined" && mun.length > 0) {
- return false;
- }
- if (lun != null && typeof lun != "undefined" && lun.length > 0) {
- return false;
- }
- if (hun != null && typeof hun != "undefined" && hun.length > 0) {
- return false;
- }
- }
- }
- return true;
- } catch (e) {
- return true;
- }
- return true;
- };
- /**
- * Gets the type of the data container in which the selections are
- * @return 'list', 'crosstab' or an empty string if there was an error finding the container type
- */
- CSelectionController.prototype.getDataContainerType = function() {
- try {
- if( !this.getAllSelectedObjects()[0] ){
- return "";
- }
-
- return this.getAllSelectedObjects()[0].m_dataContainerType;
- } catch (e) {
- return "";
- }
- };
- /**
- * Looks to make sure that the selected cells are either columns or rows
- * @return true if the selected cells are either columns or rows
- */
- CSelectionController.prototype.areSelectionsColumnRowTitles = function() {
- try {
- var aSelectedObjects = this.getAllSelectedObjects();
- for (var index=0; index < aSelectedObjects.length; index++) {
- var selectedObject = aSelectedObjects[index];
- if (selectedObject.getLayoutType() != "columnTitle" || selectedObject.isHomeCell()) {
- return false;
- }
- }
- } catch (e) {
- return false;
- }
- return true;
- };
- /**
- * Checks to see if all the current selections are measures
- * @return true if all the current selections are measures, false otherwise
- */
- CSelectionController.prototype.selectionsAreMeasures = function() {
- try {
- var aSelectedObjects = this.getAllSelectedObjects();
- for (var index=0; index < aSelectedObjects.length; index++) {
- var selectedObject = aSelectedObjects[index];
- if (this.getUsageInfo(selectedObject.getSelectedContextIds()[0][0]) != this.c_usageMeasure) {
- return false;
- }
- }
- } catch (e) {
- return false;
- }
- return true;
- };
- /**
- * @return true if the current selections have muns and aren't measures
- */
- CSelectionController.prototype.selectionsNonMeasureWithMUN = function() {
- var aSelectedObjects = this.getAllSelectedObjects();
- if (aSelectedObjects.length == 0) {
- return false;
- }
- for (var index=0; index < aSelectedObjects.length; index++) {
- var selectedObject = aSelectedObjects[0];
- if (selectedObject.getSelectedContextIds().length == 0) {
- return false;
- }
- var contextId = selectedObject.getSelectedContextIds()[0][0];
- var mun = this.getMun(contextId);
- var sUsage = this.getUsageInfo(contextId);
- if (mun == null || typeof mun == "undefined" || mun.length == 0 || sUsage == this.c_usageMeasure) {
- return false;
- }
- }
- return true;
- };
- /**
- * @return true if the current selections are all measure or calculation
- */
- CSelectionController.prototype.areSelectionsMeasureOrCalculation = function() {
- var aSelectedObjects = this.getAllSelectedObjects();
- if (aSelectedObjects.length == 0) {
- return false;
- }
- var bHaveCalcMetaData = this.selectionsHaveCalculationMetadata();
- for (var index=0; index < aSelectedObjects.length; index++) {
- var selectedObject = aSelectedObjects[index];
- var contextId = selectedObject.getSelectedContextIds()[0][0];
- if( !this.isCalculationOrMeasure(contextId, bHaveCalcMetaData) ){
- return false;
- }
- }
- return true;
- };
- /**
- * @return true if the metadata is appropriate for calculations.
- * Measure OR (Relational: no model item, Dimensional: no MUN)
- */
- CSelectionController.prototype.selectionsHaveCalculationMetadata = function() {
- try {
- var containerType = this.getDataContainerType();
- var aSelectedObjects = this.getAllSelectedObjects();
- for (var index=0; index < aSelectedObjects.length; index++) {
- var selectedObject = aSelectedObjects[index];
- var contextIds = selectedObject.getSelectedContextIds();
- var contextId = contextIds[0][0];
- var sHun = this.getHun(contextId);
- if( !this.hasCalculationMetadata( contextId, contextIds, containerType) ){
- return false;
- }
- }
- } catch (e) {
- return false;
- }
- return true;
- };
- CSelectionController.prototype.isCalculationOrMeasure = function( contextId, bHaveCalcMetaData ){
- var mun = this.getMun(contextId);
- var sUsage = this.getUsageInfo(contextId);
- if (!(( (mun == null || typeof mun == "undefined" || mun.length == 0) && bHaveCalcMetaData) ||
- sUsage == this.c_usageMeasure)) {
- return false;
- }
- return true;
- };
- /**
- * @return true if the metadata is appropriate for calculations.
- * Measure OR (Relational: no model item, Dimensional: no MUN)
- */
- CSelectionController.prototype.hasCalculationMetadata = function( contextId, contextIds, containerType ){
- var sHun = this.getHun(contextId);
- if (this.getUsageInfo(contextId) != this.c_usageMeasure) {
- if ((this.isRelational(contextIds) && this.getQueryModelId(contextId) != null)
- || (!this.isRelational(contextIds) && containerType == "list" && (sHun && sHun != "")))
- {
- return false;
- }
- }
- return true;
- };
- CSelectionController.prototype.selectionsAreDateTime = function() {
- try {
- var aSelectedObjects = this.getAllSelectedObjects();
- for (var index=0; index < aSelectedObjects.length; index++) {
- var selectedObject = aSelectedObjects[index];
- var contextIds = selectedObject.getSelectedContextIds();
- var contextId = contextIds[0][0];
- var dType = this.getDataType(contextId);
- if (dType && typeof this.m_ccl_dateTypes[dType]!=="undefined") {
- return true;
- }
- }
- } catch (e) {
- return false;
- }
- return false;
- };
- /*
- * @return array of json object which contains the context of each selected object
- */
- CSelectionController.prototype.getSelectedObjectsJsonContext = function() {
- try {
- var aSelectedObjects = this.getAllSelectedObjects();
- if ( aSelectedObjects=== null || aSelectedObjects.length <=0 ) {
- return null;
- }
- var modelPath = this.m_oCognosViewer.getModelPath();
- var aJsonObjects = [];
- for (var i=0; i < aSelectedObjects.length; i++) {
- var obj = aSelectedObjects[i].getContextJsonObject(this, modelPath);
- aJsonObjects.push(obj);
- }
- return aJsonObjects;
- } catch (e) {
- //ignore
- }
- };
- CSelectionController.prototype.destroy = function()
- {
- delete this.m_oCognosViewer;
- delete this.m_aCutColumns;
- delete this.m_aSelectedObjects;
- delete this.m_selectedClass;
- delete this.m_cutClass;
-
- if (this.m_oObserver && this.m_oObserver.destroy) {
- this.m_oObserver.destroy();
- }
- delete this.m_oObserver;
- delete this.m_aReportMetadataArray;
- delete this.m_aReportContextDataArray;
- if (this.m_oCDManager && this.m_oCDManager.destroy) {
- this.m_oCDManager.destroy();
- }
-
- delete this.m_oCDManager;
-
- if(this.m_oSelectionObjectFactory && this.m_oSelectionObjectFactory.destroy) {
- this.m_oSelectionObjectFactory.destroy();
- }
- delete this.m_oSelectionObjectFactory;
- delete this.m_selectedChartArea;
- delete this.m_selectedChartNodes;
- delete this.m_selectionContainerMap;
- delete this.m_chartHelpers;
- delete this.m_oJsonForMarshal;
-
- if( this.hasSavedSelections() ){
- this.clearSavedSelections();
- }
- }
- function clearTextSelection(theDocument)
- {
- if (!theDocument) {
- theDocument = document;
- }
- try
- {
- if (typeof theDocument.selection == "object" && theDocument.selection !== null)
- {
- theDocument.selection.empty();
- }
- else if (typeof window.getSelection == "function" && typeof window.getSelection() == "object" && window.getSelection() !== null)
- {
- //NS6 specific
- window.getSelection().removeAllRanges();
- }
- }
- catch(e)
- {
- }
- }
|