[Pkg-mozext-commits] [firebug] 25/68: Issue 6215: Menu & Toolbar: support for hierarchical menus (submenus)

David Prévot taffit at moszumanska.debian.org
Mon Mar 31 22:45:51 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to tag fbtest-1.11.4
in repository firebug.

commit 475eeca001cc28815820d2aa5437ca89bcf9d91d
Author: Jan Odvarko <odvarko at gmail.com>
Date:   Fri Jan 25 17:33:42 2013 +0100

    Issue 6215: 	Menu & Toolbar: support for hierarchical menus (submenus)
---
 extension/content/firebug/chrome/menu.js       | 23 ++++++++++++++++-------
 extension/content/firebug/chrome/toolbar.js    |  8 ++++++--
 extension/content/firebug/firefox/bindings.xml |  8 ++++++++
 3 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/extension/content/firebug/chrome/menu.js b/extension/content/firebug/chrome/menu.js
index c156834..a2a834f 100644
--- a/extension/content/firebug/chrome/menu.js
+++ b/extension/content/firebug/chrome/menu.js
@@ -26,13 +26,19 @@ Menu.createMenu = function(popup, item)
     }
 
     var menu = popup.ownerDocument.createElement("menu");
+    popup.appendChild(menu);
 
     Menu.setItemIntoElement(menu, item);
 
-    var menuPopup = popup.ownerDocument.createElement("menupopup");
+    this.createMenuPopup(menu, item);
 
-    popup.appendChild(menu);
-    menu.appendChild(menuPopup);
+    return menu;
+};
+
+Menu.createMenuPopup = function(parent, item)
+{
+    var menuPopup = parent.ownerDocument.createElement("menupopup");
+    parent.appendChild(menuPopup);
 
     if (item.items)
     {
@@ -41,7 +47,7 @@ Menu.createMenu = function(popup, item)
     }
 
     return menuPopup;
-};
+}
 
 // Menu.createMenuItems(popup, items[, before])
 Menu.createMenuItems = function(popup, items, before)
@@ -55,10 +61,12 @@ Menu.createMenuItem = function(popup, item, before)
     if ((typeof(item) == "string" && item == "-") || item.label == "-")
         return Menu.createMenuSeparator(popup, item, before);
 
-    if (item.items)
-        return Menu.createMenu(popup, item);
+    var menuitem;
 
-    var menuitem = popup.ownerDocument.createElement("menuitem");
+    if (item.items)
+        menuitem = Menu.createMenu(popup, item);
+    else
+        menuitem = popup.ownerDocument.createElement("menuitem");
 
     Menu.setItemIntoElement(menuitem, item);
 
@@ -167,6 +175,7 @@ Menu.createMenuSeparator = function(popup, item, before)
         popup.insertBefore(menuItem, before);
     else
         popup.appendChild(menuItem);
+
     return menuItem;
 };
 
diff --git a/extension/content/firebug/chrome/toolbar.js b/extension/content/firebug/chrome/toolbar.js
index 50fd37e..e8b4edb 100644
--- a/extension/content/firebug/chrome/toolbar.js
+++ b/extension/content/firebug/chrome/toolbar.js
@@ -4,9 +4,10 @@ define([
     "firebug/lib/trace",
     "firebug/lib/locale",
     "firebug/lib/options",
-    "firebug/lib/css"
+    "firebug/lib/css",
+    "firebug/chrome/menu"
 ],
-function(FBTrace, Locale, Options, Css) {
+function(FBTrace, Locale, Options, Css, Menu) {
 
 // ********************************************************************************************* //
 // Constants
@@ -80,6 +81,9 @@ Toolbar.setItemIntoElement = function(element, item)
     if (item.name)
         element.setAttribute("name", item.name);
 
+    if (item.items)
+        Menu.createMenuPopup(element, item);
+
     return element;
 }
 
diff --git a/extension/content/firebug/firefox/bindings.xml b/extension/content/firebug/firefox/bindings.xml
index 96a4cb0..813ecaf 100644
--- a/extension/content/firebug/firefox/bindings.xml
+++ b/extension/content/firebug/firefox/bindings.xml
@@ -856,6 +856,10 @@
         ]]></handler>
 
         <handler event="popupshowing"><![CDATA[
+            // If the event comes from a sub-menu ignore it (just the root has "menuPopup" class)
+            if (!FBL.hasClass(event.originalTarget, "menuPopup"))
+                return;
+
             var tab = this.parentNode;
             if (!tab)
                 return false;
@@ -894,6 +898,10 @@
         ]]></handler>
 
         <handler event="popuphidden"><![CDATA[
+            // If the event comes from a sub-menu ignore it (just the root has "menuPopup" class)
+            if (!FBL.hasClass(event.originalTarget, "menuPopup"))
+                return;
+
             this.setAttribute("role", "presentation");
             FBL.eraseNode(this.popup);
         ]]></handler>

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/firebug.git



More information about the Pkg-mozext-commits mailing list