From 4082b90b53c8ca6521c5b8ddb25c0df55ea60330 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 27 Aug 2008 22:50:12 +0000 Subject: [PATCH] Monotone-Parent: 673b05009820fc5ced4357cc9f1e8582b31301cb Monotone-Revision: 600e156688324637e9fcc6c445ab1c78a04e29ae Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-08-27T22:50:12 Monotone-Branch: ca.inverse.sogo --- UI/WebServerResources/UIxMailEditor.js | 41 ++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/UI/WebServerResources/UIxMailEditor.js b/UI/WebServerResources/UIxMailEditor.js index 4566190fb..61f331fa1 100644 --- a/UI/WebServerResources/UIxMailEditor.js +++ b/UI/WebServerResources/UIxMailEditor.js @@ -226,8 +226,8 @@ function onAttachmentChange(event) { this.removeClassName("currentAttachment"); var list = $("attachments"); createAttachment(this, list); - clickedEditorAttach(null) - } + clickedEditorAttach(null); + } } function createAttachment(node, list) { @@ -270,6 +270,36 @@ function onTextFocus() { input.parentNode.removeChild(input); } +function onTextKeyDown(event) { + if (event.keyCode == 9) { + if (event.shiftKey) { + var nodes = $("subjectRow").childNodesWithTag("input"); + var objectInput = $(nodes[0]); + objectInput.focus(); + objectInput.selectText(0, objectInput.value.length); + preventDefault(event); + } + else { + if (!(event.shiftKey || event.metaKey || event.ctrlKey)) { + if (this.selectionStart) { // FF + var startText = this.value.substr(0, this.selectionStart); + var endText = this.value.substr(this.selectionStart); + this.value = startText + " " + endText; + } + else if (this.selectionRange) // IE + this.selectionRange.text = " "; + else { // others ? + } + preventDefault(event); + } + } + } +} + +function onTextIEUpdateCursorPos(event) { + this.selectionRange = document.selection.createRange().duplicate(); +} + function onTextFirstFocus() { var content = this.getValue(); if (content.lastIndexOf("--") == 0) { @@ -496,6 +526,13 @@ function initMailEditor() { textarea.observe("focus", onTextFocus); // textarea.observe("contextmenu", onTextContextMenu); textarea.observe("mousedown", onTextMouseDown, true); + textarea.observe("keydown", onTextKeyDown); + + if (Prototype.Browser.IE) { + var ieEvents = [ "click", "select", "keyup" ]; + for (var i = 0; i < ieEvents.length; i++) + textarea.observe(ieEvents[i], onTextIEUpdateCursorPos, false); + } initTabIndex($("addressList"), $$("div#subjectRow input").first(), textarea); onWindowResize(null);