Skip to content

Instantly share code, notes, and snippets.

@harthur
Created Oct 12, 2010
Embed
What would you like to do?
diff --git a/mozmill/mozmill/extension/resource/modules/controller.js b/mozmill/mozmill/extension/resource/modules/controller.js
index ffd8467..64f5ea3 100644
--- a/mozmill/mozmill/extension/resource/modules/controller.js
+++ b/mozmill/mozmill/extension/resource/modules/controller.js
@@ -100,47 +100,6 @@ waitForEvents.prototype = {
}
}
-/**
- * Dynamically create hierarchy of available menu entries
- *
- * @param object aWindow
- * Browser window to use
- * @param object aElements
- * Array of menu or menuitem elements
- */
-var Menu = function (aWindow, aElements) {
- for each (var node in aElements) {
- var entry = null;
-
- switch (node.tagName) {
- case "menu":
- var popup = node.getElementsByTagName("menupopup")[0];
-
- // Fake a click onto the menu to add dynamic entries
- if (popup) {
- if (popup.allowevents) {
- events.fakeOpenPopup(aWindow, popup);
- }
- entry = new Menu(aWindow, popup.childNodes);
- }
- break;
- case "menuitem":
- entry = node;
- break;
- default:
- continue;
- }
-
- if (entry) {
- var label = node.getAttribute("label");
- this[label] = entry;
-
- if (node.id)
- this[node.id] = this[label];
- }
- }
-};
-
var MozMillController = function (window) {
this.window = window;
@@ -480,7 +439,7 @@ MozMillController.prototype.__defineGetter__("menus", function() {
var menubar = this.window.document.getElementsByTagName('menubar');
if(menubar && menubar.length > 0)
- menu = new Menu(this.window, menubar[0].childNodes);
+ menu = new this.Menu(menubar[0].childNodes);
return menu;
});
@@ -970,6 +929,46 @@ MozMillController.prototype.dragDropElemToElem = function (dstart, ddest) {
return true;
}
+/**
+* Dynamically create hierarchy of available menu entries
+*
+* @param object aWindow
+* Browser window to use
+* @param object aElements
+* Array of menu or menuitem elements
+*/
+MozMillController.prototype.Menu = function (aElements) {
+ for each (var node in aElements) {
+ var entry = null;
+
+ switch (node.tagName) {
+ case "menu":
+ var popup = node.getElementsByTagName("menupopup")[0];
+
+ // Fake a click onto the menu to add dynamic entries
+ if (popup) {
+ if (popup.allowevents) {
+ events.fakeOpenPopup(this.window, popup);
+ }
+ entry = new Menu(this.window, popup.childNodes);
+ }
+ break;
+ case "menuitem":
+ entry = node;
+ break;
+ default:
+ continue;
+ }
+
+ if (entry) {
+ var label = node.getAttribute("label");
+ this[label] = entry;
+
+ if (node.id)
+ this[node.id] = this[label];
+ }
+ }
+};
function preferencesAdditions(controller) {
var mainTabs = controller.window.document.getAnonymousElementByAttribute(controller.window.document.documentElement, 'anonid', 'selector');
controller.tabs = {};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment