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