mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-03-26 08:32:44 +00:00
Monotone-Parent: e8bfb90da0079ca2c3e5079818a7e7532b26ea31
Monotone-Revision: 7d281c6a5f9cd3517f1a818c99070b3bba45594c Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-07-27T20:03:05 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -120,3 +120,150 @@ function updateInlineAttachmentList(sender, attachments) {
|
||||
else
|
||||
div.style.display = "";
|
||||
}
|
||||
/* mail editor */
|
||||
|
||||
function validateEditorInput(sender) {
|
||||
var errortext = "";
|
||||
var field;
|
||||
|
||||
field = document.pageform.subject;
|
||||
if (field.value == "")
|
||||
errortext = errortext + labels.error_missingsubject + "\n";
|
||||
|
||||
if (!UIxRecipientSelectorHasRecipients())
|
||||
errortext = errortext + labels.error_missingrecipients + "\n";
|
||||
|
||||
if (errortext.length > 0) {
|
||||
alert(labels.error_validationfailed.decodeEntities() + ":\n"
|
||||
+ errortext.decodeEntities());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function clickedEditorSend(sender) {
|
||||
if (!validateEditorInput(sender))
|
||||
return false;
|
||||
|
||||
document.pageform.action = "send";
|
||||
document.pageform.submit();
|
||||
|
||||
window.alert("cocou");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function clickedEditorAttach(sender) {
|
||||
var area = $("attachmentsArea");
|
||||
|
||||
area.setStyle({ display: "block" });
|
||||
|
||||
var inputs = area.getElementsByTagName("input");
|
||||
var attachmentName = "attachment" + inputs.length;
|
||||
var newAttachment = createElement("input", attachmentName,
|
||||
"currentAttachment", null,
|
||||
{ type: "file",
|
||||
name: attachmentName },
|
||||
area);
|
||||
Event.observe(newAttachment, "change",
|
||||
onAttachmentChange.bindAsEventListener(newAttachment));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function onAddAttachment() {
|
||||
var area = $("attachmentsArea");
|
||||
var inputs = area.getElementsByTagName("input");
|
||||
var attachmentName = "attachment" + inputs.length;
|
||||
var newAttachment = createElement("input", attachmentName,
|
||||
"currentAttachment", null,
|
||||
{ type: "file",
|
||||
name: attachmentName },
|
||||
area);
|
||||
Event.observe(newAttachment, "change",
|
||||
onAttachmentChange.bindAsEventListener(newAttachment));
|
||||
}
|
||||
|
||||
function onAttachmentChange(event) {
|
||||
if (this.value == "")
|
||||
this.parentNode.removeChild(this);
|
||||
else {
|
||||
this.addClassName("attachment");
|
||||
this.removeClassName("currentAttachment");
|
||||
var list = $("attachments");
|
||||
createAttachment(this, list);
|
||||
}
|
||||
}
|
||||
|
||||
function createAttachment(node, list) {
|
||||
var attachment = createElement("li", null, null, { node: node }, null, list);
|
||||
createElement("img", null, null, { src: ResourcesURL + "/attachment.gif" },
|
||||
null, attachment);
|
||||
Event.observe(attachment, "click", onRowClick);
|
||||
|
||||
var filename = node.value;
|
||||
var separator;
|
||||
if (navigator.appVersion.indexOf("Windows") > -1)
|
||||
separator = "\\";
|
||||
else
|
||||
separator = "/";
|
||||
var fileArray = filename.split(separator);
|
||||
var attachmentName = document.createTextNode(fileArray[fileArray.length-1]);
|
||||
attachment.appendChild(attachmentName);
|
||||
}
|
||||
|
||||
function clickedEditorSave(sender) {
|
||||
document.pageform.action = "save";
|
||||
document.pageform.submit();
|
||||
refreshOpener();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function clickedEditorDelete(sender) {
|
||||
document.pageform.action = "delete";
|
||||
document.pageform.submit();
|
||||
refreshOpener();
|
||||
window.close();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function initMailEditor() {
|
||||
var list = $("attachments");
|
||||
$(list).attachMenu("attachmentsMenu");
|
||||
var elements = list.childNodesWithTag("li");
|
||||
for (var i = 0; i < elements.length; i++)
|
||||
Event.observe(elements[i], "click",
|
||||
onRowClick.bindAsEventListener(elements[i]));
|
||||
}
|
||||
|
||||
function getMenus() {
|
||||
return { "attachmentsMenu": new Array(null, onRemoveAttachments,
|
||||
onSelectAllAttachments,
|
||||
"-",
|
||||
onAddAttachment, null) };
|
||||
}
|
||||
|
||||
function onRemoveAttachments() {
|
||||
var list = $("attachments");
|
||||
var nodes = list.getSelectedNodes();
|
||||
for (var i = nodes.length-1; i > -1; i--) {
|
||||
var input = $(nodes[i]).node;
|
||||
if (input) {
|
||||
input.parentNode.removeChild(input);
|
||||
list.removeChild(nodes[i]);
|
||||
}
|
||||
else
|
||||
window.alert("Server attachments not handled");
|
||||
}
|
||||
}
|
||||
|
||||
function onSelectAllAttachments() {
|
||||
var list = $("attachments");
|
||||
var nodes = list.childNodesWithTag("li");
|
||||
for (var i = 0; i < nodes.length; i++)
|
||||
nodes[i].select();
|
||||
}
|
||||
|
||||
window.addEventListener("load", initMailEditor, false);
|
||||
|
||||
Reference in New Issue
Block a user