MyBB Community Forums

Full Version: Popup menu javascripts broken?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
I've used the steamprofile since I first started the forum, and it used to work fine. Should I remove it?
(2010-12-31, 12:09 AM)Renegader Wrote: [ -> ]I've used the steamprofile since I first started the forum, and it used to work fine. Should I remove it?

For now untill we can get to the bottom of this problem, you can then re-enable them after we're done.

Also, could you replace the popup_menu.js line
http://cdn.gamingbay.org/popup_menu.js?ver=1600

with this one:

<snip> This was just a temporary link for the js
Disabled. I've replaced it too.

Don't think it works. :/

Also, the admin CP stuff doesn't work either. I cannot edit a usergroup because the popup isn't working.
In your headerinclude where you have

<script type="text/javascript">
<!--
	var cookieDomain = ".gamingbay.org";
.......

Put this after // -->
</script>
It worked, you're a genius. I have no idea what happened. o.o

When I change it back to the original URL though, the problem occurs again.
(2010-12-31, 12:44 AM)Renegader Wrote: [ -> ]It worked, you're a genius. I have no idea what happened. o.o

When I change it back to the original URL though, the problem occurs again.

Thats because the popup_menu.js file you have there is corrupt which is why I asked you to change to mine temporarily. When you re-upload the file, delete the one on the ftp before uploading, some ftps don't overwrite so you might still end up with the old one. Also make sure you got a fresh copy of the mybb files from here.

EDIT: once thats done, you can then start re-enabling your other stuff like steamprofile, checking to make sure inbetween that the popup still works
That seemed to fix the problem, but now in the admin control panel the popups don't work.

Which JS file are the popups in the admin cp attached to?
The admincp uses the same popup_menu.js file that is used in the frontend, however, since you're using a cdn to distribute your js files, you'll have to set the location of the jscripts in admin/inc/class_page.php around line 94

EDIT: Or you can just have a copy of the jscripts in /jscripts for the admincp use

Also, I'm going to go ahead and remove the temporary popup js script I put up for you since you're done.
This is what's in that page now:

	echo "	<script type=\"text/javascript\" src=\"http://cdn.gamingbay.org/prototype.js\"></script>\n";
		echo "	<script type=\"text/javascript\" src=\"http://cdn.gamingbay.org/general.js\"></script>\n";
		echo "	<script type=\"text/javascript\" src=\"http://gamingbay.org/jscripts/popup_menu.js\"></script>\n";
		echo "	<script type=\"text/javascript\" src=\"./jscripts/admincp.js\"></script>\n";
		echo "	<script type=\"text/javascript\" src=\"http://cdn.gamingbay.org/tabs.js\"></script>\n";

I'm not using the CDN for the popup page. It's on http://gamingbay.org/jscripts/popup_menu.js

Still doesn't work. Sad

Also, this is what's in the header of admin cp:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head profile="http://gmpg.org/xfn/1"> 
	<title>Manage User Groups</title> 
	<meta name="author" content="MyBB Group" /> 
	<meta name="copyright" content="Copyright 2010 MyBB Group." /> 
	<link rel="stylesheet" href="styles/sharepoint/main.css" type="text/css" /> 
	<link rel="stylesheet" href="styles/sharepoint/user.css" type="text/css" /> 
	<script type="text/javascript" src="http://cdn.gamingbay.org/prototype.js"></script> 
	<script type="text/javascript" src="http://cdn.gamingbay.org/general.js"></script> 
	<script type="text/javascript" src="http://gamingbay.org/jscripts/popup_menu.js"></script> 
	<script type="text/javascript" src="./jscripts/admincp.js"></script> 
	<script type="text/javascript" src="http://cdn.gamingbay.org/tabs.js"></script> 
  <style type="text/css">.popup_button { display: none; } </style> 
  <script type="text/javascript"> 
And once more...the popup_menu.js file you're using is not correct. Here are the contents of http://gamingbay.org/jscripts/popup_menu.js

var PopupMenu = Class.create();

PopupMenu.prototype = {

	initialize: function(id, options)
	{
		document.currentMenu = "";

		if(!$(id))
		{
			return false;
		}
		this.id = id;
		var element = $(id);
		}
		var popupMenu = element.id+"_popup";})
		if(!$(popupMenu))
		{
			return false;
		}
		
		this.menu = $(popupMenu);
		this.menu.style.display = "none";
		element.onclick = this.openMenu.bindAsEventListener(this);
	},
	
	openMenu: function(e)
	{
		Event.stop(e);
		if(document.currentMenu && document.currentMenu == this.id)
		{
			this.closeMenu();
			return false;
		}
		else if(document.currentMenu != "")
		{
			this.closeMenu();
		}
		
		offsetTop = offsetLeft = 0;
		var element = $(this.id);
		do
		{
			offsetTop += element.offsetTop || 0;
			offsetLeft += element.offsetLeft || 0;
			element = element.offsetParent;
			if(element)
			{
				if(Element.getStyle(element, 'position') == 'relative' || Element.getStyle(element, 'position') == 'absolute') break;
			}
		} while(element);
		offsetTopReal = offsetTop;
		offsetLeftReal = offsetLeft;
		if(element) // will be true if we broke off the last loop
		{
			// calculate the true top/left position relative to page borders (this is used for checking whether the popup menu will be displayed within the page)
			do
			{
				offsetTopReal += element.offsetTop || 0;
				offsetLeftReal += element.offsetLeft || 0;
			} while(element = element.offsetParent);
		}
		element = $(this.id);
		element.blur();
		this.menu.style.position = "absolute";
		this.menu.style.zIndex = 100;
		this.menu.style.top = (offsetTop+element.offsetHeight-1)+"px";
		// Bad browser detection - yes, only choice - yes.
		if(MyBB.browser == "opera" || MyBB.browser == "safari")
		{
			this.menu.style.top = (parseInt(this.menu.style.top)-2)+"px";
		}
		this.menu.style.left = offsetLeft+"px";
		this.menu.style.visibility = 'hidden';
		this.menu.style.display = 'block';
		if(this.menu.style.width)
		{
			menuWidth = parseInt(this.menu.style.width);
		}
		else
		{
			menuWidth = this.menu.offsetWidth;
		}
		pageSize = DomLib.getPageSize();
		if(offsetLeftReal+menuWidth >= pageSize[0])
		{
			this.menu.style.left = (offsetLeft-menuWidth+element.offsetWidth)+"px";
		}
		this.menu.style.display = 'block';	
		this.menu.style.visibility = 'visible';

		document.currentMenu = element.id;
		Event.observe(document, 'click', this.closeMenu.bindAsEventListener(this));
	},
	
	closeMenu: function()
	{
		if(!document.currentMenu)
		{
			return;
		}
		var menu = document.currentMenu;
		menu = $(menu+"_popup");
		menu.style.display = "none";
		document.currentMenu = "";
		document.onclick = function() {  
	}
 

Here is what the default popup_menu.js is supposed to be:

var PopupMenu = Class.create();

PopupMenu.prototype = {

	initialize: function(id, options)
	{
		document.currentMenu = "";

		if(!$(id))
		{
			return false;
		}
		this.id = id;
		var element = $(id);
		
		var popupMenu = element.id+"_popup";
		if(!$(popupMenu))
		{
			return false;
		}
		
		this.menu = $(popupMenu);
		this.menu.style.display = "none";
		element.onclick = this.openMenu.bindAsEventListener(this);
	},
	
	openMenu: function(e)
	{
		Event.stop(e);
		if(document.currentMenu && document.currentMenu == this.id)
		{
			this.closeMenu();
			return false;
		}
		else if(document.currentMenu != "")
		{
			this.closeMenu();
		}
		
		offsetTop = offsetLeft = 0;
		var element = $(this.id);
		do
		{
			offsetTop += element.offsetTop || 0;
			offsetLeft += element.offsetLeft || 0;
			element = element.offsetParent;
			if(element)
			{
				if(Element.getStyle(element, 'position') == 'relative' || Element.getStyle(element, 'position') == 'absolute') break;
			}
		} while(element);
		offsetTopReal = offsetTop;
		offsetLeftReal = offsetLeft;
		if(element) // will be true if we broke off the last loop
		{
			// calculate the true top/left position relative to page borders (this is used for checking whether the popup menu will be displayed within the page)
			do
			{
				offsetTopReal += element.offsetTop || 0;
				offsetLeftReal += element.offsetLeft || 0;
			} while(element = element.offsetParent);
		}
		element = $(this.id);
		element.blur();
		this.menu.style.position = "absolute";
		this.menu.style.zIndex = 100;
		this.menu.style.top = (offsetTop+element.offsetHeight-1)+"px";
		// Bad browser detection - yes, only choice - yes.
		if(MyBB.browser == "opera" || MyBB.browser == "safari")
		{
			this.menu.style.top = (parseInt(this.menu.style.top)-2)+"px";
		}
		this.menu.style.left = offsetLeft+"px";
		this.menu.style.visibility = 'hidden';
		this.menu.style.display = 'block';
		if(this.menu.style.width)
		{
			menuWidth = parseInt(this.menu.style.width);
		}
		else
		{
			menuWidth = this.menu.offsetWidth;
		}
		pageSize = DomLib.getPageSize();
		if(offsetLeftReal+menuWidth >= pageSize[0])
		{
			this.menu.style.left = (offsetLeft-menuWidth+element.offsetWidth)+"px";
		}
		this.menu.style.display = 'block';	
		this.menu.style.visibility = 'visible';

		document.currentMenu = element.id;
		Event.observe(document, 'click', this.closeMenu.bindAsEventListener(this));
	},
	
	closeMenu: function()
	{
		if(!document.currentMenu)
		{
			return;
		}
		var menu = document.currentMenu;
		menu = $(menu+"_popup");
		menu.style.display = "none";
		document.currentMenu = "";
		document.onclick = function() { };
	}
};

Its missing the last line };

EDIT: If you can just PM the ftp details, it'll be easier that way
Pages: 1 2 3