PageSourceSearch

https://www.andersonandlow.com/chromejs/chrome.js

js andersonandlow.com collected 2026-10-04 00:26:02 UTC 9,099 bytes, 209 lines download raw bytes

1//** Chrome Drop Down Menu- Author: Dynamic Drive (http://www.dynamicdrive.com)
2
3//** Updated: July 14th 06' to v2.0
4	//1) Ability to "left", "center", or "right" align the menu items easily, just by modifying the CSS property "text-align".
5	//2) Added an optional "swipe down" transitional effect for revealing the drop down menus.
6	//3) Support for multiple Chrome menus on the same page.
7
8//** Updated: Nov 14th 06' to v2.01- added iframe shim technique
9
10//** Updated: July 23rd, 08 to v2.4
11	//1) Main menu items now remain "selected" (CSS class "selected" applied) when user moves mouse into corresponding drop down menu. 
12	//2) Adds ability to specify arbitrary HTML that gets added to the end of each menu item that carries a drop down menu (ie: a down arrow image).
13	//3) All event handlers added to the menu are now unobstrusive, allowing you to define your own "onmouseover" or "onclick" events on the menu items.
14	//4) Fixed elusive JS error in FF that sometimes occurs when mouse quickly moves between main menu items and drop down menus
15
16//** Updated: Oct 29th, 08 to v2.5 (only .js file modified from v2.4)
17	//1) Added ability to customize reveal animation speed (# of steps)
18	//2) Menu now works in IE8 beta2 (a valid doctype at the top of the page is required)
19
20var cssdropdown={
21disappeardelay: 250, //set delay in miliseconds before menu disappears onmouseout
22dropdownindicator: '<img src="/art/cleardot.png" border="0" />', //specify full HTML to add to end of each menu item with a drop down menu
23enablereveal: [true, 8], //enable swipe effect? [true/false, steps (Number of animation steps. Integer between 1-20. Smaller=faster)]
24enableiframeshim: 1, //enable "iframe shim" in IE5.5 to IE7? (1=yes, 0=no)
25
26//No need to edit beyond here////////////////////////
27
28dropmenuobj: null, asscmenuitem: null, domsupport: document.all || document.getElementById, standardbody: null, iframeshimadded: false, revealtimers: {},
29
30getposOffset:function(what, offsettype){
31	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
32	var parentEl=what.offsetParent;
33	while (parentEl!=null){
34		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
35		parentEl=parentEl.offsetParent;
36	}
37	return totaloffset;
38},
39
40css:function(el, targetclass, action){
41	var needle=new RegExp("(^|\\s+)"+targetclass+"($|\\s+)", "ig")
42	if (action=="check")
43		return needle.test(el.className)
44	else if (action=="remove")
45		el.className=el.className.replace(needle, "")
46	else if (action=="add" && !needle.test(el.className))
47		el.className+=" "+targetclass
48},
49
50showmenu:function(dropmenu, e){
51	if (this.enablereveal[0]){
52		if (!dropmenu._trueheight || dropmenu._trueheight<10)
53			dropmenu._trueheight=dropmenu.offsetHeight
54		clearTimeout(this.revealtimers[dropmenu.id])
55		dropmenu.style.height=dropmenu._curheight=0
56		dropmenu.style.height="auto"
57		dropmenu.style.maxHeight="calc(100vh - 10px)"
58		dropmenu.style.overflow="hidden"
59		dropmenu.style.visibility="visible"
60		this.revealtimers[dropmenu.id]=setInterval(function(){cssdropdown.revealmenu(dropmenu)}, 10)
61	}
62	else{
63		dropmenu.style.visibility="visible"
64	}
65	this.css(this.asscmenuitem, "selected", "add")
66},
67
68revealmenu:function(dropmenu, dir){
69	var curH=dropmenu._curheight, maxH=dropmenu._trueheight, steps=this.enablereveal[1]
70	if (curH<maxH){
71		var newH=Math.min(curH, maxH)
72		dropmenu.style.height=newH+"px"
73		dropmenu._curheight= newH + Math.round((maxH-newH)/steps) + 1
74	}
75	else{ //if done revealing menu
76		dropmenu.style.height="auto"
77		dropmenu.style.maxHeight="calc(100vh - 10px)"
78		dropmenu.style.overflow="auto"
79		clearInterval(this.revealtimers[dropmenu.id])
80	}
81},
82
83clearbrowseredge:function(obj, whichedge){
84	var edgeoffset=0
85	if (whichedge=="rightedge"){
86		var windowedge=document.all && !window.opera? this.standardbody.scrollLeft+this.standardbody.clientWidth-15 : window.pageXOffset+window.innerWidth-15
87		var dropmenuW=this.dropmenuobj.offsetWidth
88		if (windowedge-this.dropmenuobj.x < dropmenuW)  //move menu to the left?
89			edgeoffset=dropmenuW-obj.offsetWidth
90	}
91	else{
92		var topedge=document.all && !window.opera? this.standardbody.scrollTop : window.pageYOffset
93		var windowedge=document.all && !window.opera? this.standardbody.scrollTop+this.standardbody.clientHeight-15 : window.pageYOffset+window.innerHeight-18
94		var dropmenuH=this.dropmenuobj._trueheight
95		if (windowedge-this.dropmenuobj.y < dropmenuH){ //move up?
96			edgeoffset=dropmenuH+obj.offsetHeight
97			if ((this.dropmenuobj.y-topedge)<dropmenuH) //up no good either?
98				edgeoffset=this.dropmenuobj.y+obj.offsetHeight-topedge
99		}
100	}
101	return edgeoffset
102},
103
104dropit:function(obj, e, dropmenuID){
105	if (this.dropmenuobj!=null) //hide previous menu
106		this.hidemenu() //hide menu
107	this.clearhidemenu()
108	this.dropmenuobj=document.getElementById(dropmenuID) //reference drop down menu
109	this.asscmenuitem=obj //reference associated menu item
110	this.showmenu(this.dropmenuobj, e)
111	this.dropmenuobj.x=this.getposOffset(obj, "left")
112	this.dropmenuobj.y=this.getposOffset(obj, "top")
113	this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(obj, "rightedge")+"px"
114	this.dropmenuobj.style.top=this.dropmenuobj.y-this.clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+1+"px"
115	this.positionshim() //call iframe shim function
116},
117
118positionshim:function(){ //display iframe shim function
119	if (this.iframeshimadded){
120		if (this.dropmenuobj.style.visibility=="visible"){
121			this.shimobject.style.width=this.dropmenuobj.offsetWidth+"px"
122			this.shimobject.style.height=this.dropmenuobj._trueheight+"px"
123			this.shimobject.style.left=parseInt(this.dropmenuobj.style.left)+"px"
124			this.shimobject.style.top=parseInt(this.dropmenuobj.style.top)+"px"
125			this.shimobject.style.display="block"
126		}
127	}
128},
129
130hideshim:function(){
131	if (this.iframeshimadded)
132		this.shimobject.style.display='none'
133},
134
135isContained:function(m, e){
136	var e=window.event || e
137	var c=e.relatedTarget || ((e.type=="mouseover")? e.fromElement : e.toElement)
138	while (c && c!=m)try {c=c.parentNode} catch(e){c=m}
139	if (c==m)
140		return true
141	else
142		return false
143},
144
145dynamichide:function(m, e){
146	if (!this.isContained(m, e)){
147		this.delayhidemenu()
148	}
149},
150
151delayhidemenu:function(){
152	this.delayhide=setTimeout("cssdropdown.hidemenu()", this.disappeardelay) //hide menu
153},
154
155hidemenu:function(){
156	this.css(this.asscmenuitem, "selected", "remove")
157	this.dropmenuobj.style.visibility='hidden'
158	this.dropmenuobj.style.left=this.dropmenuobj.style.top="-1000px"
159	this.hideshim()
160},
161
162clearhidemenu:function(){
163	if (this.delayhide!="undefined")
164		clearTimeout(this.delayhide)
165},
166
167addEvent:function(target, functionref, tasktype){
168	if (target.addEventListener)
169		target.addEventListener(tasktype, functionref, false);
170	else if (target.attachEvent)
171		target.attachEvent('on'+tasktype, function(){return functionref.call(target, window.event)});
172},
173
174startchrome:function(){
175	if (!this.domsupport)
176		return
177	this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
178	for (var ids=0; ids<arguments.length; ids++){
179		var menuitems=document.getElementById(arguments[ids]).getElementsByTagName("a")
180		for (var i=0; i<menuitems.length; i++){
181			if (menuitems[i].getAttribute("rel")){
182				var relvalue=menuitems[i].getAttribute("rel")
183				var asscdropdownmenu=document.getElementById(relvalue)
184				this.addEvent(asscdropdownmenu, function(){cssdropdown.clearhidemenu()}, "mouseover")
185				this.addEvent(asscdropdownmenu, function(e){cssdropdown.dynamichide(this, e)}, "mouseout")
186				this.addEvent(asscdropdownmenu, function(){cssdropdown.delayhidemenu()}, "click")
187				try{
188					menuitems[i].innerHTML=menuitems[i].innerHTML// +" "+this.dropdownindicator
189				}catch(e){}
190				this.addEvent(menuitems[i], function(e){ //show drop down menu when main menu items are mouse over-ed
191					if (!cssdropdown.isContained(this, e)){
192						var evtobj=window.event || e
193						cssdropdown.dropit(this, evtobj, this.getAttribute("rel"))
194					}
195				}, "mouseover")
196				this.addEvent(menuitems[i], function(e){cssdropdown.dynamichide(this, e)}, "mouseout") //hide drop down menu when main menu items are mouse out
197				this.addEvent(menuitems[i], function(){cssdropdown.delayhidemenu()}, "click") //hide drop down menu when main menu items are clicked on
198			}
199		} //end inner for
200	} //end outer for
201	if (this.enableiframeshim && document.all && !window.XDomainRequest && !this.iframeshimadded){ //enable iframe shim in IE5.5 thru IE7?
202		document.write('<IFRAME id="iframeshim" src="about:blank" frameBorder="0" scrolling="auto" style="left:0; top:0; position:absolute; display:none;z-index:90; background: transparent;"></IFRAME>')
203		this.shimobject=document.getElementById("iframeshim") //reference iframe object
204		this.shimobject.style.filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)'
205		this.iframeshimadded=true
206	}
207} //end startchrome
208
209}

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.