From e20bd357566730aa273764f11438835fcfc472bd Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 14 Mar 2013 19:00:52 -0400 Subject: [PATCH 01/16] Don't clear other tag colors when rename colored tag --- chrome/content/zotero/xpcom/data/tags.js | 1 + 1 file changed, 1 insertion(+) diff --git a/chrome/content/zotero/xpcom/data/tags.js b/chrome/content/zotero/xpcom/data/tags.js index b0f1ed032b..125f8f11ae 100644 --- a/chrome/content/zotero/xpcom/data/tags.js +++ b/chrome/content/zotero/xpcom/data/tags.js @@ -517,6 +517,7 @@ Zotero.Tags = new function() { // Just to be safe, remove colors for tags that don't exist tagColors = tagColors.filter(function (val) { + let tagIDs = self.getIDs(val.name, libraryID); // TEMP: handle future getIDs return format change return tagIDs && tagIDs.length; }); From d60b0221db46bde6143aee3a13f534287f4b2a72 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 14 Mar 2013 19:03:20 -0400 Subject: [PATCH 02/16] Fix error trying to toggle colored tag with no tag (This should be fixed so that the setting is always removed, though.) --- chrome/content/zotero/xpcom/data/tags.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/data/tags.js b/chrome/content/zotero/xpcom/data/tags.js index 125f8f11ae..2b77cc0038 100644 --- a/chrome/content/zotero/xpcom/data/tags.js +++ b/chrome/content/zotero/xpcom/data/tags.js @@ -635,7 +635,12 @@ Zotero.Tags = new function() { this.toggleItemsListTags = function (libraryID, items, name) { var self = this; return Q.fcall(function () { - var tagIDs = self.getIDs(name, libraryID); + var tagIDs = self.getIDs(name, libraryID) || []; + // If there's a color setting but no matching tag, don't throw + // an error (though ideally this wouldn't be possible). + if (!tagIDs.length) { + return; + } var tags = tagIDs.map(function (tagID) { return Zotero.Tags.get(tagID, true); }); From 4e1fbf9747bd6d3694b5446fd2ccf90d30b10231 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 14 Mar 2013 20:06:34 -0400 Subject: [PATCH 03/16] Fix clearing selected tag when removed from last item in view I somehow broke this in d2f028d797c5c0ae3d77d54a5bbabaa5cd4a961b, though I'm not sure how. --- chrome/content/zotero/bindings/tagselector.xml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/chrome/content/zotero/bindings/tagselector.xml b/chrome/content/zotero/bindings/tagselector.xml index 45d63bccf7..65cfae7005 100644 --- a/chrome/content/zotero/bindings/tagselector.xml +++ b/chrome/content/zotero/bindings/tagselector.xml @@ -279,6 +279,14 @@ break; } } + + // If tag isn't in scope and is still selected, + // deselect it + if (!inScope && self.selection[labels[i].value]) { + labels[i].setAttribute('selected', false); + delete self.selection[labels[i].value]; + var doCommand = true; + } } // If not in filter, hide @@ -303,16 +311,6 @@ } else { labels[i].setAttribute('inScope', false); - - // If out of scope, make sure it's not selected (otherwise a tag - // stays selected after removing an item with that tag from the - // current collection) - if (self.selection[labels[i].value]) { - labels[i].setAttribute('selected', false); - delete self.selection[labels[i].value]; - var doCommand = true; - } - } labels[i].setAttribute('hidden', false); From 1e59c5ab7e57c1f1ccc2e2762c2a827d9ec3a22b Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 15 Mar 2013 04:13:14 -0400 Subject: [PATCH 04/16] More tags box fixes (follow-up to f932f312ebbc) Use the Notifier for all tags box updates to ensure that it always updates. Also fix the tag count and some other things. Post-tab focus still isn't 100% correct in all situations, but it's real close. --- chrome/content/zotero/bindings/tagsbox.xml | 395 ++++++++++++--------- chrome/content/zotero/xpcom/data/item.js | 4 +- 2 files changed, 226 insertions(+), 173 deletions(-) diff --git a/chrome/content/zotero/bindings/tagsbox.xml b/chrome/content/zotero/bindings/tagsbox.xml index 4a5630ee71..4a8a84b4af 100644 --- a/chrome/content/zotero/bindings/tagsbox.xml +++ b/chrome/content/zotero/bindings/tagsbox.xml @@ -118,7 +118,7 @@ this.mode = this.getAttribute('mode'); } - this._notifierID = Zotero.Notifier.registerObserver(this, ['setting']); + this._notifierID = Zotero.Notifier.registerObserver(this, ['item-tag', 'setting']); ]]> @@ -142,6 +142,55 @@ } return; } + else if (type == 'item-tag') { + let itemID, tagID; + + for (var i=0; i newTabIndex) { + this._lastTabIndex++; + } + } + else if (this._tabDirection == 1) { + if (this._lastTabIndex > newTabIndex) { + this._lastTabIndex++; + } + } + } + else if (event == 'remove') { + var oldTabIndex = this.remove(tagID); + if (oldTabIndex == -1) { + return; + } + if (this._tabDirection == -1) { + if (this._lastTabIndex > oldTabIndex) { + this._lastTabIndex--; + } + } + else if (this._tabDirection == 1) { + if (this._lastTabIndex >= oldTabIndex) { + this._lastTabIndex--; + } + } + } + } + + this.updateCount(); + } + else if (type == 'tag') { + if (event == 'modify') { + this.reload(); + } + } ]]> @@ -166,14 +215,11 @@ while(rows.hasChildNodes()) { rows.removeChild(rows.firstChild); } - var tags = self.item.getTags(); - if (tags) { - for (var i=0; i + @@ -234,10 +283,13 @@ + - @@ -583,21 +633,11 @@ 1) { - var lastTag = row == row.parentNode.lastChild; - - Zotero.DB.beginTransaction(); - - // If old tag isn't in array, remove it - if (id) { - var oldValue = Zotero.Tags.getName(id); - if (tagArray.indexOf(oldValue) == -1) { - this.item.removeTag(id); - } - } - - this.item.addTags(tagArray); - - Zotero.DB.commitTransaction(); - - // TODO: get tab index right - - if (lastTag) { - this._lastTabIndex = this.item.getTags().length; - } - - this.reload(); - return; - } - // Single tag at end + // Existing tag cleared else { - id = tagsbox.add(value); - // New tag - if (id) { - // Stay put, since a tag was added above - if (this._tabDirection == -1) { - this._tabDirection = false; - } + this.item.removeTag(oldTagID); + } + } + // Multiple tags + else if (tagArray.length > 1) { + var lastTag = row == row.parentNode.lastChild; + + Zotero.DB.beginTransaction(); + + if (oldTagID) { + var oldValue = Zotero.Tags.getName(oldTagID); + // If old tag isn't in array, remove it + if (tagArray.indexOf(oldValue) == -1) { + this.item.removeTag(oldTagID); } - // Already exists + // If old tag is staying, restore the textbox + // immediately. This isn't strictly necessary, but it + // makes the transition nicer. else { - // Go back one, since we'll remove this below - if (this._tabDirection == 1) { - this._lastTabIndex--; - } + textbox.value = textbox.getAttribute('value'); + this.textboxToLabel(textbox); } } - } - - if (id) { - var elem = this.createValueElement( - value, - tabindex - ); - var row = textbox.parentNode; - row.replaceChild(elem, textbox); + this.item.addTags(tagArray); - this.updateRow(row, Zotero.Tags.get(id), tabindex); + Zotero.DB.commitTransaction(); - if (!unchanged) { - // Move row to appropriate place, alphabetically - var collation = Zotero.getLocaleCollation(); - var rows = row.parentNode; - var labels = rows.getElementsByAttribute('fieldname', 'tag'); - - rows.removeChild(row); - var currentTabIndex = elem.getAttribute('ztabindex'); - - var before = null; - var inserted = false; - for (var i=0; i 0) { - labels[i].setAttribute('ztabindex', newTabIndex); - continue; - } - - elem.setAttribute('ztabindex', newTabIndex); - rows.insertBefore(row, labels[i].parentNode); - inserted = true; - - // Adjust last tab index - if (this._tabDirection == -1) { - if (this._lastTabIndex > newTabIndex) { - this._lastTabIndex++; - } - } - else if (this._tabDirection == 1) { - if (this._lastTabIndex < newTabIndex) { - this._lastTabIndex--; - } - } - } - if (!inserted) { - elem.setAttribute('ztabindex', i + 1); - rows.appendChild(row); - } + if (lastTag) { + this._lastTabIndex = this.item.getTags().length; } + + this.reload(); } + // Single tag at end else { - // Just remove the row - // - // If there's an open popup, this throws NODE CANNOT BE FOUND - try { - var row = rows.removeChild(row); - } - catch (e) {} + row.parentNode.removeChild(row); + this.item.addTag(value); } ]]> @@ -769,16 +729,84 @@ + + + + + + - - - + - + + if (collation.compareString(1, name, labels[i].textContent) > 0) { + labels[i].setAttribute('ztabindex', index); + continue; + } + + elem.setAttribute('ztabindex', index); + rowsElement.insertBefore(row, labels[i].parentNode); + newTabIndex = index; + inserted = true; + } + if (!inserted) { + newTabIndex = i + 1; + elem.setAttribute('ztabindex', newTabIndex); + rowsElement.appendChild(row); + } + + return newTabIndex; + ]]> @@ -803,12 +831,35 @@ - - - + @@ -816,7 +867,7 @@ Date: Fri, 15 Mar 2013 04:39:57 -0400 Subject: [PATCH 05/16] Fix glitch entering tag with whitespace If an existing colored tag was added to an item with whitespace around it, the tag didn't immediately show up with a color. --- chrome/content/zotero/bindings/tagsbox.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/chrome/content/zotero/bindings/tagsbox.xml b/chrome/content/zotero/bindings/tagsbox.xml index 4a8a84b4af..16ea34e16c 100644 --- a/chrome/content/zotero/bindings/tagsbox.xml +++ b/chrome/content/zotero/bindings/tagsbox.xml @@ -638,6 +638,7 @@ var tabindex = textbox.getAttribute('ztabindex'); var oldValue = textbox.getAttribute('value'); + textbox.value = textbox.value.trim(); var value = textbox.value; var tagsbox = Zotero.getAncestorByTagName(textbox, 'tagsbox'); From a1197883bbe62ff16a4d46f31a6419e9fd9c9f6e Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 15 Mar 2013 14:09:31 -0400 Subject: [PATCH 06/16] Disable key navigation on 1-6 keys if any tag colors are assigned Previously any unused numbers were still available for key navigation, but I think it's too easy hit the wrong key that way, and getting moved to another part of the items list is annoying. --- chrome/content/zotero/xpcom/itemTreeView.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js index 4309489faf..772899ef2f 100644 --- a/chrome/content/zotero/xpcom/itemTreeView.js +++ b/chrome/content/zotero/xpcom/itemTreeView.js @@ -188,10 +188,13 @@ Zotero.ItemTreeView.prototype._setTreeGenerator = function(treebox) let position = parseInt(key) - 1; return Zotero.Tags.getColorByPosition(libraryID, position) .then(function (colorData) { - // If a color isn't assigned to this number, allow key navigation, - // though I'm not sure this is a good idea. + // If a color isn't assigned to this number or any + // other numbers, allow key navigation if (!colorData) { - return true; + return Zotero.Tags.getColors(libraryID) + .then(function (colors) { + return !Object.keys(colors).length; + }); } var items = self.getSelectedItems(); From d726ce41fa4a91d08530792467a1695152dd5fc4 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 15 Mar 2013 16:56:55 -0400 Subject: [PATCH 07/16] Fixes incorrect post-edit scrolling Fixes #268, broken in 2cd45be19162d Post-edit scrolling can probably be smarter, but this fixes the brokenness. --- chrome/content/zotero/xpcom/itemTreeView.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js index f9d43da8ae..543eae4587 100644 --- a/chrome/content/zotero/xpcom/itemTreeView.js +++ b/chrome/content/zotero/xpcom/itemTreeView.js @@ -237,7 +237,6 @@ Zotero.ItemTreeView.prototype._refreshGenerator = function() } var savedSelection = this.saveSelection(); var savedOpenState = this.saveOpenState(); - var savedFirstRow = this.saveFirstRow(); var oldRows = this.rowCount; this._dataItems = []; @@ -320,7 +319,6 @@ Zotero.ItemTreeView.prototype._refreshGenerator = function() } this.rememberOpenState(savedOpenState); - this.rememberFirstRow(savedFirstRow); this.rememberSelection(savedSelection); this.expandMatchParents(); if (unsuppress) { From 2b7d7ebfbf92ce224ad7665951071076da80930e Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 15 Mar 2013 17:40:59 -0400 Subject: [PATCH 08/16] Don't rely on object property order to sort tags It works, but in theory it's not guaranteed in JS. --- .../content/zotero/bindings/tagselector.xml | 22 ++++++++++++++----- chrome/content/zotero/xpcom/data/tags.js | 5 ----- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/chrome/content/zotero/bindings/tagselector.xml b/chrome/content/zotero/bindings/tagselector.xml index 65cfae7005..b2af3340fe 100644 --- a/chrome/content/zotero/bindings/tagselector.xml +++ b/chrome/content/zotero/bindings/tagselector.xml @@ -226,9 +226,19 @@ // Remove children tagsToggleBox.textContent = ""; - var lastTag; + // Sort by name + var orderedTags = []; + var collation = Zotero.getLocaleCollation(); for (let tagID in self._tags) { - let tagButton = self._makeClickableTag(tagID, lastTag, self.editable); + orderedTags.push(self._tags[tagID]) + } + orderedTags.sort(function(a, b) { + return collation.compareString(1, a.name, b.name); + }); + + var lastTag; + for (let i=0; i - + Date: Sat, 16 Mar 2013 03:34:53 -0400 Subject: [PATCH 09/16] Show colored tags in tag selector in all views Always show colored tags at the top of the tag selector, regardless of whether they're in the current scope. If not, they're shown with reduced opacity (as an equivalent to the gray style for out-of-scope tags in Display All Tags mode). As a corollary, colored tags are now shown even if they have no associated items and will remain until they're explicitly deleted. Also: - Don't show outline on out-of-scope tags in "Display All Tags" mode --- .../content/zotero/bindings/tagselector.xml | 238 ++++++++++++------ chrome/content/zotero/xpcom/data/tags.js | 29 +-- .../default/zotero/bindings/tagselector.css | 8 +- 3 files changed, 174 insertions(+), 101 deletions(-) diff --git a/chrome/content/zotero/bindings/tagselector.xml b/chrome/content/zotero/bindings/tagselector.xml index b2af3340fe..75d11bd66d 100644 --- a/chrome/content/zotero/bindings/tagselector.xml +++ b/chrome/content/zotero/bindings/tagselector.xml @@ -100,21 +100,13 @@ - false - null - + null + =0; i--) { + let name = colorTags[positions[i]]; + let ids = Zotero.Tags.getIDs(name, self.libraryID); + orderedTags.unshift({ + id: ids ? ids.join('-') : null, + name: name, + type: 0, + hasColor: true + }); + } + var lastTag; for (let i=0; i=0; i--) { - tagsToggleBox.insertBefore(colorTags[positions[i]], tagsToggleBox.firstChild); - } - //start tag cloud code var tagCloud = Zotero.Prefs.get('tagCloud'); @@ -524,7 +556,12 @@ // This could be more optimized to insert new/changed tags at the appropriate // spot if we cared, but we probably don't var t = me.id('tags-search').inputField; - me.setFilterTags(Zotero.Tags.search(t.value), true); + if (t.value) { + me.setSearch(t.value, true); + } + else { + me.setSearch(false, true); + } me._dirty = true; me.doCommand(); @@ -598,7 +635,7 @@ if (typeof clear != 'undefined') { if (clear){ t.value = ''; - this.setFilterTags(false); + this.setSearch(); return false; } else { @@ -606,7 +643,12 @@ } } - this.setFilterTags(Zotero.Tags.search(t.value)); + if (t.value) { + this.setSearch(t.value); + } + else { + this.setSearch(); + } return true; ]]> @@ -647,16 +689,9 @@ - + - + @@ -765,10 +835,12 @@ } var label = document.createElement('label'); - label.className = 'zotero-clicky'; label.setAttribute('value', tagName); - label.setAttribute('tagID', tagID); + // Not used for color tags + if (tagID) { + label.setAttribute('tagID', tagID); + } label.setAttribute('tagType', tagType); if (editable) { label.setAttribute('context', 'tag-menu'); @@ -780,14 +852,12 @@ - + - - - + + + diff --git a/chrome/content/zotero/xpcom/data/tags.js b/chrome/content/zotero/xpcom/data/tags.js index 57dcb05869..a8b8949cc8 100644 --- a/chrome/content/zotero/xpcom/data/tags.js +++ b/chrome/content/zotero/xpcom/data/tags.js @@ -470,13 +470,6 @@ Zotero.Tags = new function() { tagColors = tagColors || []; - // Remove colors for tags that don't exist - tagColors = tagColors.filter(function (val) { - var tagIDs = self.getIDs(val.name, libraryID); - // TEMP: handle future getIDs return format change - return tagIDs && tagIDs.length; - }); - _libraryColors[libraryID] = tagColors; _libraryColorsByName[libraryID] = {}; @@ -510,13 +503,6 @@ Zotero.Tags = new function() { var tagColors = _libraryColors[libraryID]; var tagIDs = self.getIDs(name, libraryID); - // Just to be safe, remove colors for tags that don't exist - tagColors = tagColors.filter(function (val) { - let tagIDs = self.getIDs(val.name, libraryID); - // TEMP: handle future getIDs return format change - return tagIDs && tagIDs.length; - }); - // Unset if (!color) { // Trying to clear color on tag that doesn't have one @@ -835,14 +821,29 @@ Zotero.Tags = new function() { function erase(ids) { ids = Zotero.flattenArguments(ids); + var deleted = []; + Zotero.DB.beginTransaction(); for each(var id in ids) { var tag = this.get(id); if (tag) { + deleted.push({ + libraryID: tag.libraryID ? parseInt(tag.libraryID) : 0, + name: tag.name + }); tag.erase(); } } Zotero.DB.commitTransaction(); + + // Also delete tag color setting + // + // Note that this isn't done in purge(), so the setting will not + // be removed if the tag is just removed from all items without + // without being explicitly deleted. + for (var i in deleted) { + this.setColor(deleted[i].libraryID, deleted[i].name, false); + } } diff --git a/chrome/skin/default/zotero/bindings/tagselector.css b/chrome/skin/default/zotero/bindings/tagselector.css index 22b0659ff1..fd0f86aad1 100644 --- a/chrome/skin/default/zotero/bindings/tagselector.css +++ b/chrome/skin/default/zotero/bindings/tagselector.css @@ -28,16 +28,14 @@ checkbox } /* Visible out-of-scope tags should be grey */ -#tags-toggle label[inScope="false"] +#tags-toggle label[inScope=false]:not([hasColor=true]) { color: #666 !important; } -/* Don't display clicky effect to out-of-scope icons */ -label.zotero-clicky[inScope="false"]:hover, -label.zotero-clicky[inScope="false"]:active +#tags-toggle label[inScope=false][hasColor=true] { - background: inherit !important; + opacity: .6; } #tags-toggle label[draggedOver="true"] From fec159f96932084e35a4474e6fe6d400db8c8eac Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 16 Mar 2013 03:45:15 -0400 Subject: [PATCH 10/16] Fix error on tag change without a selected item (from 1e59c5ab7) --- chrome/content/zotero/bindings/tagsbox.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/bindings/tagsbox.xml b/chrome/content/zotero/bindings/tagsbox.xml index 16ea34e16c..9ef7ab6abf 100644 --- a/chrome/content/zotero/bindings/tagsbox.xml +++ b/chrome/content/zotero/bindings/tagsbox.xml @@ -147,7 +147,7 @@ for (var i=0; i Date: Sat, 16 Mar 2013 03:46:49 -0400 Subject: [PATCH 11/16] Fix broken checkboxes in tag selector context menu (OS X only?) On OS X, the checked state of still doesn't work right if set before the menu is opened. To get around this, the state is now set manually in onpopupshown(). There's an annoying delay before the UI update, but this is better than nothing. --- .../content/zotero/bindings/tagselector.xml | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/chrome/content/zotero/bindings/tagselector.xml b/chrome/content/zotero/bindings/tagselector.xml index 75d11bd66d..88a969426c 100644 --- a/chrome/content/zotero/bindings/tagselector.xml +++ b/chrome/content/zotero/bindings/tagselector.xml @@ -151,8 +151,8 @@ @@ -1012,15 +1012,28 @@ onkeypress="if (event.keyCode == event.DOM_VK_ESCAPE) { document.getBindingParent(this).handleKeyPress(true); }"/> - + - - + + From edfdbdec1c1b6bedac7b85465c2c040dc27c595f Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 16 Mar 2013 03:59:25 -0400 Subject: [PATCH 12/16] Keep tag selector label heights consistent Use a transparent border so that the height is the same with or without zotero-clicky being set --- chrome/skin/default/zotero/bindings/tagselector.css | 1 + 1 file changed, 1 insertion(+) diff --git a/chrome/skin/default/zotero/bindings/tagselector.css b/chrome/skin/default/zotero/bindings/tagselector.css index fd0f86aad1..e67b6211b2 100644 --- a/chrome/skin/default/zotero/bindings/tagselector.css +++ b/chrome/skin/default/zotero/bindings/tagselector.css @@ -25,6 +25,7 @@ checkbox padding: 0 .25em 0 .25em !important; -moz-user-focus: ignore; max-width: 250px; + border: 1px solid transparent; /* always include border so height is same as zotero-clicky */ } /* Visible out-of-scope tags should be grey */ From 5f283a6b7f44ef93764805c047b9576cc085aef7 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 16 Mar 2013 04:02:27 -0400 Subject: [PATCH 13/16] Fix tag selector glitch after removing last tag, again Better fix than 4e1fbf9747 --- chrome/content/zotero/bindings/tagselector.xml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/chrome/content/zotero/bindings/tagselector.xml b/chrome/content/zotero/bindings/tagselector.xml index 88a969426c..413fa516e1 100644 --- a/chrome/content/zotero/bindings/tagselector.xml +++ b/chrome/content/zotero/bindings/tagselector.xml @@ -329,14 +329,6 @@ break; } } - - // If tag isn't in scope and is still selected, - // deselect it - if (!inScope && self.selection[name]) { - labels[i].setAttribute('selected', false); - delete self.selection[name]; - var doCommand = true; - } } // If not in search, hide @@ -371,6 +363,14 @@ empty = false; } + // If tag isn't in scope and is still selected, deselect it + if (labels[i].getAttribute('hidden') == 'true' && self.selection[name]) { + labels[i].setAttribute('selected', false); + delete self.selection[name]; + var doCommand = true; + } + + // Always show colored tags at top if (colorData) { labels[i].setAttribute('hidden', false); From 022ee4481b69220177a60340cef1348f90e4d7a8 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 16 Mar 2013 22:55:50 -0400 Subject: [PATCH 14/16] Add "Delete Collection and Items..." context-menu option Also update collection/search deletion dialogs with better button text and no more "[JavaScript Application]" --- .../zotero/xpcom/collectionTreeView.js | 14 ++-- .../content/zotero/xpcom/data/collection.js | 2 +- chrome/content/zotero/zoteroPane.js | 70 ++++++++++++++----- chrome/content/zotero/zoteroPane.xul | 1 + chrome/locale/en-US/zotero/zotero.properties | 14 +++- 5 files changed, 73 insertions(+), 28 deletions(-) diff --git a/chrome/content/zotero/xpcom/collectionTreeView.js b/chrome/content/zotero/xpcom/collectionTreeView.js index 0989ae3665..cce85c05d4 100644 --- a/chrome/content/zotero/xpcom/collectionTreeView.js +++ b/chrome/content/zotero/xpcom/collectionTreeView.js @@ -814,7 +814,7 @@ Zotero.CollectionTreeView.prototype.getLastViewedRow = function () { /* * Delete the selection */ -Zotero.CollectionTreeView.prototype.deleteSelection = function() +Zotero.CollectionTreeView.prototype.deleteSelection = function(deleteItems) { if(this.selection.count == 0) return; @@ -842,14 +842,12 @@ Zotero.CollectionTreeView.prototype.deleteSelection = function() for (var i=0; i + diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties index a821742d64..bb0e2d066b 100644 --- a/chrome/locale/en-US/zotero/zotero.properties +++ b/chrome/locale/en-US/zotero/zotero.properties @@ -34,6 +34,7 @@ general.permissionDenied = Permission Denied general.character.singular = character general.character.plural = characters general.create = Create +general.delete = Delete general.seeForMoreInformation = See %S for more information. general.enable = Enable general.disable = Disable @@ -132,8 +133,14 @@ date.relative.daysAgo.multiple = %S days ago date.relative.yearsAgo.one = 1 year ago date.relative.yearsAgo.multiple = %S years ago +pane.collections.delete.title = Delete Collection pane.collections.delete = Are you sure you want to delete the selected collection? -pane.collections.deleteSearch = Are you sure you want to delete the selected search? +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.collections.deleteSearch.title = Delete Search +pane.collections.deleteSearch = Are you sure you want to delete the selected search? pane.collections.emptyTrash = Are you sure you want to permanently remove items in the Trash? pane.collections.newCollection = New Collection pane.collections.name = Enter a name for this collection: @@ -149,8 +156,9 @@ pane.collections.duplicate = Duplicate Items 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.delete.collection = Delete Collection… +pane.collections.menu.delete.collectionAndItems = Delete Collection and Items… +pane.collections.menu.delete.savedSearch = Delete 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… From 3c6728e30f2e2214a7a8c17d61791a0354797639 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Sat, 16 Mar 2013 23:51:34 -0400 Subject: [PATCH 15/16] Remove unnecessary version checking code --- chrome/content/zotero/xpcom/utilities.js | 28 ++++++------------------ 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js index 41e7b98046..44a7b3f01a 100644 --- a/chrome/content/zotero/xpcom/utilities.js +++ b/chrome/content/zotero/xpcom/utilities.js @@ -408,29 +408,15 @@ Zotero.Utilities = { // Create a node and use the textContent property to do unescaping where // possible, because this approach preserves
if(node === undefined) { - var platformVersion = Components.classes["@mozilla.org/xre/app-info;1"] - .getService(Components.interfaces.nsIXULAppInfo).platformVersion; - if(Components.classes["@mozilla.org/xpcom/version-comparator;1"] - .getService(Components.interfaces.nsIVersionComparator) - .compare(platformVersion, "12.0") >= 0) { - var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"] - .createInstance(Components.interfaces.nsIDOMParser); - var domDocument = parser.parseFromString("", - "text/html"); - node = domDocument.createElement("div"); - } else { - node = false; - } + var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"] + .createInstance(Components.interfaces.nsIDOMParser); + var domDocument = parser.parseFromString("", + "text/html"); + node = domDocument.createElement("div"); } - if(node) { - node.innerHTML = str; - return node.textContent.replace(/ {2,}/g, " "); - } else if(!nsIScriptableUnescapeHTML) { - nsIScriptableUnescapeHTML = Components.classes["@mozilla.org/feed-unescapehtml;1"] - .getService(Components.interfaces.nsIScriptableUnescapeHTML); - } - return nsIScriptableUnescapeHTML.unescape(str); + node.innerHTML = str; + return node.textContent.replace(/ {2,}/g, " "); } else if(Zotero.isNode) { /*var doc = require('jsdom').jsdom(str, null, { "features":{ From 5a863d97c8e394c86f9334b7f970d92f8bce7421 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 17 Mar 2013 01:18:19 -0400 Subject: [PATCH 16/16] Context-menu string cleanup - Remove all "Selected" from "Selected Item", because that's how a context menu works - Change "Remove Selected Item" to "Remove Item from Collection" (fixes #122) - Change "Delete Selected Item from Library" to "Move Item to Trash") - Change "Remove" on Duplicate/Unfiled Items to "Hide" (fixes #122) - Change "Create Parent Item from Selected Item" to "Create Parent Item" --- chrome/content/zotero/zoteroPane.js | 4 ++-- chrome/locale/en-US/zotero/zotero.dtd | 2 +- chrome/locale/en-US/zotero/zotero.properties | 25 ++++++++++---------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index 34f90777a4..f22c754caf 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -2087,7 +2087,7 @@ var ZoteroPane = new function() m.deleteCollection ]; - menu.childNodes[m.deleteCollection].setAttribute('label', Zotero.getString('general.remove')); + menu.childNodes[m.deleteCollection].setAttribute('label', Zotero.getString('general.hide')); } else if (itemGroup.isHeader()) { if (itemGroup.ref.id == 'commons-header') { @@ -2375,7 +2375,7 @@ var ZoteroPane = new function() } // Plural if necessary - menu.childNodes[m.deleteFromLibrary].setAttribute('label', Zotero.getString('pane.items.menu.erase' + multiple)); + menu.childNodes[m.deleteFromLibrary].setAttribute('label', Zotero.getString('pane.items.menu.moveToTrash' + multiple)); menu.childNodes[m.exportItems].setAttribute('label', Zotero.getString('pane.items.menu.export' + multiple)); menu.childNodes[m.createBib].setAttribute('label', Zotero.getString('pane.items.menu.createBib' + multiple)); menu.childNodes[m.loadReport].setAttribute('label', Zotero.getString('pane.items.menu.generateReport' + multiple)); diff --git a/chrome/locale/en-US/zotero/zotero.dtd b/chrome/locale/en-US/zotero/zotero.dtd index 0e4fa616dc..e51128f262 100644 --- a/chrome/locale/en-US/zotero/zotero.dtd +++ b/chrome/locale/en-US/zotero/zotero.dtd @@ -85,7 +85,7 @@ - + diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties index bb0e2d066b..8bcb61c2ed 100644 --- a/chrome/locale/en-US/zotero/zotero.properties +++ b/chrome/locale/en-US/zotero/zotero.properties @@ -40,6 +40,7 @@ general.enable = Enable general.disable = Disable general.remove = Remove general.reset = Reset +general.hide = Hide general.quit = Quit general.useDefault = Use Default general.openDocumentation = Open Documentation @@ -188,22 +189,22 @@ pane.items.trash.multiple = Are you sure you want to move the selected items to pane.items.delete.title = Delete pane.items.delete = Are you sure you want to delete the selected item? pane.items.delete.multiple = Are you sure you want to delete the selected items? -pane.items.menu.remove = Remove Selected Item -pane.items.menu.remove.multiple = Remove Selected Items -pane.items.menu.erase = Delete Selected Item from Library… -pane.items.menu.erase.multiple = Delete Selected Items from Library… -pane.items.menu.export = Export Selected Item… -pane.items.menu.export.multiple = Export Selected Items… -pane.items.menu.createBib = Create Bibliography from Selected Item… -pane.items.menu.createBib.multiple = Create Bibliography from Selected Items… -pane.items.menu.generateReport = Generate Report from Selected Item… -pane.items.menu.generateReport.multiple = Generate Report from Selected Items… +pane.items.menu.remove = Remove Item from Collection +pane.items.menu.remove.multiple = Remove Items from Collection +pane.items.menu.moveToTrash = Move Item to Trash… +pane.items.menu.moveToTrash.multiple = Move Items to Trash… +pane.items.menu.export = Export Item… +pane.items.menu.export.multiple = Export Items… +pane.items.menu.createBib = Create Bibliography from Item… +pane.items.menu.createBib.multiple = Create Bibliography from Items… +pane.items.menu.generateReport = Generate Report from Item… +pane.items.menu.generateReport.multiple = Generate Report from Items… pane.items.menu.reindexItem = Reindex Item pane.items.menu.reindexItem.multiple = Reindex Items pane.items.menu.recognizePDF = Retrieve Metadata for PDF pane.items.menu.recognizePDF.multiple = Retrieve Metadata for PDFs -pane.items.menu.createParent = Create Parent Item from Selected Item -pane.items.menu.createParent.multiple = Create Parent Items from Selected Items +pane.items.menu.createParent = Create Parent Item +pane.items.menu.createParent.multiple = Create Parent Items pane.items.menu.renameAttachments = Rename File from Parent Metadata pane.items.menu.renameAttachments.multiple = Rename Files from Parent Metadata