| 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();
|
|
|