- Changed toolbar note button to context-sensitive menu for adding standalone and child notes

- Added toolbar button with context-sensitive menu for adding child attachments
This commit is contained in:
Dan Stillman 2009-09-14 04:18:58 +00:00
parent a60bfc1518
commit 11c1277ea7
4 changed files with 89 additions and 10 deletions

View File

@ -1118,6 +1118,55 @@ var ZoteroPane = new function()
}
this.updateNoteButtonMenu = function () {
var items = ZoteroPane.getSelectedItems();
var button = document.getElementById('zotero-tb-add-child-note');
button.disabled = this.canEdit() && !(items.length == 1
&& (items[0].isRegularItem() || !items[0].isTopLevelItem()));
}
this.updateAttachmentButtonMenu = function (popup) {
var items = ZoteroPane.getSelectedItems();
var disabled = !this.canEdit() || !(items.length == 1 && items[0].isRegularItem());
if (disabled) {
for each(var node in popup.childNodes) {
node.disabled = true;
}
return;
}
var itemgroup = this.collectionsView._getItemAtRow(this.collectionsView.selection.currentIndex);
var canEditFiles = this.canEditFiles();
var prefix = "menuitem-iconic zotero-menuitem-attachments-";
for (var i=0; i<popup.childNodes.length; i++) {
var node = popup.childNodes[i];
switch (node.className) {
case prefix + 'link':
node.disabled = itemgroup.isWithinGroup();
break;
case prefix + 'snapshot':
case prefix + 'file':
node.disabled = !canEditFiles;
break;
case prefix + 'web-link':
node.disabled = false;
break;
default:
throw ("Invalid class name '" + node.className + "' in ZoteroPane.updateAttachmentButtonMenu()");
}
}
}
function reindexItem() {
var items = this.getSelectedItems();
if (!items) {
@ -1920,6 +1969,10 @@ var ZoteroPane = new function()
show.push(m.duplicateItem);
hide.push(m.recognizePDF, m.renameAttachments, m.reindexItem);
}
// Update attachment submenu
var popup = document.getElementById('zotero-add-attachment-popup')
this.updateAttachmentButtonMenu(popup);
}
}
// No items selected
@ -2468,6 +2521,11 @@ var ZoteroPane = new function()
this.addItemFromPage = function (itemType, saveSnapshot, row) {
if (!this.canEdit(row)) {
this.displayCannotEditLibraryMessage();
return;
}
return this.addItemFromDocument(window.content.document, itemType, saveSnapshot, row);
}

View File

@ -114,11 +114,11 @@
<menuitem label="&zotero.items.menu.attach.note;" oncommand="ZoteroPane.newNote(false, this.parentNode.getAttribute('itemID'))"/>
<!-- TODO: localize -->
<menu label="Add Attachment">
<menupopup>
<menuitem class="menuitem-iconic" id="zotero-menuitem-attachments-snapshot" label="&zotero.items.menu.attach.snapshot;" oncommand="var itemID = parseInt(this.parentNode.parentNode.parentNode.getAttribute('itemID')); ZoteroPane.addAttachmentFromPage(false, itemID)"/>
<menuitem class="menuitem-iconic" id="zotero-menuitem-attachments-web-link" label="&zotero.items.menu.attach.link;" oncommand="var itemID = parseInt(this.parentNode.parentNode.parentNode.getAttribute('itemID')); ZoteroPane.addAttachmentFromPage(true, itemID)"/>
<menuitem class="menuitem-iconic" id="zotero-menuitem-attachments-link" label="Attach Link to File..." oncommand="var itemID = parseInt(this.parentNode.parentNode.parentNode.getAttribute('itemID')); ZoteroPane.addAttachmentFromDialog(true, itemID);"/>
<menuitem class="menuitem-iconic" id="zotero-menuitem-attachments-file" label="Attach Stored Copy of File..." oncommand="var itemID = parseInt(this.parentNode.parentNode.parentNode.getAttribute('itemID')); ZoteroPane.addAttachmentFromDialog(false, itemID);"/>
<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.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.addAttachmentFromPage(true, itemID)"/>
<menuitem class="menuitem-iconic zotero-menuitem-attachments-file" label="Attach Stored Copy of File..." oncommand="var itemID = parseInt(this.parentNode.parentNode.parentNode.getAttribute('itemID')); ZoteroPane.addAttachmentFromDialog(false, itemID);"/>
<menuitem class="menuitem-iconic zotero-menuitem-attachments-link" label="Attach Link to File..." oncommand="var itemID = parseInt(this.parentNode.parentNode.parentNode.getAttribute('itemID')); ZoteroPane.addAttachmentFromDialog(true, itemID);"/>
</menupopup>
</menu>
<menuseparator/>
@ -222,7 +222,21 @@
</toolbarbutton>
<toolbarbutton id="zotero-tb-item-from-page" class="zotero-tb-button" tooltiptext="&zotero.toolbar.newItemFromPage.label;" oncommand="ZoteroPane.addItemFromPage('temporaryPDFHack', event.shiftKey ? !Zotero.Prefs.get('automaticSnapshots') : null)"/>
<toolbarbutton id="zotero-tb-lookup" class="zotero-tb-button" tooltiptext="&zotero.toolbar.lookup.label;" oncommand="ZoteroPane.openLookupWindow()"/>
<toolbarbutton id="zotero-tb-note-add" class="zotero-tb-button" tooltiptext="&zotero.toolbar.note.standalone;" oncommand="ZoteroPane.newNote(event.shiftKey);"/>
<!--<toolbarbutton id="zotero-tb-note-add" class="zotero-tb-button" tooltiptext="&zotero.toolbar.note.standalone;" oncommand="ZoteroPane.newNote(event.shiftKey);"/>-->
<toolbarbutton id="zotero-tb-note-add" class="zotero-tb-button" tooltiptext="New Note" type="menu">
<menupopup onpopupshowing="ZoteroPane.updateNoteButtonMenu()">
<menuitem label="Add Standalone Note" oncommand="ZoteroPane.newNote(event.shiftKey);"/>
<menuitem id="zotero-tb-add-child-note" label="Add Child Note" oncommand="var selected = ZoteroPane.getSelectedItems()[0]; var parent = selected.getSource(); parent = parent ? parent : selected.id; ZoteroPane.newNote(event.shiftKey, parent);"/>
</menupopup>
</toolbarbutton>
<toolbarbutton id="zotero-tb-attachment-add" class="zotero-tb-button" tooltiptext="New Child Attachment" type="menu">
<menupopup onpopupshowing="ZoteroPane.updateAttachmentButtonMenu(this)">
<menuitem class="menuitem-iconic zotero-menuitem-attachments-snapshot" label="&zotero.items.menu.attach.snapshot;" oncommand="var itemID = ZoteroPane.getSelectedItems()[0].id; ZoteroPane.addAttachmentFromPage(false, itemID)"/>
<menuitem class="menuitem-iconic zotero-menuitem-attachments-web-link" label="&zotero.items.menu.attach.link;" oncommand="var itemID = ZoteroPane.getSelectedItems()[0].id; ZoteroPane.addAttachmentFromPage(true, itemID)"/>
<menuitem class="menuitem-iconic zotero-menuitem-attachments-file" label="Attach Stored Copy of File..." oncommand="var itemID = ZoteroPane.getSelectedItems()[0].id; ZoteroPane.addAttachmentFromDialog(false, itemID);"/>
<menuitem class="menuitem-iconic zotero-menuitem-attachments-link" label="Attach Link to File..." oncommand="var itemID = ZoteroPane.getSelectedItems()[0].id; ZoteroPane.addAttachmentFromDialog(true, itemID);"/>
</menupopup>
</toolbarbutton>
<toolbarseparator/>
<toolbarbutton id="zotero-tb-advanced-search" class="zotero-tb-button" tooltiptext="&zotero.toolbar.advancedSearch;" oncommand="ZoteroPane.openAdvancedSearchWindow()"/>
<spacer flex="1"/>

Binary file not shown.

After

Width:  |  Height:  |  Size: 391 B

View File

@ -140,6 +140,7 @@
list-style-image: url('chrome://zotero/skin/toolbar-item-from-page.png');
}
/*
#zotero-tb-link-page
{
list-style-image: url('chrome://zotero/skin/toolbar-link-add.png');
@ -149,6 +150,12 @@
{
list-style-image: url('chrome://zotero/skin/toolbar-snapshot-add.png');
}
*/
#zotero-tb-attachment-add
{
list-style-image: url('chrome://zotero/skin/attach.png');
}
#zotero-tb-note-add
{
@ -160,22 +167,22 @@
list-style-image: url('chrome://zotero/skin/treeitem-note.png');
}
#zotero-menuitem-attachments-file
.zotero-menuitem-attachments-file
{
list-style-image: url('chrome://zotero/skin/treeitem-attachment-file.png');
}
#zotero-menuitem-attachments-link
.zotero-menuitem-attachments-link
{
list-style-image: url('chrome://zotero/skin/treeitem-attachment-link.png');
}
#zotero-menuitem-attachments-snapshot
.zotero-menuitem-attachments-snapshot
{
list-style-image: url('chrome://zotero/skin/treeitem-attachment-snapshot.png');
}
#zotero-menuitem-attachments-web-link
.zotero-menuitem-attachments-web-link
{
list-style-image: url('chrome://zotero/skin/treeitem-attachment-web-link.png');
}