/** * boolean flag used to determine if user * has pending preference modifications which * require saving **/ var preferencesChangedFlag = false; /** * Hides a div * * id - String variable for the div to be hidden * **/ function hide(id) { if ( id != null ) div = document.getElementById(id); if (div != null) { div.style.visibility = 'hidden'; div.style.display = 'none'; } } /** * Shows a div * * id - String variable for the div to be shown * **/ function show(id) { if ( id != null ) div = document.getElementById(id); if (div != null) { div.style.visibility = 'visible'; div.style.display = ''; } } /** * Closes a portlet and saves the state of the portlet * * id - portlet ID variable * **/ function closePortlet(id) { if ( id != null ) { hide('P_' + id ); savePortletState(id,'0'); } } /** * Expands a the portlet by showing both * the portlet outter table and the portlet * body table * * id - portlet ID variable * **/ function maximizePortlet(id) { if ( id != null ) { show('PB_' + id); show('P_' + id ); savePortletState(id,'2'); } } /** * Minimizes a the portlet by setting the * portlet outter table to visible and hidding * the portlet body table. * * id - portlet ID variable * **/ function minimizePortlet(id) { if ( id != null ) { show('P_' + id ); hide('PB_' + id ); savePortletState(id,'1'); } } /** * Flips the state of portlet between minimized * and maximized based on the current visibility * of the portlet body table. * * id - portlet ID variable * **/ function togglePortlet(id) { if ( id != null ) { div = document.getElementById('PB_' + id ); if ( div != null ) { if (div.style.visibility == 'hidden') { maximizePortlet(id); setMinimizedImage(id); } else { minimizePortlet(id); setMaximizedImage(id); } } } } /** * Displays the maximized image button * * id - portlet ID variable * **/ function setMaximizedImage(id) { if ( id != null ){ div = document.getElementById('IM_' + id ); if ( div !=null ) { div.src = '/CFODirectWeb/resources/newimages/maximize.gif'; } } } /** * Displays the minimized image button * * id - portlet ID variable * **/ function setMinimizedImage(id) { if ( id != null ){ div = document.getElementById('IM_' + id ); if ( div !=null ) { div.src = '/CFODirectWeb/resources/newimages/minimize.gif'; } } } /** * Sends the url request to save the current portlet states * using ajax * **/ function savePortletDisplayStates() { if ( preferencesChangedFlag ) { url = location.protocol + '//' + location.host + '/CFODirectWeb/cfocustom/preference/PreferenceController.jpf?savePortletDisplayStates=Y'; sendXMLHttpRequest(url); } } /** * Sends the url request to save a single portlet state * using ajax. * * id - portlet ID variable * state - state of the portlet 0,1,2 (closed,min,max) * **/ function savePortletState(id, state) { if ( id != null && location !=null ){ preferencesChangedFlag = true; url = location.protocol + '//' + location.host + '/CFODirectWeb/cfocustom/preference/PreferenceController.jpf?portletId=' + id + '&state=' + state; sendXMLHttpRequest(url); } } /** * Sends the url request to save the current portlet states * using ajax * **/ function saveSummaryStates(state) { //if ( preferencesChangedFlag ) { url = location.protocol + '//' + location.host + '/CFODirectWeb/cfocustom/summary/SummaryController.jpf?SUMMARY_STATE='+state; sendXMLHttpRequest(url); // } } /** * Sends the url request to save a single portlet state * using ajax. * * id - portlet ID variable * state - state of the portlet 0,1,2 (closed,min,max) * **/ function saveSummaryStatesWithId(id, state) { if ( id != null && location !=null ){ preferencesChangedFlag = true; url = location.protocol + '//' + location.host + '/CFODirectWeb/cfocustom/summary/SummaryController.jpf?SUMMARY_STATE=' + id + '&state=' + state; sendXMLHttpRequest(url); } } /** * Sends a XMLHttpRequest using ajax * **/ function sendXMLHttpRequest(url) { var req; // branch for native XMLHttpRequest object if (window.XMLHttpRequest) { req = new XMLHttpRequest(); req.open("GET", url, true); req.send(null); } else if (window.ActiveXObject) { // branch for IE/Windows ActiveX version req = new ActiveXObject("Microsoft.XMLHTTP"); if (req) { req.open("GET", url, true); req.send(); } } }