瀏覽代碼

- Fixed behaviour of the popup menu (Trac #316).

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@453 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 15 年之前
父節點
當前提交
257b360dd2
共有 1 個文件被更改,包括 7 次插入11 次删除
  1. 7 11
      js/jquery.popupmenu.js

+ 7 - 11
js/jquery.popupmenu.js

@@ -7,32 +7,27 @@
  * http://www.combodo.com/
  *
  * Built upon jQuery jQuery 1.2.3a (http://jquery.com)
- * Requires the jQuery positionBy plugin by Jonathan Sharp (http://jdsharp.us)
+ * Requires the (modified) jQuery positionBy plugin by Jonathan Sharp (http://jdsharp.us)
  */
-
 jQuery.fn.popupmenu = function ()
 {
 	var popupmenu = null;
-
 	return this.each(function() 
 	{
-		$(this).bind('mouseenter.popup_menu click.popup_menu', function (evt)
+		$(this).bind('click.popup_menu', function (evt)
 		{
 			var previous_popup = popupmenu;
 			var bMenuClosed = false;
 			popupmenu = $(this).find('ul');
 			if ( previous_popup != null)
 			{
-				if ( ((evt.type == 'click') && ((previous_popup[0] == popupmenu[0])) || // Comparing the jQuery objects
-					(evt.type == 'mouseenter') && (previous_popup[0] != popupmenu[0])) )
-				// The user clicked again in the menu or moved over another menu let's close it
+				// The user clicked while a menu is open, close the currently opened menu
 				previous_popup.css('display', 'none');
-				bMenuClosed = true;
 				
 			}
-			if ( (previous_popup == null) || (previous_popup[0] != popupmenu[0])) // Comparing the jQuery objects
+			if ( (previous_popup == null) || (previous_popup.get(0) != popupmenu.get(0))) // Comparing the DOM objects
 			{
-				// We really clicked in a different menu, let's open it
+				// The user clicked in a different menu, let's open it
 				popupmenu.bgiframe();
 				popupmenu.positionBy({ target: $(this), 
 										targetPos: 	4, 
@@ -41,8 +36,9 @@ jQuery.fn.popupmenu = function ()
 										});
 				popupmenu.css('display', 'block');
 			}
-			if (bMenuClosed)
+			else
 			{
+				// The user clicked in the opened menu, it is closed now
 				popupmenu = null;
 			}
 			evt.stopPropagation();