vBulletin.add_event("vBmenuShow"); vBulletin.add_event("vBmenuHide"); function vB_Popup_Handler() { this.open_steps = 10; this.open_fade = false; this.active = false; this.menus = new Array(); this.activemenu = null; this.hidden_selects = new Array(); }; vB_Popup_Handler.prototype.activate = function(active) { this.active = active; }; vB_Popup_Handler.prototype.register = function(controlkey, noimage, noslide) { this.menus[controlkey] = new vB_Popup_Menu(controlkey, noimage, noslide); return this.menus[controlkey]; }; vB_Popup_Handler.prototype.hide = function() { if (this.activemenu != null) { //this.activemenu.hide(); this.menus[this.activemenu].hide(); } }; var vBmenu = new vB_Popup_Handler(); function vbmenu_hide(e) { if (e && e.button && e.button != 1 && e.type == 'click') { return true; } else { vBmenu.hide(); } }; function vB_Popup_Menu(controlkey, noimage, noslide) { this.controlkey = controlkey; this.menuname = this.controlkey.split('.')[0] + '_menu'; this.init_control(noimage); if (fetch_object(this.menuname)) { this.init_menu(); } this.slide_open = ((is_opera || noslide) ? false : true); this.open_steps = vBmenu.open_steps; vBulletin.add_event("vBmenuShow_" + this.controlkey); vBulletin.add_event("vBmenuHide_" + this.controlkey); }; vB_Popup_Menu.prototype.init_control = function(noimage) { this.controlobj = fetch_object(this.controlkey); this.controlobj.state = false; if (this.controlobj.firstChild && (this.controlobj.firstChild.tagName == 'TEXTAREA' || this.controlobj.firstChild.tagName == 'INPUT')) { // do nothing } else { if (!noimage && !(is_mac && is_ie)) { var space = document.createTextNode(' '); this.controlobj.appendChild(space); var img = document.createElement('img'); img.src = IMGDIR_MISC + '/menu_open.gif'; img.border = 0; img.title = ''; img.alt = ''; this.controlobj.appendChild(img); } this.controlobj.unselectable = true; if (!noimage) { this.controlobj.style.cursor = pointer_cursor; } this.controlobj.onclick = vB_Popup_Events.prototype.controlobj_onclick; this.controlobj.onmouseover = vB_Popup_Events.prototype.controlobj_onmouseover; } }; vB_Popup_Menu.prototype.init_menu = function() { this.menuobj = fetch_object(this.menuname); if (this.menuobj && !this.menuobj.initialized) { this.menuobj.initialized = true; this.menuobj.onclick = e_by_gum; this.menuobj.style.position = 'absolute'; this.menuobj.style.zIndex = 50; // init popup filters (ie only) if (is_ie && !is_mac) { this.menuobj.style.filter += "progid:DXImageTransform.Microsoft.alpha(enabled=1,opacity=100)"; this.menuobj.style.filter += "progid:DXImageTransform.Microsoft.shadow(direction=135,color=#8E8E8E,strength=3)"; } this.init_menu_contents(); } }; vB_Popup_Menu.prototype.init_menu_contents = function() { var tds = fetch_tags(this.menuobj, 'td'); for (var i = 0; i < tds.length; i++) { if (tds[i].className == 'vbmenu_option') { if (tds[i].title && tds[i].title == 'nohilite') { // not an active cell tds[i].title = ''; } else { // create a reference back to the menu class tds[i].controlkey = this.controlkey; // handle mouseover / mouseout highlighting events tds[i].onmouseover = vB_Popup_Events.prototype.menuoption_onmouseover; tds[i].onmouseout = vB_Popup_Events.prototype.menuoption_onmouseout; var links = fetch_tags(tds[i], 'a'); if (links.length == 1) { tds[i].className = tds[i].className + ' vbmenu_option_alink'; tds[i].islink = true; var linkobj = links[0]; var remove_link = false; tds[i].target = linkobj.getAttribute('target'); if (typeof linkobj.onclick == 'function') { tds[i].ofunc = linkobj.onclick; tds[i].onclick = vB_Popup_Events.prototype.menuoption_onclick_function; remove_link = true; } else if (typeof tds[i].onclick == 'function') { tds[i].ofunc = tds[i].onclick; tds[i].onclick = vB_Popup_Events.prototype.menuoption_onclick_function; remove_link = true; } else { tds[i].href = linkobj.href; tds[i].onclick = vB_Popup_Events.prototype.menuoption_onclick_link; } if (remove_link) { var newlink = document.createElement('a'); newlink.innerHTML = linkobj.innerHTML; newlink.href = '#'; newlink.onclick = function(e) { e = e ? e : window.event; e.returnValue = false; return false; }; tds[i].insertBefore(newlink, linkobj); tds[i].removeChild(linkobj); } } else if (typeof tds[i].onclick == 'function') { tds[i].ofunc = tds[i].onclick; tds[i].onclick = vB_Popup_Events.prototype.menuoption_onclick_function; } } } } }; vB_Popup_Menu.prototype.show = function(obj, instant) { if (!vBmenu.active) { return false; } else if (!this.menuobj) { this.init_menu(); } if (!this.menuobj) { return false; } if (vBmenu.activemenu != null) { vBmenu.menus[vBmenu.activemenu].hide(); } vBmenu.activemenu = this.controlkey; this.menuobj.style.display = ''; if (this.slide_open) { this.menuobj.style.clip = 'rect(auto, 0px, 0px, auto)'; } this.set_menu_position(obj); if (!instant && this.slide_open) { this.intervalX = Math.ceil(this.menuobj.offsetWidth / this.open_steps); this.intervalY = Math.ceil(this.menuobj.offsetHeight / this.open_steps); this.slide((this.direction == 'left' ? 0 : this.menuobj.offsetWidth), 0, 0); } else if (this.menuobj.style.clip && this.slide_open) { this.menuobj.style.clip = 'rect(auto, auto, auto, auto)'; } // deal with IE putting