www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 0d34e34a3aa9e681ab33ec93db0714553c75f69e
parent 3c500b8ebff442e4bbbbb98f3a38112e63c4ec84
Author: Dan Stillman <dstillman@zotero.org>
Date:   Mon, 20 Feb 2012 03:31:22 -0500

Don't add 'Web Page" to new item menu by accident

And ignore it if it's there

Diffstat:
Mchrome/content/zotero/xpcom/data/cachedTypes.js | 2+-
Mchrome/content/zotero/zoteroPane.js | 32+++++++++++++++++---------------
2 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/chrome/content/zotero/xpcom/data/cachedTypes.js b/chrome/content/zotero/xpcom/data/cachedTypes.js @@ -273,7 +273,7 @@ Zotero.ItemTypes = new function() { mru = mru.split(',').slice(0, limit); for (var i=0, len=mru.length; i<len; i++) { var id = parseInt(mru[i]); - if (!isNaN(id)) { + if (!isNaN(id) && id != 13) { // ignore 'webpage' item type params.push(id); } } diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js @@ -276,7 +276,7 @@ var ZoteroPane = new function() menuitem.setAttribute("label", itemTypes[i].localized); menuitem.setAttribute("tooltiptext", ""); let type = itemTypes[i].id; - menuitem.addEventListener("command", function() { ZoteroPane_Local.newItem(type); }, false); + menuitem.addEventListener("command", function() { ZoteroPane_Local.newItem(type, {}, null, true); }, false); moreMenu.appendChild(menuitem); } } @@ -314,7 +314,7 @@ var ZoteroPane = new function() menuitem.setAttribute("label", itemTypes[i].localized); menuitem.setAttribute("tooltiptext", ""); let type = itemTypes[i].id; - menuitem.addEventListener("command", function() { ZoteroPane_Local.newItem(type); }, false); + menuitem.addEventListener("command", function() { ZoteroPane_Local.newItem(type, {}, null, true); }, false); menuitem.className = "zotero-tb-add"; addMenu.insertBefore(menuitem, separator); } @@ -665,7 +665,7 @@ var ZoteroPane = new function() * * _data_ is an optional object with field:value for itemData */ - function newItem(typeID, data, row) + function newItem(typeID, data, row, manual) { if (!Zotero.stateCheck()) { this.displayErrorMessage(true); @@ -682,7 +682,7 @@ var ZoteroPane = new function() } } - if (row !== undefined) { + if (row !== undefined && row !== null) { var itemGroup = this.collectionsView._getItemAtRow(row); var libraryID = itemGroup.ref.libraryID; } @@ -710,19 +710,21 @@ var ZoteroPane = new function() document.getElementById('zotero-view-item').selectedIndex = 0; // Update most-recently-used list for New Item menu - var mru = Zotero.Prefs.get('newItemTypeMRU'); - if (mru) { - var mru = mru.split(','); - var pos = mru.indexOf(typeID + ''); - if (pos != -1) { - mru.splice(pos, 1); + if (manual) { + var mru = Zotero.Prefs.get('newItemTypeMRU'); + if (mru) { + var mru = mru.split(','); + var pos = mru.indexOf(typeID + ''); + if (pos != -1) { + mru.splice(pos, 1); + } + mru.unshift(typeID); } - mru.unshift(typeID); - } - else { - var mru = [typeID + '']; + else { + var mru = [typeID + '']; + } + Zotero.Prefs.set('newItemTypeMRU', mru.slice(0, 5).join(',')); } - Zotero.Prefs.set('newItemTypeMRU', mru.slice(0, 5).join(',')); return Zotero.Items.get(itemID); }