зеркало из https://github.com/mozilla/pjs.git
add support for and/or radiobuttons
This commit is contained in:
Родитель
9c5bc746e0
Коммит
29dd4f49b2
|
@ -83,6 +83,17 @@ function setSearchScope(scope) {
|
|||
}
|
||||
|
||||
function booleanChanged(event) {
|
||||
// when boolean changes, we have to update all the attributes on the
|
||||
// filter terms
|
||||
|
||||
var newBoolValue =
|
||||
(event.target.getAttribute("data") == "and") ? true : false;
|
||||
searchTermElements = gSearchTermContainer.childNodes;
|
||||
if (!searchTermElements) return;
|
||||
for (var i=0; i<searchTermElements.length; i++) {
|
||||
var searchTerm = searchTermElements[i];
|
||||
searchTerm.booleanAnd = newBoolValue;
|
||||
}
|
||||
dump("Boolean is now " + event.target.data + "\n");
|
||||
}
|
||||
|
||||
|
@ -128,6 +139,24 @@ function initializeSearchWidgets() {
|
|||
gSearchTermContainer = document.getElementById("searchterms");
|
||||
}
|
||||
|
||||
function initializeBooleanWidgets() {
|
||||
gSearchBooleanRadiogroup = document.getElementById("booleanAndGroup");
|
||||
|
||||
var booleanAnd = true;
|
||||
// get the boolean value from the first term
|
||||
var firstTerm = gSearchTermContainer.firstChild;
|
||||
if (firstTerm)
|
||||
booleanAnd = firstTerm.booleanAnd;
|
||||
|
||||
// target radio items have data="and" or data="or"
|
||||
targetValue = "or";
|
||||
if (booleanAnd) targetValue = "and";
|
||||
|
||||
targetElement = gSearchBooleanRadiogroup.getElementsByAttribute("data", targetValue)[0];
|
||||
|
||||
gSearchBooleanRadiogroup.selectedItem = targetElement;
|
||||
}
|
||||
|
||||
// move to overlay
|
||||
function initializeSearchRows(scope, searchTerms)
|
||||
{
|
||||
|
@ -137,6 +166,7 @@ function initializeSearchRows(scope, searchTerms)
|
|||
var searchTerm = searchTerms.QueryElementAt(i, nsIMsgSearchTerm);
|
||||
createSearchRow(i, scope, searchTerm);
|
||||
}
|
||||
initializeBooleanWidgets();
|
||||
}
|
||||
|
||||
// move to overlay
|
||||
|
@ -190,6 +220,8 @@ function createSearchRow(index, scope, searchTerm)
|
|||
searchTermElement.searchScope = scope;
|
||||
if (searchTerm)
|
||||
searchTermElement.searchTerm = searchTerm;
|
||||
else
|
||||
searchTermElement.booleanAnd = getBooleanAnd();
|
||||
|
||||
}
|
||||
|
||||
|
@ -248,6 +280,18 @@ function removeSearchRow(index)
|
|||
searchTermElement.parentNode.removeChild(searchTermElement);
|
||||
}
|
||||
|
||||
function getBooleanAnd()
|
||||
{
|
||||
var booleanAndElement = document.getElementById("booleanAndGroup");
|
||||
if (!booleanAndElement) return;
|
||||
|
||||
if (booleanAndElement.selectedItem)
|
||||
return (booleanAndElement.selectedItem.getAttribute("data") == "and") ? true : false;
|
||||
|
||||
// default to false
|
||||
return false;
|
||||
}
|
||||
|
||||
function saveFilter() {
|
||||
|
||||
if (!gFilter) {
|
||||
|
|
|
@ -46,9 +46,9 @@ Rights Reserved.
|
|||
<text value="&conditions.label;"/>
|
||||
</title>
|
||||
<text value="&conditionDesc.label;"/>
|
||||
<radiogroup id="matchGroup" oncommand="booleanChanged(event);">
|
||||
<radio group="matchGroup" data="true" value="&matchAll.label;"/>
|
||||
<radio group="matchGroup" data="false" value="&matchAny.label;"/>
|
||||
<radiogroup id="booleanAndGroup" oncommand="booleanChanged(event);">
|
||||
<radio group="booleanAndGroup" data="and" value="&matchAll.label;"/>
|
||||
<radio group="booleanAndGroup" data="or" value="&matchAny.label;"/>
|
||||
</radiogroup>
|
||||
|
||||
<spring class="spacer"/>
|
||||
|
|
Загрузка…
Ссылка в новой задаче