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

Unified Diff: chrome/browser/resources/options/edit_search_engine_overlay.js

Issue 6151004: DOMUI Prefs: Replace search engine edit overlay with inline editing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address last comment Created 9 years, 11 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/options/edit_search_engine_overlay.js
diff --git a/chrome/browser/resources/options/edit_search_engine_overlay.js b/chrome/browser/resources/options/edit_search_engine_overlay.js
deleted file mode 100644
index a4f72b5dbb9c8a8b7a4ff81c9b28837eb61e6738..0000000000000000000000000000000000000000
--- a/chrome/browser/resources/options/edit_search_engine_overlay.js
+++ /dev/null
@@ -1,158 +0,0 @@
-// Copyright (c) 2010 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('options', function() {
- const OptionsPage = options.OptionsPage;
-
- /**
- * EditSearchEngineOverlay class
- * Encapsulated handling of the 'Edit Search Engine' overlay page.
- * @class
- * @constructor
- */
- function EditSearchEngineOverlay() {
- OptionsPage.call(this, 'editSearchEngineOverlay',
- templateData.editSearchEngineTitle,
- 'editSearchEngineOverlay');
- }
-
- cr.addSingletonGetter(EditSearchEngineOverlay);
-
- EditSearchEngineOverlay.prototype = {
- __proto__: OptionsPage.prototype,
-
- /**
- * Initializes the page.
- */
- initializePage: function() {
- OptionsPage.prototype.initializePage.call(this);
-
- var self = this;
- var editForm = $('editSearchEngineForm');
- editForm.onreset = function(e) {
- chrome.send('searchEngineEditCancelled');
- self.dismissOverlay_();
- };
- editForm.onsubmit = function(e) {
- chrome.send('searchEngineEditCompleted', self.getInputFieldValues_());
- self.dismissOverlay_();
- return false;
- };
- var fieldIDs = ['editSearchEngineName',
- 'editSearchEngineKeyword',
- 'editSearchEngineURL'];
- for (var i = 0; i < fieldIDs.length; i++) {
- var field = $(fieldIDs[i]);
- field.oninput = this.validateFields_.bind(this);
- field.onkeydown = function(e) {
- if (e.keyCode == 27) // Esc
- editForm.reset();
- };
- }
- },
-
- /**
- * Clears any uncommited input, and dismisses the overlay.
- * @private
- */
- dismissOverlay_: function() {
- this.setEditDetails_();
- OptionsPage.clearOverlays();
- },
-
- /**
- * Fills the text fields from the given search engine.
- * @private
- */
- setEditDetails_: function(engineDetails) {
- if (engineDetails) {
- $('editSearchEngineName').value = engineDetails['name'];
- $('editSearchEngineKeyword').value = engineDetails['keyword'];
- var urlField = $('editSearchEngineURL');
- urlField.value = engineDetails['url'];
- urlField.disabled = engineDetails['urlLocked'];
- this.validateFields_();
- } else {
- $('editSearchEngineName').value = '';
- $('editSearchEngineKeyword').value = '';
- $('editSearchEngineURL').value = '';
- var invalid = { name: false, keyword: false, url: false };
- this.updateValidityWithResults_(invalid);
- }
- },
-
- /**
- * Starts the process of asynchronously validating the user input. Results
- * will be reported to updateValidityWithResults_.
- * @private
- */
- validateFields_: function() {
- chrome.send('checkSearchEngineInfoValidity', this.getInputFieldValues_());
- },
-
- /**
- * Sets the validation images and the enabled state of the Add button based
- * on the current values of the text fields.
- * @private
- * @param {Object} The dictionary of validity states.
- */
- updateValidityWithResults_: function(validity) {
- this.setBadgeValidity_($('editSearchEngineNameValidity'),
- validity['name'],
- 'editSearchEngineInvalidTitleToolTip');
- this.setBadgeValidity_($('editSearchEngineKeywordValidity'),
- validity['keyword'],
- 'editSearchEngineInvalidKeywordToolTip');
- this.setBadgeValidity_($('editSearchEngineURLValidity'),
- validity['url'],
- 'editSearchEngineInvalidURLToolTip');
- $('editSearchEngineOkayButton').disabled =
- !(validity['name'] && validity['keyword'] && validity['url']);
- },
-
- /**
- * Updates the state of the given validity indicator badge.
- * @private
- * @param {HTMLElement} The badge element to adjust.
- * @param {boolean} Whether or not the badge should be set to the valid
- * state.
- * @param {string} The tooltip string id for the invalid state.
- */
- setBadgeValidity_: function(element, isValid, tooltip_id) {
- if (isValid) {
- element.className = 'valid-badge';
- element.title = '';
- } else {
- element.className = 'alert-badge';
- element.title = localStrings.getString(tooltip_id);
- }
- },
-
- /**
- * Returns the input field values as an array suitable for passing to
- * chrome.send. The order of the array is important.
- * @private
- * @return {array} The current input field values.
- */
- getInputFieldValues_: function() {
- return [ $('editSearchEngineName').value,
- $('editSearchEngineKeyword').value,
- $('editSearchEngineURL').value ];
- }
- };
-
- EditSearchEngineOverlay.setEditDetails = function(engineDetails) {
- EditSearchEngineOverlay.getInstance().setEditDetails_(engineDetails);
- };
-
- EditSearchEngineOverlay.validityCheckCallback = function(validity) {
- EditSearchEngineOverlay.getInstance().updateValidityWithResults_(validity);
- };
-
- // Export
- return {
- EditSearchEngineOverlay: EditSearchEngineOverlay
- };
-
-});

Powered by Google App Engine
This is Rietveld 408576698