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

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

Issue 8118012: WebUI Edit Search Engine Dialog (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: arv review 1 Created 9 years, 2 months 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
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..95773f536eeddf7bb397f9a154c26f1c3e8e58f2
--- /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}=} opt_result
+ * The value to pass to the dialog close handler.
+ */
+ function closeWithResult(opt_result) {
+ disableControls();
+ var json = JSON.stringify(opt_result ? [opt_result] : []);
+ chrome.send('DialogClose', [json]);
+ }
+
+ /**
+ * Sets the text of the dialog's editable text boxes.
+ * @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);
+
+ document.title = chrome.dialogArguments == 'add' ? templateData.titleNew :
+ templateData.titleEdit;
+
+ $('cancel').onclick = function() {
+ closeWithResult();
+ }
+
+ $('save').onclick = function() {
+ closeWithResult({description: $('description-text').value,
+ keyword: $('keyword-text').value,
+ url: $('url-text').value});
+ }
+
+ chrome.send('requestDetails')
+ }
+
+ return {
+ initialize: initialize,
+ setDetails: setDetails,
+ };
+});
+
+document.addEventListener('DOMContentLoaded',
+ editSearchEngineDialog.initialize);

Powered by Google App Engine
This is Rietveld 408576698