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

And ignore it if it's there
This commit is contained in:
Dan Stillman 2012-02-20 03:31:22 -05:00
parent 3c500b8ebf
commit 0d34e34a3a
2 changed files with 18 additions and 16 deletions

View file

@ -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);
}
}

View file

@ -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,6 +710,7 @@ var ZoteroPane = new function()
document.getElementById('zotero-view-item').selectedIndex = 0;
// Update most-recently-used list for New Item menu
if (manual) {
var mru = Zotero.Prefs.get('newItemTypeMRU');
if (mru) {
var mru = mru.split(',');
@ -723,6 +724,7 @@ var ZoteroPane = new function()
var mru = [typeID + ''];
}
Zotero.Prefs.set('newItemTypeMRU', mru.slice(0, 5).join(','));
}
return Zotero.Items.get(itemID);
}