1function OlbCascadingCheckBoxTree(ControlID, PropageteDown, PropageteUp) { 2 var ParentControl = document.getElementById(ControlID); 3 if (PropageteDown == null) PropageteDown = true; 4 if (PropageteUp == null) PropageteUp = true; 5 Initialize(); 6 7 function Initialize() { 8 var ChildChkBoxes = ParentControl.getElementsByTagName("input"); 9 for (var i = 0; i < ChildChkBoxes.length; i++) { 10 var Chk = ChildChkBoxes[i]; 11 if (Chk.type == "checkbox") { 12 CheckUncheckParents(Chk, Chk.checked); 13 if (Chk.checked) { 14 PropagateToChildren(Chk); 15 } 16 } 17 } 18 } 19 20 jQuery("#" + ControlID).click( 21 function() { 22 var Src = window.event != window.undefined ? window.event.srcElement : evt.target; 23 if (Src.tagName.toLowerCase() == "input" && Src.type == "checkbox") { //It's a checkbox 24 PropagateToChildren(Src); 25 CheckUncheckParents(Src, Src.checked); 26 } 27 } 28 ); 29 30 function PropagateToChildren(Chk) { 31 if (!PropageteDown) return; 32 33 var ParentTable = GetParentByTagName("table", Chk); 34 var NextSibling = ParentTable.nextSibling; 35 if (NextSibling && NextSibling.nodeType == 1) { //The next sibling is not null & is an element node 36 if (NextSibling.tagName.toLowerCase() == "div") { //The node has children 37 //check or uncheck children at all levels 38 CheckUncheckChildren(NextSibling, Chk.checked); 39 } 40 } 41 } 42 43 function CheckUncheckChildren(ChildContainer, Check) { 44 var ChildChkBoxes = ChildContainer.getElementsByTagName("input"); 45 for (var i = 0; i < ChildChkBoxes.length; i++) { 46 ChildChkBoxes[i].checked = Check; 47 } 48 } 49 50 function CheckUncheckParents(SourceChild, Check) 51 { 52 if (!PropageteUp) return; 53 54 var ParentDiv = GetParentByTagName("div", SourceChild); 55 var ParentNodeTable = ParentDiv.previousSibling; 56 57 if (ParentNodeTable){ 58 if(Check && !AreAllSiblingsChecked(SourceChild)) { //Nothing needs changed 59 return 60 } 61 62 var inpElemsInParentTable = ParentNodeTable.getElementsByTagName("input"); 63 if (inpElemsInParentTable.length > 0){ 64 var ParentNodeChkBox = inpElemsInParentTable[0]; 65 ParentNodeChkBox.checked = Check; 66 //Do the same recursively 67 CheckUncheckParents(ParentNodeChkBox, Check); 68 } 69 } 70 } 71 72 function AreAllSiblingsChecked(ChkBox) { 73 var ParentDiv = GetParentByTagName("div", ChkBox); 74 var ChildCount = ParentDiv.childNodes.length; 75 for(var i=0; i < ChildCount; i++){ 76 if(ParentDiv.childNodes[i].nodeType == 1){ //The child node is an element node 77 if(ParentDiv.childNodes[i].tagName.toLowerCase() == "table"){ 78 var prevChkBox = ParentDiv.childNodes[i].getElementsByTagName("input")[0]; 79 //If any of sibling nodes are not checked, return false 80 if(!prevChkBox.checked){ 81 return false; 82 } 83 } 84 } 85 } 86 return true; 87 } 88 89 function GetParentByTagName(ParentTagName, ChildElementObj) { 90 var Parent = ChildElementObj.parentNode; 91 while (Parent.tagName.toLowerCase() != ParentTagName.toLowerCase()) 92 { 93 Parent = Parent.parentNode; 94 } 95 return Parent; 96 97 } 98}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.