/** * Copyright (c) 2004-2016 Omnitracs, LLC. All rights reserved. * Confidential and Proprietary - Omnitracs, LLC. * This software may be subject to U.S. and international export, re-export, or transfer * ("export") laws. * Diversion contrary to U.S. and international laws is strictly prohibited. */ /* matchHeight() is based on the work of Alejandro Gervasio. Revised by Adena Chung, September 2006 (510 332 2329). More information: http://www.devarticles.com/c/a/Web-Design-Standards/Matching-div-heights-with-CSS-and-JavaScript/ */ function matchHeight(situation) { var divs,columnDivs,maxHeight,divHeight,d,strMaxHeight; divs = document.getElementsByTagName('div'); columnDivs = []; maxHeight = 0; for ( var i = 0; i < divs.length; i++ ) { if ( /\bcolumn\b/.test(divs[i].className) ) { d = divs[i]; columnDivs[columnDivs.length] = d; if (d.offsetHeight) { divHeight = d.offsetHeight; } else if (d.style.pixelHeight) { divHeight = d.style.pixelHeight; } maxHeight = Math.max(maxHeight,divHeight); strMaxHeight = maxHeight + 'px'; } } var leftColumnDiv = document.getElementById('leftContent'); var mainColumnDiv = document.getElementById('mainContent'); var quickSearchDiv = document.getElementById('quickSearch'); var leftColumnDivH, mainColumnDivH, quickSearchDivH; if (leftColumnDiv.offsetHeight) { leftColumnDivH = leftColumnDiv.offsetHeight; mainColumnDivH = mainColumnDiv.offsetHeight; quickSearchDivH = quickSearchDiv.offsetHeight; } else if (leftColumnDiv.style.pixelHeight) { leftColumnDivH = leftColumnDiv.style.pixelHeight; mainColumnDivH = mainColumnDiv.style.pixelHeight; quickSearchDivH = quickSearchDiv.style.pixelHeight; } if (navigator.userAgent.indexOf('Firefox')!=-1) { document.getElementById('graphBox').style.minHeight = strMaxHeight; document.getElementById('fleetStatus').style.minHeight = ((maxHeight - quickSearchDivH - 11) + 'px'); } } // GW removed original hide and show since it was causing exception to be thrown when an element is not found // these c_*Element functions always check if the el exists in the first place var show = c_showElement; var hide = c_hideElement; // considering removing this function and pointing it to the $ version. var e = $; function getWindowHeight() { if (window.self && self.innerHeight) { return self.innerHeight; } if (document.documentElement && document.documentElement.clientHeight) { return document.documentElement.clientHeight; } return 0; } /* Sets the heights of list panel and map on window load and window resize. Events are registered to resizeApp in the head of the document. Called by switchTo() so elements are properly resized in the case user closes the detail tabs. Also sets the widths of the two content grids in the overview tab. */ var resizeOption = ''; function resizeApp() { var mapOffsetTop = 0; var trailerListOffsetTop = 0; var mapElem = $('map'); var trailerListElem = $('trailerListContainer'); if ($('topRight').style.display == 'none') { $('detailsContainer').style.marginTop = '0px'; } else { $('detailsContainer').style.marginTop = '8px'; } for (var elem = mapElem; elem != null; elem = elem.offsetParent) { // AC: elem should now be "main_map" mapOffsetTop += elem.offsetTop; } if (mapOffsetTop == 0) { mapOffsetTop = $('panel').offsetTop; } for (var elem = trailerListElem; elem != null; elem = elem.offsetParent) { // AC: elem should now be "main_map" trailerListOffsetTop += elem.offsetTop; } // GW modified to have minimum of 335 px height var maxHeight = getWindowHeight(); // 25 is the footer var fullMapHeight = maxHeight - mapOffsetTop - 40 + 25; // AC: to account for the footer and tab height //var detailsMapHeight = fullMapHeight - 370; var detailsMapHeight = Math.max(fullMapHeight - 370, 200); var height; if (fullMapHeight >= 0) { $('mapPgMainContent').style.height = fullMapHeight + 16 +'px'; $('panel').style.height = (fullMapHeight - 22) + 20 + 'px'; // AC: to account for panel top and bottom padding if (openedDetailTab == '') height = fullMapHeight; else if (openedDetailTab != '' && $('tabContentContainer').style.display=='none') height=fullMapHeight-35; else height = detailsMapHeight; mapElem.style.height = height + 'px'; } if ($('tabContentContainer').style.display!='none') openUp(openedDetailTab); // GW now set the height of the tabContentContainer, normally if (openedDetailTab != '' && $('tabContentContainer').style.display!='none') { if ($('topRight').style.display != 'none') { if (height + 370 >= fullMapHeight && fullMapHeight >= 250) { // 310 $('tabContentContainer').style.height = 318 - (height + 370 - fullMapHeight) + 'px'; $('detailsContainer').style.height = 370 - (height + 370 - fullMapHeight) - 15 + 8 + 'px'; } else { $('tabContentContainer').style.height = '310px'; $('detailsContainer').style.height = '355px'; } } else { $('detailsContainer').style.height = (fullMapHeight - 22) + 20 + 'px'; $('tabContentContainer').style.height = (fullMapHeight - 22) - 25 + 'px'; } } //if (window.attachEvent && !window.XMLHttpRequest) { if ($('topRight').style.display != 'none' && $('map').offsetWidth < 576){ $('detailsContainer').style.width = '576px'; $('detailsContainer').style.position = 'absolute'; } else { $('detailsContainer').style.width = ''; $('detailsContainer').style.position = ''; } //} try{ var formHeight = document.getElementById('showTrailerList').offsetHeight; trailerListHeight = maxHeight - trailerListOffsetTop - formHeight + 14 + 25; // AC: to account for the footer trailerListHeight = trailerListHeight + formHeight - 74; //accounts for a change when the list of options grows }catch(err){ trailerListHeight = maxHeight - trailerListOffsetTop - 78 + 14 + 25; // AC: to account for the footer } if (trailerListHeight >= 0) { trailerListElem.style.height = trailerListHeight + 'px'; } //if (openedDetailTab=='overview') resizeOverviewContent(); } function resizeOverviewContent () { var tccWidth = ($('tabContentContainer')).offsetWidth; if (tccWidth >= 558) { // don't bother calculating if container isn't big enough // used to be -34, now -40 var ovSummWidth = Math.floor((tccWidth - 34)/2); try { // modified to check not throw exception since this is not always available! $('currentStatusInfo').style.width = ovSummWidth + 'px'; $('trailerDetailsInfo').style.width = ovSummWidth + 'px'; } catch (exception) {} } } function openUp(newDetailTab) { if (newDetailTab == '') return; show('detailsContainer'); //show(newDetailTab); } /* Handles the switching of the tabs, including open and close. openedDetailTab is set in the header of the page and remembers which tab is currently open. */ function switchTo(newDetailTab) { var openedDetailTabId = openedDetailTab + 'Tab'; var containerOpen = $('detailsContainer').style.display != 'none'; if (newDetailTab == '') { hide(openedDetailTab); hide('detailsContainer'); } else { show('detailsContainer'); if (!(openedDetailTab == '')) { hide(openedDetailTab); } show(newDetailTab); } openedDetailTab = newDetailTab; if (!containerOpen || openedDetailTab=='' || openedDetailTab=='overview') resizeApp(); return containerOpen; } // GW changed this function since it was really just adding/removing the 'active' string to classnames function updateActiveTab(newDetailTab) { if (newDetailTab == openedDetailTab) return; var newDiv = $(newDetailTab + 'Tab'); var oldDiv = $(openedDetailTab + 'Tab'); if (oldDiv != null && oldDiv) oldDiv.className = oldDiv.className.replace(/\s?active/g,''); if (newDiv != null && newDiv) newDiv.className += ' active'; openedDetailTab = newDetailTab; }