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 serial_number;
|
||||||
var io;
|
var io;
|
||||||
|
|
||||||
this.load = load;
|
|
||||||
this.toggleMultipleSources = toggleMultipleSources;
|
this.toggleMultipleSources = toggleMultipleSources;
|
||||||
this.toggleEditor = toggleEditor;
|
this.toggleEditor = toggleEditor;
|
||||||
this.treeItemSelected = treeItemSelected;
|
this.treeItemSelected = treeItemSelected;
|
||||||
|
@ -70,7 +69,7 @@ var Zotero_Citation_Dialog = new function () {
|
||||||
/*
|
/*
|
||||||
* initialize add citation dialog
|
* initialize add citation dialog
|
||||||
*/
|
*/
|
||||||
function load() {
|
this.load = Zotero.Promise.coroutine(function* () {
|
||||||
// make sure we are visible
|
// make sure we are visible
|
||||||
window.setTimeout(function() {
|
window.setTimeout(function() {
|
||||||
var screenX = window.screenX;
|
var screenX = window.screenX;
|
||||||
|
@ -129,7 +128,7 @@ var Zotero_Citation_Dialog = new function () {
|
||||||
menu.selectedIndex = 0;
|
menu.selectedIndex = 0;
|
||||||
|
|
||||||
// load (from selectItemsDialog.js)
|
// load (from selectItemsDialog.js)
|
||||||
doLoad();
|
yield doLoad();
|
||||||
|
|
||||||
// if we already have a citation, load data from it
|
// if we already have a citation, load data from it
|
||||||
document.getElementById('editor').format = "RTF";
|
document.getElementById('editor').format = "RTF";
|
||||||
|
@ -139,20 +138,12 @@ var Zotero_Citation_Dialog = new function () {
|
||||||
toggleMultipleSources(false);
|
toggleMultipleSources(false);
|
||||||
_suppressNextTreeSelect = true;
|
_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 id = io.citation.citationItems[0].id;
|
||||||
var collectionTreeRow = collectionsView.selectedTreeRow;
|
var selected = yield itemsView.selectItem(id);
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(var box in _preserveData) {
|
for(var box in _preserveData) {
|
||||||
var property = _preserveData[box][0];
|
var property = _preserveData[box][0];
|
||||||
|
@ -209,7 +200,7 @@ var Zotero_Citation_Dialog = new function () {
|
||||||
} else {
|
} else {
|
||||||
toggleMultipleSources(false);
|
toggleMultipleSources(false);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* turn on/off multiple sources item list
|
* 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
|
* Controls whether the accept (OK) button should be enabled
|
||||||
*/
|
*/
|
||||||
function _updateAccept(status) {
|
function _updateAccept() {
|
||||||
if(_multipleSourcesOn) {
|
if(_multipleSourcesOn) {
|
||||||
_acceptButton.disabled = !_citationList.getRowCount();
|
_acceptButton.disabled = !_citationList.getRowCount();
|
||||||
// To prevent accidental data loss, do not allow change to
|
// To prevent accidental data loss, do not allow change to
|
||||||
|
@ -664,9 +655,14 @@ var Zotero_Citation_Dialog = new function () {
|
||||||
_multipleSourceButton.disabled = false;
|
_multipleSourceButton.disabled = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
collectionsView.addEventListener('load', () => {
|
collectionsView.addEventListener('load', Zotero.Promise.coroutine(function* () {
|
||||||
_acceptButton.disabled = !itemsView.getSelectedItems().length;
|
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>
|
</treecols>
|
||||||
<treechildren/>
|
<treechildren/>
|
||||||
</tree>
|
</tree>
|
||||||
|
|
||||||
<tree id="zotero-items-tree"
|
<deck id="zotero-items-pane-content" selectedIndex="0" flex="1">
|
||||||
enableColumnDrag="true" flex="1" seltype="single"
|
<tree id="zotero-items-tree"
|
||||||
onselect="Zotero_Citation_Dialog.treeItemSelected();">
|
enableColumnDrag="true" flex="1" seltype="single"
|
||||||
<treecols id="zotero-items-columns-header">
|
onselect="Zotero_Citation_Dialog.treeItemSelected();">
|
||||||
<treecol
|
<treecols id="zotero-items-columns-header">
|
||||||
id="zotero-items-column-title" primary="true"
|
<treecol
|
||||||
label="&zotero.items.title_column;"
|
id="zotero-items-column-title" primary="true"
|
||||||
flex="4" persist="width ordinal hidden sortActive sortDirection"/>
|
label="&zotero.items.title_column;"
|
||||||
<splitter class="tree-splitter"/>
|
flex="4" persist="width ordinal hidden sortActive sortDirection"/>
|
||||||
<treecol
|
<splitter class="tree-splitter"/>
|
||||||
id="zotero-items-column-firstCreator"
|
<treecol
|
||||||
label="&zotero.items.creator_column;"
|
id="zotero-items-column-firstCreator"
|
||||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
label="&zotero.items.creator_column;"
|
||||||
<splitter class="tree-splitter"/>
|
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||||
<treecol
|
<splitter class="tree-splitter"/>
|
||||||
id="zotero-items-column-itemType" hidden="true"
|
<treecol
|
||||||
label="&zotero.items.type_column;"
|
id="zotero-items-column-itemType" hidden="true"
|
||||||
width="40" persist="width ordinal hidden sortActive sortDirection"/>
|
label="&zotero.items.type_column;"
|
||||||
<splitter class="tree-splitter"/>
|
width="40" persist="width ordinal hidden sortActive sortDirection"/>
|
||||||
<treecol
|
<splitter class="tree-splitter"/>
|
||||||
id="zotero-items-column-date" hidden="true"
|
<treecol
|
||||||
label="&zotero.items.date_column;"
|
id="zotero-items-column-date" hidden="true"
|
||||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
label="&zotero.items.date_column;"
|
||||||
<splitter class="tree-splitter"/>
|
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||||
<treecol
|
<splitter class="tree-splitter"/>
|
||||||
id="zotero-items-column-year" hidden="true"
|
<treecol
|
||||||
label="&zotero.items.year_column;"
|
id="zotero-items-column-year" hidden="true"
|
||||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
label="&zotero.items.year_column;"
|
||||||
<splitter class="tree-splitter"/>
|
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||||
<treecol
|
<splitter class="tree-splitter"/>
|
||||||
id="zotero-items-column-publisher" hidden="true"
|
<treecol
|
||||||
label="&zotero.items.publisher_column;"
|
id="zotero-items-column-publisher" hidden="true"
|
||||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
label="&zotero.items.publisher_column;"
|
||||||
<splitter class="tree-splitter"/>
|
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||||
<treecol
|
<splitter class="tree-splitter"/>
|
||||||
id="zotero-items-column-publicationTitle" hidden="true"
|
<treecol
|
||||||
label="&zotero.items.publication_column;"
|
id="zotero-items-column-publicationTitle" hidden="true"
|
||||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
label="&zotero.items.publication_column;"
|
||||||
<splitter class="tree-splitter"/>
|
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||||
<treecol
|
<splitter class="tree-splitter"/>
|
||||||
id="zotero-items-column-journalAbbreviation" hidden="true"
|
<treecol
|
||||||
label="&zotero.items.journalAbbr_column;"
|
id="zotero-items-column-journalAbbreviation" hidden="true"
|
||||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
label="&zotero.items.journalAbbr_column;"
|
||||||
<splitter class="tree-splitter"/>
|
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||||
<treecol
|
<splitter class="tree-splitter"/>
|
||||||
id="zotero-items-column-language" hidden="true"
|
<treecol
|
||||||
label="&zotero.items.language_column;"
|
id="zotero-items-column-language" hidden="true"
|
||||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
label="&zotero.items.language_column;"
|
||||||
<splitter class="tree-splitter"/>
|
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||||
<treecol
|
<splitter class="tree-splitter"/>
|
||||||
id="zotero-items-column-accessDate" hidden="true"
|
<treecol
|
||||||
label="&zotero.items.accessDate_column;"
|
id="zotero-items-column-accessDate" hidden="true"
|
||||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
label="&zotero.items.accessDate_column;"
|
||||||
<splitter class="tree-splitter"/>
|
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||||
<treecol
|
<splitter class="tree-splitter"/>
|
||||||
id="zotero-items-column-libraryCatalog" hidden="true"
|
<treecol
|
||||||
label="&zotero.items.libraryCatalog_column;"
|
id="zotero-items-column-libraryCatalog" hidden="true"
|
||||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
label="&zotero.items.libraryCatalog_column;"
|
||||||
<splitter class="tree-splitter"/>
|
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||||
<treecol
|
<splitter class="tree-splitter"/>
|
||||||
id="zotero-items-column-callNumber" hidden="true"
|
<treecol
|
||||||
submenu="true"
|
id="zotero-items-column-callNumber" hidden="true"
|
||||||
label="&zotero.items.callNumber_column;"
|
submenu="true"
|
||||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
label="&zotero.items.callNumber_column;"
|
||||||
<splitter class="tree-splitter"/>
|
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||||
<treecol
|
<splitter class="tree-splitter"/>
|
||||||
id="zotero-items-column-rights" hidden="true"
|
<treecol
|
||||||
submenu="true"
|
id="zotero-items-column-rights" hidden="true"
|
||||||
label="&zotero.items.rights_column;"
|
submenu="true"
|
||||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
label="&zotero.items.rights_column;"
|
||||||
<splitter class="tree-splitter"/>
|
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||||
<treecol
|
<splitter class="tree-splitter"/>
|
||||||
id="zotero-items-column-dateAdded" hidden="true"
|
<treecol
|
||||||
label="&zotero.items.dateAdded_column;"
|
id="zotero-items-column-dateAdded" hidden="true"
|
||||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
label="&zotero.items.dateAdded_column;"
|
||||||
<splitter class="tree-splitter"/>
|
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||||
<treecol
|
<splitter class="tree-splitter"/>
|
||||||
id="zotero-items-column-dateModified" hidden="true"
|
<treecol
|
||||||
label="&zotero.items.dateModified_column;"
|
id="zotero-items-column-dateModified" hidden="true"
|
||||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
label="&zotero.items.dateModified_column;"
|
||||||
<splitter class="tree-splitter"/>
|
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||||
<treecol
|
<splitter class="tree-splitter"/>
|
||||||
id="zotero-items-column-archive" hidden="true"
|
<treecol
|
||||||
submenu="true"
|
id="zotero-items-column-archive" hidden="true"
|
||||||
label="&zotero.items.archive_column;"
|
submenu="true"
|
||||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
label="&zotero.items.archive_column;"
|
||||||
<splitter class="tree-splitter"/>
|
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||||
<treecol
|
<splitter class="tree-splitter"/>
|
||||||
id="zotero-items-column-archiveLocation" hidden="true"
|
<treecol
|
||||||
submenu="true"
|
id="zotero-items-column-archiveLocation" hidden="true"
|
||||||
label="&zotero.items.archiveLocation_column;"
|
submenu="true"
|
||||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
label="&zotero.items.archiveLocation_column;"
|
||||||
<splitter class="tree-splitter"/>
|
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||||
<treecol
|
<splitter class="tree-splitter"/>
|
||||||
id="zotero-items-column-place" hidden="true"
|
<treecol
|
||||||
submenu="true"
|
id="zotero-items-column-place" hidden="true"
|
||||||
label="&zotero.items.place_column;"
|
submenu="true"
|
||||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
label="&zotero.items.place_column;"
|
||||||
<splitter class="tree-splitter"/>
|
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||||
<treecol
|
<splitter class="tree-splitter"/>
|
||||||
id="zotero-items-column-volume" hidden="true"
|
<treecol
|
||||||
submenu="true"
|
id="zotero-items-column-volume" hidden="true"
|
||||||
label="&zotero.items.volume_column;"
|
submenu="true"
|
||||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
label="&zotero.items.volume_column;"
|
||||||
<splitter class="tree-splitter"/>
|
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||||
<treecol
|
<splitter class="tree-splitter"/>
|
||||||
id="zotero-items-column-edition" hidden="true"
|
<treecol
|
||||||
submenu="true"
|
id="zotero-items-column-edition" hidden="true"
|
||||||
label="&zotero.items.edition_column;"
|
submenu="true"
|
||||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
label="&zotero.items.edition_column;"
|
||||||
<splitter class="tree-splitter"/>
|
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||||
<treecol
|
<splitter class="tree-splitter"/>
|
||||||
id="zotero-items-column-pages" hidden="true"
|
<treecol
|
||||||
submenu="true"
|
id="zotero-items-column-pages" hidden="true"
|
||||||
label="&zotero.items.pages_column;"
|
submenu="true"
|
||||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
label="&zotero.items.pages_column;"
|
||||||
<splitter class="tree-splitter"/>
|
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||||
<treecol
|
<splitter class="tree-splitter"/>
|
||||||
id="zotero-items-column-issue" hidden="true"
|
<treecol
|
||||||
submenu="true"
|
id="zotero-items-column-issue" hidden="true"
|
||||||
label="&zotero.items.issue_column;"
|
submenu="true"
|
||||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
label="&zotero.items.issue_column;"
|
||||||
<splitter class="tree-splitter"/>
|
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||||
<treecol
|
<splitter class="tree-splitter"/>
|
||||||
id="zotero-items-column-series" hidden="true"
|
<treecol
|
||||||
submenu="true"
|
id="zotero-items-column-series" hidden="true"
|
||||||
label="&zotero.items.series_column;"
|
submenu="true"
|
||||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
label="&zotero.items.series_column;"
|
||||||
<splitter class="tree-splitter"/>
|
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||||
<treecol
|
<splitter class="tree-splitter"/>
|
||||||
id="zotero-items-column-seriesTitle" hidden="true"
|
<treecol
|
||||||
submenu="true"
|
id="zotero-items-column-seriesTitle" hidden="true"
|
||||||
label="&zotero.items.seriesTitle_column;"
|
submenu="true"
|
||||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
label="&zotero.items.seriesTitle_column;"
|
||||||
<splitter class="tree-splitter"/>
|
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||||
<treecol
|
<splitter class="tree-splitter"/>
|
||||||
id="zotero-items-column-court" hidden="true"
|
<treecol
|
||||||
submenu="true"
|
id="zotero-items-column-court" hidden="true"
|
||||||
label="&zotero.items.court_column;"
|
submenu="true"
|
||||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
label="&zotero.items.court_column;"
|
||||||
<splitter class="tree-splitter"/>
|
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||||
<treecol
|
<splitter class="tree-splitter"/>
|
||||||
id="zotero-items-column-medium" hidden="true"
|
<treecol
|
||||||
submenu="true"
|
id="zotero-items-column-medium" hidden="true"
|
||||||
label="&zotero.items.medium_column;"
|
submenu="true"
|
||||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
label="&zotero.items.medium_column;"
|
||||||
<splitter class="tree-splitter"/>
|
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||||
<treecol
|
<splitter class="tree-splitter"/>
|
||||||
id="zotero-items-column-genre" hidden="true"
|
<treecol
|
||||||
submenu="true"
|
id="zotero-items-column-genre" hidden="true"
|
||||||
label="&zotero.items.genre_column;"
|
submenu="true"
|
||||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
label="&zotero.items.genre_column;"
|
||||||
<splitter class="tree-splitter"/>
|
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||||
<treecol
|
<splitter class="tree-splitter"/>
|
||||||
id="zotero-items-column-system" hidden="true"
|
<treecol
|
||||||
submenu="true"
|
id="zotero-items-column-system" hidden="true"
|
||||||
label="&zotero.items.system_column;"
|
submenu="true"
|
||||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
label="&zotero.items.system_column;"
|
||||||
<splitter class="tree-splitter"/>
|
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||||
<treecol
|
<splitter class="tree-splitter"/>
|
||||||
id="zotero-items-column-extra" hidden="true"
|
<treecol
|
||||||
label="&zotero.items.extra_column;"
|
id="zotero-items-column-extra" hidden="true"
|
||||||
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
label="&zotero.items.extra_column;"
|
||||||
</treecols>
|
flex="1" zotero-persist="width ordinal hidden sortActive sortDirection"/>
|
||||||
<treechildren/>
|
</treecols>
|
||||||
</tree>
|
<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>
|
</hbox>
|
||||||
</vbox>
|
</vbox>
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
var itemsView;
|
var itemsView;
|
||||||
var collectionsView;
|
var collectionsView;
|
||||||
var io;
|
var io;
|
||||||
|
var connectionSelectedDeferred;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* window takes two arguments:
|
* 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.addBorder) document.getElementsByTagName("dialog")[0].style.border = "1px solid black";
|
||||||
if(io.singleSelection) document.getElementById("zotero-items-tree").setAttribute("seltype", "single");
|
if(io.singleSelection) document.getElementById("zotero-items-tree").setAttribute("seltype", "single");
|
||||||
|
|
||||||
|
setItemsPaneMessage(Zotero.getString('pane.items.loading'));
|
||||||
|
|
||||||
collectionsView = new Zotero.CollectionTreeView();
|
collectionsView = new Zotero.CollectionTreeView();
|
||||||
// Don't show Commons when citing
|
|
||||||
collectionsView.hideSources = ['duplicates', 'trash', 'feeds'];
|
collectionsView.hideSources = ['duplicates', 'trash', 'feeds'];
|
||||||
document.getElementById('zotero-collections-tree').view = collectionsView;
|
document.getElementById('zotero-collections-tree').view = collectionsView;
|
||||||
|
|
||||||
|
@ -51,7 +53,12 @@ var doLoad = Zotero.Promise.coroutine(function* () {
|
||||||
collectionsView.addEventListener('load', () => deferred.resolve());
|
collectionsView.addEventListener('load', () => deferred.resolve());
|
||||||
yield deferred.promise;
|
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);
|
Zotero.updateQuickSearchBox(document);
|
||||||
});
|
});
|
||||||
|
@ -63,30 +70,37 @@ function doUnload()
|
||||||
itemsView.unregister();
|
itemsView.unregister();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onCollectionSelected()
|
var onCollectionSelected = Zotero.Promise.coroutine(function* ()
|
||||||
{
|
{
|
||||||
if(itemsView)
|
if(itemsView)
|
||||||
itemsView.unregister();
|
itemsView.unregister();
|
||||||
|
|
||||||
if(collectionsView.selection.count == 1 && collectionsView.selection.currentIndex != -1)
|
if(collectionsView.selection.count == 1 && collectionsView.selection.currentIndex != -1)
|
||||||
{
|
{
|
||||||
var collection = collectionsView.getRow(collectionsView.selection.currentIndex);
|
var collectionTreeRow = collectionsView.getRow(collectionsView.selection.currentIndex);
|
||||||
collection.setSearch('');
|
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;
|
document.getElementById('zotero-items-tree').view = itemsView;
|
||||||
|
var deferred = Zotero.Promise.defer();
|
||||||
|
itemsView.addEventListener('load', () => deferred.resolve());
|
||||||
|
yield deferred.promise;
|
||||||
|
|
||||||
if (collection.isLibrary()) {
|
clearItemsPaneMessage();
|
||||||
Zotero.Prefs.set('lastViewedFolder', 'L');
|
|
||||||
}
|
connectionSelectedDeferred.resolve();
|
||||||
if (collection.isCollection()) {
|
|
||||||
Zotero.Prefs.set('lastViewedFolder', 'C' + collection.ref.getID());
|
|
||||||
}
|
|
||||||
else if (collection.isSearch()) {
|
|
||||||
Zotero.Prefs.set('lastViewedFolder', 'S' + collection.ref.id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
function onSearch()
|
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()
|
function doAccept()
|
||||||
{
|
{
|
||||||
io.dataOut = itemsView.getSelectedItems(true);
|
io.dataOut = itemsView.getSelectedItems(true);
|
||||||
|
|
Loading…
Reference in a new issue