Fix IE11 issue with mail editor

Conflicts:
	NEWS
	UI/Templates/MailerUI/UIxMailEditor.wox
	UI/WebServerResources/UIxMailEditor.js
maint-2.1.1
Francis Lachapelle 2014-01-28 14:01:04 -05:00
parent c04f5a4775
commit 2643cff3f9
3 changed files with 29 additions and 30 deletions

View File

@ -137,7 +137,7 @@
/></div>
<!-- separator line --><hr class="fieldSeparator"/>
</div>
<textarea id="text" name="text" rows="30" var:value="text"></textarea>
<textarea id="text" name="text" rows="25" style="display:none" var:value="text"/>
<!-- img rsrc:src="tbird_073_compose.png" alt="screenshot" / -->
</form>
</div>

View File

@ -173,8 +173,7 @@ UL#attachments LI IMG
{ width: 99%; }
TEXTAREA#text
{ display: none;
background: #fff; }
{ background: #fff; }
/* Contacts search pane */

View File

@ -283,18 +283,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);
@ -307,10 +309,13 @@ function onTextFocus(event) {
input.parentNode.removeChild(input);
}
/**
* 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);
@ -319,8 +324,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)
@ -333,8 +337,6 @@ function onTextKeyDown(event) {
}
else if (this.selectionRange) // IE
this.selectionRange.text = " ";
else { // others ?
}
preventDefault(event);
}
}
@ -345,13 +347,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();
@ -425,8 +420,10 @@ function configureDragHandle() {
}
function initMailEditor() {
var textarea = $("text");
if (composeMode != "html" && $("text"))
$("text").style.display = "block";
textarea.show();
var list = $("attachments");
if (!list) return;
@ -489,10 +486,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);
@ -504,10 +501,7 @@ function initMailEditor() {
$("contactFolder").observe("change", onContactFolderChange);
Event.observe(window, "resize", onWindowResize);
Event.observe(window, "beforeunload", onMailEditorClose);
onWindowResize.defer();
}
function initializePriorityMenu() {
@ -593,13 +587,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() {
@ -637,6 +634,9 @@ function onSelectOptions(event) {
}
}
/**
* Overwrite definition of MailerUI.js
*/
function onWindowResize(event) {
if (!document.pageform)
return;