Closes #299, Method for viewing a child item that shows up in a search in its hierarchical context
Right-click option "Show in Library" for items in collections and saved searches Other changes: - Fixed error when focusing a collection with no items - selectItem() now takes an inLibrary option to always use the Library even if the item is in the current collection - Reworked buildCollectionContextMenu() to be much easier to change (will do the same for buildItemContextMenu() eventually) -- this required moving some DTD strings to properties, which I only did for en-US now, but I'll do it for the other locales we have as well
This commit is contained in:
parent
5ad86d2f50
commit
77b631f04e
|
@ -555,25 +555,42 @@ var ZoteroPane = new function()
|
|||
return itemsView;
|
||||
}
|
||||
|
||||
function selectItem(id)
|
||||
|
||||
/*
|
||||
* Select item in current collection or, if not there, in Library
|
||||
*
|
||||
* If _inLibrary_, force switch to Library
|
||||
*/
|
||||
function selectItem(itemID, inLibrary)
|
||||
{
|
||||
if (!itemID) {
|
||||
return false;
|
||||
}
|
||||
if(itemsView)
|
||||
{
|
||||
if(!itemsView._itemGroup.isLibrary())
|
||||
{
|
||||
//select the Library if the item is not in the current collection
|
||||
|
||||
var item = Zotero.Items.get(id);
|
||||
var collectionID = itemsView._itemGroup.ref.getID();
|
||||
if(!item.isRegularItem())
|
||||
{
|
||||
if(!Zotero.Items.get(item.getSource()).inCollection(collectionID))
|
||||
collectionsView.selection.select(0);
|
||||
}
|
||||
else if(!item.inCollection(collectionID))
|
||||
if (inLibrary) {
|
||||
collectionsView.selection.select(0);
|
||||
}
|
||||
// Select the Library if the item is not in the current collection
|
||||
// TODO: does not work in saved searches
|
||||
else {
|
||||
var item = Zotero.Items.get(itemID);
|
||||
var collectionID = itemsView._itemGroup.ref.getID();
|
||||
if (!item.isRegularItem()) {
|
||||
// If this isn't a regular item, check if the parent is
|
||||
// in the collection instead
|
||||
if (!Zotero.Items.get(item.getSource()).inCollection(collectionID)) {
|
||||
collectionsView.selection.select(0);
|
||||
}
|
||||
}
|
||||
else if (!item.inCollection(collectionID)) {
|
||||
collectionsView.selection.select(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
itemsView.selectItem(id);
|
||||
itemsView.selectItem(itemID);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -662,45 +679,71 @@ var ZoteroPane = new function()
|
|||
{
|
||||
var menu = document.getElementById('zotero-collectionmenu');
|
||||
|
||||
var m = {
|
||||
newCollection: 0,
|
||||
newSavedSearch: 1,
|
||||
newSubcollection: 2,
|
||||
sep1: 3,
|
||||
editSelectedCollection: 4,
|
||||
removeCollection: 5,
|
||||
sep2: 6,
|
||||
exportCollection: 7,
|
||||
createBibCollection: 8,
|
||||
exportFile: 9,
|
||||
loadReport: 10
|
||||
};
|
||||
|
||||
// Collection
|
||||
if (collectionsView.selection.count == 1 &&
|
||||
collectionsView._getItemAtRow(collectionsView.selection.currentIndex).isCollection())
|
||||
{
|
||||
var hide = [0,1,5,7,10,12,13];
|
||||
var show = [2,3,4,6,8,9,11,14];
|
||||
var hide = [m.newCollection, m.newSavedSearch, m.exportFile];
|
||||
var show = [m.newSubcollection, m.sep1, m.editSelectedCollection, m.removeCollection,
|
||||
m.sep2, m.exportCollection, m.createBibCollection, m.loadReport];
|
||||
if (itemsView.rowCount>0)
|
||||
{
|
||||
var enable = [9,11,14];
|
||||
var enable = [m.exportCollection, m.createBibCollection, m.loadReport];
|
||||
}
|
||||
else
|
||||
{
|
||||
var disable = [9,11,14];
|
||||
var disable = [m.exportCollection, m.createBibCollection, m.loadReport];
|
||||
}
|
||||
|
||||
menu.childNodes[14].setAttribute('label', Zotero.getString('pane.collections.menu.generateReport.collection'));
|
||||
menu.childNodes[m.editSelectedCollection].setAttribute('label', Zotero.getString('pane.collections.menu.rename.collection'));
|
||||
menu.childNodes[m.removeCollection].setAttribute('label', Zotero.getString('pane.collections.menu.remove.collection'));
|
||||
menu.childNodes[m.exportCollection].setAttribute('label', Zotero.getString('pane.collections.menu.export.collection'));
|
||||
menu.childNodes[m.createBibCollection].setAttribute('label', Zotero.getString('pane.collections.menu.createBib.collection'));
|
||||
menu.childNodes[m.loadReport].setAttribute('label', Zotero.getString('pane.collections.menu.generateReport.collection'));
|
||||
}
|
||||
// Saved Search
|
||||
else if (collectionsView.selection.count == 1 &&
|
||||
collectionsView._getItemAtRow(collectionsView.selection.currentIndex).isSearch())
|
||||
{
|
||||
var hide = [0,1,2,3,4,6,9,11,13];
|
||||
var show = [5,7,8,10,12,14];
|
||||
var hide = [m.newCollection, m.newSavedSearch, m.newSubcollection, m.sep1, m.exportFile]
|
||||
var show = [m.editSelectedCollection, m.removeCollection, m.sep2, m.exportCollection,
|
||||
m.createBibCollection, m.loadReport];
|
||||
|
||||
if (itemsView.rowCount>0)
|
||||
{
|
||||
var enable = [10,12,14];
|
||||
var enable = [m.exportCollection, m.createBibCollection, m.loadReport];
|
||||
}
|
||||
else
|
||||
{
|
||||
var disable = [10,12,14];
|
||||
var disable = [m.exportCollection, m.createBibCollection, m.loadReport];
|
||||
}
|
||||
|
||||
menu.childNodes[14].setAttribute('label', Zotero.getString('pane.collections.menu.generateReport.savedSearch'));
|
||||
menu.childNodes[m.editSelectedCollection].setAttribute('label', Zotero.getString('pane.collections.menu.edit.savedSearch'));
|
||||
menu.childNodes[m.removeCollection].setAttribute('label', Zotero.getString('pane.collections.menu.remove.savedSearch'));
|
||||
menu.childNodes[m.exportCollection].setAttribute('label', Zotero.getString('pane.collections.menu.export.savedSearch'));
|
||||
menu.childNodes[m.createBibCollection].setAttribute('label', Zotero.getString('pane.collections.menu.createBib.savedSearch'));
|
||||
menu.childNodes[m.loadReport].setAttribute('label', Zotero.getString('pane.collections.menu.generateReport.savedSearch'));
|
||||
}
|
||||
// Library
|
||||
else
|
||||
{
|
||||
var hide = [2,4,5,6,7,8,9,10,11,12,14];
|
||||
var show = [0,1,3,13];
|
||||
var hide = [m.newSubcollection, m.editSelectedCollection, m.removeCollection, m.sep2,
|
||||
m.exportCollection, m.createBibCollection, m.loadReport];
|
||||
var show = [m.newCollection, m.newSavedSearch, m.sep1, m.exportFile];
|
||||
}
|
||||
|
||||
for (var i in disable)
|
||||
|
@ -732,69 +775,85 @@ var ZoteroPane = new function()
|
|||
|
||||
if(itemsView && itemsView.selection.count > 0)
|
||||
{
|
||||
enable.push(0,1,2,4,5,7,8,9,10);
|
||||
enable.push(0,2,3,4,6,7,8,10,11,12);
|
||||
|
||||
// Multiple items selected
|
||||
if (itemsView.selection.count > 1)
|
||||
{
|
||||
var multiple = '.multiple';
|
||||
hide.push(0,1,2,3,4);
|
||||
hide.push(0,1,2,3,4,5,6);
|
||||
}
|
||||
// Single item selected
|
||||
else
|
||||
{
|
||||
var item = itemsView._getItemAtRow(itemsView.selection.currentIndex).ref;
|
||||
var itemID = item.getID();
|
||||
menu.setAttribute('itemID', itemID);
|
||||
|
||||
// Show in Library
|
||||
if (!itemsView._itemGroup.isLibrary()) {
|
||||
show.push(0,1);
|
||||
}
|
||||
else {
|
||||
hide.push(0,1);
|
||||
}
|
||||
|
||||
if (item.isRegularItem())
|
||||
{
|
||||
var itemID = item.getID();
|
||||
menu.setAttribute('itemID', itemID);
|
||||
|
||||
show.push(0,1,2,4);
|
||||
hide.push(3); // abstract
|
||||
show.push(2,3,4,6);
|
||||
hide.push(5); // abstract
|
||||
}
|
||||
else
|
||||
{
|
||||
hide.push(0,1,2);
|
||||
hide.push(2,3,4);
|
||||
|
||||
// Abstract
|
||||
if (item.isNote() && item.getSource()) {
|
||||
show.push(3,4);
|
||||
show.push(5,6);
|
||||
if (item.isAbstract()) {
|
||||
menu.childNodes[3].setAttribute('label', Zotero.getString('pane.items.menu.abstract.unset'));
|
||||
menu.childNodes[5].setAttribute('label', Zotero.getString('pane.items.menu.abstract.unset'));
|
||||
}
|
||||
else {
|
||||
menu.childNodes[3].setAttribute('label', Zotero.getString('pane.items.menu.abstract.set'));
|
||||
menu.childNodes[5].setAttribute('label', Zotero.getString('pane.items.menu.abstract.set'));
|
||||
}
|
||||
}
|
||||
else {
|
||||
hide.push(3,4);
|
||||
hide.push(5,6);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
disable.push(0,1,2,5,6,8,9,10);
|
||||
hide.push(3); // abstract
|
||||
show.push(4); // separator
|
||||
// Show in Library
|
||||
if (!itemsView._itemGroup.isLibrary()) {
|
||||
show.push(0,1);
|
||||
}
|
||||
else {
|
||||
hide.push(0,1);
|
||||
}
|
||||
|
||||
disable.push(0,2,3,4,7,8,10,11,12);
|
||||
hide.push(5); // abstract
|
||||
show.push(6); // separator
|
||||
}
|
||||
|
||||
// Remove from collection
|
||||
if (itemsView._itemGroup.isCollection())
|
||||
{
|
||||
menu.childNodes[5].setAttribute('label', Zotero.getString('pane.items.menu.remove' + multiple));
|
||||
show.push(5);
|
||||
menu.childNodes[7].setAttribute('label', Zotero.getString('pane.items.menu.remove' + multiple));
|
||||
show.push(7);
|
||||
}
|
||||
else
|
||||
{
|
||||
hide.push(5);
|
||||
hide.push(7);
|
||||
}
|
||||
|
||||
// Plural if necessary
|
||||
menu.childNodes[6].setAttribute('label', Zotero.getString('pane.items.menu.erase' + multiple));
|
||||
menu.childNodes[8].setAttribute('label', Zotero.getString('pane.items.menu.export' + multiple));
|
||||
menu.childNodes[9].setAttribute('label', Zotero.getString('pane.items.menu.createBib' + multiple));
|
||||
menu.childNodes[10].setAttribute('label', Zotero.getString('pane.items.menu.generateReport' + multiple));
|
||||
menu.childNodes[8].setAttribute('label', Zotero.getString('pane.items.menu.erase' + multiple));
|
||||
menu.childNodes[10].setAttribute('label', Zotero.getString('pane.items.menu.export' + multiple));
|
||||
menu.childNodes[11].setAttribute('label', Zotero.getString('pane.items.menu.createBib' + multiple));
|
||||
menu.childNodes[12].setAttribute('label', Zotero.getString('pane.items.menu.generateReport' + multiple));
|
||||
|
||||
for (var i in disable)
|
||||
{
|
||||
|
|
|
@ -70,19 +70,17 @@
|
|||
<menuitem label="&zotero.toolbar.newSavedSearch.label;" oncommand="ZoteroPane.newSearch()"/>
|
||||
<menuitem label="&zotero.toolbar.newSubcollection.label;" oncommand="ZoteroPane.newCollection(ZoteroPane.getSelectedCollection().getID())"/>
|
||||
<menuseparator/>
|
||||
<menuitem label="&zotero.toolbar.renameCollection.label;" oncommand="ZoteroPane.editSelectedCollection();"/>
|
||||
<menuitem label="&zotero.toolbar.renameSavedSearch.label;" oncommand="ZoteroPane.editSelectedCollection()"/>
|
||||
<menuitem label="&zotero.toolbar.removeCollection.label;" oncommand="ZoteroPane.deleteSelectedCollection();"/>
|
||||
<menuitem label="&zotero.toolbar.removeSavedSearch.label;" oncommand="ZoteroPane.deleteSelectedCollection()"/>
|
||||
<menuitem oncommand="ZoteroPane.editSelectedCollection();"/>
|
||||
<menuitem oncommand="ZoteroPane.deleteSelectedCollection();"/>
|
||||
<menuseparator/>
|
||||
<menuitem label="&zotero.toolbar.exportCollection.label;" oncommand="Zotero_File_Interface.exportCollection();"/>
|
||||
<menuitem label="&zotero.toolbar.exportSavedSearch.label;" oncommand="Zotero_File_Interface.exportCollection()"/>
|
||||
<menuitem label="&zotero.toolbar.createBibCollection.label;" oncommand="Zotero_File_Interface.bibliographyFromCollection();"/>
|
||||
<menuitem label="&zotero.toolbar.createBibSavedSearch.label;" oncommand="Zotero_File_Interface.bibliographyFromCollection()"/>
|
||||
<menuitem oncommand="Zotero_File_Interface.exportCollection();"/>
|
||||
<menuitem oncommand="Zotero_File_Interface.bibliographyFromCollection();"/>
|
||||
<menuitem label="&zotero.toolbar.export.label;" oncommand="Zotero_File_Interface.exportFile()"/>
|
||||
<menuitem oncommand="Zotero_Report_Interface.loadCollectionReport()"/>
|
||||
</popup>
|
||||
<popup id="zotero-itemmenu" onpopupshowing="ZoteroPane.buildItemContextMenu();">
|
||||
<menuitem label="&zotero.items.menu.showInLibrary;" oncommand="ZoteroPane.selectItem(this.parentNode.getAttribute('itemID'), true)"/>
|
||||
<menuseparator/>
|
||||
<menuitem label="&zotero.items.menu.attach.note;" oncommand="ZoteroPane.newNote(false, this.parentNode.getAttribute('itemID'))"/>
|
||||
<menuitem label="&zotero.items.menu.attach.snapshot;" oncommand="ZoteroPane.addAttachmentFromPage(false, this.parentNode.getAttribute('itemID'));"/>
|
||||
<menuitem label="&zotero.items.menu.attach.link;" oncommand="ZoteroPane.addAttachmentFromPage(true, this.parentNode.getAttribute('itemID'));"/>
|
||||
|
@ -162,7 +160,7 @@
|
|||
id="zotero-items-tree" context="zotero-itemmenu"
|
||||
ondblclick="ZoteroPane.onDoubleClick(event, this);"
|
||||
enableColumnDrag="true"
|
||||
onfocus="if (!ZoteroPane.getItemsView().selection.count) { ZoteroPane.getItemsView().selection.select(0); }"
|
||||
onfocus="if (ZoteroPane.getItemsView().rowCount && !ZoteroPane.getItemsView().selection.count) { ZoteroPane.getItemsView().selection.select(0); }"
|
||||
onkeypress="if (event.keyCode == event.DOM_VK_BACK_SPACE || event.keyCode == event.DOM_VK_DELETE){ ZoteroPane.deleteSelectedItem(); event.preventDefault(); }"
|
||||
onselect="ZoteroPane.itemSelected();"
|
||||
ondraggesture="if (event.target.localName == 'treechildren') nsDragAndDrop.startDrag(event,ZoteroPane.getItemsView());"
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
<!ENTITY zotero.items.dateAdded_column "Date Added">
|
||||
<!ENTITY zotero.items.dateModified_column "Date Modified">
|
||||
|
||||
<!ENTITY zotero.items.menu.showInLibrary "Show in Library">
|
||||
<!ENTITY zotero.items.menu.attach.note "Add Note">
|
||||
<!ENTITY zotero.items.menu.attach.snapshot "Attach Snapshot of Current Page">
|
||||
<!ENTITY zotero.items.menu.attach.link "Attach Link to Current Page">
|
||||
|
@ -33,19 +34,11 @@
|
|||
<!ENTITY zotero.toolbar.newSubcollection.label "New Subcollection...">
|
||||
<!ENTITY zotero.toolbar.newSavedSearch.label "New Saved Search...">
|
||||
<!ENTITY zotero.toolbar.tagSelector.label "Show/Hide Tag Selector">
|
||||
<!ENTITY zotero.toolbar.renameCollection.label "Rename Collection...">
|
||||
<!ENTITY zotero.toolbar.removeCollection.label "Remove Collection...">
|
||||
<!ENTITY zotero.toolbar.exportCollection.label "Export Collection...">
|
||||
<!ENTITY zotero.toolbar.renameSavedSearch.label "Edit Saved Search...">
|
||||
<!ENTITY zotero.toolbar.removeSavedSearch.label "Remove Saved Search...">
|
||||
<!ENTITY zotero.toolbar.exportSavedSearch.label "Export Saved Search...">
|
||||
<!ENTITY zotero.toolbar.actions.label "Actions">
|
||||
<!ENTITY zotero.toolbar.import.label "Import...">
|
||||
<!ENTITY zotero.toolbar.export.label "Export Library...">
|
||||
<!ENTITY zotero.toolbar.preferences.label "Preferences...">
|
||||
<!ENTITY zotero.toolbar.about.label "About Zotero...">
|
||||
<!ENTITY zotero.toolbar.createBibCollection.label "Create Bibliography From Collection...">
|
||||
<!ENTITY zotero.toolbar.createBibSavedSearch.label "Create Bibliography From Saved Search...">
|
||||
<!ENTITY zotero.toolbar.search.label "Search:">
|
||||
<!ENTITY zotero.toolbar.fullscreen.tooltip "Toggle Fullscreen Mode">
|
||||
<!ENTITY zotero.toolbar.goToURL.label "View">
|
||||
|
|
|
@ -4,6 +4,16 @@ pane.collections.name = Collection name:
|
|||
pane.collections.rename = Rename collection:
|
||||
pane.collections.library = My Library
|
||||
pane.collections.untitled = Untitled
|
||||
|
||||
pane.collections.menu.rename.collection = Rename Collection...
|
||||
pane.collections.menu.edit.savedSearch = Edit Saved Search
|
||||
pane.collections.menu.remove.collection = Remove Collection...
|
||||
pane.collections.menu.remove.savedSearch = Remove Saved Search...
|
||||
pane.collections.menu.export.collection = Export Collection...
|
||||
pane.collections.menu.export.savedSearch = Export Saved Search...
|
||||
pane.collections.menu.createBib.collection = Create Bibliography From Collection...
|
||||
pane.collections.menu.createBib.savedSearch = Create Bibliography From Saved Search...
|
||||
|
||||
pane.collections.menu.generateReport.collection = Generate Report from Collection...
|
||||
pane.collections.menu.generateReport.savedSearch = Generate Report from Saved Search...
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user