first consumer of searchattribute tag - dynamically change contents based on scope

This commit is contained in:
alecf%netscape.com 2000-04-30 08:51:43 +00:00
parent 26f0b8b125
commit ba86aad319
2 changed files with 62 additions and 32 deletions

View File

@ -1,34 +1,48 @@
function filterEditorOnLoad(pickerID)
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Alec Flett <alecf@netscape.com>
*/
var validityManager;
function filterEditorOnLoad()
{
MsgFolderPickerOnLoad(pickerID);
validityManager = Components.classes["mozilla.mail.search.validityManager.1"].getService(Components.interfaces.nsIMsgSearchValidityManager);
var searchAttr = document.getElementById("searchAttr");
searchAttr.scope = 0;
}
function updateRule(boxnode) {
var ruleid=boxnode.getAttribute("id");
function scopeChanged(event)
{
var menuitem = event.target;
var selectNode = document.getElementById(ruleid + "-attribute");
if (!selectNode) return;
var option = selectNode.options[selectNode.selectedIndex];
if (!option) return;
if (!option.value) return;
var destBox = document.getElementById(ruleid + "-verb");
var destParent = destBox.parentNode;
dump("Looking for " + option.value + "-template\n");
var verbTemplate = document.getElementById(option.value + "-template");
var newVerb = verbTemplate.cloneNode(true);
dump("I will dump " + option.value + " into " + destParent.nodeName + "\n");
destParent.replaceChild(newVerb, destBox);
}
function updateFilterObject(node) {
selectbox=document.getElementById("rule1");
updateRule(selectbox);
var searchattr = document.getElementById("searchAttr");
dump("setting scope to " + menuitem.data + "\n");
try {
searchattr.scope = menuitem.data;
} catch (ex) {
}
// DumpDOM(searchattr.anonymousContent[0]);
}

View File

@ -33,12 +33,25 @@ Rights Reserved.
<script language="JavaScript" src="chrome://messenger/content/FilterEditor.js"/>
<script language="JavaScript" src="chrome://global/content/strres.js"/>
<script language="JavaScript" src="chrome://messenger/content/widgetglue.js"/>
<script src="chrome://global/content/default/DumpDOM.js"/>
<box orient="horizontal" class="padded">
<text value="&filterName.label;"/>
<textfield flex="1"/>
</box>
<box>
<text value="(For debugging only) Scope:"/>
<menulist oncommand="scopeChanged(event);">
<menupopup>
<menuitem value="onlineMail" data="0"/>
<menuitem value="offlineMailFilter" data="1"/>
<menuitem value="offlineMail" data="2"/>
<menuitem value="localNews" data="3"/>
<menuitem value="news" data="4"/>
<menuitem value="newsEx" data="5"/>
</menupopup>
</menulist>
</box>
<titledbox orient="vertical">
<title>
<text value="&conditions.label;"/>
@ -56,13 +69,16 @@ Rights Reserved.
<treecol id="a" />
<treecol id="b"/>
<treecol id="c"/>
<treechildren>
<treeitem>
<treerow>
<treecell value="the.."/>
<treecell value="contains.."/>
<treecell allowevents="true">
<searchattribute id="searchAttr" flex="1"/>
</treecell>
<treecell allowevents="true">
<searchoperator id="searchOp" flex="1"/>
</treecell>
<treecell value="text here"/>
</treerow>
</treeitem>