merge of '9995223a0452fd05c8a2bc29a4e75bddaa07438b'
and 'aa0162c14e4f909e63d3ee7b4d7c67aea973ddd2' Monotone-Parent: 9995223a0452fd05c8a2bc29a4e75bddaa07438b Monotone-Parent: aa0162c14e4f909e63d3ee7b4d7c67aea973ddd2 Monotone-Revision: 6df5fda5f5dd4cf08493fa5086b30a1bbf5c0b2d Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2009-06-17T14:40:41 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
commit
fd399be4c0
|
@ -218,18 +218,17 @@ Element.addMethods(
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
setCaretTo: function(element, pos) {
|
setCaretTo: function(element, pos) {
|
||||||
element = $(element);
|
element = $(element);
|
||||||
if (typeof(element.selectionStart)
|
if (element.setSelectionRange) { // For Mozilla and Safari
|
||||||
!= "undefined") { // For Mozilla and Safari
|
element.focus();
|
||||||
element.focus();
|
|
||||||
element.setSelectionRange(pos, pos);
|
element.setSelectionRange(pos, pos);
|
||||||
}
|
}
|
||||||
else if (element.createTextRange) { // For IE
|
else if (element.createTextRange) { // For IE
|
||||||
var range = element.createTextRange();
|
var range = element.createTextRange();
|
||||||
range.move("character", pos);
|
range.move("character", pos);
|
||||||
range.select();
|
range.select();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
selectText: function(element, start, end) {
|
selectText: function(element, start, end) {
|
||||||
|
|
|
@ -8,7 +8,8 @@ var MailEditor = {
|
||||||
selectedIndex: -1,
|
selectedIndex: -1,
|
||||||
delay: 750,
|
delay: 750,
|
||||||
delayedSearch: false,
|
delayedSearch: false,
|
||||||
signatureLength: 0
|
signatureLength: 0,
|
||||||
|
textFirstFocus: true
|
||||||
};
|
};
|
||||||
|
|
||||||
function onContactAdd() {
|
function onContactAdd() {
|
||||||
|
@ -267,7 +268,25 @@ function clickedEditorSave(sender) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onTextFocus() {
|
function onTextFocus(event) {
|
||||||
|
if (MailEditor.textFirstFocus) {
|
||||||
|
var content = this.getValue();
|
||||||
|
var replyPlacement = UserDefaults["ReplyPlacement"];
|
||||||
|
if (replyPlacement == "above") {
|
||||||
|
this.insertBefore(document.createTextNode("\r\r"), this.lastChild);
|
||||||
|
this.setCaretTo(0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var caretPosition = this.getValue().length - MailEditor.signatureLength;
|
||||||
|
if (Prototype.Browser.IE)
|
||||||
|
caretPosition -= lineBreakCount(this.getValue().substring(0, caretPosition));
|
||||||
|
if (hasSignature())
|
||||||
|
caretPosition -= 1;
|
||||||
|
this.setCaretTo(caretPosition);
|
||||||
|
}
|
||||||
|
MailEditor.textFirstFocus = false;
|
||||||
|
}
|
||||||
|
|
||||||
var input = currentAttachmentInput();
|
var input = currentAttachmentInput();
|
||||||
if (input)
|
if (input)
|
||||||
input.parentNode.removeChild(input);
|
input.parentNode.removeChild(input);
|
||||||
|
@ -275,11 +294,11 @@ function onTextFocus() {
|
||||||
|
|
||||||
function onTextKeyDown(event) {
|
function onTextKeyDown(event) {
|
||||||
if (event.keyCode == Event.KEY_TAB) {
|
if (event.keyCode == Event.KEY_TAB) {
|
||||||
|
// Change behavior of tab key
|
||||||
if (event.shiftKey) {
|
if (event.shiftKey) {
|
||||||
var nodes = $("subjectRow").childNodesWithTag("input");
|
var subjectField = $$("div#subjectRow input").first();
|
||||||
var objectInput = $(nodes[0]);
|
subjectField.focus();
|
||||||
objectInput.focus();
|
subjectField.selectText(0, subjectField.value.length);
|
||||||
objectInput.selectText(0, objectInput.value.length);
|
|
||||||
preventDefault(event);
|
preventDefault(event);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -310,31 +329,6 @@ function onTextIEUpdateCursorPos(event) {
|
||||||
this.selectionRange = document.selection.createRange().duplicate();
|
this.selectionRange = document.selection.createRange().duplicate();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onTextFirstFocus() {
|
|
||||||
var content = this.getValue();
|
|
||||||
var replyPlacement = UserDefaults["ReplyPlacement"];
|
|
||||||
|
|
||||||
if (replyPlacement == "above") {
|
|
||||||
this.insertBefore(document.createTextNode("\r\r"), this.lastChild);
|
|
||||||
this.setCaretTo(0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var caretPosition = this.getValue().length - MailEditor.signatureLength;
|
|
||||||
if (Prototype.Browser.IE)
|
|
||||||
caretPosition -= lineBreakCount(this.getValue().substring(0, caretPosition));
|
|
||||||
if (hasSignature())
|
|
||||||
caretPosition -= 2;
|
|
||||||
this.setCaretTo(caretPosition);
|
|
||||||
}
|
|
||||||
|
|
||||||
Event.stopObserving(this, "focus", onTextFirstFocus);
|
|
||||||
}
|
|
||||||
|
|
||||||
function onTextContextMenu(event) {
|
|
||||||
event.returnValue = true;
|
|
||||||
event.cancelBubble = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function onTextMouseDown(event) {
|
function onTextMouseDown(event) {
|
||||||
if (event.button == 0) {
|
if (event.button == 0) {
|
||||||
event.returnValue = false;
|
event.returnValue = false;
|
||||||
|
@ -555,10 +549,8 @@ function initMailEditor() {
|
||||||
if (UserDefaults["ReplyPlacement"] != "above") {
|
if (UserDefaults["ReplyPlacement"] != "above") {
|
||||||
textarea.scrollTop = textarea.scrollHeight;
|
textarea.scrollTop = textarea.scrollHeight;
|
||||||
}
|
}
|
||||||
textarea.observe("focus", onTextFirstFocus);
|
|
||||||
textarea.observe("focus", onTextFocus);
|
textarea.observe("focus", onTextFocus);
|
||||||
// textarea.observe("contextmenu", onTextContextMenu);
|
//textarea.observe("mousedown", onTextMouseDown);
|
||||||
textarea.observe("mousedown", onTextMouseDown, true);
|
|
||||||
textarea.observe("keydown", onTextKeyDown);
|
textarea.observe("keydown", onTextKeyDown);
|
||||||
|
|
||||||
if (Prototype.Browser.IE) {
|
if (Prototype.Browser.IE) {
|
||||||
|
@ -693,7 +685,6 @@ function onSelectPriority(event) {
|
||||||
node = $(node).up("button");
|
node = $(node).up("button");
|
||||||
popupToolbarMenu(node, "priority-menu");
|
popupToolbarMenu(node, "priority-menu");
|
||||||
Event.stop(event);
|
Event.stop(event);
|
||||||
// preventDefault(event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue