commit d815154efa674d3ed8dc527743a1ed614e34cdc6
parent 9c496770a6be2f88aafd841e66f9fc3c814bad72
Author: David Norton <david@nortoncrew.com>
Date: Thu, 10 Aug 2006 22:39:21 +0000
Removing a saved search removes the item in the left pane.
Search dialog:
- should work now.
- Any/All control
- All 8 operators
Add search button uses an icon
Diffstat:
7 files changed, 65 insertions(+), 39 deletions(-)
diff --git a/chrome/chromeFiles/content/scholar/bindings/scholarsearch.xml b/chrome/chromeFiles/content/scholar/bindings/scholarsearch.xml
@@ -34,9 +34,18 @@
conditionsBox.removeChild(conditionsBox.firstChild);
var conditions = this.search.getSearchConditions();
- if(conditions.length)
- for(var i = 0, len = conditions.length; i<len; i++)
- this.addCondition(i);
+ for(var id in conditions)
+ {
+ if(conditions[id]['condition'] == 'joinMode')
+ {
+ this.id('joinModeMenu').setAttribute('condition',id);
+ this.id('joinModeMenu').value = conditions[id]['operator'];
+ }
+ else
+ {
+ this.addCondition(conditions[id]);
+ }
+ }
]]>
</setter>
@@ -44,12 +53,12 @@
<method name="onAddClicked">
<body>
<![CDATA[
- this.addCondition(this.search.addCondition("itemType","is","1"));
+ this.addCondition(this.search.getSearchCondition(this.search.addCondition("title","contains","")));
]]>
</body>
</method>
<method name="addCondition">
- <parameter name="id"/>
+ <parameter name="ref"/>
<body>
<![CDATA[
var conditionsBox = this.id('conditions');
@@ -58,26 +67,42 @@
conditionsBox.appendChild(condition);
- condition.initWithParentAndConditionID(this, id);
+ condition.initWithParentAndCondition(this, ref);
conditionsBox.childNodes[0].id('remove').hidden = (conditionsBox.childNodes.length == 1);
]]>
</body>
</method>
<method name="removeCondition">
- <parameter name="idx"/>
+ <parameter name="id"/>
<body>
<![CDATA[
var conditionsBox = this.id('conditions');
- this.search.removeCondition(idx);
- conditionsBox.removeChild(conditionsBox.childNodes[idx]);
- for(var i = idx, len=conditionsBox.childNodes.length; i < len; i++)
- conditionsBox.childNodes[i].conditionID = i;
-
+ this.search.removeCondition(id);
+
+ for(var i = 0, len=conditionsBox.childNodes.length; i < len; i++)
+ if(conditionsBox.childNodes[i].conditionID == id)
+ {
+ conditionsBox.removeChild(conditionsBox.childNodes[i]);
+
+ i = len;
+ }
+
conditionsBox.childNodes[0].id('remove').hidden = (conditionsBox.childNodes.length == 1);
]]>
</body>
</method>
+ <method name="updateJoinMode">
+ <body>
+ <![CDATA[
+ var menu = this.id('joinModeMenu');
+ if(menu.hasAttribute('condition'))
+ this.search.updateCondition(menu.getAttribute('condition'),'joinMode',menu.value,null);
+ else
+ menu.setAttribute('condition', this.search.addCondition('joinMode',menu.value,null));
+ ]]>
+ </body>
+ </method>
<method name="save">
<body>
<![CDATA[
@@ -87,8 +112,7 @@
for(var i = 0, len=conditionsBox.childNodes.length; i < len; i++)
conditionsBox.childNodes[i].updateSearch();
- this.search.save();
-
+ return this.search.save();
]]>
</body>
</method>
@@ -107,10 +131,10 @@
<xul:groupbox xbl:inherits="flex">
<xul:caption align="center">
<xul:label value="Match"/>
- <xul:menulist>
+ <xul:menulist id="joinModeMenu" oncommand="this.parentNode.parentNode.parentNode.updateJoinMode();">
<xul:menupopup>
<xul:menuitem label="Any" value="any"/>
- <xul:menuitem label="All" value="all"/>
+ <xul:menuitem label="All" value="all" selected="true"/>
</xul:menupopup>
</xul:menulist>
<xul:label value="of the following:"/>
@@ -124,10 +148,12 @@
<implementation>
<constructor>
<![CDATA[
- this.operators = new Array('is', 'isNot', 'contains', 'doesNotContain');
+ var operators = new Array('is', 'isNot', 'contains', 'doesNotContain', 'lessThan', 'greaterThan', 'isBefore', 'isAfter');
+ var operatorsList = this.id('operatorsmenu');
+ for(i in operators)
+ operatorsList.appendItem(Scholar.getString('searchOperator.'+operators[i]),operators[i]);
+
var conditionsList = this.id('conditionsmenu');
- conditionsList.removeAllItems;
-
var conditions = Scholar.SearchConditions.getStandardConditions();
for(var i=0, len=conditions.length; i<len; i++)
@@ -156,22 +182,20 @@
]]>
</body>
</method>
- <field name="operators"/>
<field name="dontupdate"/>
<field name="parent"/>
<field name="conditionID"/>
- <method name="initWithParentAndConditionID">
+ <method name="initWithParentAndCondition">
<parameter name="parent"/>
- <parameter name="id"/>
+ <parameter name="condition"/>
<body>
<![CDATA[
this.parent = parent;
- this.conditionID = id;
+ this.conditionID = condition['id'];
if(this.parent.search)
{
this.dontupdate = true; //so that the search doesn't get updated while we are creating controls.
- var condition = this.parent.search.getSearchCondition(this.conditionID);
this.id('conditionsmenu').value = condition['condition'];
this.id('operatorsmenu').value = condition['operator'];
@@ -226,12 +250,7 @@
<xul:menupopup/>
</xul:menulist>
<xul:menulist id="operatorsmenu">
- <xul:menupopup>
- <xul:menuitem label="is" value="is"/>
- <xul:menuitem label="isNot" value="isNot"/>
- <xul:menuitem label="contains" value="contains"/>
- <xul:menuitem label="doesNotContain" value="doesNotContain"/>
- </xul:menupopup>
+ <xul:menupopup/>
</xul:menulist>
<xul:textbox id="valuefield" flex="1"/>
<xul:toolbarbutton id="remove" class="clicky" label="-" oncommand="this.parentNode.parentNode.onRemoveClicked();"/>
diff --git a/chrome/chromeFiles/content/scholar/collectionTreeView.js b/chrome/chromeFiles/content/scholar/collectionTreeView.js
@@ -65,10 +65,7 @@ Scholar.CollectionTreeView.prototype.refresh = function()
var savedSearches = Scholar.Searches.getAll();
for(var i = 0; i < savedSearches.length; i++)
- {
this._showItem(new Scholar.ItemGroup('search',savedSearches[i]), 0, this._dataItems.length); //itemgroup ref, level, beforeRow
- Scholar.debug(i);
- }
this._refreshHashMap();
}
@@ -106,6 +103,8 @@ Scholar.CollectionTreeView.prototype.notify = function(action, type, ids)
{
var madeChanges = false;
+ Scholar.debug(action+', '+type+', '+ids);
+
if(action == 'remove')
{
ids = Scholar.flattenArguments(ids);
@@ -310,7 +309,10 @@ Scholar.CollectionTreeView.prototype.deleteSelection = function()
if(group.isCollection())
group.ref.erase();
else if(group.isSearch())
+ {
Scholar.Searches.erase(group.ref['id']);
+ this._hideItem(rows[i]-i); //we don't have the notification system set up with searches.
+ }
}
this._treebox.endUpdateBatch();
diff --git a/chrome/chromeFiles/content/scholar/overlay.js b/chrome/chromeFiles/content/scholar/overlay.js
@@ -177,7 +177,7 @@ var ScholarPane = new function()
window.openDialog('chrome://scholar/content/searchDialog.xul','','chrome,modal',io);
if(io.dataOut)
- getCollectionsView().reload();
+ getCollectionsView().reload(); //we don't have notification support for searches
}
function onCollectionSelected()
@@ -300,7 +300,7 @@ var ScholarPane = new function()
var io = {dataIn: {search: s, name: collection.getName()}, dataOut: null};
window.openDialog('chrome://scholar/content/searchDialog.xul','','chrome,modal',io);
if(io.dataOut)
- onCollectionSelected();
+ onCollectionSelected(); //reload itemsView
}
}
}
diff --git a/chrome/chromeFiles/content/scholar/overlay.xul b/chrome/chromeFiles/content/scholar/overlay.xul
@@ -69,8 +69,8 @@
<vbox id="collections-pane" persist="width" flex="1">
<toolbar>
<toolbarbutton id="tb-collection-add" tooltiptext="&toolbar.newCollection.label;" command="cmd_scholar_newCollection"/>
+ <toolbarbutton id="tb-collection-addsearch" tooltiptext="&toolbar.newSearch.label;" oncommand="ScholarPane.newSearch();"/>
<toolbarbutton id="tb-collection-rename" tooltiptext="&toolbar.renameCollection.label;" oncommand="ScholarPane.renameSelectedCollection();" disabled="true"/>
- <toolbarbutton id="tb-collection-addsearch" label="Add Search" oncommand="ScholarPane.newSearch();"/>
<spacer flex="1"/>
<toolbarbutton id="tb-collection-menu" type="menu">
<menupopup>
diff --git a/chrome/chromeFiles/content/scholar/searchDialog.js b/chrome/chromeFiles/content/scholar/searchDialog.js
@@ -39,6 +39,5 @@ function doUnload()
function doAccept()
{
document.getElementById('search-box').search.setName(document.getElementById('search-name').value);
- document.getElementById('search-box').save();
- io.dataOut = true;
+ io.dataOut = document.getElementById('search-box').save();
}
\ No newline at end of file
diff --git a/chrome/chromeFiles/locale/en-US/scholar/scholar.dtd b/chrome/chromeFiles/locale/en-US/scholar/scholar.dtd
@@ -19,8 +19,9 @@
<!ENTITY collections.name_column "Name">
<!ENTITY toolbar.newItem.label "New Item">
-<!ENTITY toolbar.removeItem.label "Remove Item...">
+<!ENTITY toolbar.removeItem.label "Remove Item...">
<!ENTITY toolbar.newCollection.label "New Project">
+<!ENTITY toolbar.newSearch.label "New Search">
<!ENTITY toolbar.renameCollection.label "Rename Project...">
<!ENTITY toolbar.removeCollection.label "Remove Project...">
<!ENTITY toolbar.exportCollection.label "Export Project...">
diff --git a/chrome/chromeFiles/skin/default/scholar/overlay.css b/chrome/chromeFiles/skin/default/scholar/overlay.css
@@ -135,6 +135,11 @@
width: 150px;
}
+#tb-collection-addsearch
+{
+ list-style-image: url('chrome://scholar/skin/treesource-search.png');
+}
+
#tb-search-cancel
{
margin: 0px;