OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /* |
| 6 * Code for the main user-visible status page. |
| 7 */ |
| 8 |
| 9 window.onload = function() { |
| 10 document.add_new_message.message.focus(); |
| 11 help_init(); |
| 12 } |
| 13 |
| 14 /* |
| 15 * Functions for managing the help text. |
| 16 */ |
| 17 |
| 18 function help_init() { |
| 19 // Set up the help text logic. |
| 20 var message = document.add_new_message.message; |
| 21 message.onmouseover = help_show; |
| 22 message.onmousemove = help_show; |
| 23 message.onmouseout = help_hide; |
| 24 message.onkeypress = auto_submit; |
| 25 |
| 26 var help = document.getElementById('help'); |
| 27 help.onmouseover = help_show; |
| 28 help.onmouseout = help_hide; |
| 29 } |
| 30 |
| 31 function help_show() { |
| 32 var message = document.add_new_message.message; |
| 33 var help = document.getElementById('help'); |
| 34 help.style.left = message.offsetLeft + 'px'; |
| 35 help.style.top = message.offsetTop + message.offsetHeight + 'px'; |
| 36 help.hidden = false; |
| 37 } |
| 38 |
| 39 function help_hide() { |
| 40 var help = document.getElementById('help'); |
| 41 help.hidden = true; |
| 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 |