1 /* See license.txt for terms of usage */
  2 
  3 define([
  4     "firebug/lib/trace",
  5     "firebug/lib/options",
  6     "firebug/lib/locale",
  7     "firebug/firefox/browserOverlayLib",
  8 ],
  9 function(FBTrace, Options, Locale, BrowserOverlayLib) {
 10 with (BrowserOverlayLib) {
 11 
 12 // ********************************************************************************************* //
 13 // GlobalCommands Implementation
 14 
 15 var BrowserMenu =
 16 {
 17     overlay: function(doc)
 18     {
 19         this.overlayStartButtonMenu(doc);
 20         this.overlayFirebugMenu(doc);
 21         this.overlayFirefoxMenu(doc);
 22     },
 23 
 24     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 25     // Firebug Start Button Popup Menu
 26 
 27     overlayStartButtonMenu: function(doc)
 28     {
 29         $menupopupOverlay(doc, $(doc, "mainPopupSet"), [
 30             $menupopup(doc, 
 31             {
 32                 id: "fbStatusContextMenu",
 33                 onpopupshowing: "Firebug.browserOverlay.onOptionsShowing(this)"
 34             },
 35             [
 36                 $menu(doc, 
 37                 {
 38                     label: "firebug.uiLocation",
 39                     tooltiptext: "firebug.menu.tip.UI_Location",
 40                     "class": "fbInternational"
 41                 },
 42                 [
 43                     $menupopup(doc, {
 44                         onpopupshowing: "Firebug.browserOverlay.onPositionPopupShowing(this)"
 45                     })
 46                 ]),
 47                 $menuseparator(doc),
 48                 $menuitem(doc, {
 49                     id: "menu_firebug_ClearConsole",
 50                     label: "firebug.ClearConsole",
 51                     tooltiptext: "firebug.ClearTooltip",
 52                     command: "cmd_firebug_clearConsole",
 53                     key: "key_firebug_clearConsole"
 54                 }),
 55                 $menuitem(doc, {
 56                     id: "menu_firebug_showErrorCount",
 57                     type: "checkbox",
 58                     label: "firebug.Show_Error_Count",
 59                     tooltiptext: "firebug.menu.tip.Show_Error_Count",
 60                     oncommand: "Firebug.browserOverlay.onToggleOption(this)",
 61                     option: "showErrorCount"
 62                 }),
 63                 $menuseparator(doc),
 64                 $menuitem(doc, {
 65                     id: "menu_firebug_enablePanels",
 66                     label: "firebug.menu.Enable_All_Panels",
 67                     tooltiptext: "firebug.menu.tip.Enable_All_Panels",
 68                     command: "cmd_firebug_enablePanels"
 69                 }),
 70                 $menuitem(doc, {
 71                     id: "menu_firebug_disablePanels",
 72                     label: "firebug.menu.Disable_All_Panels",
 73                     tooltiptext: "firebug.menu.tip.Disable_All_Panels",
 74                     command: "cmd_firebug_disablePanels"
 75                 }),
 76                 $menuseparator(doc),
 77                 $menuitem(doc, {
 78                     id: "menu_firebug_AllOn",
 79                     type: "checkbox",
 80                     label: "On_for_all_web_pages",
 81                     tooltiptext: "firebug.menu.tip.On_for_all_Web_Sites",
 82                     command: "cmd_firebug_allOn",
 83                     option: "allPagesActivation"
 84                 }),
 85                 $menuitem(doc, {
 86                     id: "menu_firebug_clearActivationList",
 87                     label: "firebug.menu.Clear_Activation_List",
 88                     tooltiptext: "firebug.menu.tip.Clear_Activation_List",
 89                     command: "cmd_firebug_clearActivationList"
 90                 })
 91             ])
 92         ])
 93     },
 94 
 95     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 96     // Firebug Global Menu
 97 
 98     /**
 99      * There are more instances of Firebug Menu (e.g. one in Firefox -> Tools -> Web Developer
100      * and one in Firefox 4 (top-left orange button menu) -> Web Developer
101      *
102      * If extensions want to override the menu thay need to iterate all existing instance
103      * using document.querySelectorAll(".fbFirebugMenuPopup") and append new menu items to all
104      * of them. Iteration must be done in the global space (browser.xul)
105      *
106      * The same menu is also used for Firebug Icon Menu (Firebug's toolbar). This menu is cloned
107      * and initialized as soon as Firebug UI is actually loaded. Since it's cloned from the original
108      * (global scope) extensions don't have to extend it (possible new menu items are already there).
109      */
110     overlayFirebugMenu: function(doc)
111     {
112         this.firebugMenuContent =
113         [
114             // Open/close Firebug
115             $menuitem(doc,
116             {
117                 id: "menu_firebug_toggleFirebug",
118                 label: "firebug.ShowFirebug",
119                 tooltiptext: "firebug.menu.tip.Open_Firebug",
120                 command: "cmd_firebug_toggleFirebug",
121                 key: "key_firebug_toggleFirebug",
122                 "class": "fbInternational"
123             }),
124             $menuitem(doc,
125             {
126                 id: "menu_firebug_closeFirebug",
127                 label: "firebug.Deactivate_Firebug",
128                 tooltiptext: "firebug.tip.Deactivate_Firebug",
129                 command: "cmd_firebug_closeFirebug",
130                 key: "key_firebug_closeFirebug",
131                 "class": "fbInternational"
132             }),
133 
134             // Firebug UI position
135             $menu(doc,
136             {
137                 label: "firebug.uiLocation",
138                 tooltiptext: "firebug.menu.tip.UI_Location",
139                 "class": "fbInternational"
140             },
141             [
142                 $menupopup(doc, {
143                     onpopupshowing: "Firebug.browserOverlay.onPositionPopupShowing(this)"
144                 })
145             ]),
146 
147             $menuseparator(doc),
148 
149             // External Editors
150             $menu(doc,
151             {
152                 id: "FirebugMenu_OpenWith",
153                 label:"firebug.OpenWith",
154                 tooltiptext:"firebug.menu.tip.Open_With",
155                 "class": "fbInternational",
156                 insertafter: "menu_firebug_openActionsSeparator",
157                 openFromContext: "true",
158                 command: "cmd_firebug_openInEditor"
159             },
160             [
161                 $menupopup(doc,{id:"fbFirebugMenu_OpenWith",
162                     onpopupshowing: "return Firebug.browserOverlay.onEditorsShowing(this);"})
163             ]),
164 
165             // Text Size
166             $menu(doc,
167             {
168                 id: "FirebugMenu_TextSize",
169                 label: "firebug.TextSize",
170                 tooltiptext: "firebug.menu.tip.Text_Size",
171                 "class": "fbInternational"
172             },
173             [
174                 $menupopup(doc,{},
175                 [
176                     $menuitem(doc,
177                     {
178                         id: "menu_firebug_increaseTextSize",
179                         label: "firebug.IncreaseTextSize",
180                         tooltiptext: "firebug.menu.tip.Increase_Text_Size",
181                         command: "cmd_firebug_increaseTextSize",
182                         key: "key_firebug_increaseTextSize",
183                         "class": "fbInternational"
184                     }),
185                     $menuitem(doc,
186                     {
187                         id: "menu_firebug_decreaseTextSize",
188                         label: "firebug.DecreaseTextSize",
189                         tooltiptext: "firebug.menu.tip.Decrease_Text_Size",
190                         command: "cmd_firebug_decreaseTextSize",
191                         key: "key_firebug_decreaseTextSize",
192                         "class": "fbInternational"
193                     }),
194                     $menuitem(doc,
195                     {
196                         id: "menu_firebug_normalTextSize",
197                         label: "firebug.NormalTextSize",
198                         tooltiptext: "firebug.menu.tip.Normal_Text_Size",
199                         command: "cmd_firebug_normalTextSize",
200                         key: "key_firebug_normalTextSize",
201                         "class": "fbInternational"
202                     }),
203                 ])
204             ]),
205 
206             // Options
207             $menu(doc,
208             {
209                 id: "FirebugMenu_Options",
210                 label: "firebug.Options",
211                 tooltiptext: "firebug.menu.tip.Options",
212                 "class": "fbInternational"
213             },
214             [
215                 $menupopup(doc,
216                 {
217                     id: "FirebugMenu_OptionsPopup",
218                     onpopupshowing: "return Firebug.browserOverlay.onOptionsShowing(this);"
219                 },
220                 [
221                     $menuitem(doc,
222                     {
223                         id: "menu_firebug_toggleShowErrorCount",
224                         type: "checkbox",
225                         label: "firebug.Show_Error_Count",
226                         tooltiptext: "firebug.menu.tip.Show_Error_Count",
227                         oncommand: "Firebug.browserOverlay.onToggleOption(this)",
228                         option: "showErrorCount",
229                         "class": "fbInternational"
230                     }),
231                     $menuitem(doc,
232                     {
233                         id: "menu_firebug_showTooltips",
234                         type: "checkbox",
235                         label: "firebug.menu.Show_Info_Tips",
236                         tooltiptext: "firebug.menu.tip.Show_Info_Tips",
237                         oncommand: "Firebug.browserOverlay.onToggleOption(this)",
238                         option: "showInfoTips",
239                         "class": "fbInternational"
240                     }),
241                     $menuitem(doc,
242                     {
243                         id: "menu_firebug_shadeBoxModel",
244                         type: "checkbox",
245                         label: "ShadeBoxModel",
246                         tooltiptext: "inspect.option.tip.Shade_Box_Model",
247                         oncommand: "Firebug.browserOverlay.onToggleOption(this)",
248                         option: "shadeBoxModel",
249                         "class": "fbInternational"
250                     }),
251                     $menuitem(doc,
252                     {
253                         id: "menu_firebug_showQuickInfoBox",
254                         type: "checkbox",
255                         label: "ShowQuickInfoBox",
256                         tooltiptext: "inspect.option.tip.Show_Quick_Info_Box",
257                         oncommand: "Firebug.browserOverlay.onToggleOption(this)",
258                         option: "showQuickInfoBox",
259                         "class": "fbInternational"
260                     }),
261                     $menuitem(doc,
262                     {
263                         id: "menu_firebug_enableA11y",
264                         type: "checkbox",
265                         label: "firebug.menu.Enable_Accessibility_Enhancements",
266                         tooltiptext: "firebug.menu.tip.Enable_Accessibility_Enhancements",
267                         oncommand: "Firebug.browserOverlay.onToggleOption(this)",
268                         option: "a11y.enable",
269                         "class": "fbInternational"
270                     }),
271                     $menuitem(doc,
272                     {
273                         id: "menu_firebug_activateSameOrigin",
274                         type: "checkbox",
275                         label: "firebug.menu.Activate_Same_Origin_URLs2",
276                         tooltiptext: "firebug.menu.tip.Activate_Same_Origin_URLs",
277                         oncommand: "Firebug.browserOverlay.onToggleOption(this)",
278                         option: "activateSameOrigin",
279                         "class": "fbInternational"
280                     }),
281                     $menuitem(doc,
282                     {
283                         id: "menu_firebug_toggleOrient",
284                         type: "checkbox",
285                         label: "firebug.menu.Vertical_Panels",
286                         tooltiptext: "firebug.menu.tip.Vertical_Panels",
287                         command: "cmd_firebug_toggleOrient",
288                         option: "viewPanelOrient",
289                         "class": "fbInternational"
290                     }),
291                     $menuseparator(doc, {id: "menu_firebug_optionsSeparator"}),
292                     $menuitem(doc,
293                     {
294                         id: "menu_firebug_resetAllOptions",
295                         label: "firebug.menu.Reset_All_Firebug_Options",
296                         tooltiptext: "firebug.menu.tip.Reset_All_Firebug_Options",
297                         command: "cmd_firebug_resetAllOptions",
298                         "class": "fbInternational"
299                     }),
300                 ])
301             ]),
302 
303             $menuseparator(doc,{id: "FirebugBetweenOptionsAndSites", collapsed: "true"}),
304 
305             // Sites
306             $menu(doc,
307             {
308                 id: "FirebugMenu_Sites",
309                 label: "firebug.menu.Firebug_Online",
310                 tooltiptext: "firebug.menu.tip.Firebug_Online",
311                 "class": "fbInternational"
312             },
313             [
314                 $menupopup(doc,{},
315                 [
316                     $menuitem(doc,
317                     {
318                         id: "menu_firebug_firebugUrlWebsite",
319                         label: "firebug.Website",
320                         tooltiptext: "firebug.menu.tip.Website",
321                         oncommand: "Firebug.chrome.visitWebsite('main')",
322                         "class": "fbInternational"
323                     }),
324                     $menuitem(doc,
325                     {
326                         id: "menu_firebug_firebugUrlExtensions",
327                         label: "firebug.menu.Extensions",
328                         tooltiptext: "firebug.menu.tip.Extensions",
329                         oncommand: "Firebug.chrome.visitWebsite('extensions')",
330                         "class": "fbInternational"
331                     }),
332                     $menuitem(doc,
333                     {
334                         id: "menu_firebug_firebugHelp",
335                         label: "firebug.help",
336                         tooltiptext: "firebug.menu.tip.help",
337                         command: "cmd_firebug_openHelp",
338                         key: "key_firebug_help",
339                         "class": "fbInternational"
340                     }),
341                     $menuitem(doc,
342                     {
343                         id: "menu_firebug_firebugDoc",
344                         label: "firebug.Documentation",
345                         tooltiptext: "firebug.menu.tip.Documentation",
346                         oncommand: "Firebug.chrome.visitWebsite('docs')",
347                         "class": "fbInternational"
348                     }),
349                     $menuitem(doc,
350                     {
351                         id: "menu_firebug_firebugKeyboard",
352                         label: "firebug.KeyShortcuts",
353                         tooltiptext: "firebug.menu.tip.Key_Shortcuts",
354                         oncommand: "Firebug.chrome.visitWebsite('keyboard')",
355                         "class": "fbInternational"
356                     }),
357                     $menuitem(doc,
358                     {
359                         id: "menu_firebug_firebugForums",
360                         label: "firebug.Forums",
361                         tooltiptext: "firebug.menu.tip.Forums",
362                         oncommand: "Firebug.chrome.visitWebsite('discuss')",
363                         "class": "fbInternational"
364                     }),
365                     $menuitem(doc,
366                     {
367                         id: "menu_firebug_firebugIssues",
368                         label: "firebug.Issues",
369                         tooltiptext: "firebug.menu.tip.Issues",
370                         oncommand: "Firebug.chrome.visitWebsite('issues')",
371                         "class": "fbInternational"
372                     }),
373                     $menuitem(doc,
374                     {
375                         id: "menu_firebug_firebugDonate",
376                         label: "firebug.Donate",
377                         tooltiptext: "firebug.menu.tip.Donate",
378                         oncommand: "Firebug.chrome.visitWebsite('donate')",
379                         "class": "fbInternational"
380                     }),
381                 ])
382             ]),
383 
384             $menuseparator(doc, {id: "menu_firebug_miscActionsSeparator", collapsed: "true"}),
385 
386             $menuseparator(doc, {id: "menu_firebug_toolsSeparator", collapsed: "true"}),
387 
388             $menuitem(doc,
389             {
390                 id: "menu_firebug_customizeShortcuts",
391                 label: "firebug.menu.Customize_shortcuts",
392                 tooltiptext: "firebug.menu.tip.Customize_Shortcuts",
393                 command: "cmd_firebug_customizeFBKeys",
394                 key: "key_firebug_customizeFBKeys",
395                 "class": "fbInternational"
396             }),
397 
398             $menuseparator(doc, {id: "menu_firebug_aboutSeparator"}),
399 
400             $menuitem(doc, {
401                 id: "menu_firebug_about",
402                 label: "firebug.About",
403                 tooltiptext: "firebug.menu.tip.About",
404                 oncommand: "Firebug.browserOverlay.openAboutDialog()",
405                 "class": "firebugAbout fbInternational"
406             }),
407         ];
408     },
409 
410     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
411     // Global Menu Overlays
412 
413     overlayFirefoxMenu: function(doc)
414     {
415         // Firefox page context menu
416         $menupopupOverlay(doc, $(doc, "contentAreaContextMenu"), [
417             $menuseparator(doc),
418             $menuitem(doc,{
419                 id: "menu_firebug_firebugInspect",
420                 label: "firebug.InspectElementWithFirebug",
421                 command: "cmd_firebug_inspect",
422                 "class": "menuitem-iconic fbInternational"
423             })
424         ]);
425 
426         // Firefox view menu
427         $menupopupOverlay(doc, $(doc, "menu_viewPopup"), [
428             $menuitem(doc, {
429                 id: "menu_firebug_viewToggleFirebug",
430                 insertbefore: "toggle_taskbar",
431                 label: "firebug.Firebug",
432                 type: "checkbox",
433                 key: "key_firebug_toggleFirebug",
434                 command: "cmd_firebug_toggleFirebug",
435                 "class": "fbInternational"
436             })
437         ]);
438         
439         // SeaMonkey view menu
440         $menupopupOverlay(doc, $(doc, "menu_View_Popup"), [
441             $menuitem(doc, {
442                 id: "menu_firebug_viewToggleFirebug",
443                 insertafter: "menuitem_fullScreen",
444                 label: "firebug.Firebug",
445                 type: "checkbox",
446                 key: "key_firebug_toggleFirebug",
447                 command: "cmd_firebug_toggleFirebug",
448                 "class": "menuitem-iconic fbInternational"
449             })
450         ]);
451 
452         // Firefox Tools -> Web Developer Menu
453         $menupopupOverlay(doc, $(doc, "menuWebDeveloperPopup"), [
454             $menu(doc, {
455                 id: "menu_webDeveloper_firebug",
456                 position: 1,
457                 label: "firebug.Firebug",
458                 "class": "menu-iconic fbInternational"
459             }, [
460                 $menupopup(doc, {
461                     id: "menu_firebug_firebugMenuPopup",
462                     "class": "fbFirebugMenuPopup",
463                     onpopupshowing: "return Firebug.browserOverlay.onMenuShowing(this, event);",
464                     onpopuphiding: "return Firebug.browserOverlay.onMenuHiding(this, event);"
465                 })
466             ]),
467             $menuseparator(doc, {
468                 insertafter: "menu_webDeveloper_firebug"
469             })
470         ]);
471 
472         // Firefox Button -> Web Developer Menu
473         $menupopupOverlay(doc, $(doc, "appmenu_webDeveloper_popup"), [
474             $splitmenu(doc, {
475                 id: "appmenu_firebug",
476                 position: 1,
477                 command: "cmd_firebug_toggleFirebug",
478                 key: "key_firebug_toggleFirebug",
479                 label: "firebug.Firebug",
480                 iconic: "true",
481                 "class": "fbInternational"
482             }, [
483                 $menupopup(doc, {
484                     id: "appmenu_firebugMenuPopup",
485                     "class": "fbFirebugMenuPopup",
486                     onpopupshowing: "return Firebug.browserOverlay.onMenuShowing(this, event);",
487                     onpopuphiding: "return Firebug.browserOverlay.onMenuHiding(this, event);"
488                 })
489             ]),
490             $menuseparator(doc, {
491                 insertafter: "appmenu_firebug"
492             })
493         ]);
494 
495         // Sea Monkey Tools Menu
496         $menupopupOverlay(doc, $(doc, "toolsPopup"), [
497             $menu(doc, {
498                 id: "menu_firebug",
499                 insertbefore: "appmenu_webConsole",
500                 command: "cmd_firebug_toggleFirebug",
501                 key: "key_firebug_toggleFirebug",
502                 label: "firebug.Firebug",
503                 "class": "menuitem-iconic fbInternational"
504             }, [
505                 $menupopup(doc, {
506                     id: "toolsmenu_firebugMenuPopup",
507                     "class": "fbFirebugMenuPopup",
508                     onpopupshowing: "return Firebug.browserOverlay.onMenuShowing(this, event);",
509                     onpopupshowing: "return Firebug.browserOverlay.onMenuHiding(this, event);"
510                 })
511             ])
512         ]);
513     }
514 }
515 
516 // ********************************************************************************************* //
517 // Registration
518 
519 return BrowserMenu;
520 
521 // ********************************************************************************************* //
522 }});
523