Permalink
Browse files

some code improvements

  • Loading branch information...
1 parent e9bb01a commit e4a900c063e67be55095fe71b9193d4a8508c094 @fflorent fflorent committed Aug 27, 2012
Showing with 17 additions and 19 deletions.
  1. +1 −0 extension/content/firebug/dom/domPanel.js
  2. +16 −19 extension/content/firebug/js/watchPanel.js
@@ -1577,6 +1577,7 @@ Firebug.DOMBasePanel.prototype = Obj.extend(Firebug.Panel,
items.push(
{
label: isWatch ? "DeleteWatch" : "DeleteProperty",
+ id: "DeleteProperty",
tooltiptext: isWatch ? "watch.tip.Delete_Watch" :
"dom.tip.Delete_Property",
command: Obj.bindFixed(this.deleteProperty, this, row)
@@ -389,28 +389,25 @@ Firebug.WatchPanel.prototype = Obj.extend(Firebug.DOMBasePanel.prototype,
var items = Firebug.DOMBasePanel.prototype.getContextMenuItems.apply(this, arguments);
// find the index of "DeleteWatch" in the items:
- var iDeleteWatch = items.map(function(item)
+ var deleteWatchIndex = items.map(function(item)
{
- return item.label;
- }).indexOf("DeleteWatch");
+ return item.id;
+ }).indexOf("DeleteProperty");
- // if DeleteWatch was found:
- if (iDeleteWatch >= 0)
- {
- if (FBTrace.DBG_WATCH)
- FBTrace.sysout("insert DeleteAllWatches at : "+ (iDeleteWatch+1));
-
- // insert DeleteAllWatches after DeleteWatch
- items.splice(iDeleteWatch + 1, 0, {
- id: "fbDeleteAllWatches",
- label: "DeleteAllWatches",
- tooltiptext: "watch.tip.Delete_All_Watches",
- command: Obj.bindFixed(this.deleteAllWatches, this)
- });
- }
- else if (FBTrace.DBG_WATCH)
- FBTrace.sysout("could not insert DeleteAllWatches");
+ // if DeleteWatch was found, we insert DeleteAllWatches after it
+ // otherwise, we insert the item at the beginning of the menu
+ var deleteAllWatchesIndex = (deleteWatchIndex >= 0) ? deleteWatchIndex + 1 : 0;
+ if (FBTrace.DBG_WATCH)
+ FBTrace.sysout("insert DeleteAllWatches at: "+ deleteAllWatchesIndex);
+
+ // insert DeleteAllWatches after DeleteWatch
+ items.splice(deleteAllWatchesIndex, 0, {
+ id: "deleteAllWatches",
+ label: "DeleteAllWatches",
+ tooltiptext: "watch.tip.Delete_All_Watches",
+ command: Obj.bindFixed(this.deleteAllWatches, this)
+ });
return items;
}

0 comments on commit e4a900c

Please sign in to comment.