diff --git a/NEWS b/NEWS
index aa7e84434..8d2204d4c 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,7 @@ Enhancements
- updated Finnish translation
- XMLHttpRequest.js is now loaded conditionaly (< IE9)
- format time in attendees invitation window according to the user's locale
+ - improved IE11 support
Bug fixes
- don't load 'background' attribute (#2437)
diff --git a/UI/Templates/MailerUI/UIxMailEditor.wox b/UI/Templates/MailerUI/UIxMailEditor.wox
index b5fe79da3..ea18d9c4f 100644
--- a/UI/Templates/MailerUI/UIxMailEditor.wox
+++ b/UI/Templates/MailerUI/UIxMailEditor.wox
@@ -123,7 +123,7 @@
-
+
diff --git a/UI/WebServerResources/UIxMailEditor.css b/UI/WebServerResources/UIxMailEditor.css
index 019401d08..6590507a3 100644
--- a/UI/WebServerResources/UIxMailEditor.css
+++ b/UI/WebServerResources/UIxMailEditor.css
@@ -200,8 +200,7 @@ UL#attachments .progressDone .icon-attachment:hover
{ width: 99%; }
TEXTAREA#text
-{ display: none;
- background: #fff; }
+{ background: #fff; }
#cke_text
{ clear: both; }
diff --git a/UI/WebServerResources/UIxMailEditor.js b/UI/WebServerResources/UIxMailEditor.js
index debe65db1..d8b7f13d1 100644
--- a/UI/WebServerResources/UIxMailEditor.js
+++ b/UI/WebServerResources/UIxMailEditor.js
@@ -255,18 +255,20 @@ function clickedEditorSave() {
return false;
}
+/**
+ * On first focus of textarea, position the caret with respect to user's preferences
+ */
function onTextFocus(event) {
if (MailEditor.textFirstFocus) {
- // On first focus, position the caret at the proper position
var content = this.getValue();
var replyPlacement = UserDefaults["SOGoMailReplyPlacement"];
- if (replyPlacement == "above" || !mailIsReply) { // for forwards, place caret at top unconditionally
+ if (replyPlacement == "above" || !mailIsReply) {
+ // For forwards, place caret at top unconditionally
this.setCaretTo(0);
}
else {
var caretPosition = this.getValue().length - MailEditor.signatureLength;
- if (Prototype.Browser.IE)
- caretPosition -= lineBreakCount(this.getValue().substring(0, caretPosition));
+ caretPosition = adjustOffset(this, caretPosition);
if (hasSignature())
caretPosition -= 2;
this.setCaretTo(caretPosition);
@@ -275,10 +277,13 @@ function onTextFocus(event) {
}
}
+/**
+ * Change behavior of tab key in textarea (plain-text mail)
+ */
function onTextKeyDown(event) {
if (event.keyCode == Event.KEY_TAB) {
- // Change behavior of tab key in textarea
if (event.shiftKey) {
+ // Shift-tab goes back to subject field
var subjectField = $$("div#subjectRow input").first();
subjectField.focus();
subjectField.selectText(0, subjectField.value.length);
@@ -287,8 +292,7 @@ function onTextKeyDown(event) {
else {
if (!(event.shiftKey || event.metaKey || event.ctrlKey)) {
// Convert a tab to 4 spaces
- if (typeof(this.selectionStart)
- != "undefined") { // For Mozilla and Safari
+ if (typeof(this.selectionStart) != "undefined") { // Mozilla and Safari
var cursor = this.selectionStart;
var startText = ((cursor > 0)
? this.value.substr(0, cursor)
@@ -301,8 +305,6 @@ function onTextKeyDown(event) {
}
else if (this.selectionRange) // IE
this.selectionRange.text = " ";
- else { // others ?
- }
preventDefault(event);
}
}
@@ -313,13 +315,6 @@ function onTextIEUpdateCursorPos(event) {
this.selectionRange = document.selection.createRange().duplicate();
}
-function onTextMouseDown(event) {
- if (event.button == 0) {
- event.returnValue = false;
- event.cancelBubble = false;
- }
-}
-
function onHTMLFocus(event) {
if (MailEditor.textFirstFocus) {
var s = event.editor.getSelection();
@@ -471,14 +466,15 @@ function configureAttachments() {
}
function initMailEditor() {
+ var textarea = $("text");
+
if (composeMode != "html" && $("text"))
- $("text").style.display = "block";
+ textarea.show();
configureAttachments();
initAddresses();
- var textarea = $("text");
var focusField = textarea;
if (!mailIsReply) {
focusField = $("addr_0");
@@ -527,10 +523,10 @@ function initMailEditor() {
textarea.scrollTop = textarea.scrollHeight;
}
textarea.observe("focus", onTextFocus);
- //textarea.observe("mousedown", onTextMouseDown);
textarea.observe("keydown", onTextKeyDown);
if (Prototype.Browser.IE) {
+ // Hack to allow to replace the tab by spaces in IE < 9
var ieEvents = [ "click", "select", "keyup" ];
for (var i = 0; i < ieEvents.length; i++)
textarea.observe(ieEvents[i], onTextIEUpdateCursorPos, false);
@@ -542,10 +538,7 @@ function initMailEditor() {
$("contactFolder").observe("change", onContactFolderChange);
- Event.observe(window, "resize", onWindowResize);
Event.observe(window, "beforeunload", onMailEditorClose);
-
- onWindowResize.defer();
}
function initializePriorityMenu() {
@@ -606,13 +599,16 @@ function attachmentDeleteCallback(http) {
}
}
-function lineBreakCount(str){
- /* counts \n */
- try {
- return((str.match(/[^\n]*\n[^\n]*/gi).length));
- } catch(e) {
- return 0;
+/**
+ * Adjust offset when the browser uses two characters for line feeds.
+ */
+function adjustOffset(element, offset) {
+ var val = element.value, newOffset = offset;
+ if (val.indexOf("\r\n") > -1) {
+ var matches = val.replace(/\r\n/g, "\n").slice(0, offset).match(/\n/g);
+ newOffset -= matches ? matches.length - 1 : 0;
}
+ return newOffset;
}
function hasSignature() {
@@ -646,6 +642,9 @@ function onSelectOptions(event) {
}
}
+/**
+ * Overwrite definition of MailerUI.js
+ */
function onWindowResize(event) {
if (!document.pageform)
return;