From 1e73421522cbdfec845a67e3df744f7858378853 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 1 Jun 2011 04:22:45 +0000 Subject: [PATCH] Closes #909, Have New Item drop-down display the most recently used item types --- .../content/zotero/xpcom/data/cachedTypes.js | 51 +++++++++-- chrome/content/zotero/zoteroPane.js | 86 +++++++++++-------- chrome/content/zotero/zoteroPane.xul | 4 +- 3 files changed, 95 insertions(+), 46 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/cachedTypes.js b/chrome/content/zotero/xpcom/data/cachedTypes.js index 87f937f914..0a2fa1bdaa 100644 --- a/chrome/content/zotero/xpcom/data/cachedTypes.js +++ b/chrome/content/zotero/xpcom/data/cachedTypes.js @@ -97,12 +97,15 @@ Zotero.CachedTypes = function() { } - function getTypes(where) { - return Zotero.DB.query('SELECT ' + this._idCol + ' AS id, ' - + this._nameCol + ' AS name' - + (this._hasCustom ? ', custom' : '') - + ' FROM ' + this._table - + (where ? ' ' + where : '')); + function getTypes(where, params) { + return Zotero.DB.query( + 'SELECT ' + this._idCol + ' AS id, ' + + this._nameCol + ' AS name' + + (this._hasCustom ? ', custom' : '') + + ' FROM ' + this._table + + (where ? ' ' + where : ''), + params ? params : false + ); } @@ -231,11 +234,43 @@ Zotero.ItemTypes = new function() { var _customLabels = {}; function getPrimaryTypes() { - return this.getTypes('WHERE display=2'); + var limit = 5; + + // TODO: get rid of ' AND itemTypeID!=5' and just remove display=2 + // from magazineArticle in system.sql + var sql = 'WHERE (display=2 AND itemTypeID!=5) '; + + var mru = Zotero.Prefs.get('newItemTypeMRU'); + if (mru) { + var params = []; + mru = mru.split(',').slice(0, limit); + for (var i=0, len=mru.length; i - + - +