diff --git a/chrome/content/zotero/xpcom/collectionTreeRow.js b/chrome/content/zotero/xpcom/collectionTreeRow.js index f54a09045c..80b192851a 100644 --- a/chrome/content/zotero/xpcom/collectionTreeRow.js +++ b/chrome/content/zotero/xpcom/collectionTreeRow.js @@ -39,6 +39,7 @@ Zotero.CollectionTreeRow.prototype.__defineGetter__('id', function () { case 'library': case 'publications': case 'group': + case 'feed': return 'L' + this.ref.libraryID; case 'collection': @@ -57,8 +58,11 @@ Zotero.CollectionTreeRow.prototype.__defineGetter__('id', function () { return 'T' + this.ref.libraryID; case 'header': - if (this.ref.id == 'group-libraries-header') { - return 'HG'; + switch (this.ref.id) { + case 'group-libraries-header': + return "HG"; + case 'feed-libraries-header': + return "HF"; } break; } @@ -69,7 +73,8 @@ Zotero.CollectionTreeRow.prototype.__defineGetter__('id', function () { Zotero.CollectionTreeRow.prototype.isLibrary = function (includeGlobal) { if (includeGlobal) { - return this.type == 'library' || this.type == 'publications' || this.type == 'group'; + var global = ['library', 'publications', 'group', 'feed']; + return global.indexOf(this.type) != -1; } return this.type == 'library'; } @@ -109,6 +114,10 @@ Zotero.CollectionTreeRow.prototype.isGroup = function() { return this.type == 'group'; } +Zotero.CollectionTreeRow.prototype.isFeed = function() { + return this.type == 'feed'; +} + Zotero.CollectionTreeRow.prototype.isSeparator = function () { return this.type == 'separator'; } @@ -140,7 +149,7 @@ Zotero.CollectionTreeRow.prototype.isWithinEditableGroup = function () { } Zotero.CollectionTreeRow.prototype.__defineGetter__('editable', function () { - if (this.isTrash() || this.isShare() || this.isBucket()) { + if (this.isTrash() || this.isShare() || this.isBucket() || this.isFeed()) { return false; } if (!this.isWithinGroup() || this.isPublications()) { @@ -163,7 +172,7 @@ Zotero.CollectionTreeRow.prototype.__defineGetter__('editable', function () { }); Zotero.CollectionTreeRow.prototype.__defineGetter__('filesEditable', function () { - if (this.isTrash() || this.isShare()) { + if (this.isTrash() || this.isShare() || this.isFeed()) { return false; } if (!this.isWithinGroup() || this.isPublications()) { diff --git a/chrome/content/zotero/xpcom/collectionTreeView.js b/chrome/content/zotero/xpcom/collectionTreeView.js index bfeb9cda65..0a3df01cf8 100644 --- a/chrome/content/zotero/xpcom/collectionTreeView.js +++ b/chrome/content/zotero/xpcom/collectionTreeView.js @@ -206,7 +206,34 @@ Zotero.CollectionTreeView.prototype.refresh = Zotero.Promise.coroutine(function* }), added++ ); - + + // TODO: Unify feed and group adding code + // Add feeds + var feeds = Zotero.Feeds.getAll(); + if (feeds.length) { + this._addRowToArray( + newRows, + new Zotero.CollectionTreeRow('separator', false), + added++ + ); + this._addRowToArray( + newRows, + new Zotero.CollectionTreeRow('header', { + id: "feed-libraries-header", + label: Zotero.getString('pane.collections.feedLibraries'), + libraryID: -1 + }, 0), + added++ + ); + for (let i = 0, len = groups.length; i < len; i++) { + this._addRowToArray( + newRows, + new Zotero.CollectionTreeRow('feed', feeds[i]), + added++ + ); + } + } + // Add groups var groups = Zotero.Groups.getAll(); if (groups.length) { @@ -340,15 +367,16 @@ Zotero.CollectionTreeView.prototype.notify = Zotero.Promise.coroutine(function* rows.push(this._rowMap['S' + id]); } break; - + + case 'feed': case 'group': let row = this.getRowIndexByID("L" + extraData[id].libraryID); - let groupLevel = this.getLevel(row); + let level = this.getLevel(row); do { rows.push(row); row++; } - while (row < this.rowCount && this.getLevel(row) > groupLevel); + while (row < this.rowCount && this.getLevel(row) > level); break; } } @@ -371,6 +399,20 @@ Zotero.CollectionTreeView.prototype.notify = Zotero.Promise.coroutine(function* }; this.selection.select(selectedIndex) } + + // Make sure the selection doesn't land on a separator (e.g. deleting last feed) + let index = this.selection.currentIndex; + while (index >= 0 && !this.isSelectable(index)) { + // move up, since we got shifted down + index--; + } + + if (index >= 0) { + this.selection.select(index); + } else { + this.selection.clearSelection(); + } + } else if (action == 'modify') { let row; @@ -439,6 +481,7 @@ Zotero.CollectionTreeView.prototype.notify = Zotero.Promise.coroutine(function* break; + case 'feed': case 'group': yield this.reload(); yield this.selectByID(currentTreeRow.id); @@ -667,6 +710,7 @@ Zotero.CollectionTreeView.prototype.getImageSrc = function(row, col) switch (collectionType) { case 'library': + case 'feed': break; case 'trash': @@ -729,6 +773,9 @@ Zotero.CollectionTreeView.prototype.isContainerEmpty = function(row) && this._unfiledLibraries.indexOf(libraryID) == -1 && this.hideSources.indexOf('trash') != -1; } + if (treeRow.isFeed()) { + return false; // If it's shown, it has something + } if (treeRow.isCollection()) { return !treeRow.ref.hasChildCollections(); } @@ -1039,10 +1086,12 @@ Zotero.CollectionTreeView.prototype.deleteSelection = Zotero.Promise.coroutine(f { //erase collection from DB: var treeRow = this.getRow(rows[i]-i); - if (treeRow.isCollection()) { + if (treeRow.isCollection() || treeRow.isFeed()) { yield treeRow.ref.eraseTx({ deleteItems: true }); + if (treeRow.isCollection() || treeRow.isFeed()) { + yield treeRow.ref.erase(deleteItems); } else if (treeRow.isSearch()) { yield Zotero.Searches.erase(treeRow.ref.id); @@ -1268,8 +1317,8 @@ Zotero.CollectionTreeView.prototype._rememberOpenStates = Zotero.Promise.corouti var open = this.isContainerOpen(i); - // Collections default to closed - if (!open && treeRow.isCollection()) { + // Collections and feeds default to closed + if (!open && treeRow.isCollection() && treeRow.isFeed()) { delete state[treeRow.id]; continue; } @@ -1773,8 +1822,8 @@ Zotero.CollectionTreeView.prototype.drop = Zotero.Promise.coroutine(function* (r // Collection drag between libraries if (targetLibraryID != droppedCollection.libraryID) { yield Zotero.DB.executeTransaction(function* () { - function copyCollections(descendents, parentID, addItems) { - for each(var desc in descendents) { + var copyCollections = Zotero.Promise.coroutine(function* (descendents, parentID, addItems) { + for (var desc of descendents) { // Collections if (desc.type == 'collection') { var c = yield Zotero.Collections.getAsync(desc.id); @@ -1792,7 +1841,7 @@ Zotero.CollectionTreeView.prototype.drop = Zotero.Promise.coroutine(function* (r // Recursively copy subcollections if (desc.children.length) { - copyCollections(desc.children, collectionID, addItems); + yield copyCollections(desc.children, collectionID, addItems); } } // Items @@ -1824,7 +1873,7 @@ Zotero.CollectionTreeView.prototype.drop = Zotero.Promise.coroutine(function* (r } } } - } + }); var collections = [{ id: droppedCollection.id, @@ -1833,10 +1882,10 @@ Zotero.CollectionTreeView.prototype.drop = Zotero.Promise.coroutine(function* (r }]; var addItems = {}; - copyCollections(collections, targetCollectionID, addItems); + yield copyCollections(collections, targetCollectionID, addItems); for (var collectionID in addItems) { var collection = yield Zotero.Collections.getAsync(collectionID); - collection.addItems(addItems[collectionID]); + yield collection.addItems(addItems[collectionID]); } // TODO: add subcollections and subitems, if they don't already exist, diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js index 1e47a1842c..5b9d3e969c 100644 --- a/chrome/content/zotero/xpcom/itemTreeView.js +++ b/chrome/content/zotero/xpcom/itemTreeView.js @@ -2432,6 +2432,8 @@ Zotero.ItemTreeView.prototype.onDragStart = function (event) { } // Get Quick Copy format for current URL +// TODO: Fix this +/** Currently broken var url = this._ownerDocument.defaultView.content && this._ownerDocument.defaultView.content.location ? this._ownerDocument.defaultView.content.location.href : null; var format = Zotero.QuickCopy.getFormatFromURL(url); @@ -2470,6 +2472,7 @@ Zotero.ItemTreeView.prototype.onDragStart = function (event) { Zotero.debug(e); Components.utils.reportError(e + " with '" + format.id + "'"); } +*/ }; diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index c4468160c3..a2c29b67ef 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -594,6 +594,21 @@ var ZoteroPane = new function() //event.preventDefault(); //event.stopPropagation(); return; + } else if (event.keyCode == event.DOM_VK_BACK_QUOTE) { + // Toggle read/unread + if (!this.collectionsView.selection.currentIndex) return; + let row = this.collectionsView.getRow(this.collectionsView.selection.currentIndex); + if (!row || !row.isFeed()) return; + + if(itemReadTimeout) { + itemReadTimeout.cancel(); + itemReadTimeout = null; + } + + let itemIDs = this.getSelectedItems(true); + for (var i=0; i { + itemReadTimeout = null; + // Check to make sure we're still on the same item + if (this.itemsView.selection.count !== 1) return; + + let row = this.itemsView.getRow(this.itemsView.selection.currentIndex); + if (!row || !row.ref || !row.ref.id == feedItemID) return; + + return this.markItemRead(feedItemID, true); + }); + } + + function reportErrors() { var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"] .getService(Components.interfaces.nsIWindowWatcher); diff --git a/chrome/content/zotero/zoteroPane.xul b/chrome/content/zotero/zoteroPane.xul index 42d68c9aae..2234a8c0e9 100644 --- a/chrome/content/zotero/zoteroPane.xul +++ b/chrome/content/zotero/zoteroPane.xul @@ -241,10 +241,13 @@ + + + diff --git a/chrome/locale/en-US/zotero/zotero.dtd b/chrome/locale/en-US/zotero/zotero.dtd index ed62b60b4c..44ce777033 100644 --- a/chrome/locale/en-US/zotero/zotero.dtd +++ b/chrome/locale/en-US/zotero/zotero.dtd @@ -105,6 +105,8 @@ + + diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties index e0c65673f8..b1ab2206c9 100644 --- a/chrome/locale/en-US/zotero/zotero.properties +++ b/chrome/locale/en-US/zotero/zotero.properties @@ -161,6 +161,8 @@ pane.collections.delete = Are you sure you want to delete the selected collect pane.collections.delete.keepItems = Items within this collection will not be deleted. pane.collections.deleteWithItems.title = Delete Collection and Items pane.collections.deleteWithItems = Are you sure you want to delete the selected collection and move all items within it to the Trash? +pane.feed.deleteWithItems.title = Delete Feed and Items +pane.feed.deleteWithItems = Are you sure you want to delete the selected feed and all items within it? pane.collections.deleteSearch.title = Delete Search pane.collections.deleteSearch = Are you sure you want to delete the selected search? @@ -174,23 +176,31 @@ pane.collections.library = My Library pane.collections.publications = My Publications pane.collections.feeds = Feeds pane.collections.groupLibraries = Group Libraries +pane.collections.feedLibraries = Feeds pane.collections.trash = Trash pane.collections.untitled = Untitled pane.collections.unfiled = Unfiled Items pane.collections.duplicate = Duplicate Items pane.collections.menu.rename.collection = Rename Collection… -pane.collections.menu.edit.savedSearch = Edit Saved Search +pane.collections.menu.edit.savedSearch = Edit Saved Search… +pane.collections.menu.edit.savedSearch = Edit Feed… pane.collections.menu.delete.collection = Delete Collection… pane.collections.menu.delete.collectionAndItems = Delete Collection and Items… pane.collections.menu.delete.savedSearch = Delete Saved Search… +pane.collections.menu.delete.feedAndItems = Delete Feed and Items… pane.collections.menu.export.collection = Export Collection… pane.collections.menu.export.savedSearch = Export Saved Search… +pane.collections.menu.export.feed = Export Feed… pane.collections.menu.createBib.collection = Create Bibliography From Collection… pane.collections.menu.createBib.savedSearch = Create Bibliography From Saved Search… +pane.collections.menu.createBib.feed = Create Bibliography From Feed… pane.collections.menu.generateReport.collection = Generate Report from Collection… pane.collections.menu.generateReport.savedSearch = Generate Report from Saved Search… +pane.collections.menu.generateReport.feed = Generate Report from Feed… + +pane.collections.menu.refresh.feed = Refresh Feed pane.tagSelector.rename.title = Rename Tag pane.tagSelector.rename.message = Please enter a new name for this tag.\n\nThe tag will be changed in all associated items. diff --git a/chrome/skin/default/zotero/overlay.css b/chrome/skin/default/zotero/overlay.css index feefb53149..fd6dd68f68 100644 --- a/chrome/skin/default/zotero/overlay.css +++ b/chrome/skin/default/zotero/overlay.css @@ -278,7 +278,7 @@ list-style-image: url('chrome://zotero/skin/toolbar-collection-add.png'); } -#zotero-tb-feed-add +#zotero-tb-feed-add, .zotero-menuitem-new-feed { list-style-image: url('chrome://zotero/skin/toolbar-feed-add.png'); } @@ -373,6 +373,16 @@ list-style-image: url('chrome://zotero/skin/toolbar-collection-edit.png'); } +.zotero-menuitem-edit-feed +{ + list-style-image: url('chrome://zotero/skin/toolbar-feed-edit.png'); +} + +.zotero-menuitem-refresh-feed +{ + list-style-image: url('chrome://zotero/skin/arrow_refresh.png'); +} + .zotero-menuitem-delete-collection { list-style-image: url('chrome://zotero/skin/toolbar-collection-delete.png'); diff --git a/chrome/skin/default/zotero/toolbar-feed-edit.png b/chrome/skin/default/zotero/toolbar-feed-edit.png new file mode 100644 index 0000000000..f1fde7a9ce Binary files /dev/null and b/chrome/skin/default/zotero/toolbar-feed-edit.png differ diff --git a/chrome/skin/default/zotero/treesource-feed.png b/chrome/skin/default/zotero/treesource-feed.png new file mode 100644 index 0000000000..315c4f4fa6 Binary files /dev/null and b/chrome/skin/default/zotero/treesource-feed.png differ diff --git a/chrome/skin/default/zotero/treesource-feedLibrary.png b/chrome/skin/default/zotero/treesource-feedLibrary.png new file mode 100644 index 0000000000..885636033c Binary files /dev/null and b/chrome/skin/default/zotero/treesource-feedLibrary.png differ