Chromium Code Reviews| 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 74174607e7c3b29b644654b19728b6067d6def61..69cd888df23e38d4aa41abb8426e8f5f7e26533c 100644 |
| --- a/chrome/browser/resources/input_window_dialog.js |
| +++ b/chrome/browser/resources/input_window_dialog.js |
| @@ -19,11 +19,14 @@ cr.define('inputWindowDialog', function() { |
| */ |
| function closeWithResult(result) { |
| disableControls(); |
| - var value = [result]; |
| + var values = [result]; |
| if (result) { |
| - value.push($('name').value); |
| + values.push($('name').value); |
| + if ($('url-area').style.display != 'none') { |
|
flackr
2011/11/02 15:38:18
Use class to determine whether a URL is being edit
mazda
2011/11/07 09:59:23
Done.
I added a function to check if a URL field i
|
| + values.push($('url').value); |
| + } |
| } |
| - var json = JSON.stringify(value); |
| + var json = JSON.stringify(values); |
| chrome.send('DialogClose', [json]); |
| } |
| @@ -34,8 +37,16 @@ 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; |
| + |
| + if (args.urlLabel && args.url) { |
| + $('url-label').textContent = args.urlLabel; |
| + $('url').value = args.url; |
| + $('url-area').style.display = '-webkit-box'; |
|
flackr
2011/11/02 15:38:18
Use class to toggle CSS properties.
mazda
2011/11/07 09:59:23
Done.
|
| + } else { |
| + $('url-area').style.display = 'none'; |
| + } |
| $('cancel').onclick = function() { |
| closeWithResult(false); |
| @@ -47,11 +58,17 @@ cr.define('inputWindowDialog', function() { |
| } |
| } |
| - $('name').oninput = function() { |
| - var name = $('name').value; |
| - chrome.send('validate', [name]); |
| + function validate() { |
| + var values = [$('name').value] |
| + if ($('url-area').style.display != 'none') { |
|
flackr
2011/11/02 15:38:18
Same as above, check class instead of style.
mazda
2011/11/07 09:59:23
Done.
|
| + values.push($('url').value); |
| + } |
| + chrome.send('validate', values); |
| } |
| + $('name').oninput = validate; |
| + $('url').oninput = $('url-area').style.display != 'none' ? validate : null; |
| + |
| document.body.onkeydown = function(evt) { |
| if (evt.keyCode == 13) { // Enter key |
| $('ok').onclick(); |