mirror of
https://github.com/zotero/zotero.git
synced 2026-10-08 03:08:19 +00:00
Closes #47, Advanced search window
And they said it would never happen. Doesn't yet support dragging items to other windows, etc., but you can double-click to focus the item in the most recent Zotero pane. You can also save the search as...a saved search, which means that theoretically we could get rid of the now-redundant "New Saved Search" icon. == Other/related changes == Search dialog: - Better keyboard handling (focus condition menu by default, Enter to trigger command (e.g. search in the Advanced Search window), Shift-Enter to add new row) Zotero.Search: - Zotero.Search.clone() -- return copy of search - Zotero.Search.getSearchConditions() now returns copy of conditions itemTreeView: - Always sort by the first column if no sort column set; removed isSorted() logic, since isSorted() now always returns true - Made itemsTreeView.refresh() call rowCountChanged, since there were cases in which the tree could end up looking for nonexistent rows after they'd been removed - selectItem() now takes a second parameter, expand, to open the selected item if it's a container - selectItem() now tries to get the selected item at least slightly away from the bottom (since ensureRowIsVisible does only the bare minimum) and also tries to get the parent item in view when scrolling upwards to make a child item visible - Moved getSelectedItems() logic into the treeview instead of overlay.js
This commit is contained in:
parent
a124ae3f64
commit
7fbe630c85
13 changed files with 396 additions and 76 deletions
125
chrome/content/zotero/advancedSearch.js
Normal file
125
chrome/content/zotero/advancedSearch.js
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
var ZoteroAdvancedSearch = new function() {
|
||||
this.onLoad = onLoad;
|
||||
this.search = search;
|
||||
this.clear = clear;
|
||||
this.save = save;
|
||||
this.onDblClick = onDblClick;
|
||||
this.onUnload = onUnload;
|
||||
|
||||
var _searchBox;
|
||||
var _itemsView;
|
||||
|
||||
function onLoad() {
|
||||
_searchBox = document.getElementById('zotero-search-box');
|
||||
|
||||
var io = window.arguments[0];
|
||||
_searchBox.search = io.dataIn.search;
|
||||
}
|
||||
|
||||
|
||||
function search() {
|
||||
_searchBox.updateSearch();
|
||||
|
||||
// A minimal implementation of Zotero.CollectionTreeView
|
||||
var itemGroup = {
|
||||
getChildItems: function () {
|
||||
var ids = _searchBox.search.search();
|
||||
return Zotero.Items.get(ids);
|
||||
},
|
||||
isLibrary: function () { return false; },
|
||||
isCollection: function () { return false; },
|
||||
isSearch: function () { return true; }
|
||||
}
|
||||
|
||||
if (_itemsView) {
|
||||
_itemsView.unregister();
|
||||
}
|
||||
|
||||
_itemsView = new Zotero.ItemTreeView(itemGroup, false);
|
||||
document.getElementById('zotero-items-tree').view = _itemsView;
|
||||
}
|
||||
|
||||
|
||||
function clear() {
|
||||
if (_itemsView) {
|
||||
_itemsView.unregister();
|
||||
}
|
||||
document.getElementById('zotero-items-tree').view = null;
|
||||
|
||||
var s = new Zotero.Search();
|
||||
s.addCondition('title', 'contains', '');
|
||||
_searchBox.search = s;
|
||||
}
|
||||
|
||||
|
||||
function save() {
|
||||
_searchBox.updateSearch();
|
||||
|
||||
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(Components.interfaces.nsIPromptService);
|
||||
|
||||
var untitled = Zotero.DB.getNextName('collections', 'collectionName',
|
||||
Zotero.getString('pane.collections.untitled'));
|
||||
|
||||
var name = { value: untitled };
|
||||
var result = promptService.prompt(window, "",
|
||||
Zotero.getString('pane.collections.savedSearchName'), name, "", {});
|
||||
|
||||
if (!result)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!name.value)
|
||||
{
|
||||
newName.value = untitled;
|
||||
}
|
||||
|
||||
var s = _searchBox.search.clone();
|
||||
s.setName(name.value);
|
||||
s.save();
|
||||
}
|
||||
|
||||
|
||||
// Adapted from: http://www.xulplanet.com/references/elemref/ref_tree.html#cmnote-9
|
||||
function onDblClick(event, tree)
|
||||
{
|
||||
if (event && tree && event.type == "dblclick")
|
||||
{
|
||||
var row = {}, col = {}, obj = {};
|
||||
tree.treeBoxObject.getCellAt(event.clientX, event.clientY, row, col, obj);
|
||||
// obj.value == cell/text/image
|
||||
// TODO: handle collection double-click
|
||||
if (obj.value && _itemsView && _itemsView.selection.currentIndex > -1)
|
||||
{
|
||||
var item = _itemsView.getSelectedItems()[0];
|
||||
|
||||
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
|
||||
.getService(Components.interfaces.nsIWindowMediator);
|
||||
|
||||
var lastWin = wm.getMostRecentWindow("navigator:browser");
|
||||
|
||||
if (!lastWin) {
|
||||
window.open();
|
||||
var newWindow = wm.getMostRecentWindow("navigator:browser");
|
||||
var b = newWindow.getBrowser();
|
||||
return;
|
||||
}
|
||||
|
||||
if (lastWin.document.getElementById('zotero-pane').getAttribute('collapsed') == 'true') {
|
||||
lastWin.ZoteroPane.toggleDisplay();
|
||||
}
|
||||
|
||||
lastWin.ZoteroPane.selectItem(item.getID(), false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function onUnload() {
|
||||
// Unregister search from Notifier
|
||||
if (_itemsView) {
|
||||
_itemsView.unregister();
|
||||
}
|
||||
}
|
||||
}
|
||||
55
chrome/content/zotero/advancedSearch.xul
Normal file
55
chrome/content/zotero/advancedSearch.xul
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin/"?>
|
||||
<?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://zotero/skin/overlay.css" type="text/css"?>
|
||||
|
||||
<!DOCTYPE window [
|
||||
<!ENTITY % zoteroDTD SYSTEM "chrome://zotero/locale/zotero.dtd">
|
||||
%zoteroDTD;
|
||||
<!ENTITY % searchboxDTD SYSTEM "chrome://zotero/locale/searchbox.dtd">
|
||||
%searchboxDTD;
|
||||
]>
|
||||
|
||||
<window
|
||||
id="zotero-advanced-search-dialog"
|
||||
title="Advanced Search"
|
||||
orient="vertical"
|
||||
persist="screenX screenY width height"
|
||||
onload="ZoteroAdvancedSearch.onLoad()"
|
||||
onunload="ZoteroAdvancedSearch.onUnload()"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<script src="include.js"/>
|
||||
<script src="advancedSearch.js"/>
|
||||
|
||||
<hbox>
|
||||
<zoterosearch id="zotero-search-box" oncommand="ZoteroAdvancedSearch.search()" flex="1"/>
|
||||
</hbox>
|
||||
|
||||
<hbox id="zotero-search-buttons">
|
||||
<button label="&zotero.search.search;" default="true" oncommand="ZoteroAdvancedSearch.search()"/>
|
||||
<button label="&zotero.search.clear;" oncommand="ZoteroAdvancedSearch.clear()"/>
|
||||
<button label="&zotero.search.saveSearch;" oncommand="ZoteroAdvancedSearch.save()"/>
|
||||
</hbox>
|
||||
|
||||
<tree id="zotero-items-tree" flex="1" hidecolumnpicker="true" seltype="multiple"
|
||||
ondblclick="ZoteroAdvancedSearch.onDblClick(event, this)">
|
||||
<treecols>
|
||||
<treecol
|
||||
id="zotero-items-column-title" primary="true"
|
||||
label="&zotero.items.title_column;"
|
||||
flex="4" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
<treecol
|
||||
id="zotero-items-column-firstCreator"
|
||||
label="&zotero.items.creator_column;"
|
||||
flex="1" persist="width ordinal hidden sortActive sortDirection"/>
|
||||
<splitter class="tree-splitter"/>
|
||||
</treecols>
|
||||
<treechildren alternatingbackground="true"/>
|
||||
</tree>
|
||||
|
||||
<keyset>
|
||||
<key id="key_close" key="W" modifiers="accel" oncommand="window.close()"/>
|
||||
</keyset>
|
||||
</window>
|
||||
|
|
@ -160,7 +160,7 @@
|
|||
</implementation>
|
||||
|
||||
<content>
|
||||
<xul:textbox xbl:inherits="flex">
|
||||
<xul:textbox id="textbox" xbl:inherits="flex">
|
||||
<xul:popupset>
|
||||
<xul:menupopup id="textbox-fulltext-menu">
|
||||
<xul:menuitem type="radio" checked="true" label="&zotero.search.textModes.phrase;"/>
|
||||
|
|
|
|||
|
|
@ -56,17 +56,9 @@
|
|||
this.addCondition(conditions[id]);
|
||||
}
|
||||
}
|
||||
|
||||
]]>
|
||||
</setter>
|
||||
</property>
|
||||
<method name="onAddClicked">
|
||||
<body>
|
||||
<![CDATA[
|
||||
this.addCondition(this.search.getSearchCondition(this.search.addCondition("title","contains","")));
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
<method name="addCondition">
|
||||
<parameter name="ref"/>
|
||||
<body>
|
||||
|
|
@ -77,6 +69,11 @@
|
|||
|
||||
conditionsBox.appendChild(condition);
|
||||
|
||||
// Default to an empty 'title' condition
|
||||
if (!ref) {
|
||||
ref = this.search.getSearchCondition(this.search.addCondition("title","contains",""))
|
||||
}
|
||||
|
||||
condition.initWithParentAndCondition(this, ref);
|
||||
|
||||
if (conditionsBox.childNodes.length == 2){
|
||||
|
|
@ -137,21 +134,49 @@
|
|||
]]>
|
||||
</body>
|
||||
</method>
|
||||
<method name="save">
|
||||
<!-- Gets values from all rows and updates the associated search conditions -->
|
||||
<method name="updateSearch">
|
||||
<body>
|
||||
<![CDATA[
|
||||
var conditionsBox = this.id('conditions');
|
||||
|
||||
if(conditionsBox.hasChildNodes())
|
||||
for(var i = 0, len=conditionsBox.childNodes.length; i < len; i++)
|
||||
{
|
||||
if (conditionsBox.hasChildNodes()) {
|
||||
for(var i = 0, len=conditionsBox.childNodes.length; i < len; i++) {
|
||||
conditionsBox.childNodes[i].updateSearch();
|
||||
}
|
||||
|
||||
}
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
<method name="save">
|
||||
<body>
|
||||
<![CDATA[
|
||||
this.updateSearch();
|
||||
return this.search.save();
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="handleKeyPress">
|
||||
<parameter name="event"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
switch (event.keyCode) {
|
||||
case event.DOM_VK_RETURN:
|
||||
case event.DOM_VK_ENTER:
|
||||
if (event.shiftKey) {
|
||||
this.addCondition();
|
||||
}
|
||||
else {
|
||||
this.doCommand();
|
||||
}
|
||||
break;
|
||||
}
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
|
||||
<method name="id">
|
||||
<parameter name="id"/>
|
||||
<body>
|
||||
|
|
@ -161,14 +186,13 @@
|
|||
</body>
|
||||
</method>
|
||||
</implementation>
|
||||
<handlers>
|
||||
</handlers>
|
||||
|
||||
<content>
|
||||
<xul:vbox flex="1">
|
||||
<xul:vbox flex="1" onkeypress="this.parentNode.handleKeyPress(event)">
|
||||
<xul:groupbox xbl:inherits="flex">
|
||||
<xul:caption align="center">
|
||||
<xul:label value="&zotero.search.joinMode.prefix;"/>
|
||||
<xul:menulist id="joinModeMenu" oncommand="this.parentNode.parentNode.parentNode.parentNode.updateJoinMode()">
|
||||
<xul:menulist id="joinModeMenu" oncommand="this.parentNode.parentNode.parentNode.parentNode.updateJoinMode(); event.stopPropagation()">
|
||||
<xul:menupopup>
|
||||
<xul:menuitem label="&zotero.search.joinMode.any;" value="any"/>
|
||||
<xul:menuitem label="&zotero.search.joinMode.all;" value="all" selected="true"/>
|
||||
|
|
@ -178,7 +202,7 @@
|
|||
</xul:caption>
|
||||
<xul:vbox id="conditions"/>
|
||||
</xul:groupbox>
|
||||
<xul:checkbox id="recursiveCheckbox" label="&zotero.search.recursive.label;" oncommand="this.parentNode.parentNode.updateRecursive()"/>
|
||||
<xul:checkbox id="recursiveCheckbox" label="&zotero.search.recursive.label;" oncommand="this.parentNode.parentNode.updateRecursive(); event.stopPropagation()"/>
|
||||
</xul:vbox>
|
||||
</content>
|
||||
</binding>
|
||||
|
|
@ -411,9 +435,12 @@
|
|||
}
|
||||
|
||||
this.onConditionSelected();
|
||||
|
||||
this.id('conditionsmenu').focus();
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
<!-- Gets the value from the field and updates the associated search condition -->
|
||||
<method name="updateSearch">
|
||||
<body>
|
||||
<![CDATA[
|
||||
|
|
@ -480,8 +507,8 @@
|
|||
<![CDATA[
|
||||
if (this.parent){
|
||||
this.parent.removeCondition(this.conditionID);
|
||||
window.sizeToContent()
|
||||
}
|
||||
window.sizeToContent()
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
|
@ -489,9 +516,9 @@
|
|||
<body>
|
||||
<![CDATA[
|
||||
if (this.parent){
|
||||
this.parent.onAddClicked();
|
||||
this.parent.addCondition();
|
||||
window.sizeToContent();
|
||||
}
|
||||
window.sizeToContent()
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
|
@ -520,10 +547,10 @@
|
|||
</implementation>
|
||||
<content>
|
||||
<xul:hbox xbl:inherits="flex">
|
||||
<xul:menulist id="conditionsmenu" oncommand="this.parentNode.parentNode.onConditionSelected();">
|
||||
<xul:menulist id="conditionsmenu" oncommand="this.parentNode.parentNode.onConditionSelected(); event.stopPropagation()">
|
||||
<xul:menupopup/>
|
||||
</xul:menulist>
|
||||
<xul:menulist id="operatorsmenu" oncommand="this.parentNode.parentNode.onOperatorSelected()">
|
||||
<xul:menulist id="operatorsmenu" oncommand="this.parentNode.parentNode.onOperatorSelected(); event.stopPropagation()">
|
||||
<xul:menupopup/>
|
||||
</xul:menulist>
|
||||
<xul:zoterosearchtextbox id="valuefield" flex="1"/>
|
||||
|
|
@ -531,8 +558,8 @@
|
|||
<xul:menupopup/>
|
||||
</xul:menulist>
|
||||
<xul:zoterosearchagefield id="value-date-age" hidden="true" flex="1"/>
|
||||
<xul:toolbarbutton id="remove" class="zotero-clicky" label="-" oncommand="this.parentNode.parentNode.onRemoveClicked();"/>
|
||||
<xul:toolbarbutton id="add" class="zotero-clicky" label="+" oncommand="this.parentNode.parentNode.onAddClicked();"/>
|
||||
<xul:toolbarbutton id="remove" class="zotero-clicky" label="-" oncommand="this.parentNode.parentNode.onRemoveClicked(event); event.stopPropagation()"/>
|
||||
<xul:toolbarbutton id="add" class="zotero-clicky" label="+" oncommand="this.parentNode.parentNode.onAddClicked(event); event.stopPropagation()"/>
|
||||
</xul:hbox>
|
||||
</content>
|
||||
</binding>
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ var ZoteroPane = new function()
|
|||
this.newItem = newItem;
|
||||
this.newCollection = newCollection;
|
||||
this.newSearch = newSearch;
|
||||
this.openAdvancedSearchWindow = openAdvancedSearchWindow;
|
||||
this.toggleTagSelector = toggleTagSelector;
|
||||
this.updateTagSelectorSize = updateTagSelectorSize;
|
||||
this.getTagSelection = getTagSelection;
|
||||
|
|
@ -285,8 +286,7 @@ var ZoteroPane = new function()
|
|||
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(Components.interfaces.nsIPromptService);
|
||||
|
||||
var untitled = Zotero.getString('pane.collections.untitled');
|
||||
untitled = Zotero.DB.getNextName('collections', 'collectionName',
|
||||
var untitled = Zotero.DB.getNextName('collections', 'collectionName',
|
||||
Zotero.getString('pane.collections.untitled'));
|
||||
|
||||
var newName = { value: untitled };
|
||||
|
|
@ -319,6 +319,14 @@ var ZoteroPane = new function()
|
|||
}
|
||||
|
||||
|
||||
function openAdvancedSearchWindow() {
|
||||
var s = new Zotero.Search();
|
||||
s.addCondition('title', 'contains', '');
|
||||
var io = {dataIn: {search: s}, dataOut: null};
|
||||
window.openDialog('chrome://zotero/content/advancedSearch.xul', '', 'chrome,dialog=no,centerscreen', io);
|
||||
}
|
||||
|
||||
|
||||
function toggleTagSelector(){
|
||||
var zoteroPane = document.getElementById('zotero-pane');
|
||||
var tagSelector = document.getElementById('zotero-tag-selector');
|
||||
|
|
@ -761,8 +769,9 @@ var ZoteroPane = new function()
|
|||
* Select item in current collection or, if not there, in Library
|
||||
*
|
||||
* If _inLibrary_, force switch to Library
|
||||
* If _expand_, open item if it's a container
|
||||
*/
|
||||
function selectItem(itemID, inLibrary)
|
||||
function selectItem(itemID, inLibrary, expand)
|
||||
{
|
||||
if (!itemID) {
|
||||
return;
|
||||
|
|
@ -773,10 +782,10 @@ var ZoteroPane = new function()
|
|||
collectionsView.selection.select(0);
|
||||
}
|
||||
|
||||
var selected = itemsView.selectItem(itemID);
|
||||
var selected = itemsView.selectItem(itemID, expand);
|
||||
if (!selected) {
|
||||
collectionsView.selection.select(0);
|
||||
itemsView.selectItem(itemID);
|
||||
itemsView.selectItem(itemID, expand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -822,6 +831,11 @@ var ZoteroPane = new function()
|
|||
*/
|
||||
function getSelectedItems(asIDs)
|
||||
{
|
||||
if (itemsView) {
|
||||
return itemsView.getSelectedItems(asIDs);
|
||||
}
|
||||
return [];
|
||||
|
||||
if(itemsView)
|
||||
{
|
||||
var items = new Array();
|
||||
|
|
|
|||
|
|
@ -161,6 +161,8 @@
|
|||
<toolbarbutton id="zotero-tb-link-page" tooltiptext="&zotero.toolbar.attachment.weblink;" oncommand="ZoteroPane.addAttachmentFromPage(true)"/>
|
||||
<toolbarbutton id="zotero-tb-snapshot-page" tooltiptext="&zotero.toolbar.attachment.snapshot;" oncommand="ZoteroPane.addAttachmentFromPage()"/>
|
||||
<toolbarbutton id="zotero-tb-note-add" tooltiptext="&zotero.toolbar.note.standalone;" oncommand="ZoteroPane.newNote(event.shiftKey);"/>
|
||||
<toolbarseparator/>
|
||||
<toolbarbutton id="zotero-tb-advanced-search" tooltiptext="&zotero.toolbar.advancedSearch;" oncommand="ZoteroPane.openAdvancedSearchWindow()"/>
|
||||
<spacer flex="1"/>
|
||||
<label value="&zotero.toolbar.search.label;" control="zotero-tb-search"/>
|
||||
<textbox id="zotero-tb-search" type="conditional-timed" timeout="250" command="cmd_zotero_search" dir="reverse"
|
||||
|
|
|
|||
|
|
@ -66,14 +66,7 @@ Zotero.ItemTreeView.prototype.setTree = function(treebox)
|
|||
return;
|
||||
this._treebox = treebox;
|
||||
|
||||
if(!this.isSorted())
|
||||
{
|
||||
this.cycleHeader(this._treebox.columns.getNamedColumn('firstCreator'));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.sort();
|
||||
}
|
||||
this.sort();
|
||||
|
||||
//Zotero.debug('Running callbacks in itemTreeView.setTree()', 4);
|
||||
this._runCallbacks();
|
||||
|
|
@ -86,6 +79,8 @@ Zotero.ItemTreeView.prototype.setTree = function(treebox)
|
|||
*/
|
||||
Zotero.ItemTreeView.prototype.refresh = function()
|
||||
{
|
||||
var oldRows = this.rowCount;
|
||||
|
||||
this._dataItems = new Array();
|
||||
this.rowCount = 0;
|
||||
|
||||
|
|
@ -103,6 +98,12 @@ Zotero.ItemTreeView.prototype.refresh = function()
|
|||
}
|
||||
|
||||
this._refreshHashMap();
|
||||
|
||||
// Update the treebox's row count
|
||||
var diff = this.rowCount - oldRows;
|
||||
if (this._treebox && diff != 0) {
|
||||
this._treebox.rowCountChanged(oldRows - 1, diff);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -175,8 +176,15 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids)
|
|||
}
|
||||
else if (action == 'modify')
|
||||
{
|
||||
// If saved search, just re-run search
|
||||
if (this._itemGroup.isSearch())
|
||||
{
|
||||
this.refresh();
|
||||
madeChanges = true;
|
||||
}
|
||||
|
||||
// If no quicksearch, process modifications manually
|
||||
if (quicksearch.value == '')
|
||||
else if (!quicksearch || quicksearch.value == '')
|
||||
{
|
||||
for(var i=0, len=ids.length; i<len; i++)
|
||||
{
|
||||
|
|
@ -282,15 +290,8 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids)
|
|||
|
||||
if(madeChanges)
|
||||
{
|
||||
if(this.isSorted())
|
||||
{
|
||||
this.sort(); //this also refreshes the hash map
|
||||
this._treebox.invalidate();
|
||||
}
|
||||
else
|
||||
{
|
||||
this._refreshHashMap();
|
||||
}
|
||||
this.sort(); //this also refreshes the hash map
|
||||
this._treebox.invalidate();
|
||||
|
||||
// If adding and this is the active window, select the item
|
||||
if(action == 'add' && ids.length===1 && activeWindow)
|
||||
|
|
@ -303,18 +304,12 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids)
|
|||
else if (action == 'modify' && ids.length == 1 &&
|
||||
savedSelection.length == 1 && savedSelection[0] == ids[0]) {
|
||||
// If the item no longer matches the search term, clear the search
|
||||
if (this._itemRowMap[ids[0]] == undefined) {
|
||||
if (quicksearch && this._itemRowMap[ids[0]] == undefined) {
|
||||
Zotero.debug('Selected item no longer matches quicksearch -- clearing');
|
||||
quicksearch.value = '';
|
||||
quicksearch.doCommand();
|
||||
if (this.isSorted())
|
||||
{
|
||||
this.sort();
|
||||
this._treebox.invalidate();
|
||||
}
|
||||
else
|
||||
{
|
||||
this._refreshHashMap();
|
||||
}
|
||||
this.sort();
|
||||
this._treebox.invalidate();
|
||||
}
|
||||
|
||||
this.rememberSelection(savedSelection);
|
||||
|
|
@ -482,10 +477,8 @@ Zotero.ItemTreeView.prototype.toggleOpenState = function(row)
|
|||
|
||||
Zotero.ItemTreeView.prototype.isSorted = function()
|
||||
{
|
||||
for(var i=0, len=this._treebox.columns.count; i<len; i++)
|
||||
if(this._treebox.columns.getColumnAt(i).element.getAttribute('sortActive'))
|
||||
return true;
|
||||
return false;
|
||||
// We sort by the first column if none selected, so return true
|
||||
return true;
|
||||
}
|
||||
|
||||
Zotero.ItemTreeView.prototype.cycleHeader = function(column)
|
||||
|
|
@ -521,7 +514,6 @@ Zotero.ItemTreeView.prototype.sort = function()
|
|||
{
|
||||
var column = this._treebox.columns.getSortedColumn();
|
||||
if (!column){
|
||||
// DEBUG: This may be necessary for 1.0.0b2.r1=>1.0.0b2.r2 transition
|
||||
column = this._treebox.columns.getFirstColumn();
|
||||
}
|
||||
var order = column.element.getAttribute('sortDirection') == 'ascending';
|
||||
|
|
@ -624,30 +616,80 @@ Zotero.ItemTreeView.prototype.sort = function()
|
|||
/*
|
||||
* Select an item
|
||||
*/
|
||||
Zotero.ItemTreeView.prototype.selectItem = function(id)
|
||||
Zotero.ItemTreeView.prototype.selectItem = function(id, expand)
|
||||
{
|
||||
var row = this._itemRowMap[id];
|
||||
|
||||
// Get the row of the parent, if there is one
|
||||
var parentRow = null;
|
||||
var item = Zotero.Items.get(id);
|
||||
var parent = item.getSource();
|
||||
if (parent && this._itemRowMap[parent]) {
|
||||
parentRow = this._itemRowMap[parent];
|
||||
}
|
||||
|
||||
// If row with id not visible, check to see if it's hidden under a parent
|
||||
if(row == null)
|
||||
{
|
||||
var item = Zotero.Items.get(id);
|
||||
var parent = item.getSource();
|
||||
if (!parent)
|
||||
if (!parent || !parentRow)
|
||||
{
|
||||
// No parent -- it's not here
|
||||
return false;
|
||||
}
|
||||
this.toggleOpenState(this._itemRowMap[parent]); //opens the parent of the item
|
||||
this.toggleOpenState(parentRow); //opens the parent of the item
|
||||
row = this._itemRowMap[id];
|
||||
}
|
||||
|
||||
this.selection.select(row);
|
||||
this._treebox.ensureRowIsVisible(row);
|
||||
// If _expand_, open container
|
||||
if (expand && this.isContainer(row) && !this.isContainerOpen(row)) {
|
||||
this.toggleOpenState(row);
|
||||
}
|
||||
this.selection.select(row);
|
||||
|
||||
// We aim for a row 5 below the target row, since ensureRowIsVisible() does
|
||||
// the bare minimum to get the row in view
|
||||
for (var v = row + 5; v>=row; v--) {
|
||||
if (this._dataItems[v]) {
|
||||
this._treebox.ensureRowIsVisible(v);
|
||||
if (this._treebox.getFirstVisibleRow() <= row) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the parent row isn't in view and we have enough room, make parent visible
|
||||
if (parentRow !== null && this._treebox.getFirstVisibleRow() > parentRow) {
|
||||
if ((row - parentRow) < this._treebox.getPageLength()) {
|
||||
this._treebox.ensureRowIsVisible(parentRow);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Return an array of Item objects for selected items
|
||||
*
|
||||
* If asIDs is true, return an array of itemIDs instead
|
||||
*/
|
||||
Zotero.ItemTreeView.prototype.getSelectedItems = function(asIDs)
|
||||
{
|
||||
var items = [], start = {}, end = {};
|
||||
for (var i=0, len = this.selection.getRangeCount(); i<len; i++)
|
||||
{
|
||||
this.selection.getRangeAt(i,start,end);
|
||||
for (var j=start.value; j<=end.value; j++) {
|
||||
if (asIDs) {
|
||||
items.push(this._getItemAtRow(j).ref.getID());
|
||||
}
|
||||
else {
|
||||
items.push(this._getItemAtRow(j).ref);
|
||||
}
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -714,10 +756,9 @@ Zotero.ItemTreeView.prototype.setFilter = function(type, data) {
|
|||
}
|
||||
var oldCount = this.rowCount;
|
||||
this.refresh();
|
||||
this._treebox.rowCountChanged(0,this.rowCount-oldCount);
|
||||
|
||||
this.sort();
|
||||
|
||||
|
||||
this.rememberOpenState(savedOpenState);
|
||||
this.rememberFirstRow(savedFirstRow);
|
||||
this.rememberSelection(savedSelection);
|
||||
|
|
@ -878,7 +919,7 @@ Zotero.ItemTreeView.prototype.getSortedItems = function() {
|
|||
Zotero.ItemTreeView.prototype.getSortField = function() {
|
||||
var column = this._treebox.columns.getSortedColumn()
|
||||
if (!column) {
|
||||
return false;
|
||||
column = this._treebox.columns.getFirstColumn()
|
||||
}
|
||||
// zotero-items-column-_________
|
||||
return column.id.substring(20);
|
||||
|
|
|
|||
|
|
@ -167,6 +167,20 @@ Zotero.Search.prototype.save = function(){
|
|||
}
|
||||
|
||||
|
||||
Zotero.Search.prototype.clone = function() {
|
||||
var s = new Zotero.Search();
|
||||
|
||||
var conditions = this.getSearchConditions();
|
||||
|
||||
for each(var condition in conditions) {
|
||||
s.addCondition(condition.condition, condition.operator, condition.value,
|
||||
condition.required);
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
Zotero.Search.prototype.addCondition = function(condition, operator, value, required){
|
||||
if (!Zotero.SearchConditions.hasOperator(condition, operator)){
|
||||
throw ("Invalid operator '" + operator + "' for condition " + condition);
|
||||
|
|
@ -228,9 +242,12 @@ Zotero.Search.prototype.updateCondition = function(searchConditionID, condition,
|
|||
throw ("Invalid operator '" + operator + "' for condition " + condition);
|
||||
}
|
||||
|
||||
var [condition, mode] = Zotero.SearchConditions.parseCondition(condition);
|
||||
|
||||
this._conditions[searchConditionID] = {
|
||||
id: searchConditionID,
|
||||
condition: condition,
|
||||
mode: mode,
|
||||
operator: operator,
|
||||
value: value,
|
||||
required: required
|
||||
|
|
@ -264,8 +281,20 @@ Zotero.Search.prototype.getSearchCondition = function(searchConditionID){
|
|||
* used in the search, indexed by searchConditionID
|
||||
*/
|
||||
Zotero.Search.prototype.getSearchConditions = function(){
|
||||
// TODO: make copy
|
||||
return this._conditions;
|
||||
var conditions = [];
|
||||
var i = 1;
|
||||
for each(var condition in this._conditions) {
|
||||
conditions[i] = {
|
||||
id: i,
|
||||
condition: condition.condition,
|
||||
mode: condition.mode,
|
||||
operator: condition.operator,
|
||||
value: condition.value,
|
||||
required: condition.required
|
||||
};
|
||||
i++;
|
||||
}
|
||||
return conditions;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,3 +15,7 @@
|
|||
<!ENTITY zotero.search.date.units.days "days">
|
||||
<!ENTITY zotero.search.date.units.months "months">
|
||||
<!ENTITY zotero.search.date.units.years "years">
|
||||
|
||||
<!ENTITY zotero.search.search "Search">
|
||||
<!ENTITY zotero.search.clear "Clear">
|
||||
<!ENTITY zotero.search.saveSearch "Save Search">
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
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.name = Collection name:
|
||||
pane.collections.savedSearchName = Enter a name for this saved search:
|
||||
pane.collections.rename = Rename collection:
|
||||
pane.collections.library = My Library
|
||||
pane.collections.untitled = Untitled
|
||||
|
|
|
|||
|
|
@ -173,6 +173,11 @@
|
|||
list-style-image: url('chrome://zotero/skin/treeitem-attachment-web-link.png');
|
||||
}
|
||||
|
||||
#zotero-tb-advanced-search
|
||||
{
|
||||
list-style-image: url('chrome://zotero/skin/toolbar-advanced-search.png');
|
||||
}
|
||||
|
||||
#zotero-tb-fullscreen
|
||||
{
|
||||
list-style-image: url('chrome://zotero/skin/toolbar-fullscreen-bottom.png');
|
||||
|
|
|
|||
BIN
chrome/skin/default/zotero/toolbar-advanced-search.png
Executable file
BIN
chrome/skin/default/zotero/toolbar-advanced-search.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 615 B |
|
|
@ -193,4 +193,21 @@ zoterosearchagefield textbox
|
|||
.zotero-scrape-popup-collection
|
||||
{
|
||||
list-style-image: url('chrome://zotero/skin/treesource-collection.png');
|
||||
}
|
||||
|
||||
|
||||
#zotero-advanced-search-dialog
|
||||
{
|
||||
padding: 8px 8px 14px;
|
||||
height: 400px;
|
||||
}
|
||||
|
||||
#zotero-advanced-search-dialog #zotero-search-buttons
|
||||
{
|
||||
margin: 3px 0;
|
||||
}
|
||||
|
||||
#zotero-advanced-search-dialog #zotero-items-tree
|
||||
{
|
||||
min-height: 170px;
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue