Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Unified Diff: static/js/main/main.js

Issue 58593002: chromium-status: add status field help text (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/chromium-status
Patch Set: fixup javascript/wrapping Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | status.py » ('j') | templates/main.html » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: static/js/main/main.js
diff --git a/static/js/main/main.js b/static/js/main/main.js
new file mode 100644
index 0000000000000000000000000000000000000000..52f16453cacc5c876dcb4f19c954c16591b3cb9f
--- /dev/null
+++ b/static/js/main/main.js
@@ -0,0 +1,58 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/*
+ * Code for the main user-visible status page.
+ */
+
+window.onload = function() {
+ document.add_new_message.message.focus();
+ help_init();
+}
+
+/*
+ * Functions for managing the help text.
+ */
+
+function help_init() {
+ // Set up the help text logic.
+ var message = document.add_new_message.message;
+ message.onmouseover = help_show;
+ message.onmousemove = help_show;
+ message.onmouseout = help_hide;
+ message.onkeypress = auto_submit;
+
+ var help = document.getElementById('help');
+ help.onmouseover = help_show;
+ help.onmouseout = help_hide;
+}
+
+function help_show() {
+ var message = document.add_new_message.message;
+ var help = document.getElementById('help');
+ help.style.left = message.offsetLeft + 'px';
+ help.style.top = message.offsetTop + message.offsetHeight + 'px';
+ help.hidden = false;
+}
+
+function help_hide() {
+ var help = document.getElementById('help');
+ help.hidden = true;
+}
+
+/*
+ * Misc functions.
+ */
+
+// Used by the status field.
+function auto_submit(e) {
+ if (!e.shiftKey && e.keyCode == 13) {
+ // Catch the enter key in the textarea. Allow shift+enter to work
+ // so people editing a lot of text can play around with things.
+ var form = document.getElementsByName('add_new_message')[0]
+ form.submit();
+ return false;
+ }
+ return true;
+}
« no previous file with comments | « no previous file | status.py » ('j') | templates/main.html » ('J')

Powered by Google App Engine
This is Rietveld 408576698