From 7d961409e750e877d5d7c8706665d06084953876 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20Kr=E6mmer=20Nielsen?= Date: Tue, 4 Dec 2007 20:56:05 +0100 Subject: [PATCH] Started context menu branch --- content/tv2developer-main.js | 3 +++ content/tv2developer.js | 28 ++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/content/tv2developer-main.js b/content/tv2developer-main.js index 921da76..73b189d 100755 --- a/content/tv2developer-main.js +++ b/content/tv2developer-main.js @@ -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); diff --git a/content/tv2developer.js b/content/tv2developer.js index 92f44ec..443cad3 100755 --- a/content/tv2developer.js +++ b/content/tv2developer.js @@ -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]); + } + } + } } -- 2.52.0