Started context menu branch contextmenu
authorKristian Kræmmer Nielsen <jkkn@jkkn.dk>
Tue, 4 Dec 2007 19:56:05 +0000 (20:56 +0100)
committerKristian Kræmmer Nielsen <jkkn@jkkn.dk>
Tue, 4 Dec 2007 19:56:05 +0000 (20:56 +0100)
content/tv2developer-main.js
content/tv2developer.js

index 921da768ae21a33778d87d861569572cb67a2956..73b189dc678109f10c210d567268195370b68436 100755 (executable)
@@ -1,2 +1,5 @@
 
 window.addEventListener("load", function(e) { TV2Developer.init(); }, false);
+
+document.getElementById('contentAreaContextMenu').addEventListener("popupshowing", function(e) { TV2Developer.showContextMenu(e); }, false);
+document.getElementById('contentAreaContextMenu').addEventListener("popuphiding", function(e) { TV2Developer.hideContextMenu(e); }, false);
index 92f44ec00c5240abe4245e656bcef130ffd46eb1..443cad38491d9df076f6a29679dfb5bbe95e7d1b 100755 (executable)
@@ -413,7 +413,7 @@ var TV2Developer = {
                         if (tv2_uriOnly.substr(0,2)=='/s') {
                             typeId = 8; typeName = 'I2_Image_Selection';
                         } else {
-                            typeId = 7; typeName = ' I2_Image';
+                            typeId = 7; typeName = 'I2_Image';
                         }
                     }
                     links.push(new this.TV2LinkSplit());
@@ -687,7 +687,31 @@ var TV2Developer = {
       var instantApply = getBoolPref("browser.preferences.instantApply", false);
       var features = "chrome,titlebar,toolbar,centerscreen" + (instantApply ? ",dialog=no" : ",modal");
       window.openDialog('chrome://tv2developer/content/options.xul','tv2options',features);
-  }
+    },
+    
+    /* Show Context Menu */
+    showContextMenu: function(event) {
+        var menu = document.getElementById('contentAreaContextMenu');
+        var menuLocation = document.getElementById('context-sep-open');
+        function createItem() {
+            var menuItem = document.createElement('menuitem');
+            menuItem.setAttribute('id', 'tv2developer-link');
+            menuItem.setAttribute('label', 'Test link');
+            menu.insertBefore(menuItem, menuLocation);
+        }
+    },
+    
+    /* Clean up on close */
+    hideContextMenu: function(event) {
+        var menu = document.getElementById('contentAreaContextMenu');
+        /* clean up menu */
+        var children = menu.childNodes;
+        for (var i = children.length - 1; i >= 0; --i) {
+            if (children[i].getAttribute('id').substr(0, 13) == 'tv2developer-') {
+                menu.removeChild(children[i]);
+            }
+        }
+    }
 
 
 }