From dea69fac3d5a82ebbe7b8169b4a46b98a6d696d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikko=20R=C3=B6nkk=C3=B6?= Date: Thu, 3 Nov 2011 16:31:31 +0200 Subject: [PATCH 1/3] Added grouping of items by library and separators for libraries to QuickFormat dialog --- .../content/zotero/integration/quickFormat.js | 72 +++++++++++++++++-- 1 file changed, 66 insertions(+), 6 deletions(-) diff --git a/chrome/content/zotero/integration/quickFormat.js b/chrome/content/zotero/integration/quickFormat.js index 9c2e0e2706..b7d53d6f92 100644 --- a/chrome/content/zotero/integration/quickFormat.js +++ b/chrome/content/zotero/integration/quickFormat.js @@ -265,19 +265,38 @@ var Zotero_QuickFormat = new function () { while(referenceBox.hasChildNodes()) referenceBox.removeChild(referenceBox.firstChild); + var firstSelectableIndex = 0; + if(ids.length) { if(ids.length > 50) ids = ids.slice(0, 50); var items = Zotero.Items.get(ids); + + firstSelectableIndex = 1; + + //TODO: sort the currently used items in before any other items + items.sort(function(a, b) {return a.libraryID > b.libraryID}) + + var previousLibrary = -1; + for(var i=0, n=items.length; i Date: Fri, 25 Nov 2011 12:45:06 -0500 Subject: [PATCH 2/3] Tweak UI and don't allow selection of library headers --- .../content/zotero/integration/quickFormat.js | 56 ++++++++++++++----- chrome/skin/default/zotero/integration.css | 11 +++- 2 files changed, 50 insertions(+), 17 deletions(-) diff --git a/chrome/content/zotero/integration/quickFormat.js b/chrome/content/zotero/integration/quickFormat.js index b7d53d6f92..59b4586836 100644 --- a/chrome/content/zotero/integration/quickFormat.js +++ b/chrome/content/zotero/integration/quickFormat.js @@ -25,8 +25,8 @@ var Zotero_QuickFormat = new function () { var io, qfs, qfi, qfiWindow, qfiDocument, qfe, qfb, qfbHeight, keepSorted, showEditor, - referencePanel, referenceBox, referenceHeight, dragX, dragY, curLocator, curLocatorLabel, - curIDs = [], curResizer, dragging; + referencePanel, referenceBox, referenceHeight, separatorHeight, dragX, dragY, curLocator, + curLocatorLabel, curIDs = [], curResizer, dragging; // A variable that contains the timeout object for the latest onKeyPress event var eventTimeout = null; @@ -279,14 +279,17 @@ var Zotero_QuickFormat = new function () { var previousLibrary = -1; for(var i=0, n=items.length; i 30) { @@ -522,7 +545,9 @@ var Zotero_QuickFormat = new function () { var panelShowing = referencePanel.state === "open" || referencePanel.state === "showing"; if(numReferences) { - var height = referenceHeight ? Math.min(numReferences, SHOWN_REFERENCES)*referenceHeight+2 : 39; + var height = referenceHeight ? + Math.min(numReferences*referenceHeight+1+numSeparators*separatorHeight, + SHOWN_REFERENCES*referenceHeight+1+separatorHeight) : 39; if(panelShowing && height !== referencePanel.clientHeight) { referencePanel.sizeTo((window.outerWidth-30), height); @@ -535,9 +560,11 @@ var Zotero_QuickFormat = new function () { false, false, null); if(!referenceHeight) { - referenceHeight = referenceBox.firstChild.scrollHeight; - height = Math.min(numReferences, SHOWN_REFERENCES)*referenceHeight+2; - referencePanel.sizeTo((window.innerWidth-30), height); + separatorHeight = referenceBox.firstChild.scrollHeight; + referenceHeight = referenceBox.childNodes[1].scrollHeight; + height = Math.min(numReferences*referenceHeight+1+numSeparators*separatorHeight, + SHOWN_REFERENCES*referenceHeight+1+separatorHeight); + referencePanel.sizeTo((window.outerWidth-30), height); } } } else { @@ -739,7 +766,6 @@ var Zotero_QuickFormat = new function () { * Handle return or escape */ function _onQuickSearchKeyPress(event) { - var keyCode = event.keyCode; if(keyCode === event.DOM_VK_RETURN || keyCode === event.DOM_VK_ENTER) { event.preventDefault(); diff --git a/chrome/skin/default/zotero/integration.css b/chrome/skin/default/zotero/integration.css index b4ac863bda..cdf3c8c8b4 100644 --- a/chrome/skin/default/zotero/integration.css +++ b/chrome/skin/default/zotero/integration.css @@ -150,15 +150,22 @@ body { font-size: 12px; font: -moz-field; -moz-user-focus: normal; - padding: 5px; + padding: 3px 5px 3px 10px; } -.quick-format-item:not(:last-child) { +.quick-format-item:not(:last-child), .quick-format-separator:not(:last-child) { border-style: solid; border-width: 0 0 1px 0; border-color: #BBB; } +.quick-format-separator { + font-size: 12px; + font: -moz-field; + -moz-user-focus: ignore; + color: gray; +} + richlistitem[selected="true"] { background: Highlight; color: HighlightText; From 9d9ab86729922d7dbd169c4934031741635412e1 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 1 Dec 2011 14:33:43 -0500 Subject: [PATCH 3/3] Update titles/creators quicksearch mode to include year Also: Change "All Fields" to "All Fields & Tags" to reflect reality Increase width of search box slightly --- chrome/content/zotero/xpcom/search.js | 29 +++++++++++++++++++++++--- chrome/content/zotero/xpcom/zotero.js | 11 +++++++--- chrome/skin/default/zotero/overlay.css | 2 +- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/chrome/content/zotero/xpcom/search.js b/chrome/content/zotero/xpcom/search.js index 5bae446853..851c687956 100644 --- a/chrome/content/zotero/xpcom/search.js +++ b/chrome/content/zotero/xpcom/search.js @@ -410,8 +410,9 @@ Zotero.Search.prototype.addCondition = function(condition, operator, value, requ for each(var part in parts) { this.addCondition('blockStart'); - if (condition == 'quicksearch-titlesAndCreators') { + if (condition == 'quicksearch-titleCreatorYear') { this.addCondition('title', operator, part.text, false); + this.addCondition('year', operator, part.text, false); } else { this.addCondition('field', operator, part.text, false); @@ -437,7 +438,7 @@ Zotero.Search.prototype.addCondition = function(condition, operator, value, requ this.addCondition('blockEnd'); } - if (condition == 'quicksearch-titlesAndCreators') { + if (condition == 'quicksearch-titleCreatorYear') { this.addCondition('noChildren', 'true'); } @@ -1189,6 +1190,15 @@ Zotero.Search.prototype._buildQuery = function(){ openParens++; break; + case 'year': + condSQL += 'fieldID IN (?) AND '; + condSQLParams.push(Zotero.ItemFields.getID('date')); + condSQL += "valueID IN (SELECT valueID FROM " + + "itemDataValues WHERE "; + + openParens++; + break; + case 'collection': var col; if (condition.value) { @@ -1872,7 +1882,7 @@ Zotero.SearchConditions = new function(){ }, { - name: 'quicksearch-titlesAndCreators', + name: 'quicksearch-titleCreatorYear', operators: { is: true, isNot: true, @@ -2129,6 +2139,19 @@ Zotero.SearchConditions = new function(){ template: true // mark for special handling }, + { + name: 'year', + operators: { + is: true, + isNot: true, + contains: true, + doesNotContain: true + }, + table: 'itemData', + field: 'STRFTIME("%Y", SUBSTR(value, 1, 10))', + special: true + }, + { name: 'numberfield', operators: { diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 3cf9afb247..fb038859d1 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -1754,12 +1754,12 @@ const ZOTERO_CONFIG = { var prefixLen = prefix.length; var modes = { - titlesAndCreators: { - label: "Titles & Creators" + titleCreatorYear: { + label: "Title, Creator, Year" }, fields: { - label: "All Fields" + label: "All Fields & Tags" }, everything: { @@ -1771,6 +1771,11 @@ const ZOTERO_CONFIG = { Zotero.Prefs.set("search.quicksearch-mode", "fields"); mode = 'fields'; } + // TEMP -- pre-3.0b3 + else if (modes[mode] == 'titlesAndCreators') { + Zotero.Prefs.set("search.quicksearch-mode", "titleCreatorYear"); + mode = 'titleCreatorYear' + } var hbox = document.getAnonymousNodes(searchBox)[0]; var input = hbox.getElementsByAttribute('class', 'textbox-input')[0]; diff --git a/chrome/skin/default/zotero/overlay.css b/chrome/skin/default/zotero/overlay.css index b893677073..0e87369f23 100644 --- a/chrome/skin/default/zotero/overlay.css +++ b/chrome/skin/default/zotero/overlay.css @@ -421,7 +421,7 @@ #zotero-tb-search { font-size: 11px !important; - width: 150px; + width: 160px; } #zotero-tb-search-menu-button