1//Drop Down/ Overlapping Content: http://www.dynamicdrive.com 2//**Updated: Dec 19th, 07': Added ability to dynamically populate a Drop Down content using an external file (Ajax feature) 3//**Updated: Feb 29th, 08': 4 //1) Added ability to reveal drop down content via "click" of anchor link (instead of default "mouseover") 5 //2) Added ability to disable drop down content from auto hiding when mouse rolls out of it 6 //3) Added hidediv(id) public function to directly hide drop down div dynamically 7 8//**Updated: Sept 11th, 08': Fixed bug whereby drop down content isn't revealed onClick of anchor in Safari/ Google Chrome 9//**Updated: April 9th, 10': Minor change 10 11var dropdowncontent={ 12 disableanchorlink: true, //when user clicks on anchor link, should link itself be disabled (always true if "revealbehavior" above set to "click") 13 hidedivmouseout: [true, 2000], //Set hiding behavior within Drop Down DIV itself: [hide_div_onmouseover?, miliseconds_before_hiding] 14 ajaxloadingmsg: "Loading content. Please wait...", //HTML to show while ajax page is being feched, if applicable 15 ajaxbustcache: true, //Bust cache when fetching Ajax pages? 16 17 getposOffset:function(what, offsettype){ 18 return (what.offsetParent)? what[offsettype]+this.getposOffset(what.offsetParent, offsettype) : what[offsettype] 19 }, 20 21 isContained:function(m, e){ 22 var e=window.event || e 23 var c=e.relatedTarget || ((e.type=="mouseover")? e.fromElement : e.toElement) 24 while (c && c!=m)try {c=c.parentNode} catch(e){c=m} 25 if (c==m) 26 return true 27 else 28 return false 29 }, 30 31 show:function(anchorobj, subobj, e){ 32 if (!this.isContained(anchorobj, e) || (e && e.type=="click")){ 33 var e=window.event || e 34 if (e.type=="click" && subobj.style.visibility=="visible"){ 35 subobj.style.visibility="hidden" 36 return 37 } 38 39 var horizontaloffset=(subobj.dropposition[0]=="left")? -(subobj.offsetWidth-anchorobj.offsetWidth) : 0 //calculate user added horizontal offset 40 var verticaloffset=(subobj.dropposition[1]=="top")? -subobj.offsetHeight : anchorobj.offsetHeight //calculate user added vertical offset 41 subobj.style.left=this.getposOffset(anchorobj, "offsetLeft") + horizontaloffset + "px" 42 subobj.style.top=this.getposOffset(anchorobj, "offsetTop")+verticaloffset+"px" 43 subobj.style.clip=(subobj.dropposition[1]=="top")? "rect(auto auto auto 0)" : "rect(0 auto 0 0)" //hide drop down box initially via clipping 44 subobj.style.visibility="visible" 45 subobj.startTime=new Date().getTime() 46 subobj.contentheight=parseInt(subobj.offsetHeight) 47 if (typeof window["hidetimer_"+subobj.id]!="undefined") //clear timer that hides drop down box? 48 clearTimeout(window["hidetimer_"+subobj.id]) 49 this.slideengine(subobj, (subobj.dropposition[1]=="top")? "up" : "down") 50 } 51 }, 52 53 curveincrement:function(percent){ 54 return (1-Math.cos(percent*Math.PI)) / 2 //return cos curve based value from a percentage input 55 }, 56 57 slideengine:function(obj, direction){ 58 var elapsed=new Date().getTime()-obj.startTime //get time animation has run 59 if (elapsed<obj.glidetime){ //if time run is less than specified length 60 var distancepercent=(direction=="down")? this.curveincrement(elapsed/obj.glidetime) : 1-this.curveincrement(elapsed/obj.glidetime) 61 var currentclip=(distancepercent*obj.contentheight)+"px" 62 obj.style.clip=(direction=="down")? "rect(0 auto "+currentclip+" 0)" : "rect("+currentclip+" auto auto 0)" 63 window["glidetimer_"+obj.id]=setTimeout(function(){dropdowncontent.slideengine(obj, direction)}, 10) 64 } 65 else{ //if animation finished 66 obj.style.clip="rect(0 auto auto 0)" 67 } 68 }, 69 70 hide:function(activeobj, subobj, e){ 71 if (!dropdowncontent.isContained(activeobj, e)){ 72 window["hidetimer_"+subobj.id]=setTimeout(function(){ 73 subobj.style.visibility="hidden" 74 subobj.style.left=subobj.style.top=0 75 clearTimeout(window["glidetimer_"+subobj.id]) 76 }, dropdowncontent.hidedivmouseout[1]) 77 } 78 }, 79 80 hidediv:function(subobjid){ 81 document.getElementById(subobjid).style.visibility="hidden" 82 }, 83 84 ajaxconnect:function(pageurl, divId){ 85 var page_request = false 86 var bustcacheparameter="" 87 if (window.XMLHttpRequest) // if Mozilla, IE7, Safari etc 88 page_request = new XMLHttpRequest() 89 else if (window.ActiveXObject){ // if IE6 or below 90 try { 91 page_request = new ActiveXObject("Msxml2.XMLHTTP") 92 } 93 catch (e){
94 try{ 95 page_request = new ActiveXObject("Microsoft.XMLHTTP") 96 } 97 catch (e){} 98 } 99 } 100 else 101 return false 102 document.getElementById(divId).innerHTML=this.ajaxloadingmsg //Display "fetching page message" 103 page_request.onreadystatechange=function(){dropdowncontent.loadpage(page_request, divId)} 104 if (this.ajaxbustcache) //if bust caching of external page 105 bustcacheparameter=(pageurl.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime() 106 page_request.open('GET', pageurl+bustcacheparameter, true) 107 page_request.send(null) 108 }, 109 110 loadpage:function(page_request, divId){ 111 if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){ 112 document.getElementById(divId).innerHTML=page_request.responseText 113 } 114 }, 115 116 init:function(anchorid, pos, glidetime, revealbehavior){ 117 var anchorobj=document.getElementById(anchorid) 118 if (anchorobj) 119 var subobj=document.getElementById(anchorobj.getAttribute("rel")) 120 if (!anchorobj || !subobj) 121 return 122 123 var subobjsource=anchorobj.getAttribute("rev") 124 if (subobjsource!=null && subobjsource!="") 125 this.ajaxconnect(subobjsource, anchorobj.getAttribute("rel")) 126 127 subobj.dropposition=pos.split("-") 128 subobj.glidetime=glidetime || 1000 129 subobj.style.left=subobj.style.top=0 130 if (typeof revealbehavior=="undefined" || revealbehavior=="mouseover"){ 131 anchorobj.onmouseover=function(e){dropdowncontent.show(this, subobj, e)} 132 anchorobj.onmouseout=function(e){dropdowncontent.hide(subobj, subobj, e)} 133 if (this.disableanchorlink) anchorobj.onclick=function(){return false} 134 } 135 else 136 anchorobj.onclick=function(e){dropdowncontent.show(this, subobj, e); return false} 137 138 if (this.hidedivmouseout[0]==true) //hide drop down DIV when mouse rolls out of it? 139 subobj.onmouseout=function(e){dropdowncontent.hide(this, subobj, e)} 140 } 141}
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.