OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 cr.define('editSearchEngineDialog', function() { | |
6 'use strict'; | |
7 | |
8 /** | |
9 * Disables the controls while the dialog is busy. | |
10 */ | |
11 function disableControls() { | |
12 $('cancel').disabled = true; | |
13 $('save').disabled = true; | |
14 } | |
15 | |
16 /** | |
17 * Close the dialog and pass a result value to the dialog close handler. | |
18 * @param {{description: string, details: string, url: string}=} result The | |
19 * value to pass to the dialog close handler. | |
arv (Not doing code reviews)
2011/10/04 20:55:01
indent 4 spaces
wyck
2011/10/04 21:57:57
Done.
| |
20 */ | |
21 function closeWithResult(result) { | |
arv (Not doing code reviews)
2011/10/04 20:55:01
opt_result
wyck
2011/10/04 21:57:57
On 2011/10/04 20:55:01, arv wrote:
> opt_result
| |
22 disableControls(); | |
23 var json = JSON.stringify(result?[result]:[]); | |
arv (Not doing code reviews)
2011/10/04 20:55:01
ws
wyck
2011/10/04 21:57:57
Done.
| |
24 chrome.send('DialogClose', [json]); | |
25 } | |
26 | |
27 /** | |
28 * Sets the text of the dialog's editable text boxes. | |
arv (Not doing code reviews)
2011/10/04 20:55:01
fix identation
wyck
2011/10/04 21:57:57
Done.
| |
29 * @param {{description: string, details: string, url: string}} details Values | |
30 * for corresponding text fields. | |
31 */ | |
32 function setDetails(details) { | |
33 $('description-text').value = details.description; | |
34 $('keyword-text').value = details.keyword; | |
35 $('url-text').value = details.url; | |
36 } | |
37 | |
38 /** | |
39 * Inserts translated strings on loading. | |
40 */ | |
41 function initialize() { | |
42 i18nTemplate.process(document, templateData); | |
43 | |
44 $('title').textContent = (chrome.dialogArguments == 'add') ? | |
arv (Not doing code reviews)
2011/10/04 20:55:01
useless parens
arv (Not doing code reviews)
2011/10/04 20:55:01
document.title = ...
wyck
2011/10/04 21:57:57
Done.
wyck
2011/10/04 21:57:57
Done.
| |
45 templateData.titleNew : templateData.titleEdit; | |
46 | |
47 $('cancel').onclick = function() { | |
48 closeWithResult(); | |
49 } | |
50 | |
51 $('save').onclick = function() { | |
52 closeWithResult({description:$('description-text').value, | |
arv (Not doing code reviews)
2011/10/04 20:55:01
ws
wyck
2011/10/04 21:57:57
Not sure what it should be.
| |
53 keyword:$('keyword-text').value, | |
54 url:$('url-text').value}); | |
55 } | |
56 | |
57 chrome.send('requestDetails') | |
58 } | |
59 | |
60 return { | |
61 initialize: initialize, | |
62 setDetails: setDetails, | |
63 }; | |
64 }); | |
65 | |
66 document.addEventListener('DOMContentLoaded', | |
67 editSearchEngineDialog.initialize); | |
OLD | NEW |