Classic citation dialog fixes
- Fix loading for libraries that haven't yet been loaded (including if the Zotero pane hasn't yet been opened) - Show a loading message over the items tree - Fix item selection when editing citation (except if library data hasn't yet been loaded, but that doesn't happen in Standalone)
This commit is contained in:
parent
93cfc229f9
commit
8a4c8d2be0
3 changed files with 243 additions and 204 deletions
|
@ -52,7 +52,6 @@ var Zotero_Citation_Dialog = new function () {
|
|||
var serial_number;
|
||||
var io;
|
||||
|
||||
this.load = load;
|
||||
this.toggleMultipleSources = toggleMultipleSources;
|
||||
this.toggleEditor = toggleEditor;
|
||||
this.treeItemSelected = treeItemSelected;
|
||||
|
@ -70,7 +69,7 @@ var Zotero_Citation_Dialog = new function () {
|
|||
/*
|
||||
* initialize add citation dialog
|
||||
*/
|
||||
function load() {
|
||||
this.load = Zotero.Promise.coroutine(function* () {
|
||||
// make sure we are visible
|
||||
window.setTimeout(function() {
|
||||
var screenX = window.screenX;
|
||||
|
@ -129,7 +128,7 @@ var Zotero_Citation_Dialog = new function () {
|
|||
menu.selectedIndex = 0;
|
||||
|
||||
// load (from selectItemsDialog.js)
|
||||
doLoad();
|
||||
yield doLoad();
|
||||
|
||||
// if we already have a citation, load data from it
|
||||
document.getElementById('editor').format = "RTF";
|
||||
|
@ -139,20 +138,12 @@ var Zotero_Citation_Dialog = new function () {
|
|||
toggleMultipleSources(false);
|
||||
_suppressNextTreeSelect = true;
|
||||
|
||||
// If we're in a different library, switch libraries
|
||||
// DEBUG: When editing a citation before the library data has been loaded (i.e., in
|
||||
// Firefox before the pane has been opened), this is the citation id, not the item id,
|
||||
// and this fails. It works on subsequent attempts. Since this won't happen in
|
||||
// Standalone, we can ignore.
|
||||
var id = io.citation.citationItems[0].id;
|
||||
var collectionTreeRow = collectionsView.selectedTreeRow;
|
||||
var item = Zotero.Items.get(id);
|
||||
if(item.libraryID != collectionTreeRow.ref.libraryID) {
|
||||
collectionsView.selectLibrary(item.libraryID);
|
||||
}
|
||||
var selected = itemsView.selectItem(id);
|
||||
if(!selected) {
|
||||
// If item wasn't found in current view, select library root
|
||||
// and try again (in case we were in a collection of correct library)
|
||||
collectionsView.selectLibrary(item.libraryID);
|
||||
itemsView.selectItem(id);
|
||||
}
|
||||
var selected = yield itemsView.selectItem(id);
|
||||
|
||||
for(var box in _preserveData) {
|
||||
var property = _preserveData[box][0];
|
||||
|
@ -209,7 +200,7 @@ var Zotero_Citation_Dialog = new function () {
|
|||
} else {
|
||||
toggleMultipleSources(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* turn on/off multiple sources item list
|
||||
|
@ -652,7 +643,7 @@ var Zotero_Citation_Dialog = new function () {
|
|||
/*
|
||||
* Controls whether the accept (OK) button should be enabled
|
||||
*/
|
||||
function _updateAccept(status) {
|
||||
function _updateAccept() {
|
||||
if(_multipleSourcesOn) {
|
||||
_acceptButton.disabled = !_citationList.getRowCount();
|
||||
// To prevent accidental data loss, do not allow change to
|
||||
|
@ -664,9 +655,14 @@ var Zotero_Citation_Dialog = new function () {
|
|||
_multipleSourceButton.disabled = false;
|
||||
}
|
||||
} else {
|
||||
collectionsView.addEventListener('load', () => {
|
||||
_acceptButton.disabled = !itemsView.getSelectedItems().length;
|
||||
});
|
||||
collectionsView.addEventListener('load', Zotero.Promise.coroutine(function* () {
|
||||
if (itemsView) {
|
||||
var deferred = Zotero.Promise.defer();
|
||||
itemsView.addEventListener('load', () => deferred.resolve());
|
||||
yield deferred.promise;
|
||||
_acceptButton.disabled = !itemsView.getSelectedItems().length;
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -74,173 +74,179 @@
|
|||
</treecols>
|
||||
<treechildren/>
|
||||
</tree>
|
||||
|
||||
<tree id="zotero-items-tree"
|
||||
enableColumnDrag="true" flex="1" seltype="single"
|
||||
onselect="Zotero_Citation_Dialog.treeItemSelected();">
|
||||
<treecols id="zotero-items-columns-header">
|
||||
<treecol
|
||||
id="zotero-items-column-title" primary="true"
|
||||
label="&zotero.items.title_column;"
|
||||
flex="4" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-firstCreator"
|
||||
label="&zotero.items.creator_column;"
|
||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-itemType" hidden="true"
|
||||
label="&zotero.items.type_column;"
|
||||
width="40" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-date" hidden="true"
|
||||
label="&zotero.items.date_column;"
|
||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-year" hidden="true"
|
||||
label="&zotero.items.year_column;"
|
||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-publisher" hidden="true"
|
||||
label="&zotero.items.publisher_column;"
|
||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-publicationTitle" hidden="true"
|
||||
label="&zotero.items.publication_column;"
|
||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-journalAbbreviation" hidden="true"
|
||||
label="&zotero.items.journalAbbr_column;"
|
||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-language" hidden="true"
|
||||
label="&zotero.items.language_column;"
|
||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-accessDate" hidden="true"
|
||||
label="&zotero.items.accessDate_column;"
|
||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-libraryCatalog" hidden="true"
|
||||
label="&zotero.items.libraryCatalog_column;"
|
||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-callNumber" hidden="true"
|
||||
submenu="true"
|
||||
label="&zotero.items.callNumber_column;"
|
||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-rights" hidden="true"
|
||||
submenu="true"
|
||||
label="&zotero.items.rights_column;"
|
||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-dateAdded" hidden="true"
|
||||
label="&zotero.items.dateAdded_column;"
|
||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-dateModified" hidden="true"
|
||||
label="&zotero.items.dateModified_column;"
|
||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-archive" hidden="true"
|
||||
submenu="true"
|
||||
label="&zotero.items.archive_column;"
|
||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-archiveLocation" hidden="true"
|
||||
submenu="true"
|
||||
label="&zotero.items.archiveLocation_column;"
|
||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-place" hidden="true"
|
||||
submenu="true"
|
||||
label="&zotero.items.place_column;"
|
||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-volume" hidden="true"
|
||||
submenu="true"
|
||||
label="&zotero.items.volume_column;"
|
||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-edition" hidden="true"
|
||||
submenu="true"
|
||||
label="&zotero.items.edition_column;"
|
||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-pages" hidden="true"
|
||||
submenu="true"
|
||||
label="&zotero.items.pages_column;"
|
||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-issue" hidden="true"
|
||||
submenu="true"
|
||||
label="&zotero.items.issue_column;"
|
||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-series" hidden="true"
|
||||
submenu="true"
|
||||
label="&zotero.items.series_column;"
|
||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-seriesTitle" hidden="true"
|
||||
submenu="true"
|
||||
label="&zotero.items.seriesTitle_column;"
|
||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-court" hidden="true"
|
||||
submenu="true"
|
||||
label="&zotero.items.court_column;"
|
||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-medium" hidden="true"
|
||||
submenu="true"
|
||||
label="&zotero.items.medium_column;"
|
||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-genre" hidden="true"
|
||||
submenu="true"
|
||||
label="&zotero.items.genre_column;"
|
||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-system" hidden="true"
|
||||
submenu="true"
|
||||
label="&zotero.items.system_column;"
|
||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-extra" hidden="true"
|
||||
label="&zotero.items.extra_column;"
|
||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||
</treecols>
|
||||
<treechildren/>
|
||||
</tree>
|
||||
|
||||
<deck id="zotero-items-pane-content" selectedIndex="0" flex="1">
|
||||
<tree id="zotero-items-tree"
|
||||
enableColumnDrag="true" flex="1" seltype="single"
|
||||
onselect="Zotero_Citation_Dialog.treeItemSelected();">
|
||||
<treecols id="zotero-items-columns-header">
|
||||
<treecol
|
||||
id="zotero-items-column-title" primary="true"
|
||||
label="&zotero.items.title_column;"
|
||||
flex="4" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-firstCreator"
|
||||
label="&zotero.items.creator_column;"
|
||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-itemType" hidden="true"
|
||||
label="&zotero.items.type_column;"
|
||||
width="40" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-date" hidden="true"
|
||||
label="&zotero.items.date_column;"
|
||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-year" hidden="true"
|
||||
label="&zotero.items.year_column;"
|
||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-publisher" hidden="true"
|
||||
label="&zotero.items.publisher_column;"
|
||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-publicationTitle" hidden="true"
|
||||
label="&zotero.items.publication_column;"
|
||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-journalAbbreviation" hidden="true"
|
||||
label="&zotero.items.journalAbbr_column;"
|
||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-language" hidden="true"
|
||||
label="&zotero.items.language_column;"
|
||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-accessDate" hidden="true"
|
||||
label="&zotero.items.accessDate_column;"
|
||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-libraryCatalog" hidden="true"
|
||||
label="&zotero.items.libraryCatalog_column;"
|
||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-callNumber" hidden="true"
|
||||
submenu="true"
|
||||
label="&zotero.items.callNumber_column;"
|
||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-rights" hidden="true"
|
||||
submenu="true"
|
||||
label="&zotero.items.rights_column;"
|
||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-dateAdded" hidden="true"
|
||||
label="&zotero.items.dateAdded_column;"
|
||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-dateModified" hidden="true"
|
||||
label="&zotero.items.dateModified_column;"
|
||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-archive" hidden="true"
|
||||
submenu="true"
|
||||
label="&zotero.items.archive_column;"
|
||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-archiveLocation" hidden="true"
|
||||
submenu="true"
|
||||
label="&zotero.items.archiveLocation_column;"
|
||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-place" hidden="true"
|
||||
submenu="true"
|
||||
label="&zotero.items.place_column;"
|
||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-volume" hidden="true"
|
||||
submenu="true"
|
||||
label="&zotero.items.volume_column;"
|
||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-edition" hidden="true"
|
||||
submenu="true"
|
||||
label="&zotero.items.edition_column;"
|
||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-pages" hidden="true"
|
||||
submenu="true"
|
||||
label="&zotero.items.pages_column;"
|
||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-issue" hidden="true"
|
||||
submenu="true"
|
||||
label="&zotero.items.issue_column;"
|
||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-series" hidden="true"
|
||||
submenu="true"
|
||||
label="&zotero.items.series_column;"
|
||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-seriesTitle" hidden="true"
|
||||
submenu="true"
|
||||
label="&zotero.items.seriesTitle_column;"
|
||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-court" hidden="true"
|
||||
submenu="true"
|
||||
label="&zotero.items.court_column;"
|
||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-medium" hidden="true"
|
||||
submenu="true"
|
||||
label="&zotero.items.medium_column;"
|
||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-genre" hidden="true"
|
||||
submenu="true"
|
||||
label="&zotero.items.genre_column;"
|
||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-system" hidden="true"
|
||||
submenu="true"
|
||||
label="&zotero.items.system_column;"
|
||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-extra" hidden="true"
|
||||
label="&zotero.items.extra_column;"
|
||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||
</treecols>
|
||||
<treechildren/>
|
||||
</tree>
|
||||
|
||||
<!-- Label for displaying messages when items pane is hidden
|
||||
(e.g. "Advanced search mode — press Enter to search.")-->
|
||||
<vbox id="zotero-items-pane-message-box" pack="center" align="center"/>
|
||||
</deck>
|
||||
</hbox>
|
||||
</vbox>
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
var itemsView;
|
||||
var collectionsView;
|
||||
var io;
|
||||
var connectionSelectedDeferred;
|
||||
|
||||
/*
|
||||
* window takes two arguments:
|
||||
|
@ -42,8 +43,9 @@ var doLoad = Zotero.Promise.coroutine(function* () {
|
|||
if(io.addBorder) document.getElementsByTagName("dialog")[0].style.border = "1px solid black";
|
||||
if(io.singleSelection) document.getElementById("zotero-items-tree").setAttribute("seltype", "single");
|
||||
|
||||
setItemsPaneMessage(Zotero.getString('pane.items.loading'));
|
||||
|
||||
collectionsView = new Zotero.CollectionTreeView();
|
||||
// Don't show Commons when citing
|
||||
collectionsView.hideSources = ['duplicates', 'trash', 'feeds'];
|
||||
document.getElementById('zotero-collections-tree').view = collectionsView;
|
||||
|
||||
|
@ -51,7 +53,12 @@ var doLoad = Zotero.Promise.coroutine(function* () {
|
|||
collectionsView.addEventListener('load', () => deferred.resolve());
|
||||
yield deferred.promise;
|
||||
|
||||
if(io.select) itemsView.selectItem(io.select);
|
||||
connectionSelectedDeferred = Zotero.Promise.defer();
|
||||
yield connectionSelectedDeferred.promise;
|
||||
|
||||
if (io.select) {
|
||||
yield itemsView.selectItem(io.select);
|
||||
}
|
||||
|
||||
Zotero.updateQuickSearchBox(document);
|
||||
});
|
||||
|
@ -63,30 +70,37 @@ function doUnload()
|
|||
itemsView.unregister();
|
||||
}
|
||||
|
||||
function onCollectionSelected()
|
||||
var onCollectionSelected = Zotero.Promise.coroutine(function* ()
|
||||
{
|
||||
if(itemsView)
|
||||
itemsView.unregister();
|
||||
|
||||
if(collectionsView.selection.count == 1 && collectionsView.selection.currentIndex != -1)
|
||||
{
|
||||
var collection = collectionsView.getRow(collectionsView.selection.currentIndex);
|
||||
collection.setSearch('');
|
||||
var collectionTreeRow = collectionsView.getRow(collectionsView.selection.currentIndex);
|
||||
collectionTreeRow.setSearch('');
|
||||
Zotero.Prefs.set('lastViewedFolder', collectionTreeRow.id);
|
||||
|
||||
itemsView = new Zotero.ItemTreeView(collection, (window.arguments[1] ? true : false));
|
||||
// Load library data if necessary
|
||||
var library = Zotero.Libraries.get(collectionTreeRow.ref.libraryID);
|
||||
if (!library.getDataLoaded('item')) {
|
||||
Zotero.debug("Waiting for items to load for library " + library.libraryID);
|
||||
setItemsPaneMessage(Zotero.getString('pane.items.loading'));
|
||||
yield library.waitForDataLoad('item');
|
||||
}
|
||||
|
||||
// Create items list and wait for it to load
|
||||
itemsView = new Zotero.ItemTreeView(collectionTreeRow, (window.arguments[1] ? true : false));
|
||||
document.getElementById('zotero-items-tree').view = itemsView;
|
||||
var deferred = Zotero.Promise.defer();
|
||||
itemsView.addEventListener('load', () => deferred.resolve());
|
||||
yield deferred.promise;
|
||||
|
||||
if (collection.isLibrary()) {
|
||||
Zotero.Prefs.set('lastViewedFolder', 'L');
|
||||
}
|
||||
if (collection.isCollection()) {
|
||||
Zotero.Prefs.set('lastViewedFolder', 'C' + collection.ref.getID());
|
||||
}
|
||||
else if (collection.isSearch()) {
|
||||
Zotero.Prefs.set('lastViewedFolder', 'S' + collection.ref.id);
|
||||
}
|
||||
clearItemsPaneMessage();
|
||||
|
||||
connectionSelectedDeferred.resolve();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function onSearch()
|
||||
{
|
||||
|
@ -102,6 +116,29 @@ function onItemSelected()
|
|||
|
||||
}
|
||||
|
||||
function setItemsPaneMessage(content) {
|
||||
var elem = document.getElementById('zotero-items-pane-message-box');
|
||||
elem.textContent = '';
|
||||
if (typeof content == 'string') {
|
||||
let contentParts = content.split("\n\n");
|
||||
for (let part of contentParts) {
|
||||
var desc = document.createElement('description');
|
||||
desc.appendChild(document.createTextNode(part));
|
||||
elem.appendChild(desc);
|
||||
}
|
||||
}
|
||||
else {
|
||||
elem.appendChild(content);
|
||||
}
|
||||
document.getElementById('zotero-items-pane-content').selectedIndex = 1;
|
||||
}
|
||||
|
||||
|
||||
function clearItemsPaneMessage() {
|
||||
var box = document.getElementById('zotero-items-pane-message-box');
|
||||
document.getElementById('zotero-items-pane-content').selectedIndex = 0;
|
||||
}
|
||||
|
||||
function doAccept()
|
||||
{
|
||||
io.dataOut = itemsView.getSelectedItems(true);
|
||||
|
|
Loading…
Reference in a new issue