diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js index a838710e7..ff168b6aa 100644 --- a/chrome/content/zotero/overlay.js +++ b/chrome/content/zotero/overlay.js @@ -54,6 +54,7 @@ var ZoteroPane = new function() this.getSelectedCollection = getSelectedCollection; this.getSelectedSavedSearch = getSelectedSavedSearch; this.getSelectedItems = getSelectedItems; + this.getSortedItems = getSortedItems; this.getSortField = getSortField; this.getSortDirection = getSortDirection; this.buildCollectionContextMenu = buildCollectionContextMenu; @@ -762,6 +763,18 @@ var ZoteroPane = new function() } + /* + * Returns an array of item ids of visible items in current sort order + */ + function getSortedItems() { + if (!itemsView) { + return false; + } + + return itemsView.getSortedItems(); + } + + function getSortField() { if (!itemsView) { return false; diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js index 91e841a43..7daca7d3c 100644 --- a/chrome/content/zotero/xpcom/itemTreeView.js +++ b/chrome/content/zotero/xpcom/itemTreeView.js @@ -771,6 +771,17 @@ Zotero.ItemTreeView.prototype.rememberSelection = function(selection) } } +/* + * Returns an array of item ids of visible items in current sort order + */ +Zotero.ItemTreeView.prototype.getSortedItems = function() { + var ids = []; + for each(var item in this._dataItems) { + ids.push(item.ref.getID()); + } + return ids; +} + Zotero.ItemTreeView.prototype.getSortField = function() { var col = this._treebox.columns.getSortedColumn().id; // zotero.items._________.column