OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /* | 5 /* |
6 * Code for the main user-visible status page. | 6 * Code for the main user-visible status page. |
7 */ | 7 */ |
8 | 8 |
9 window.onload = function() { | 9 window.onload = function() { |
10 document.add_new_message.message.focus(); | 10 document.add_new_message.message.focus(); |
11 help_init(); | 11 help_init(); |
12 } | 12 } |
13 | 13 |
14 /* | 14 /* |
15 * Functions for managing the help text. | 15 * Functions for managing the help text. |
16 */ | 16 */ |
17 | 17 |
18 function help_init() { | 18 function help_init() { |
19 // Set up the help text logic. | 19 // Set up the help text logic. |
20 var message = document.add_new_message.message; | 20 var message = document.add_new_message.message; |
21 message.onmouseover = help_show; | 21 message.onmouseover = help_show; |
22 message.onmousemove = help_show; | 22 message.onmousemove = help_show; |
23 message.onmouseout = help_hide; | 23 message.onmouseout = help_hide; |
| 24 message.onkeypress = auto_submit; |
24 | 25 |
25 var help = document.getElementById('help'); | 26 var help = document.getElementById('help'); |
26 help.onmouseover = help_show; | 27 help.onmouseover = help_show; |
27 help.onmouseout = help_hide; | 28 help.onmouseout = help_hide; |
28 } | 29 } |
29 | 30 |
30 function help_show() { | 31 function help_show() { |
31 var message = document.add_new_message.message; | 32 var message = document.add_new_message.message; |
32 var help = document.getElementById('help'); | 33 var help = document.getElementById('help'); |
33 help.style.left = message.offsetLeft + 'px'; | 34 help.style.left = message.offsetLeft + 'px'; |
34 help.style.top = message.offsetTop + message.offsetHeight + 'px'; | 35 help.style.top = message.offsetTop + message.offsetHeight + 'px'; |
35 help.hidden = false; | 36 help.hidden = false; |
36 } | 37 } |
37 | 38 |
38 function help_hide() { | 39 function help_hide() { |
39 var help = document.getElementById('help'); | 40 var help = document.getElementById('help'); |
40 help.hidden = true; | 41 help.hidden = true; |
41 } | 42 } |
| 43 |
| 44 /* |
| 45 * Misc functions. |
| 46 */ |
| 47 |
| 48 // Used by the status field. |
| 49 function auto_submit(e) { |
| 50 if (!e.shiftKey && e.keyCode == 13) { |
| 51 // Catch the enter key in the textarea. Allow shift+enter to work |
| 52 // so people editing a lot of text can play around with things. |
| 53 var form = document.getElementsByName('add_new_message')[0] |
| 54 form.submit(); |
| 55 return false; |
| 56 } |
| 57 return true; |
| 58 } |
OLD | NEW |