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

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

Issue 8438037: Change 'Add Page' to show a simple input dialog with --use-more-webui. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Address comments Created 9 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 | « chrome/browser/resources/input_window_dialog.html ('k') | chrome/browser/ui/browser.cc » ('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
index 27960985b670ff380cc5a3394269bb3835825b2c..2c905f025064f1a064065b58b84141e8350f2c9f 100644
--- a/chrome/browser/resources/input_window_dialog.js
+++ b/chrome/browser/resources/input_window_dialog.js
@@ -14,16 +14,26 @@ cr.define('inputWindowDialog', function() {
}
/**
+ * Returns true if URL area is shown.
+ */
+ function isURLAreaShown() {
+ return !$('url-area').classList.contains('area-hidden');
+ }
+
+ /**
* 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];
+ var values = [result];
if (result) {
- value.push($('name').value);
+ values.push($('name').value);
+ if (isURLAreaShown()) {
+ values.push($('url').value);
+ }
}
- var json = JSON.stringify(value);
+ var json = JSON.stringify(values);
chrome.send('DialogClose', [json]);
}
@@ -34,10 +44,17 @@ cr.define('inputWindowDialog', function() {
i18nTemplate.process(document, templateData);
var args = JSON.parse(chrome.dialogArguments);
- $('name-label').textContent = args.label;
- $('name').value = args.contents;
+ $('name-label').textContent = args.nameLabel;
+ $('name').value = args.name;
$('ok').textContent = args.ok_button_title;
+ if (args.urlLabel && args.url) {
+ $('url-label').textContent = args.urlLabel;
+ $('url').value = args.url;
+ } else {
+ $('url-area').classList.add('area-hidden');
+ }
+
$('cancel').onclick = function() {
closeWithResult(false);
}
@@ -48,11 +65,17 @@ cr.define('inputWindowDialog', function() {
}
}
- $('name').oninput = function() {
- var name = $('name').value;
- chrome.send('validate', [name]);
+ function validate() {
+ var values = [$('name').value];
+ if (isURLAreaShown()) {
+ values.push($('url').value);
+ }
+ chrome.send('validate', values);
}
+ $('name').oninput = validate;
+ $('url').oninput = isURLAreaShown() ? validate : null;
+
document.body.onkeydown = function(evt) {
if (evt.keyCode == 13) { // Enter key
$('ok').onclick();
« no previous file with comments | « chrome/browser/resources/input_window_dialog.html ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698