PageSourceSearch

http://www.681busterminal.com/version2/jscripts/smenu.js

js 681busterminal.com collected 2026-10-02 12:14:07 UTC 11,652 bytes, 378 lines download raw bytes

1
2var menuslidetimer = null;
3
4function Popup_Handler() {
5	this.open_steps = 2;
6	this.open_fade = false;
7	this.active = false;
8	this.menus = new Array();
9	this.activemenu = null;
10	this.hidden_selects = new Array();
11
12	this.activate = function(active) {
13		this.active = active;
14	}
15
16	this.register = function(clickactive, controlkey, noimage) {
17		this.menus[controlkey] = new Popup_Menu(clickactive, controlkey, noimage);
18		return this.menus[controlkey];
19	}
20
21	this.hide = function() {
22		if(this.activemenu != null) this.menus[this.activemenu].hide();
23	}
24}
25
26function Popup_Events() {
27	this.controlobj_show = function(e) {
28		doane(e);
29		clearTimeout(this.slidetimer);
30		if(popupmenu.activemenu == null || popupmenu.menus[popupmenu.activemenu].controlkey != this.id)	{popupmenu.menus[this.id].show(this, false, popupmenu.menus[this.id].clickactive);}
31	}
32
33	this.controlobj_onclick = function(e) {
34		doane(e);
35		if(popupmenu.activemenu == null || popupmenu.menus[popupmenu.activemenu].controlkey != this.id)	{popupmenu.menus[this.id].show(this, false, popupmenu.menus[this.id].clickactive);}
36		else {popupmenu.menus[this.id].hide();}
37	}
38
39	this.controlobj_onmouseover = function(e) {
40		doane(e);
41		popupmenu.menus[this.id].hover(this);
42	}
43
44	this.menuoption_onclick_function = function(e) {
45		this.ofunc(e);
46		popupmenu.menus[this.controlkey].hide();
47	}
48
49	this.menuoption_onclick_link = function(e) {
50		popupmenu.menus[this.controlkey].choose(e, this);
51	}
52
53	this.menuoption_onmouseover = function(e) {
54		this.className = 'popupmenu_highlight';
55	}
56
57	this.menuoption_onmouseout = function(e) {
58		this.className = 'popupmenu_option';
59	}
60}
61
62popupmenu = new Popup_Handler();
63popupevents = new Popup_Events();
64
65function popupmenu_hide(e) {
66	if(e && e.button && e.button != 1 && e.type == 'click')  return true;
67	else popupmenu.hide();
68}
69
70function Popup_Menu(clickactive, controlkey, noimage) {
71	this.controlkey = controlkey;
72	this.clickactive = clickactive;
73	this.menuname = this.controlkey.split('.')[0] + '_menu';
74	if($(this.menuname)) {this.init_menu(clickactive);}
75	this.slide_open = (is_opera ? false : true);
76	this.open_steps = popupmenu.open_steps;
77
78	this.init_control = function(noimage) {
79		this.controlobj = $(this.controlkey);
80		this.controlobj.state = false;
81		if(this.controlobj.firstChild && (this.controlobj.firstChild.tagName == 'TEXTAREA' || this.controlobj.firstChild.tagName == 'INPUT')) {
82		} else {
83			if(!this.clickactive && !noimage && !(is_mac && is_ie)) {
84				var img = document.createElement('img');
85				img.src = 'jsmenu.gif';
86				img.border = 0;
87				img.title = '';
88				img.alt = '';
89				//this.controlobj.appendChild(img);
90			}
91			this.controlobj.unselectable = true;
92			if(!noimage) {
93				this.controlobj.style.cursor = is_ie ? 'hand' : 'pointer';
94			}
95			if(clickactive) {
96				this.controlobj.onclick = popupevents.controlobj_onclick;
97				this.controlobj.onmouseover = popupevents.controlobj_onmouseover;
98			} else {
99				this.controlobj.onmouseover = popupevents.controlobj_show;
100			}
101		}
102	}
103
104	this.init_control( noimage);
105
106	this.init_menu = function() {
107		this.menuobj = $(this.menuname);
108		if(this.menuobj && !this.menuobj.initialized) {
109			this.menuobj.initialized = true;
110			this.menuobj.onclick = ebygum;
111			this.menuobj.style.position = 'absolute';
112			if(!this.clickactive) {
113				this.menuobj.onmouseover = function() {
114					clearTimeout(menuslidetimer);
115				}
116				this.menuobj.onmouseout = function() {
117					menuslidetimer = setTimeout("menuhide()",500);
118				}
119			}
120			this.menuobj.style.zIndex = 50;
121			if(is_ie && !is_mac) {
122				this.menuobj.style.filter += "progid:DXImageTransform.Microsoft.shadow(direction=135,color=#cccccc,strength=2)";
123			}
124			this.init_menu_contents();
125		}
126	}
127
128	this.init_menu_contents = function() {
129		var tds = findtags(this.menuobj, 'td');
130		for(var i = 0; i < tds.length; i++) {
131			if(tds[i].className == 'popupmenu_option' || tds[i].className == 'editor_colornormal') {
132				if(is_ie && !is_mac) {
133					tds[i].style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity=85,finishOpacity=100,style=0)";
134				}
135				tds[i].style.opacity = 0.85;
136				if(tds[i].title && tds[i].title == 'nohighlight') {
137					tds[i].title = '';
138				} else {
139					tds[i].controlkey = this.controlkey;
140					if(tds[i].className != 'editor_colornormal') {
141						tds[i].onmouseover = popupevents.menuoption_onmouseover;
142						tds[i].onmouseout = popupevents.menuoption_onmouseout;
143					}
144					if(typeof tds[i].onclick == 'function') {
145						tds[i].ofunc = tds[i].onclick;
146						tds[i].onclick = popupevents.menuoption_onclick_function;
147					} else {
148						tds[i].onclick = popupevents.menuoption_onclick_link;
149					}
150					if(!is_saf && !is_kon)	{
151						try {
152							links = findtags(tds[i], 'a');
153							for(var j = 0; j < links.length; j++) {
154								if(typeof links[j].onclick  == 'undefined') links[j].onclick = ebygum;
155							}
156						}
157						catch(e) {}
158					}
159				}
160			}
161		}
162	}
163
164	this.show = function(obj, instant) { 
165		if(!popupmenu.active){return false;}
166		else if(!this.menuobj)	{ this.init_menu();}
167		if(!this.menuobj) {return false;}
168            
169		if(popupmenu.activemenu != null) { popupmenu.menus[popupmenu.activemenu].hide();}
170		popupmenu.activemenu = this.controlkey;
171		this.menuobj.style.display = '';
172		if(popupmenu.slide_open) 
173            { this.menuobj.style.clip = 'rect(auto, auto, auto, auto)';
174            }
175		this.pos = this.fetch_offset(obj);
176		this.leftpx = this.pos['left'];
177		this.toppx = this.pos['top'] + obj.offsetHeight;
178		if((this.leftpx + this.menuobj.offsetWidth) >= document.body.clientWidth && (this.leftpx + obj.offsetWidth - this.menuobj.offsetWidth) > 0) {
179			this.leftpx = this.leftpx + obj.offsetWidth - this.menuobj.offsetWidth;
180			this.direction = 'right';
181		} else {this.direction = 'left';}
182		this.menuobj.style.left = this.leftpx + 'px';
183		this.menuobj.style.top  = (this.toppx-4) + 'px';
184		if(!instant && this.slide_open) {
185			this.intervalX = Math.ceil(this.menuobj.offsetWidth / this.open_steps);
186			this.intervalY = Math.ceil(this.menuobj.offsetHeight / this.open_steps);
187			this.slide((this.direction == 'left' ? 0 : this.menuobj.offsetWidth), 0, 0);
188		} else if(this.menuobj.style.clip && popupmenu.slide_open) {
189			this.menuobj.style.clip = 'rect(auto, auto, auto, auto)';
190		}
191     
192		this.handle_overlaps(true);
193		if(this.menuobj.scrollHeight > 400) {
194			this.menuobj.style.height = '400px';
195			if(is_ie || is_opera) {
196				this.menuobj.style.width = this.menuobj.scrollWidth + 18;
197			}
198			if(is_opera) {
199				this.menuobj.style.overflow = 'scroll';
200			} else {
201				this.menuobj.style.overflowY = 'scroll';
202			}
203		}
204	}
205
206	this.hide = function(e) {
207		if(e && e.button && e.button != 1) {return true;}
208		this.stop_slide();
209		this.menuobj.style.display = 'none';
210		this.handle_overlaps(false);
211		popupmenu.activemenu = null;
212	}
213
214	this.slidehide = function() {
215		popupmenu.menus[popupmenu.activemenu].hide()
216	}
217
218	this.hover = function(obj, clickactive) {
219		if(popupmenu.activemenu != null) {
220			if(popupmenu.menus[popupmenu.activemenu].controlkey != this.id) {this.show(obj, true, clickactive);}
221		}
222	}
223
224	this.choose = function(e, obj) {
225		var links = findtags(obj, 'a');
226		if(links[0]) {
227			if(is_ie) {
228				links[0].click();
229				window.event.cancelBubble = true;
230			} else {
231				if(e.shiftKey) {
232					window.open(links[0].href);
233					e.stopPropagation();
234					e.preventDefault();
235				} else {
236					window.location = links[0].href;
237					e.stopPropagation();
238					e.preventDefault();
239				}
240			}
241			this.hide();
242		}
243	}
244
245	this.slide = function(clipX, clipY, opacity) {
246		if(this.direction == 'left' && (clipX < this.menuobj.offsetWidth || clipY < this.menuobj.offsetHeight)) {
247			if(popupmenu.open_fade && is_ie) {
248				opacity += 10;
249				this.menuobj.filters.item('DXImageTransform.Microsoft.alpha').opacity = opacity;
250			}
251			clipX += this.intervalX;
252			clipY += this.intervalY;
253			this.menuobj.style.clip = "rect(auto, " + clipX + "px, " + clipY + "px, auto)";
254			this.slidetimer = setTimeout("popupmenu.menus[popupmenu.activemenu].slide(" + clipX + ", " + clipY + ", " + opacity + ");", 0);
255		} else if(this.direction == 'right' && (clipX > 0 || clipY < this.menuobj.offsetHeight)) {
256			if(popupmenu.open_fade && is_ie) {
257				opacity += 10;
258				menuobj.filters.item('DXImageTransform.Microsoft.alpha').opacity = opacity;
259			}
260			clipX -= this.intervalX;
261			clipY += this.intervalY;
262			this.menuobj.style.clip = "rect(auto, " + this.menuobj.offsetWidth + "px, " + clipY + "px, " + clipX + "px)";
263			this.slidetimer = setTimeout("popupmenu.menus[popupmenu.activemenu].slide(" + clipX + ", " + clipY + ", " + opacity + ");", 0);
264		} else {this.stop_slide();}
265	}
266
267	this.stop_slide = function() {
268		clearTimeout(this.slidetimer);
269		this.menuobj.style.clip = 'rect(auto, auto, auto, auto)';
270		if(popupmenu.open_fade && is_ie) {this.menuobj.filters.item('DXImageTransform.Microsoft.alpha').opacity = 100;}
271	}
272
273	this.fetch_offset = function(obj) {
274		var left_offset = obj.offsetLeft;
275		var top_offset = obj.offsetTop;
276		while ((obj = obj.offsetParent) != null) {
277			left_offset += obj.offsetLeft;
278			top_offset += obj.offsetTop;
279		}
280		return { 'left' : left_offset, 'top' : top_offset };
281	}
282
283	this.overlaps = function(obj, m) {
284		var s = new Array();
285		var pos = this.fetch_offset(obj);
286		s['L'] = pos['left'];
287		s['T'] = pos['top'];
288		s['R'] = s['L'] + obj.offsetWidth;
289		s['B'] = s['T'] + obj.offsetHeight;
290		if(s['L'] > m['R'] || s['R'] < m['L'] || s['T'] > m['B'] || s['B'] < m['T']) {return false;}
291		return true;
292	}
293
294	this.handle_overlaps = function(dohide) {
295		if(is_ie) {
296			var selects = findtags(document, 'select');
297			if(dohide) {
298				var menuarea = new Array(); menuarea = {
299					'L' : this.leftpx,
300					'R' : this.leftpx + this.menuobj.offsetWidth,
301					'T' : this.toppx,
302					'B' : this.toppx + this.menuobj.offsetHeight
303				};
304				for(var i = 0; i < selects.length; i++) {
305					if(this.overlaps(selects[i], menuarea)) {
306						var hide = true;
307						var s = selects[i];
308						while (s = s.parentNode) {
309							if(s.className == 'popupmenu_popup') {
310								hide = false;
311								break;
312							}
313						}
314						if(hide) {
315							selects[i].style.visibility = 'hidden';
316							arraypush(popupmenu.hidden_selects, i);
317						}
318					}
319				}
320			} else {
321				while (true) {
322					var i = arraypop(popupmenu.hidden_selects);
323					if(typeof i == 'undefined' || i == null) break;
324					else selects[i].style.visibility = 'visible';
325				}
326			}
327		}
328	}
329}
330
331function doane(eventobj) {
332	if(!eventobj || is_ie)	{
333		window.event.returnValue = false;
334		window.event.cancelBubble = true;
335		return window.event;
336	} else {
337		eventobj.stopPropagation();
338		eventobj.preventDefault();
339		return eventobj;
340	}
341}
342
343function ebygum(eventobj) {
344	if(!eventobj || is_ie) {
345		window.event.cancelBubble = true;
346		return window.event;
347	} else {
348		if(eventobj.target.type == 'submit')  eventobj.target.form.submit();
349		eventobj.stopPropagation();
350		return eventobj;
351	}
352}
353
354function menuregister(clickactive, controlid, noimage, datefield) {
355	if(typeof popupmenu == 'object') {
356		popupmenu.register(clickactive, controlid, noimage);
357	}
358}
359
360function menuhide() {
361	if(popupmenu.activemenu != null) {
362		popupmenu.menus[popupmenu.activemenu].slidehide();
363	}
364}
365
366if(typeof popupmenu == 'object') {
367	if(window.attachEvent && !is_saf) {
368		document.attachEvent('onclick', popupmenu_hide);
369		window.attachEvent('onresize', popupmenu_hide);
370	} else if(document.addEventListener && !is_saf) {
371		document.addEventListener('click', popupmenu_hide, false);
372		window.addEventListener('resize', popupmenu_hide, false);
373	} else {
374		window.onclick = popupmenu_hide;
375		window.onresize = popupmenu_hide;
376	}
377	popupmenu.activate(true);
378}

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.