Monotone-Parent: 6364fd26aed4532b46cd1c779ef5e9f5f6c0971c

Monotone-Revision: fd35d485688e2370ae5250cfa15931e93abfd567

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2010-03-02T19:57:30
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau committed 2010-03-02 19:57:30 +00:00
1 parent e2f1faa697
commit f81f48cb90
28 files changed
+2207 -62

No files matched your search

@@ -101,14 +101,6 @@ function validateContactEditor() {
return rc;
}
function showCoords(node) {
node = $("givenName");
window.alert("x: " + node.cascadeLeftOffset()
+ ";y: " + node.cascadeTopOffset()
+ ";width: " + window.width()
+ ";height: " + window.height());
}
function onFnKeyDown() {
var fn = $("fn");
fn.onkeydown = null;
+103
View File
@@ -0,0 +1,103 @@
DIV#pageContent
{ padding: 10px;
padding-top: 15px; }
#splitter
{ cursor: n-resize;
top: 230px;
left: 0px;
right: 0px;
height: 5px; }
LABEL
{ margin: 0px;
padding: 0px; }
#pageContent INPUT,
#pageContent SELECT
{ background-color: #ccddec;
padding: 1px;
margin: 1px;
border-width: 1px; }
#pageContent INPUT
{ padding-left: 2px; }
DIV.container
{ margin-bottom: 14px; }
DIV#filterRulesContainer,
DIV#filterActionsContainer
{ position: absolute;
margin: 0px;
border: 0px;
padding: 0px;
left: 10px;
right: 10px; }
DIV#filterRulesContainer
{ top: 128px;
height: 102px; }
DIV#filterActionsContainer
{ top: 235px;
bottom: 0px; }
DIV#filterRules, DIV#filterActions
{ position: absolute;
cursor: default;
left: 0px;
right: 0px;
bottom: 21px;
border-top: 1px solid #909090;
border-left: 1px solid #909090;
border-bottom: 1px solid #ffffff;
border-right: 1px solid #ffffff;
background: #ccddec;
overflow: hidden;
overflow-y: auto; }
DIV#filterRules
{ top: 0px; }
DIV#filterActions
{ top: 20px; }
DIV.bottomToolbar
{ position: absolute;
left: 0px;
right: 0px;
margin: 0px;
padding: 0px;
bottom: 0px; }
DIV.rule,
DIV.action
{ overflow: hidden;
padding-left: 2px;
padding-right: 2px;
width: 100%;
border-bottom: 1px solid #9b9b9b; }
DIV.rule._selected,
DIV.action._selected
{ background-color: #9abcd8;
color: #fff; }
SPAN.fieldContainer
{ width: 100px; }
SPAN.operatorContainer
{ width: 300px; }
SPAN.valueContainer INPUT
{ width: 160px; }
SPAN.fileintoArgument SELECT
{ max-width: 250px; }
SPAN.rejectArgument TEXTAREA
{ height: 54px;
width: 90%;
margin-left: 5%;
padding-right: -50px; }
+794
View File
@@ -0,0 +1,794 @@
/* -*- Mode: java; tab-width: 2; c-label-minimum-indentation: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* Cyrus: comparator-i;ascii-numeric fileinto reject vacation imapflags
notify envelope relational regex subaddress copy */
var sieveCapabilities = [];
var filter;
var selectedRuleDiv = null;
var selectedActionDiv = null;
var fieldLabels;
var methodLabels;
var operatorLabels;
var operatorRequirements;
var methodRequirements;
var flagLabels;
var mailboxes = [];
function onLoadHandler() {
setupConstants();
setupEventHandlers();
if (window.opener)
sieveCapabilities = window.opener.getSieveCapabilitiesFromEditor();
if (!window.opener || filterId == "new") {
setupNewFilterData();
} else {
filter = window.opener.getFilterFromEditor(filterId);
}
if (!window.opener || window.opener.userMailboxes) {
setupFilterViews();
} else {
loadMailboxes();
}
}
function loadMailboxes() {
var url = (ApplicationBaseURL + "Mail/"
+ encodeURI(firstMailAccount) + "/mailboxes");
triggerAjaxRequest(url, onLoadMailboxesCallback);
}
function onLoadMailboxesCallback(http) {
if (http.readyState == 4) {
window.opener.userMailboxes = [];
if (http.status == 200) {
checkAjaxRequestsState();
if (http.responseText.length > 0) {
var jsonResponse = http.responseText.evalJSON(true);
var responseMboxes = jsonResponse.mailboxes;
for (var i = 0; i < responseMboxes.length; i++) {
var name = responseMboxes[i].path.substr(1);
window.opener.userMailboxes.push(name);
}
}
}
setupFilterViews();
}
}
function setupConstants() {
fieldLabels = { "subject": _("Subject"),
"from": _("From"),
"to": _("To"),
"cc": _("Cc"),
"to_or_cc": _("To or Cc"),
"size": _("Size (Kb)"),
"header": _("Header") };
methodLabels = { "addflag": _("Flag the message with:"),
"discard": _("Discard the message"),
"fileinto": _("File the message in:"),
"keep": _("Keep the message"),
"redirect": _("Forward the message to:"),
"reject": _("Send a reject message:"),
"vacation": _("Send a vacation message"),
"stop": _("Stop processing filter rules") };
operatorLabels = { "under": _("is under"),
"over": _("is over"),
"is": _("is"),
"is_not": _("is not"),
"contains": _("contains"),
"contains_not": _("does not contain"),
"matches": _("matches"),
"matches_not": _("does not match"),
"regex": _("matches regex"),
"regex_not": _("does not match regex") };
flagLabels = { "seen": _("Seen"),
"deleted": _("Deleted"),
"answered": _("Answered"),
"flagged": _("Flagged"),
"junk": _("Junk"),
"not_junk": _("Not Junk") };
for (var i = 1; i < 6; i++) {
var key = "label" + i;
flagLabels[key] = _("Label " + i);
}
}
function setupEventHandlers() {
var filterName = $("mainForm").filterName;
if (filterName) {
var boundCB = onFilterNameChange
.bindAsEventListener(filterName);
filterName.observe("change", boundCB);
}
var matchTypeSelect = $("matchType");
if (matchTypeSelect) {
var boundCB = onMatchTypeChange
.bindAsEventListener(matchTypeSelect);
matchTypeSelect.observe("change", boundCB);
}
var filterRules = $("filterRules");
var boundCB = onFilterRulesDivClick
.bindAsEventListener(filterRules);
filterRules.observe("click", boundCB);
var ruleAdd = $("ruleAdd");
if (ruleAdd) {
var boundCB = onRuleAddClick.bindAsEventListener(ruleAdd);
ruleAdd.observe("click", boundCB);
}
var ruleDelete = $("ruleDelete");
if (ruleDelete) {
var boundCB = onRuleDeleteClick.bindAsEventListener(ruleDelete);
ruleDelete.observe("click", boundCB);
}
var filterActions = $("filterActions");
var boundCB = onFilterActionsDivClick
.bindAsEventListener(filterActions);
filterActions.observe("click", boundCB);
var actionAdd = $("actionAdd");
if (actionAdd) {
var boundCB = onActionAddClick.bindAsEventListener(actionAdd);
actionAdd.observe("click", boundCB);
}
var actionDelete = $("actionDelete");
if (actionDelete) {
var boundCB = onActionDeleteClick
.bindAsEventListener(actionDelete);
actionDelete.observe("click", boundCB);
}
}
function onFilterNameChange(event) {
filter.name = this.value;
}
function onMatchTypeChange() {
var matchType = this.value;
filter.match = matchType;
var container = $("filterRulesContainer");
var otherContainer = $("filterActionsContainer");
var otherContainerTop;
if (matchType == "allmessages") {
container.hide();
otherContainerTop = 130;
} else {
container.show();
otherContainerTop = 240;
}
otherContainer.setStyle({ top: otherContainerTop + "px" });
}
function onFilterRulesDivClick(event) {
setSelectedRuleDiv(null);
event.stop();
}
function onFilterActionsDivClick(event) {
setSelectedActionDiv(null);
event.stop();
}
function createFilterRule() {
return { field: "subject", operator: "contains", value: "" };
}
function createFilterAction() {
return { method: "fileinto", argument: "INBOX" };
}
function setupNewFilterData() {
var newFilterTemplate = $({ name: _("Untitled Filter"),
match: "any" });
newFilterTemplate.rules = $([ createFilterRule() ]);
newFilterTemplate.actions = $([ createFilterAction() ]);
filter = newFilterTemplate;
}
function setupFilterViews() {
var filterName = $("mainForm").filterName;
if (filterName) {
filterName.value = filter.name;
if (filterId == "new") {
filterName.focus();
$(filterName).selectText(0, filterName.value.length);
}
}
var matchTypeSelect = $("matchType");
if (matchTypeSelect) {
matchTypeSelect.value = filter.match;
}
if (filter.match != "allmessages") {
var filterRules = $("filterRules");
if (filterRules && filter.rules) {
for (var i = 0; i < filter.rules.length; i++) {
appendRule(filterRules, filter.rules[i]);
}
}
}
var filterActions = $("filterActions");
if (filterActions && filter.actions) {
for (var i = 0; i < filter.actions.length; i++) {
appendAction(filterActions, filter.actions[i]);
}
}
}
function appendRule(container, rule) {
var ruleDiv = createElement("div", null, "rule",
{ rule: rule }, null,
container);
var boundCB = onRuleDivClick.bindAsEventListener(ruleDiv);
ruleDiv.observe("click", boundCB);
ensureRuleRepresentation(ruleDiv);
return ruleDiv;
}
function onRuleDivClick(event) {
setSelectedRuleDiv(this);
event.stop();
}
function setSelectedRuleDiv(newDiv) {
if (selectedRuleDiv) {
selectedRuleDiv.removeClassName("_selected");
}
selectedRuleDiv = newDiv;
if (selectedRuleDiv) {
selectedRuleDiv.addClassName("_selected");
}
}
function ensureRuleRepresentation(container) {
ensureFieldRepresentation(container);
ensureOperatorRepresentation(container);
ensureValueRepresentation(container);
}
function ensureFieldRepresentation(container) {
var fieldSpans = container.select("SPAN.fieldContainer");
var fieldSpan;
if (fieldSpans.length)
fieldSpan = fieldSpans[0];
else {
while (container.firstChild) {
container.removeChild(container.firstChild);
}
fieldSpan = createElement("span", null, "fieldContainer",
null, null, container);
}
ensureFieldSelectRepresentation(container, fieldSpan);
ensureFieldCustomHeaderRepresentation(container, fieldSpan);
}
function ensureFieldSelectRepresentation(container, fieldSpan) {
var fields
= [ "subject", "from", "to", "cc", "to_or_cc", "size", "header" ];
var selects = fieldSpan.select("SELECT");
var select;
if (selects.length)
select = selects[0];
else {
select = createElement("select");
select.rule = container.rule;
var boundCB = onFieldSelectChange.bindAsEventListener(select);
select.observe("change", boundCB);
for (var i = 0; i < fields.length; i++) {
var field = fields[i];
var fieldOption = createElement("option", null, null,
{ value: field }, null, select);
fieldOption.appendChild(document
.createTextNode(fieldLabels[field]));
}
fieldSpan.appendChild(select);
}
select.value = container.rule.field;
container.rule.field = select.value;
}
function onFieldSelectChange(event) {
this.rule.field = this.value;
var fieldSpan = this.parentNode;
var container = fieldSpan.parentNode;
ensureFieldCustomHeaderRepresentation(container, fieldSpan);
ensureOperatorRepresentation(container);
ensureValueRepresentation(container);
}
function ensureFieldCustomHeaderRepresentation(container, fieldSpan) {
var headerInputs = fieldSpan.select("INPUT");
var headerInput = null;
if (headerInputs.length) {
headerInput = headerInputs[0];
}
if (container.rule.field == "header") {
if (!headerInput) {
headerInput = createElement("input", null, "textField",
{ type: "text" }, null, fieldSpan);
headerInput.rule = container.rule;
if (!container.rule.custom_header)
container.rule.custom_header = "";
headerInput.value = container.rule.custom_header;
var boundCB
= onFieldCustomHeaderChange.bindAsEventListener(headerInput);
headerInput.observe("change", boundCB);
headerInput.focus();
}
} else {
if (headerInput) {
if (container.rule.custom_header)
container.rule.custom_header = null;
fieldSpan.removeChild(headerInput);
}
}
}
function onFieldCustomHeaderChange(event) {
this.rule.custom_header = this.value;
}
function ensureOperatorRepresentation(container) {
var operatorSpans = container.select("SPAN.operatorContainer");
var operatorSpan;
if (operatorSpans.length)
operatorSpan = operatorSpans[0];
else
operatorSpan = createElement("span", null, "operatorContainer",
null, null, container);
ensureOperatorSelectRepresentation(container, operatorSpan);
}
function ensureOperatorSelectRepresentation(container, operatorSpan) {
var operators = determineOperators(container.rule.field);
var ruleField = container.rule.field;
var selects = operatorSpan.select("SELECT");
var select = null;
if (selects.length) {
select = selects[0];
if ((ruleField == "size" && !select.sizeOperator)
|| (ruleField != "size" && select.sizeOperator)) {
operatorSpan.removeChild(select);
select = null;
}
}
if (!select) {
select = createElement("select");
select.rule = container.rule;
select.sizeOperator = (ruleField == "size");
var boundCB = onOperatorSelectChange.bindAsEventListener(select);
select.observe("change", boundCB);
for (var i = 0; i < operators.length; i++) {
var operator = operators[i];
var operatorOption = createElement("option", null, null,
{ value: operator }, null,
select);
operatorOption.appendChild(document
.createTextNode(operatorLabels[operator]));
}
operatorSpan.appendChild(select);
}
if (container.rule.operator
&& operators.indexOf(container.rule.operator) == -1) {
container.rule.operator = operators[0];
}
select.value = container.rule.operator;
container.rule.operator = select.value;
}
function onOperatorSelectChange(event) {
this.rule.operator = this.value;
var valueSpans = this.parentNode.parentNode.select("SPAN.valueContainer");
if (valueSpans.length) {
var valueInputs = valueSpans[0].select("INPUT");
if (valueInputs.length) {
valueInputs[0].focus();
}
}
}
function determineOperators(field) {
var operators;
if (field == "size") {
operators = [ "under", "over" ];
} else {
var baseOperators = [ "is", "contains", "matches" ];
if (sieveCapabilities.indexOf("regex") > -1) {
baseOperators.push("regex");
}
operators = [];
for (var i = 0; i < baseOperators.length; i++) {
operators.push(baseOperators[i]);
operators.push(baseOperators[i] + "_not");
}
}
return operators;
}
function ensureValueRepresentation(container) {
var valueSpans = container.select("SPAN.valueContainer");
var valueSpan;
if (valueSpans.length)
valueSpan = valueSpans[0];
else
valueSpan = createElement("span", null, "valueContainer",
null, null, container);
ensureValueInputRepresentation(container, valueSpan);
}
function ensureValueInputRepresentation(container, valueSpan) {
var inputs = valueSpan.select("INPUT");
var input;
if (inputs.length) {
input = inputs[0];
}
else {
input = createElement("input", null, "textField");
input.rule = container.rule;
var boundCB = onValueInputChange.bindAsEventListener(input);
input.observe("change", boundCB);
valueSpan.appendChild(input);
}
input.value = container.rule.value;
ensureFieldValidity(input);
}
function ensureFieldValidity(input) {
var valid = true;
if (input.rule.field == "size") {
valid = ensureFieldIsNumerical(input);
} else
input.removeClassName("_invalid");
return valid;
}
function onValueInputChange(event) {
if (ensureFieldValidity(this))
this.rule.value = this.value;
else
this.rule.value = "0";
}
function ensureFieldIsNumerical(input) {
var valid = !isNaN(input.value);
if (valid) {
input.removeClassName("_invalid");
} else {
input.addClassName("_invalid");
}
return valid;
}
function appendAction(container, action) {
var actionDiv = createElement("div", null, "action",
{ action: action }, null,
container);
var boundCB = onActionDivClick.bindAsEventListener(actionDiv);
actionDiv.observe("click", boundCB);
ensureActionRepresentation(actionDiv);
return actionDiv;
}
function onActionDivClick(event) {
setSelectedActionDiv(this);
event.stop();
}
function setSelectedActionDiv(newSpan) {
if (selectedActionDiv) {
selectedActionDiv.removeClassName("_selected");
}
selectedActionDiv = newSpan;
if (selectedActionDiv) {
selectedActionDiv.addClassName("_selected");
}
}
function ensureActionRepresentation(container) {
ensureMethodRepresentation(container);
ensureArgumentRepresentation(container);
}
function ensureMethodRepresentation(container) {
var methodSpans = container.select("SPAN.methodContainer");
var methodSpan;
if (methodSpans.length)
methodSpan = methodSpans[0];
else {
while (container.firstChild) {
container.removeChild(container.firstChild);
}
methodSpan = createElement("span", null, "methodContainer",
null, null, container);
}
ensureMethodSelectRepresentation(container, methodSpan);
}
function ensureMethodSelectRepresentation(container, methodSpan) {
var methods = [ "redirect", "discard", "keep" ];
if (sieveCapabilities.indexOf("reject") > -1) {
methods.push("reject");
}
if (sieveCapabilities.indexOf("fileinto") > -1) {
methods.push("fileinto");
}
if (sieveCapabilities.indexOf("imapflags") > -1) {
methods.push("addflag");
}
methods.push("stop");
/* TODO: those are currently unimplemented */
// if (sieveCapabilities.indexOf("notify") > -1) {
// methods.push("notify");
// }
// if (sieveCapabilities.indexOf("vacation") > -1) {
// methods.push("vacation");
// }
var selects = methodSpan.select("SELECT");
var select;
if (selects.length)
select = selects[0];
else {
select = createElement("select");
select.action = container.action;
var boundCB = onMethodSelectChange.bindAsEventListener(select);
select.observe("change", boundCB);
for (var i = 0; i < methods.length; i++) {
var method = methods[i];
var methodOption = createElement("option", null, null,
{ value: method }, null, select);
methodOption.appendChild(document
.createTextNode(methodLabels[method]));
}
methodSpan.appendChild(select);
}
select.value = container.action.method;
}
function onMethodSelectChange(event) {
this.action.method = this.value;
var methodSpan = this.parentNode;
var container = methodSpan.parentNode;
ensureArgumentRepresentation(container);
}
function ensureArgumentRepresentation(container) {
var argumentWidgetMethods
= { "addflag": ensureFlagArgRepresentation,
"fileinto": ensureMailboxArgRepresentation,
"redirect": ensureRedirectArgRepresentation,
"reject": ensureRejectArgRepresentation,
"vacation": ensureVacationArgRepresentation };
var widgetMethod = argumentWidgetMethods[container.action.method];
var spanClass = container.action.method + "Argument";
var argumentSpans = container.select("SPAN.argumentContainer");
var argumentSpan;
if (argumentSpans.length) {
argumentSpan = argumentSpans[0];
if (argumentSpan
&& (!widgetMethod || !argumentSpan.hasClassName(spanClass))) {
container.removeChild(argumentSpan);
container.action.argument = null;
argumentSpan = null;
}
}
else
argumentSpan = null;
if (!argumentSpan && widgetMethod) {
argumentSpan = createElement("span", null,
["argumentContainer", spanClass],
null, null, container);
widgetMethod(container, argumentSpan);
}
}
function ensureFlagArgRepresentation(container, argumentSpan) {
var flags = [ "seen", "deleted", "answered", "flagged", "junk",
"not_junk" ];
for (var i = 1; i < 6; i++) {
flags.push("label" + i);
}
var selects = argumentSpan.select("SELECT");
var select;
if (selects.length)
select = selects[0];
else {
select = createElement("select");
select.action = container.action;
var boundCB = onFlagArgumentSelectChange.bindAsEventListener(select);
select.observe("change", boundCB);
for (var i = 0; i < flags.length; i++) {
var flag = flags[i];
var flagOption = createElement("option", null, null,
{ value: flag }, null, select);
var label = flagLabels[flag];
flagOption.appendChild(document.createTextNode(label));
}
argumentSpan.appendChild(select);
}
/* 1) initialize the value if null
2) set the SELECT to the corresponding value
3) if value was not null in 1, we must ensure the SELECT contains it */
if (!container.action.argument)
container.action.argument = "seen";
select.value = container.action.argument;
container.action.argument = select.value;
}
function onFlagArgumentSelectChange(event) {
this.action.argument = this.value;
}
function ensureMailboxArgRepresentation(container, argumentSpan) {
var selects = argumentSpan.select("SELECT");
var select;
if (selects.length)
select = selects[0];
else {
select = createElement("select");
select.action = container.action;
if (!container.action.argument)
container.action.argument = "INBOX";
var boundCB = onMailboxArgumentSelectChange.bindAsEventListener(select);
select.observe("change", boundCB);
var mailboxes = (window.opener
? window.opener.userMailboxes
: ["INBOX" ]);
for (var i = 0; i < mailboxes.length; i++) {
var mailbox = mailboxes[i];
var mboxOption = createElement("option", null, null,
{ value: mailbox }, null, select);
mboxOption.appendChild(document.createTextNode(mailbox));
}
argumentSpan.appendChild(select);
}
select.value = container.action.argument;
container.action.argument = select.value;
}
function onMailboxArgumentSelectChange(event) {
this.action.argument = this.value;
}
function ensureRedirectArgRepresentation(container, argumentSpan) {
var emailInputs = argumentSpan.select("INPUT");
var emailInput = null;
if (emailInputs.length) {
emailInput = emailInputs[0];
}
if (!emailInput) {
emailInput = createElement("input", null, "textField",
{ type: "text" }, null, argumentSpan);
emailInput.action = container.action;
if (!container.action.argument)
container.action.argument = "";
var boundCB
= onEmailArgumentChange.bindAsEventListener(emailInput);
emailInput.observe("change", boundCB);
emailInput.focus();
}
emailInput.value = container.action.argument;
}
function onEmailArgumentChange(event) {
this.action.argument = this.value;
}
function ensureRejectArgRepresentation(container, argumentSpan) {
var msgAreas = argumentSpan.select("TEXTAREA");
var msgArea = null;
if (msgAreas.length) {
msgArea = msgAreas[0];
}
if (!msgArea) {
msgArea = createElement("textarea", null, null,
{ action: container.action }, null,
argumentSpan);
if (!container.action.argument)
container.action.argument = "";
var boundCB
= onMsgArgumentChange.bindAsEventListener(msgArea);
msgArea.observe("change", boundCB);
msgArea.focus();
}
msgArea.value = container.action.argument;
}
function onMsgArgumentChange(event) {
this.action.argument = this.value;
}
function ensureVacationArgRepresentation(container, argumentSpan) {
}
function onRuleAddClick(event) {
var filterRules = $("filterRules");
if (filterRules) {
var newRule = createFilterRule();
filter.rules.push(newRule);
var newRuleDiv = appendRule(filterRules, newRule);
setSelectedRuleDiv(newRuleDiv);
filterRules.scrollTop = newRuleDiv.offsetTop;
}
event.stop();
}
function onRuleDeleteClick(event) {
if (selectedRuleDiv) {
var ruleIndex = filter.rules.indexOf(selectedRuleDiv.rule);
filter.rules.splice(ruleIndex, 1);
var nextSelected = selectedRuleDiv.next();
if (!nextSelected)
nextSelected = selectedRuleDiv.previous();
selectedRuleDiv.parentNode.removeChild(selectedRuleDiv);
setSelectedRuleDiv(nextSelected);
}
event.stop();
}
function onActionAddClick(event) {
var filterActions = $("filterActions");
if (filterActions) {
var newAction = createFilterAction();
filter.actions.push(newAction);
var newActionDiv = appendAction(filterActions, newAction);
setSelectedActionDiv(newActionDiv);
filterActions.scrollTop = newActionDiv.offsetTop;
}
event.stop();
}
function onActionDeleteClick(event) {
if (selectedActionDiv) {
var actionIndex = filter.actions.indexOf(selectedActionDiv.action);
filter.actions.splice(actionIndex, 1);
var nextSelected = selectedActionDiv.next();
if (!nextSelected)
nextSelected = selectedActionDiv.previous();
selectedActionDiv.parentNode.removeChild(selectedActionDiv);
setSelectedActionDiv(nextSelected);
}
event.stop();
}
function savePreferences() {
if (window.opener) {
window.opener.updateFilterFromEditor(filterId, filter);
}
window.close();
return false;
}
// function configureDragHandles() {
// var handle = $("splitter");
// if (handle) {
// handle.addInterface(SOGoDragHandlesInterface);
// handle.upperBlock = $("filterRulesContainer");
// handle.lowerBlock = $("filterActionsContainer");
// }
// }
document.observe("dom:loaded", onLoadHandler);
+30
View File
@@ -76,3 +76,33 @@ DIV.bottomToolbar
left: 2em;
right: 2em;
margin: 0px; }
/* mail filters */
DIV#filtersListWrapper
{ overflow: auto;
position: absolute;
bottom: 30px;
right: 2em;
top: 154px;
left: 2em;
padding: 0px;
margin-top: 2px;
border-left: 1px solid #9b9b9b;
background: #ccddec; }
TABLE#filtersList
{ width: 100%; }
TR.filterListRow
{ background: #ccddec;
cursor: pointer; }
TD.filterListCell
{ -moz-user-select: none; }
TH#activeTableHeader
{ width: 50px;
text-align: center; }
TD.activeColumn
{ text-align: center; }
+241 -7
View File
@@ -1,4 +1,7 @@
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* -*- Mode: java; tab-width: 2; c-label-minimum-indentation: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
var isSieveScriptsEnabled = false;
var filters = [];
function savePreferences(sender) {
var sendForm = true;
@@ -37,12 +40,41 @@ function savePreferences(sender) {
}
}
if (isSieveScriptsEnabled) {
var jsonFilters = prototypeIfyFilters();
$("sieveFilters").setValue(jsonFilters.toJSON());
}
if (sendForm)
$("mainForm").submit();
$("mainForm").submit();
return false;
}
function prototypeIfyFilters() {
var newFilters = $([]);
for (var i = 0; i < filters.length; i++) {
var filter = filters[i];
var newFilter = $({});
newFilter.name = filter.name;
newFilter.match = filter.match;
newFilter.active = filter.active;
newFilter.rules = $([]);
for (var j = 0; j < filter.rules.length; j++) {
newFilter.rules.push($(filter.rules[j]));
}
newFilter.actions = $([]);
for (var j = 0; j < filter.actions.length; j++) {
newFilter.actions.push($(filter.actions[j]));
}
newFilters.push(newFilter);
}
return newFilters;
}
function _setupEvents(enable) {
var widgets = [ "timezone", "shortDateFormat", "longDateFormat",
"timeFormat", "weekStartDay", "dayStartTime", "dayEndTime",
@@ -92,6 +124,10 @@ function addDefaultEmailAddresses() {
}
function initPreferences() {
var filtersListWrapper = $("filtersListWrapper");
if (filtersListWrapper) {
isSieveScriptsEnabled = true;
}
_setupEvents(true);
if (typeof (initAdditionalPreferences) != "undefined")
initAdditionalPreferences();
@@ -122,7 +158,205 @@ function initPreferences() {
}
if ($("addDefaultEmailAddresses"))
$("addDefaultEmailAddresses").observe("click", addDefaultEmailAddresses);
$("addDefaultEmailAddresses").observe("click",
addDefaultEmailAddresses);
initSieveFilters();
}
function initSieveFilters() {
var table = $("filtersList");
if (table) {
var filtersValue = $("sieveFilters").getValue();
if (filtersValue && filtersValue.length) {
filters = $(filtersValue.evalJSON(false));
for (var i = 0; i < filters.length; i++) {
appendSieveFilterRow(table, i, filters[i]);
}
}
$("filterAdd").observe("click", onFilterAdd);
$("filterDelete").observe("click", onFilterDelete);
$("filterMoveUp").observe("click", onFilterMoveUp);
$("filterMoveDown").observe("click", onFilterMoveDown);
}
}
function appendSieveFilterRow(filterTable, number, filter) {
var row = createElement("tr");
row.observe("mousedown", onRowClick);
row.observe("dblclick", onFilterEdit.bindAsEventListener(row));
var nameColumn = createElement("td");
nameColumn.appendChild(document.createTextNode(filter["name"]));
row.appendChild(nameColumn);
var activeColumn = createElement("td", null, "activeColumn");
var cb = createElement("input", null, "checkBox",
{ checked: filter.active,
type: "checkbox" },
null, activeColumn);
var bound = onScriptActiveCheck.bindAsEventListener(cb);
cb.observe("change", bound);
row.appendChild(activeColumn);
filterTable.tBodies[0].appendChild(row);
}
function onScriptActiveCheck(event) {
var index = this.parentNode.parentNode.rowIndex - 1;
filters[index].active = this.checked;
}
function updateSieveFilterRow(filterTable, number, filter) {
var row = $(filterTable.tBodies[0].rows[number]);
var columns = row.childNodesWithTag("td");
var nameColumn = columns[0];
while (nameColumn.firstChild) {
nameColumn.removeChild(nameColumn.firstChild);
}
nameColumn.appendChild(document.createTextNode(filter.name));
var activeColumn = columns[1];
while (activeColumn.firstChild) {
activeColumn.removeChild(activeColumn.firstChild);
}
createElement("input", null, "checkBox",
{ checked: filter.active,
type: "checkbox" },
null, activeColumn);
}
function _editFilter(filterId) {
var urlstr = ApplicationBaseURL + "editFilter?filter=" + filterId;
var win = window.open(urlstr, "sieve_filter_" + filterId,
"width=450,height=380,resizable=0");
if (win)
win.focus();
}
function onFilterAdd(event) {
log("onFilterAdd");
_editFilter("new");
event.stop();
}
function onFilterDelete(event) {
var filtersList = $("filtersList").tBodies[0];
var nodes = filtersList.getSelectedNodes();
if (nodes.length > 0) {
var deletedFilters = [];
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i];
deletedFilters.push(node.rowIndex - 1);
}
deletedFilters = deletedFilters.sort(function (x,y) { return x-y; });
var rows = filtersList.rows;
for (var i = 0; i < deletedFilters.length; i++) {
var filterNbr = deletedFilters[i];
filters.splice(filterNbr, 1);
var row = rows[filterNbr];
row.parentNode.removeChild(row);
}
}
event.stop();
}
function onFilterMoveUp(event) {
var filtersList = $("filtersList").tBodies[0];
var nodes = filtersList.getSelectedNodes();
if (nodes.length > 0) {
var node = nodes[0];
var previous = node.previous();
if (previous) {
var count = node.rowIndex - 1;
node.parentNode.removeChild(node);
filtersList.insertBefore(node, previous);
var swapFilter = filters[count];
filters[count] = filters[count - 1];
filters[count - 1] = swapFilter;
}
}
event.stop();
}
function onFilterMoveDown(event) {
var filtersList = $("filtersList").tBodies[0];
var nodes = filtersList.getSelectedNodes();
if (nodes.length > 0) {
var node = nodes[0];
var next = node.next();
if (next) {
var count = node.rowIndex - 1;
filtersList.removeChild(next);
filtersList.insertBefore(next, node);
var swapFilter = filters[count];
filters[count] = filters[count + 1];
filters[count + 1] = swapFilter;
}
}
event.stop();
}
function onFilterEdit(event) {
_editFilter(this.rowIndex - 1);
event.stop();
}
function copyFilter(originalFilter) {
var newFilter = {};
newFilter.name = originalFilter.name;
newFilter.match = originalFilter.match;
newFilter.active = originalFilter.active;
newFilter.rules = [];
for (var i = 0; i < originalFilter.rules.length; i++) {
newFilter.rules.push(_copyFilterElement(originalFilter.rules[i]));
}
newFilter.actions = [];
for (var i = 0; i < originalFilter.actions.length; i++) {
newFilter.actions.push(_copyFilterElement(originalFilter.actions[i]));
}
return newFilter;
}
function _copyFilterElement(filterElement) { /* element = rule or action */
var newElement = {};
for (var k in filterElement) {
var value = filterElement[k];
if (typeof(value) == "string" || typeof(value) == "number") {
newElement[k] = value;
}
}
return newElement;
}
function getSieveCapabilitiesFromEditor() {
return sieveCapabilities;
}
function getFilterFromEditor(filterId) {
return copyFilter(filters[filterId]);
}
function updateFilterFromEditor(filterId, filter) {
var sanitized = {};
for (var k in filter) {
if (!(k == "rules" && filter.match == "allmessages")) {
sanitized[k] = filter[k];
}
}
var table = $("filtersList");
if (filterId == "new") {
var newNumber = filters.length;
filters.push(sanitized);
appendSieveFilterRow(table, newNumber, sanitized);
} else {
filters[filterId] = sanitized;
updateSieveFilterRow(table, filterId, sanitized);
}
}
function resetTableActions() {
@@ -292,7 +526,7 @@ function onComposeMessagesTypeChange(event) {
return savePreferences();
else {
// Restore previous value of composeMessagesType
$("composeMessagesType").stopObserving("change", onComposeMessagesTypeChange);
$("composeMessagesType").stopObserving("change", onComposeMessagesTypeChange);
$("composeMessagesType").value = ((Event.element(event).value == 1)?"0":"1");
Event.element(event).blur();
$("composeMessagesType").observe("change", onComposeMessagesTypeChange);
@@ -304,13 +538,13 @@ function onComposeMessagesTypeChange(event) {
// HTML mode
CKEDITOR.replace('signature',
{
height: "290px",
toolbar :
height: "290px",
toolbar :
[['Bold', 'Italic', '-', 'Link',
'Font','FontSize','-','TextColor',
'BGColor']
]
}
}
);
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 335 B

+17 -14
View File
@@ -90,7 +90,7 @@ a:hover
div#header
{ margin-left: 5px;
margin-right: 5px;
padding: 0;
padding: 0px;
border-bottom: 1px solid #000; }
div#header img.headerlogo
@@ -540,8 +540,8 @@ DIV.resize-handle
width: 2px;
border-right: 1px solid #fff;
position: absolute;
top: 0;
left: 0;
top: 0px;
left: 0px;
max-height: 2em; } /* will be set in JavaScript when setting drag handles */
@media print
@@ -584,7 +584,7 @@ DIV.dialog.left
background-position: top left; }
DIV.dialog.left DIV
{ border-left: 0;
{ border-left: 0px;
margin-left: 19px;
text-align: left; }
@@ -594,7 +594,7 @@ DIV.dialog.right
background-position: top right; }
DIV.dialog.right DIV
{ border-right: 0;
{ border-right: 0px;
margin-right: 19px;
text-align: right; }
@@ -609,7 +609,7 @@ DIV#uploadResults DIV
DIV#uploadDialog H3,
DIV#uploadResults H3
{ margin-top: 0;
{ margin-top: 0px;
font-size: 1.2em; }
/* INPUT styles */
@@ -650,6 +650,9 @@ INPUT.textField
vertical-align: middle;
width: 250px; }
INPUT.textField._invalid
{ background-color: #f00 !important; }
INPUT#searchValue
{ margin-right: 1em;
width: 20em;
@@ -722,7 +725,7 @@ TABLE.framenocaption
{ margin-top: 14px; }
TABLE.frame TD
{ padding: 0; }
{ padding: 0px; }
SPAN.caption
{ display: inline-block;
@@ -890,8 +893,8 @@ P#mailerSelectionContainer
{ line-height: 25px;
margin-top: 2px; }
DIV.bottomToolbar {
vertical-align: middle;
DIV.bottomToolbar
{ vertical-align: middle;
background-image: url("thead_bg.png");
border: 1px solid #9B9B9B;
background-color: #E6E7E6;
@@ -901,9 +904,10 @@ DIV.bottomToolbar {
margin-left: 2px;
margin-right: 2px; }
DIV.bottomToolbar A.bottomButton SPAN, DIV.bottomToolbar A.bottomButton {
margin: 0;
padding: 0;
DIV.bottomToolbar A.bottomButton SPAN,
DIV.bottomToolbar A.bottomButton
{ margin: 0px;
padding: 0px;
width: 23px;
text-align: center;
text-decoration: none;
@@ -912,8 +916,7 @@ DIV.bottomToolbar A.bottomButton SPAN, DIV.bottomToolbar A.bottomButton {
border-bottom: 1px solid #9B9B9B;
border-right: 1px solid #9B9B9B;
float: left;
height: 20px;
}
height: 20px; }
DIV.bottomToolbar A.bottomButton SPAN
{ background: transparent url('thead_bg.png') repeat-x top right; }
Binary file not shown.

After

Width:  |  Height:  |  Size: 306 B