updates
[webos-internals:modifications.git] / messaging / messaging-enter-key-for-new-line.patch
1 diff --git a/usr/palm/applications/com.palm.app.messaging/app/controllers/chatview-assistant.js b/usr/palm/applications/com.palm.app.messaging/app/controllers/chatview-assistant.js
2 index 29204c4..f42c7e5 100644
3 --- a/usr/palm/applications/com.palm.app.messaging/app/controllers/chatview-assistant.js
4 +++ b/usr/palm/applications/com.palm.app.messaging/app/controllers/chatview-assistant.js
5 @@ -315,7 +315,7 @@ var ChatviewAssistant = Class.create({
6                         hintText: $L('Enter message here...'),
7                         multiline: true,
8                         focus: false,
9 -                       enterSubmits: true,
10 +                       enterSubmits: false,
11                         inputName: "messageTextElement",
12                         className: " ",
13                         changeOnKeyPress: true
14 @@ -2066,6 +2066,7 @@ var ChatviewAssistant = Class.create({
15                                 }
16                                 //msg.messageText = PalmSystem.runTextIndexer(msg.messageText);
17                                 delayed.messageText = msg.messageText;
18 +                               msg.messageText = msg.messageText.replace(/\n/g,"<br>");
19                         }
20                         
21                         var icons = this.Messaging.IMAccounts.getIcons(msg.serviceName);
22 @@ -2929,9 +2930,10 @@ var ChatviewAssistant = Class.create({
23                 // It will be cleared on key up.
24                 if (event) {
25                         if (Mojo.Char.isEnterKey(event.keyCode)) {
26 -                               this.sendButton.addClassName('selected');
27 +                               //this.sendButton.addClassName('selected');
28                         } else if (event.keyCode===129) {
29                                 this.ctrlKeyPressed = true;
30 +                               this.sendButton.addClassName('selected');
31                         } else if (event.keyCode===Mojo.Char.spaceBar && this.ctrlKeyPressed) {
32                                 Event.stop(event);
33                                 var controller = this.controller;
34 @@ -2940,20 +2942,18 @@ var ChatviewAssistant = Class.create({
35                                 };
36                                 var emoticonPicker = new EmoticonPickerDialogAssistant(this, onselect);
37                                 emoticonPicker.show();
38 -                       }
39 +                       } 
40                 }
41         },
42  
43         handleTextAreaKeyUp: function(event) {
44                 if (event) {
45 -                       if (Mojo.Char.isEnterKey(event.keyCode)) {
46 -                               this.considerForSend();
47 -                               Event.stop(event);
48 -                               
49 -                               // Remove highlight that was added on keydown.
50 +                       if (event.keyCode===129) {
51                                 this.sendButton.removeClassName('selected');
52 -                       } else if (event.keyCode===129) {
53                                 this.ctrlKeyPressed = false;
54 +                       } else if (Mojo.Char.isEnterKey(event.keyCode) && this.ctrlKeyPressed) {
55 +                               this.considerForSend();
56 +                               Event.stop(event);
57                         }
58                 }
59         },
60 diff --git a/usr/palm/applications/com.palm.app.messaging/app/controllers/compose-assistant.js b/usr/palm/applications/com.palm.app.messaging/app/controllers/compose-assistant.js
61 index 57dfb0f..4fd4133 100644
62 --- a/usr/palm/applications/com.palm.app.messaging/app/controllers/compose-assistant.js
63 +++ b/usr/palm/applications/com.palm.app.messaging/app/controllers/compose-assistant.js
64 @@ -122,6 +122,7 @@ var ComposeAssistant = Class.create({
65                 this.considerForSend = this.considerForSend.bind(this);
66                 this.attachFilePicker = this.attachFilePicker.bind(this);
67                 this.handleTextAreaChange = this.handleTextAreaChange.bind(this);
68 +               this.handleTextAreaKeyDown = this.handleTextAreaKeyDown.bind(this);
69                 this.handleTextAreaKeyUp = this.handleTextAreaKeyUp.bind(this);
70                 this.handleCancelAttachment = this.resetTextBox.bind(this,false);               
71                 this.handleRecipientsChanged = this.handleRecipientsChanged.bind(this);
72 @@ -164,7 +165,7 @@ var ComposeAssistant = Class.create({
73                     hintText: $L('Enter message here...'),
74                     multiline: true,
75                     focus: (this.prePopulatedRecipients.length > 0),
76 -                   enterSubmits: true,
77 +                   enterSubmits: false,
78                         requiresEnterKey: true,
79                     modelProperty: "value",
80                         changeOnKeyPress: true
81 @@ -202,7 +203,7 @@ var ComposeAssistant = Class.create({
82                 this.messageTextElement  = this.messageTextWidget.querySelector('[name=messageTextElement]');
83                 this.addressingWidget = this.controller.get('searchList');
84                 this.addressingWidgetSpacer = this.controller.get('addressingWidgetSpacer');
85 -
86 +               this.messageTextElement.observe('keydown', this.handleTextAreaKeyDown);
87                 this.messageTextElement.observe('keyup', this.handleTextAreaKeyUp);
88                 this.messageTextWidget.observe(Mojo.Event.propertyChange, this.handleTextAreaChange);
89         
90 @@ -666,12 +667,24 @@ var ComposeAssistant = Class.create({
91                         this.handleTextAreaChange();                    
92                 } 
93         },
94 +       
95 +       handleTextAreaKeyDown: function(event) {
96 +               // Check for return keys, and put a fake highlight on the send button.
97 +               // It will be cleared on key up.
98 +               if (event && event.keyCode===129) {
99 +                               this.ctrlKeyPressed = true;
100 +               }
101 +       },
102  
103         handleTextAreaKeyUp: function(event) {
104 -               if (event && Mojo.Char.isEnterKey(event.keyCode)) {
105 -                       this.considerForSend();
106 -                       Event.stop(event);
107 -               }               
108 +               if (event) {
109 +                       if (event.keyCode===129) {
110 +                               this.ctrlKeyPressed = false;
111 +                       } else if (Mojo.Char.isEnterKey(event.keyCode) && this.ctrlKeyPressed) {
112 +                               this.considerForSend();
113 +                               Event.stop(event);
114 +                       }
115 +               }
116         },
117  
118         handleTextAreaChange: function() {
119 @@ -809,7 +822,7 @@ var ComposeAssistant = Class.create({
120             [Mojo.Event.addressingRecipientAdded,Mojo.Event.addressingRecipientDeleted].each(function(event) {
121               that.controller.stopListening('searchList',event,that.handleRecipientsChanged);
122             });
123 -       
124 +               this.messageTextElement.stopObserving('keydown', this.handleTextAreaKeyDown);
125                 this.messageTextElement.stopObserving('keyup', this.handleTextAreaKeyUp);
126                 this.messageTextWidget.stopObserving(Mojo.Event.propertyChange, this.handleTextAreaChange);
127