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(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 /* | 75 /* |
76 * Functions for managing the help text. | 76 * Functions for managing the help text. |
77 */ | 77 */ |
78 | 78 |
79 function help_init() { | 79 function help_init() { |
80 // Set up the help text logic. | 80 // Set up the help text logic. |
81 var message = document.add_new_message.message; | 81 var message = document.add_new_message.message; |
82 message.onmouseover = help_show; | 82 message.onmouseover = help_show; |
83 message.onmousemove = help_show; | 83 message.onmousemove = help_show; |
84 message.onmouseout = help_hide; | 84 message.onmouseout = help_hide; |
| 85 message.onkeypress = auto_submit; |
85 | 86 |
86 var help = document.getElementById('help'); | 87 var help = document.getElementById('help'); |
87 help.onmouseover = help_show; | 88 help.onmouseover = help_show; |
88 help.onmouseout = help_hide; | 89 help.onmouseout = help_hide; |
89 } | 90 } |
90 | 91 |
91 function help_show() { | 92 function help_show() { |
92 var message = document.add_new_message.message; | 93 var message = document.add_new_message.message; |
93 var help = document.getElementById('help'); | 94 var help = document.getElementById('help'); |
94 help.style.left = message.offsetLeft + 'px'; | 95 help.style.left = message.offsetLeft + 'px'; |
95 help.style.top = message.offsetTop + message.offsetHeight + 'px'; | 96 help.style.top = message.offsetTop + message.offsetHeight + 'px'; |
96 help.hidden = false; | 97 help.hidden = false; |
97 } | 98 } |
98 | 99 |
99 function help_hide() { | 100 function help_hide() { |
100 var help = document.getElementById('help'); | 101 var help = document.getElementById('help'); |
101 help.hidden = true; | 102 help.hidden = true; |
102 } | 103 } |
| 104 |
| 105 /* |
| 106 * Misc functions. |
| 107 */ |
| 108 |
| 109 // Used by the status field. |
| 110 function auto_submit(e) { |
| 111 if (!e.shiftKey && e.keyCode == 13) { |
| 112 // Catch the enter key in the textarea. Allow shift+enter to work |
| 113 // so people editing a lot of text can play around with things. |
| 114 var form = document.getElementsByName('add_new_message')[0] |
| 115 form.submit(); |
| 116 return false; |
| 117 } |
| 118 return true; |
| 119 } |
OLD | NEW |