This new release is to fix a feature request by Ungenio
when I right click inside a page (not on a link) the “Save with dijjer…” option is at the very top along with “Back”, “Forward”, etc… Could it be moved to be in the “Save Page As…” area?
Yes it can
I have made the change in version 0.1.2.
Indeed, my dijjer menuitem was after « Save Link As » — and when firefox is not over a link it doesn’t display « Save Link As » and « Dijjer this! » was on top of the context menu, before the « Back » menuitem which wasn’t very user-friendly. At first, I tried to extend insertafter in my overlay
<menuitem id="context-dijjethis"
label="&dijjer.savepage.label;"
insertafter="context-savelink, context-savepage"
class="menuitem-iconic"
image="chrome://dijjerthis/skin/arrow_16x16.png"
oncommand="DijjerthisMenu.dijjerThis();"
/>
Unfortunately, in case the context menu was not called on a link, « Save Link As » is hidden but still exists on top of the list. Thus my « dijjer this! » menu item was still on top. Arggg.
So, it was actually much harder to implement than what I was expecting. I had to define 2 menuitems (the former being « Save Page with Dijjer », the latter being « save Link with Dijjer ») and hide the one or the other depending on the context (exactly like mozilla does). The XUL overlay remains simple:
<popup id="contentAreaContextMenu" onpopupshown="DijjerthisMenu.init();">
<menuitem id="context-dijjerpage"
label="&dijjer.savepage.label;"
insertafter="context-savepage"
class="menuitem-iconic"
image="chrome://dijjerthis/skin/arrow_16x16.png"
oncommand="DijjerthisMenu.dijjerPage();"
/>
<menuitem id="context-dijjerlink"
label="&dijjer.savelink.label;"
insertafter="context-savelink"
class="menuitem-iconic"
image="chrome://dijjerthis/skin/arrow_16x16.png"
oncommand="DijjerthisMenu.dijjerLink();"
/>
</popup>
But the javascript overlay requires a function to show or hide the items:
//show or hide items depending on the context
showItems: function() {
var menuitem_page = document.getElementById("context-dijjerpage");
var menuitem_link = document.getElementById("context-dijjerlink");
if (gContextMenu.onSaveableLink) {
menuitem_page.hidden=true;
menuitem_link.hidden=false;
}
// Save+Send link depends on whether we're in a link.
else if (!( gContextMenu.inDirList || gContextMenu.isContentSelected || gContextMenu.onTextInput || gContextMenu.onLink || gContextMenu.onImage )){
menuitem_page.hidden=false;
menuitem_link.hidden=true;
}
}
And this function much be called each time the popup menu is displayed:
// I can't use gContextMenu because it is not initialized yet
var contextMenu=document.getElementById("contentAreaContextMenu");
contextMenu.addEventListener("popupshowing", DijjerthisMenu.showItems, false);
Enough technical details for now. Read the code if you want more
And do give critics agains my code, I reach my upper limits in Javascript!