/******************************************************************************************************************************** * Licensed Materials - Property of IBM * * * * IBM Cognos Products: HTS * * * * (C) Copyright IBM Corp. 2005, 2021 * * * * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. * *********************************************************************************************************************************/ var HTS_MENU_STATE = "hts_menu_state"; var HTS_FOCUS_ID = "hts_focus_id"; function hts_getMenuStateObjectFromCookie(){ var menuStateObjectStr = _F_Document.getCookie(HTS_MENU_STATE); var menuStateObject; if(menuStateObjectStr){ menuStateObjectStr = _F_Strings.urlDecode(menuStateObjectStr); menuStateObject = JSON.parse(menuStateObjectStr); }else{ //new boy menuStateObject = new Object(); } return menuStateObject; } function hts_setMenuStateObjectToCookie(menuStateObject){ var menuStateObjectStr = dojo.toJson(menuStateObject); menuStateObjectStr = _F_Strings.urlEncode(menuStateObjectStr); _F_Document.setCookie(HTS_MENU_STATE, menuStateObjectStr, '', _F_Config.gateway, '', ''); } function hts_updateMenuStateCookie(filterType,jsonStr){ var menuStateObject = hts_getMenuStateObjectFromCookie(); menuStateObject[filterType] = jsonStr; hts_setMenuStateObjectToCookie(menuStateObject); } function hts_getMenuStateCookieValue(filterType){ var menuStateObject = hts_getMenuStateObjectFromCookie(); return menuStateObject[filterType]; } function hts_setFocusCookie(focusId) { focusIdStr = _F_Strings.urlEncode(focusId); _F_Document.setCookie(HTS_FOCUS_ID, focusIdStr, '', _F_Config.gateway, '', ''); } function hts_getFocusCookie() { var focusId = _F_Document.getCookie(HTS_FOCUS_ID); return focusId; } /* * Set the filter. Update the UI and store the filter value into a fragment transient variable * frag - The fragment containing the menu * filterType - Three filter types defined : Task.Status, Task.Priority and Task.CreatedOn * newValueIndex - The menu item index (starts at zero) * value - optional value which overrides the menu value. Useful when generating dynamic values based on the menu action */ function setFilter(frag,filterType,newValueIndex,value) { var menu = this.ui_curmenu; //update the menu title with the current filter var filterValue = updateFilterMenuTitle(menu,newValueIndex); //set the value if it has been overridden, ignore the menu item value if (value!= undefined) { filterValue=value; } //flag the menu to be rebuilt the next time it is opened. This will ensure the //checkbox is shown next to the new filter menu.rebuild=true; /* * Create the placeholder in JSON format. Holds the menu index and it's value. Note that * the date filter dynamically creates it's value while the others are static */ var jsonObj = new Object(); jsonObj.name=newValueIndex; jsonObj.value=filterValue; var jsonStr = dojo.toJson(jsonObj); hts_updateMenuStateCookie(filterType, jsonStr); //set the filter value, this will call the server-side interaction stage frag.transientUpdate(filterType,jsonStr,'application'); } /* * Update the menu with the new filter and set the title to reflect the new item * returns the new value * menu - The menu * newValueIndex = the position of the selected menu item, can also pass in the menu title */ function updateFilterMenuTitle(menu,newValueIndex) { //select the new item in the menu var def = menu.menudef; var newValue=null; for(var i = 0; i < def.items.length; i++) { var item = def.items[i]; if (newValueIndex==i) { item.selected=true; if (item.image) { //We have text, but we need to display an image. var menuDivTxt = dojo.byId(def.id+"_div_text"); if (menuDivTxt) { dojo.attr(def.id+"_div_text","style",{display:"none"}); } dojo.attr(def.id+"_img", { src: item.pre+item.image+item.post, alt: item.title, title: item.title, style: {display:''} }); } else { var menuDiv = dojo.byId(def.id+"_img"); //We have an image, but we need to display text. if (menuDiv) { dojo.attr(def.id+"_img","style",{display:"none"}); } menuDiv = dojo.byId(def.id+"_div_text"); dojo.attr(menuDiv,{innerHTML:item.title,style: {display:''}}); } newValue=item.value; //change the alt/title of the arrow image to reflect the new filter name dojo.attr(def.id+"_downarrow_img_id", { alt: item.title, title: item.title }); } else { item.selected=false; } } return newValue; } /* * Initialise the filter menu * menu - the filter menu * filter - the filter details in JSON format */ function initFilter(menu,filter) { if (filter!= undefined && filter!='') { //eval the JSON object var nameValue = eval('(' + filter + ')'); //set the index updateFilterMenuTitle(menu,nameValue.name); } } function hts_getSelectedMenuItem(menu) { //select the new item in the menu var def = menu.menudef var selectedItem=null; for(var i = 0; i < def.items.length; i++) { var item = def.items[i]; if (item.selected==true) { selectedItem = item; } } return selectedItem; }