Index: chrome/browser/resources/edit_search_engine_dialog.js |
diff --git a/chrome/browser/resources/edit_search_engine_dialog.js b/chrome/browser/resources/edit_search_engine_dialog.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..dc905d5d0107444935841151483ab27f64f22152 |
--- /dev/null |
+++ b/chrome/browser/resources/edit_search_engine_dialog.js |
@@ -0,0 +1,67 @@ |
+// 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('editSearchEngineDialog', function() { |
+ 'use strict'; |
+ |
+ /** |
+ * Disables the controls while the dialog is busy. |
+ */ |
+ function disableControls() { |
+ $('cancel').disabled = true; |
+ $('save').disabled = true; |
+ } |
+ |
+ /** |
+ * Close the dialog and pass a result value to the dialog close handler. |
+ * @param {{description: string, details: string, url: string}=} result The |
+ * 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.
|
+ */ |
+ 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
|
+ disableControls(); |
+ 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.
|
+ chrome.send('DialogClose', [json]); |
+ } |
+ |
+ /** |
+ * 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.
|
+ * @param {{description: string, details: string, url: string}} details Values |
+ * for corresponding text fields. |
+ */ |
+ function setDetails(details) { |
+ $('description-text').value = details.description; |
+ $('keyword-text').value = details.keyword; |
+ $('url-text').value = details.url; |
+ } |
+ |
+ /** |
+ * Inserts translated strings on loading. |
+ */ |
+ function initialize() { |
+ i18nTemplate.process(document, templateData); |
+ |
+ $('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.
|
+ templateData.titleNew : templateData.titleEdit; |
+ |
+ $('cancel').onclick = function() { |
+ closeWithResult(); |
+ } |
+ |
+ $('save').onclick = function() { |
+ 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.
|
+ keyword:$('keyword-text').value, |
+ url:$('url-text').value}); |
+ } |
+ |
+ chrome.send('requestDetails') |
+ } |
+ |
+ return { |
+ initialize: initialize, |
+ setDetails: setDetails, |
+ }; |
+}); |
+ |
+document.addEventListener('DOMContentLoaded', |
+ editSearchEngineDialog.initialize); |