var DDCL_DROPDOWNMODE_INLINE = 0; var DDCL_DROPDOWNMODE_ONTOP = 1; var DDCL_DROPDOWNMODE_ONTOPWITHSHIM = 2; var DDCL_DISPLAYTEXTLIST_LABELS = 0; var DDCL_DISPLAYTEXTLIST_VALUES = 1; ddcl_Objects = new Array(); function DDCL_GetObject(id) { for (var i = 0; i < ddcl_Objects.length; i++) { if (id.substring(0, ddcl_Objects[i].id.length) == ddcl_Objects[i].id) { return ddcl_Objects[i] } } return null }  function DDCL_findPosX(obj) { var curleft = 0; if (obj.offsetParent) { while (obj.offsetParent) { curleft += obj.offsetLeft; obj = obj.offsetParent } } else { if (obj.x) { curleft += obj.x } } return curleft } function DDCL_findPosY(obj) { var curtop = 0; if (obj.offsetParent) { while (obj.offsetParent) { curtop += obj.offsetTop; obj = obj.offsetParent } } else { if (obj.y) { curtop += obj.y } } return curtop } function DDCL_HandleCheckboxClickById(id) { var obj = DDCL_GetObject(id); obj.HandleCheckboxClick() } function DDCL_HandleCheckboxClick(e) { if (!e) { var e = window.event } if (e) { var elem = this; if (elem) { var obj = DDCL_GetObject(elem.id); if (obj) { obj.HandleCheckboxClick(); obj.inCheckboxDiv = true } } } } function DDCL_HandleDisplayBoxClick(e) { if (!e) { var e = window.event } if (e) { var elem = this; if (elem) { var obj = DDCL_GetObject(elem.id); if (obj) { obj.HandleDisplayBoxClick(); obj.inCheckboxDiv = true } } } } function DDCL_HandleCheckboxDivClick(e) { if (!e) { var e = window.event } if (e) { var obj = DDCL_GetObject(this.id); if (obj) { obj.inCheckboxDiv = true } } } function DDCL_HandleDocumentClick(id) { var obj = DDCL_GetObject(id); if (obj) { if (obj.inCheckboxDiv == true) { obj.inCheckboxDiv = false } else { obj.CloseCheckList() } } } function DDCL_DropDownCheckList(id, textWhenNone, separator, truncateString, dropDownMode, allowExpand, displayList) { this.id = id; this.textWhenNone = textWhenNone; this.separator = separator; this.truncateString = truncateString; this.dropDownMode = dropDownMode; this.allowExpand = allowExpand; this.displayList = displayList; this.divCheckboxes = document.getElementById(id + "_checkboxes"); this.divBoundingBox = document.getElementById(id + "_boundingbox"); this.divText = document.getElementById(id + "_text"); this.divDisplayBox = document.getElementById(id + "_displaybox"); this.img = document.getElementById(id + "_img"); this.shim = document.getElementById(id + "_shim"); this.boundingBoxWidth = this.divBoundingBox.offsetWidth; this.divCheckboxes.style.display = "none"; this.divDisplayBox.onclick = DDCL_HandleDisplayBoxClick; this.divCheckboxes.onclick = DDCL_HandleCheckboxDivClick; var e = this.divCheckboxes.getElementsByTagName("input"); for (var i = 0; i < e.length; i++) { if (e[i].type == "checkbox") { e[i].onclick = DDCL_HandleCheckboxClick } } if (document.attachEvent) { document.attachEvent("onclick", function() { eval("DDCL_HandleDocumentClick('" + id + "');") }) } else { if (document.addEventListener) { document.addEventListener("click", function() { eval("DDCL_HandleDocumentClick('" + id + "');") }, false) } } this.DisplayCheckedItems(); ddcl_Objects.push(this) } function DDCL_DropDownCheckList_GetLabelForCheckbox(elem) { var e = this.divCheckboxes.getElementsByTagName("label"); for (var i = 0; i < e.length; i++) { if (e[i].htmlFor == elem.id) { for (var j = 0; j < e[i].childNodes.length; j++) { if (e[i].childNodes[j].nodeType == 3) { return e[i].childNodes[j].nodeValue } } } } return null } function DDCL_DropDownCheckList_DisplayCheckedItems() { var sLabel = ""; var sCurrent = ""; var sFull = ""; var sBefore = ""; var sCompText = ""; var bEllipsisAdded = false; var e = this.divCheckboxes.getElementsByTagName("input"); var eDropDown = document.getElementsByTagName("input"); var strDropDown; var objStatesDropDown = null; var objActivitiesDropDown = null; for (var j = 0; j < eDropDown.length; j++) { if (eDropDown[j].type == "hidden") { strDropDown = eDropDown[j].id; if (strDropDown.indexOf("hidStates") != -1) { objStatesDropDown = eDropDown[j] } else { if (strDropDown.indexOf("hidActivities") != -1) { objActivitiesDropDown = eDropDown[j] } } } } this.divText.innerHTML = ""; this.divDisplayBox.title = ""; var cnt = 0; for (var i = 0; i < e.length; i++) { strDropDown = e[i].id; if (e[i].type == "checkbox" && e[i].checked) { if (this.displayList == DDCL_DISPLAYTEXTLIST_LABELS) { sLabel = this.GetLabelForCheckbox(e[i]) } else { sLabel = e[i].value; if (strDropDown.indexOf("ddlStates") != -1) { if (cnt == 0) { objStatesDropDown.value = "" } objStatesDropDown.value = objStatesDropDown.value + "," + e[i].value; cnt++ } else { if (strDropDown.indexOf("ddlActivities") != -1) { if (cnt == 0) { objActivitiesDropDown.value = "" } if (objActivitiesDropDown.value != "") { objActivitiesDropDown.value = objActivitiesDropDown.value + "," + e[i].value } else { objActivitiesDropDown.value = e[i].value } cnt++ } } } if (sCurrent != "") { sCurrent += this.separator; sFull += this.separator } sFull += sLabel; sCurrent += sLabel; if (bEllipsisAdded == false) { this.divText.innerHTML = "<nobr>" + this.truncateString + "</nobr>"; if (this.divText.offsetWidth > this.boundingBoxWidth && this.allowExpand == false) { while (this.divText.offsetWidth > this.boundingBoxWidth && sCurrent.length > 0) { sCurrent = sCurrent.substr(0, sCurrent.length - 1) } bEllipsisAdded = true } } } else { if (strDropDown.indexOf("ddlStates") != -1) { if (cnt == 0) { objStatesDropDown.value = "" } cnt++ } else { if (strDropDown.indexOf("ddlActivities") != -1) { if (cnt == 0) { objActivitiesDropDown.value = "" } cnt++ } } } } if (this.divText.innerHTML == "") { if (this.textWhenNone == "") { this.divText.innerHTML = "&nbsp;" } else { this.divText.innerHTML = this.textWhenNone } } } function DDCL_DropDownCheckList_HandleCheckboxClick() { this.DisplayCheckedItems() } function DDCL_DropDownCheckList_HandleDisplayBoxClick() { this.ToggleCheckList() } function DDCL_DropDownCheckList_ToggleCheckList() { if (this.divCheckboxes.style.display != "none") { this.CloseCheckList() } else { this.OpenCheckList() } } function DDCL_DropDownCheckList_CloseCheckList() { this.divCheckboxes.style.display = "none"; if (this.dropDownMode == DDCL_DROPDOWNMODE_ONTOPWITHSHIM) { this.shim.style.display = "none" } } function DDCL_DropDownCheckList_OpenCheckList() { if (this.dropDownMode == DDCL_DROPDOWNMODE_INLINE) { this.divCheckboxes.style.display = "block" } else { this.divCheckboxes.style.left = DDCL_findPosX(this.divDisplayBox); this.divCheckboxes.style.top = DDCL_findPosY(this.divDisplayBox) + this.divDisplayBox.offsetHeight; this.divCheckboxes.style.display = "block"; if (this.dropDownMode == DDCL_DROPDOWNMODE_ONTOPWITHSHIM) { this.shim.style.width = this.divCheckboxes.offsetWidth; this.shim.style.height = this.divCheckboxes.offsetHeight; this.shim.style.top = this.divCheckboxes.style.top; this.shim.style.left = this.divCheckboxes.style.left; this.shim.style.zIndex = this.divCheckboxes.style.zIndex - 1; this.shim.style.display = "block" } } } DDCL_DropDownCheckList.prototype.DisplayCheckedItems = DDCL_DropDownCheckList_DisplayCheckedItems; DDCL_DropDownCheckList.prototype.GetLabelForCheckbox = DDCL_DropDownCheckList_GetLabelForCheckbox; DDCL_DropDownCheckList.prototype.HandleCheckboxClick = DDCL_DropDownCheckList_HandleCheckboxClick; DDCL_DropDownCheckList.prototype.HandleDisplayBoxClick = DDCL_DropDownCheckList_HandleDisplayBoxClick; DDCL_DropDownCheckList.prototype.ToggleCheckList = DDCL_DropDownCheckList_ToggleCheckList; DDCL_DropDownCheckList.prototype.CloseCheckList = DDCL_DropDownCheckList_CloseCheckList; DDCL_DropDownCheckList.prototype.OpenCheckList = DDCL_DropDownCheckList_OpenCheckList;
