1 /* See license.txt for terms of usage */
  2 
  3 // Runs during overlay processing
  4 function OpenEditorShowHide(event) 
  5 {
  6     var item = document.getElementById("menu_firebugOpenWithEditor");
  7 
  8     var popupNode = document.popupNode;
  9     item.hidden = (popupNode instanceof HTMLInputElement
 10         || popupNode instanceof HTMLIFrameElement
 11         || popupNode instanceof HTMLTextAreaElement
 12         || Firebug.registeredEditors.length == 0);
 13 }
 14 
 15 function addOpenEditorShowHide(event)
 16 {
 17     window.removeEventListener("load", addOpenEditorShowHide, false);
 18 
 19     var contextMenu = document.getElementById("contentAreaContextMenu");
 20     if (contextMenu)
 21     {
 22         addContextToForms();
 23         contextMenu.addEventListener("popupshowing", OpenEditorShowHide, false);
 24     }
 25 };
 26 
 27 function addContextToForms(contextMenu)
 28 {
 29     // https://bugzilla.mozilla.org/show_bug.cgi?id=433168
 30     var setTargetOriginal = nsContextMenu.prototype.setTarget;
 31     nsContextMenu.prototype.setTarget = function(aNode, aRangeParent, aRangeOffset)
 32     {
 33         setTargetOriginal.apply(this, arguments);
 34         if (this.isTargetAFormControl(aNode))
 35             this.shouldDisplay = true;
 36     };
 37 }
 38 
 39 window.addEventListener("load", addOpenEditorShowHide, false);
 40