Closes #1563, add ability to add links by URI and edit existing link attachment URIs

Thanks to ajlyon for the patch
This commit is contained in:
Dan Stillman 2011-06-16 18:17:06 +00:00
parent 5d30b8c726
commit c10fe8606c
3 changed files with 26 additions and 2 deletions

View File

@ -2853,6 +2853,27 @@ var ZoteroPane = new function()
}
this.addAttachmentFromURI = function (link, itemID) {
if (!this.canEdit()) {
this.displayCannotEditLibraryMessage();
return;
}
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
var input = {};
var check = {value : false};
// TODO: Localize
// TODO: Allow title to be specified?
var result = ps.prompt(null, "Attach Link to URI", "Enter a URI:", input, "", {});
if (!result || !input.value) return false;
// Create a new attachment
Zotero.Attachments.linkFromURL(input.value, itemID);
}
function addAttachmentFromDialog(link, id)
{
if (!this.canEdit()) {
@ -3689,4 +3710,4 @@ var ZoteroPane = new function()
* Keep track of which ZoteroPane was local (since ZoteroPane object might get swapped out for a
* tab's ZoteroPane)
*/
var ZoteroPane_Local = ZoteroPane;
var ZoteroPane_Local = ZoteroPane;

View File

@ -141,6 +141,7 @@
<menupopup onpopupshowing="ZoteroPane_Local.updateAttachmentButtonMenu(this)">
<menuitem class="menuitem-iconic zotero-menuitem-attachments-snapshot" label="&zotero.items.menu.attach.snapshot;" oncommand="var itemID = ZoteroPane_Local.getSelectedItems()[0].id; ZoteroPane_Local.addAttachmentFromPage(false, itemID)"/>
<menuitem class="menuitem-iconic zotero-menuitem-attachments-web-link" label="&zotero.items.menu.attach.link;" oncommand="var itemID = ZoteroPane_Local.getSelectedItems()[0].id; ZoteroPane_Local.addAttachmentFromPage(true, itemID)"/>
<menuitem class="menuitem-iconic zotero-menuitem-attachments-web-link" label="&zotero.items.menu.attach.link.uri;" oncommand="var itemID = ZoteroPane_Local.getSelectedItems()[0].id; ZoteroPane_Local.addAttachmentFromURI(true, itemID);"/>
<menuitem class="menuitem-iconic zotero-menuitem-attachments-file" label="Attach Stored Copy of File..." oncommand="var itemID = ZoteroPane_Local.getSelectedItems()[0].id; ZoteroPane_Local.addAttachmentFromDialog(false, itemID);"/>
<menuitem class="menuitem-iconic zotero-menuitem-attachments-link" label="Attach Link to File..." oncommand="var itemID = ZoteroPane_Local.getSelectedItems()[0].id; ZoteroPane_Local.addAttachmentFromDialog(true, itemID);"/>
</menupopup>
@ -240,6 +241,7 @@
<menupopup id="zotero-add-attachment-popup">
<menuitem class="menuitem-iconic zotero-menuitem-attachments-snapshot" label="&zotero.items.menu.attach.snapshot;" oncommand="var itemID = parseInt(this.parentNode.parentNode.parentNode.getAttribute('itemID')); ZoteroPane_Local.addAttachmentFromPage(false, itemID)"/>
<menuitem class="menuitem-iconic zotero-menuitem-attachments-web-link" label="&zotero.items.menu.attach.link;" oncommand="var itemID = parseInt(this.parentNode.parentNode.parentNode.getAttribute('itemID')); ZoteroPane_Local.addAttachmentFromPage(true, itemID)"/>
<menuitem class="menuitem-iconic zotero-menuitem-attachments-web-link" label="&zotero.items.menu.attach.link.uri;" oncommand="var itemID = parseInt(this.parentNode.parentNode.parentNode.getAttribute('itemID')); ZoteroPane_Local.addAttachmentFromURI(true, itemID);"/>
<menuitem class="menuitem-iconic zotero-menuitem-attachments-file" label="&zotero.items.menu.attach.file;" oncommand="var itemID = parseInt(this.parentNode.parentNode.parentNode.getAttribute('itemID')); ZoteroPane_Local.addAttachmentFromDialog(false, itemID);"/>
<menuitem class="menuitem-iconic zotero-menuitem-attachments-link" label="&zotero.items.menu.attach.fileLink;" oncommand="var itemID = parseInt(this.parentNode.parentNode.parentNode.getAttribute('itemID')); ZoteroPane_Local.addAttachmentFromDialog(true, itemID);"/>
</menupopup>

View File

@ -62,6 +62,7 @@
<!ENTITY zotero.items.menu.attach "Add Attachment">
<!ENTITY zotero.items.menu.attach.snapshot "Attach Snapshot of Current Page">
<!ENTITY zotero.items.menu.attach.link "Attach Link to Current Page">
<!ENTITY zotero.items.menu.attach.link.uri "Attach Link to URI...">
<!ENTITY zotero.items.menu.attach.file "Attach Stored Copy of File...">
<!ENTITY zotero.items.menu.attach.fileLink "Attach Link to File...">
@ -228,4 +229,4 @@
<!ENTITY zotero.file.choose.label "Choose File...">
<!ENTITY zotero.file.noneSelected.label "No file selected">
<!ENTITY zotero.downloadManager.label "Save to Zotero">
<!ENTITY zotero.downloadManager.label "Save to Zotero">