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

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: 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..3f65a23821cdeb9c0835ad52b49d68f123ec6f78
--- /dev/null
+++ b/static/js/main/main.js
@@ -0,0 +1,56 @@
+// 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.
+ // We do not mark these vars as local so we can use them later on.
cmp 2013/11/10 16:31:06 That is an unnecessary optimization. We should ma
vapier 2013/11/10 20:49:05 Done.
+ message = document.getElementsByName('message')[0];
+ message.onmouseover = help_show;
+ message.onmousemove = help_show;
+ message.onmouseout = help_hide;
+ message.onkeypress = auto_submit;
+
+ help = document.getElementById('help');
+ help.onmouseover = help_show;
+ help.onmouseout = help_hide;
cmp 2013/11/10 16:31:06 Consistency: if we call help_show onmousemove for
vapier 2013/11/10 20:49:05 i set it on message because the message text box c
+}
+
+function help_show() {
+ help.style.left = message.offsetLeft + 'px';
+ help.style.top = message.offsetTop + message.offsetHeight + 'px';
+ help.style.display = 'inline-block';
cmp 2013/11/10 16:31:06 http://www.whatwg.org/specs/web-apps/current-work/
vapier 2013/11/10 20:49:05 you can't use .hidden and .style.display at the sa
+}
+
+function help_hide() {
+ help.style.display = 'none';
cmp 2013/11/10 16:31:06 http://www.whatwg.org/specs/web-apps/current-work/
+}
+
+/*
+ * Misc functions.
+ */
+
+// Used by the status field.
+function auto_submit(e) {
cmp 2013/11/10 16:31:06 I think it's better to stick to the current behavi
vapier 2013/11/10 20:49:05 the current behavior allows you to simply hit ente
+ 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