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

Unified Diff: chrome/browser/resources/input_window_dialog.js

Issue 8298019: Implement InputWindowDialog with WebUI for bookmark folder management. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase again Created 9 years, 2 months 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 | « chrome/browser/resources/input_window_dialog.html ('k') | chrome/browser/ui/input_window_dialog_gtk.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/input_window_dialog.js
diff --git a/chrome/browser/resources/input_window_dialog.js b/chrome/browser/resources/input_window_dialog.js
new file mode 100644
index 0000000000000000000000000000000000000000..74174607e7c3b29b644654b19728b6067d6def61
--- /dev/null
+++ b/chrome/browser/resources/input_window_dialog.js
@@ -0,0 +1,78 @@
+// Copyright (c) 2011 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.
+
+cr.define('inputWindowDialog', function() {
+ 'use strict';
+
+ /**
+ * Disables the controls while the dialog is busy.
+ */
+ function disableControls() {
+ $('cancel').disabled = true;
+ $('ok').disabled = true;
+ }
+
+ /**
+ * Close the dialog and pass a result value to the dialog close handler.
+ * @param {boolean} result The value to pass to the dialog close handler.
+ */
+ function closeWithResult(result) {
+ disableControls();
+ var value = [result];
+ if (result) {
+ value.push($('name').value);
+ }
+ var json = JSON.stringify(value);
+ chrome.send('DialogClose', [json]);
+ }
+
+ /**
+ * Inserts translated strings on loading.
+ */
+ function initialize() {
+ i18nTemplate.process(document, templateData);
+
+ var args = JSON.parse(chrome.dialogArguments);
+ $('name-label').textContent = args.label;
+ $('name').value = args.contents;
+
+ $('cancel').onclick = function() {
+ closeWithResult(false);
+ }
+
+ $('ok').onclick = function() {
+ if (!$('ok').disabled) {
+ closeWithResult(true);
+ }
+ }
+
+ $('name').oninput = function() {
+ var name = $('name').value;
+ chrome.send('validate', [name]);
+ }
+
+ document.body.onkeydown = function(evt) {
+ if (evt.keyCode == 13) { // Enter key
+ $('ok').onclick();
+ } else if (evt.keyCode == 27) { // Escape key
+ $('cancel').onclick();
+ }
+ }
+ }
+
+ /**
+ * Called in response to validate request.
+ * @param {boolean} valid The result of validate request.
+ */
+ function ackValidation(valid) {
+ $('ok').disabled = !valid;
+ }
+
+ return {
+ initialize: initialize,
+ ackValidation: ackValidation,
+ };
+});
+
+document.addEventListener('DOMContentLoaded', inputWindowDialog.initialize);
« no previous file with comments | « chrome/browser/resources/input_window_dialog.html ('k') | chrome/browser/ui/input_window_dialog_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698