diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js index f992fb74e9..335adc460f 100644 --- a/chrome/content/zotero/overlay.js +++ b/chrome/content/zotero/overlay.js @@ -628,36 +628,74 @@ var ZoteroPane = new function() { var menu = document.getElementById('zotero-itemmenu'); + var enable = [], disable = [], show = [], hide = [], multiple = ''; + if(itemsView && itemsView.selection.count > 0) { - menu.childNodes[2].removeAttribute('disabled'); - menu.childNodes[3].removeAttribute('disabled'); - menu.childNodes[5].removeAttribute('disabled'); - menu.childNodes[6].removeAttribute('disabled'); + enable.push(3,4,5,7); + + // Multiple items selected + if (itemsView.selection.count > 1) + { + var multiple = '.multiple'; + } + // Single item selected + else + { + var item = itemsView._getItemAtRow(itemsView.selection.currentIndex); + if (item.ref.isRegularItem()) + { + var itemID = item.ref.getID(); + menu.setAttribute('itemID', itemID); + + show.push(0,1,2); + } + else + { + hide.push(0,1,2); + } + } } else { - menu.childNodes[2].setAttribute('disabled', true); - menu.childNodes[3].setAttribute('disabled', true); - menu.childNodes[5].setAttribute('disabled', true); - menu.childNodes[6].setAttribute('disabled', true); + disable.push(3,4,6,7); } - var multiple = (itemsView && itemsView.selection.count > 1) ? '.multiple' : ''; - + // Remove from collection if (itemsView._itemGroup.isCollection()) { - menu.childNodes[2].setAttribute('label', Zotero.getString('pane.items.menu.remove' + multiple)); - menu.childNodes[2].setAttribute('hidden', false); + menu.childNodes[3].setAttribute('label', Zotero.getString('pane.items.menu.remove' + multiple)); + show.push(3); } else { - menu.childNodes[2].setAttribute('hidden', true); + hide.push(3); } - menu.childNodes[3].setAttribute('label', Zotero.getString('pane.items.menu.erase' + multiple)); - menu.childNodes[5].setAttribute('label', Zotero.getString('pane.items.menu.export' + multiple)); - menu.childNodes[6].setAttribute('label', Zotero.getString('pane.items.menu.createBib' + multiple)); + // Plural if necessary + menu.childNodes[4].setAttribute('label', Zotero.getString('pane.items.menu.erase' + multiple)); + menu.childNodes[6].setAttribute('label', Zotero.getString('pane.items.menu.export' + multiple)); + menu.childNodes[7].setAttribute('label', Zotero.getString('pane.items.menu.createBib' + multiple)); + + for (var i in disable) + { + menu.childNodes[disable[i]].setAttribute('disabled', true); + } + + for (var i in enable) + { + menu.childNodes[enable[i]].setAttribute('disabled', false); + } + + for (var i in hide) + { + menu.childNodes[hide[i]].setAttribute('hidden', true); + } + + for (var i in show) + { + menu.childNodes[show[i]].setAttribute('hidden', false); + } } // Adapted from: http://www.xulplanet.com/references/elemref/ref_tree.html#cmnote-9 diff --git a/chrome/content/zotero/overlay.xul b/chrome/content/zotero/overlay.xul index d8ce1e3a36..c550515b04 100644 --- a/chrome/content/zotero/overlay.xul +++ b/chrome/content/zotero/overlay.xul @@ -65,7 +65,8 @@ - + + diff --git a/chrome/locale/en-US/zotero/zotero.dtd b/chrome/locale/en-US/zotero/zotero.dtd index c87ff3d588..a39c8ff75f 100644 --- a/chrome/locale/en-US/zotero/zotero.dtd +++ b/chrome/locale/en-US/zotero/zotero.dtd @@ -16,6 +16,9 @@ + + + diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties index 0a083907e2..a16c00945e 100644 --- a/chrome/locale/en-US/zotero/zotero.properties +++ b/chrome/locale/en-US/zotero/zotero.properties @@ -11,12 +11,12 @@ pane.items.delete.title = Delete pane.items.delete.attached = Erase attached notes and files pane.items.menu.remove = Remove Selected Item pane.items.menu.remove.multiple = Remove Selected Items -pane.items.menu.erase = Delete Selected Item From Library... -pane.items.menu.erase.multiple = Delete Selected Items From Library... +pane.items.menu.erase = Delete Selected Item from Library... +pane.items.menu.erase.multiple = Delete Selected Items from Library... pane.items.menu.export = Export Selected Item... pane.items.menu.export.multiple = Export Selected Items... -pane.items.menu.createBib = Create Bibliography From Selected Item... -pane.items.menu.createBib.multiple = Create Bibliography From Selected Items... +pane.items.menu.createBib = Create Bibliography from Selected Item... +pane.items.menu.createBib.multiple = Create Bibliography from Selected Items... pane.item.selected.zero = No items selected pane.item.selected.multiple = %1 items selected