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

Side by Side Diff: chrome/browser/resources/options2/search_engine_manager_engine_list.js

Issue 10391044: retry 136193 - convert localStrings to loadTimeData for options page (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('options.search_engines', function() { 5 cr.define('options.search_engines', function() {
6 /** @const */ var InlineEditableItemList = options.InlineEditableItemList; 6 /** @const */ var InlineEditableItemList = options.InlineEditableItemList;
7 /** @const */ var InlineEditableItem = options.InlineEditableItem; 7 /** @const */ var InlineEditableItem = options.InlineEditableItem;
8 /** @const */ var ListSelectionController = cr.ui.ListSelectionController; 8 /** @const */ var ListSelectionController = cr.ui.ListSelectionController;
9 9
10 /** 10 /**
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 urlWithButtonEl.appendChild(urlEl); 117 urlWithButtonEl.appendChild(urlEl);
118 urlWithButtonEl.className = 'url-column'; 118 urlWithButtonEl.className = 'url-column';
119 urlWithButtonEl.classList.add('weakrtl'); 119 urlWithButtonEl.classList.add('weakrtl');
120 this.contentElement.appendChild(urlWithButtonEl); 120 this.contentElement.appendChild(urlWithButtonEl);
121 // Add the Make Default button. Temporary until drag-and-drop re-ordering 121 // Add the Make Default button. Temporary until drag-and-drop re-ordering
122 // is implemented. When this is removed, remove the extra div above. 122 // is implemented. When this is removed, remove the extra div above.
123 if (engine['canBeDefault']) { 123 if (engine['canBeDefault']) {
124 var makeDefaultButtonEl = this.ownerDocument.createElement('button'); 124 var makeDefaultButtonEl = this.ownerDocument.createElement('button');
125 makeDefaultButtonEl.className = 'custom-appearance list-inline-button'; 125 makeDefaultButtonEl.className = 'custom-appearance list-inline-button';
126 makeDefaultButtonEl.textContent = 126 makeDefaultButtonEl.textContent =
127 templateData.makeDefaultSearchEngineButton; 127 loadTimeData.getString('makeDefaultSearchEngineButton');
128 makeDefaultButtonEl.onclick = function(e) { 128 makeDefaultButtonEl.onclick = function(e) {
129 chrome.send('managerSetDefaultSearchEngine', [engine['modelIndex']]); 129 chrome.send('managerSetDefaultSearchEngine', [engine['modelIndex']]);
130 }; 130 };
131 // Don't select the row when clicking the button. 131 // Don't select the row when clicking the button.
132 makeDefaultButtonEl.onmousedown = function(e) { 132 makeDefaultButtonEl.onmousedown = function(e) {
133 e.stopPropagation(); 133 e.stopPropagation();
134 }; 134 };
135 urlWithButtonEl.appendChild(makeDefaultButtonEl); 135 urlWithButtonEl.appendChild(makeDefaultButtonEl);
136 } 136 }
137 137
138 // Do final adjustment to the input fields. 138 // Do final adjustment to the input fields.
139 this.nameField_ = nameEl.querySelector('input'); 139 this.nameField_ = nameEl.querySelector('input');
140 // The editable field uses the raw name, not the display name. 140 // The editable field uses the raw name, not the display name.
141 this.nameField_.value = engine['name']; 141 this.nameField_.value = engine['name'];
142 this.keywordField_ = keywordEl.querySelector('input'); 142 this.keywordField_ = keywordEl.querySelector('input');
143 this.urlField_ = urlEl.querySelector('input'); 143 this.urlField_ = urlEl.querySelector('input');
144 144
145 if (engine['urlLocked']) 145 if (engine['urlLocked'])
146 this.urlField_.disabled = true; 146 this.urlField_.disabled = true;
147 147
148 if (this.isPlaceholder) { 148 if (this.isPlaceholder) {
149 this.nameField_.placeholder = 149 this.nameField_.placeholder =
150 localStrings.getString('searchEngineTableNamePlaceholder'); 150 loadTimeData.getString('searchEngineTableNamePlaceholder');
151 this.keywordField_.placeholder = 151 this.keywordField_.placeholder =
152 localStrings.getString('searchEngineTableKeywordPlaceholder'); 152 loadTimeData.getString('searchEngineTableKeywordPlaceholder');
153 this.urlField_.placeholder = 153 this.urlField_.placeholder =
154 localStrings.getString('searchEngineTableURLPlaceholder'); 154 loadTimeData.getString('searchEngineTableURLPlaceholder');
155 } 155 }
156 156
157 var fields = [this.nameField_, this.keywordField_, this.urlField_]; 157 var fields = [this.nameField_, this.keywordField_, this.urlField_];
158 for (var i = 0; i < fields.length; i++) { 158 for (var i = 0; i < fields.length; i++) {
159 fields[i].oninput = this.startFieldValidation_.bind(this); 159 fields[i].oninput = this.startFieldValidation_.bind(this);
160 } 160 }
161 161
162 // Listen for edit events. 162 // Listen for edit events.
163 if (engine['canBeEdited']) { 163 if (engine['canBeEdited']) {
164 this.addEventListener('edit', this.onEditStarted_.bind(this)); 164 this.addEventListener('edit', this.onEditStarted_.bind(this));
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 }, 241 },
242 242
243 /** 243 /**
244 * Callback for the completion of an input validition check. 244 * Callback for the completion of an input validition check.
245 * @param {Object} validity A dictionary of validitation results. 245 * @param {Object} validity A dictionary of validitation results.
246 */ 246 */
247 validationComplete: function(validity) { 247 validationComplete: function(validity) {
248 this.waitingForValidation_ = false; 248 this.waitingForValidation_ = false;
249 // TODO(stuartmorgan): Implement the full validation UI with 249 // TODO(stuartmorgan): Implement the full validation UI with
250 // checkmark/exclamation mark icons and tooltips showing the errors. 250 // checkmark/exclamation mark icons and tooltips showing the errors.
251 if (validity['name']) { 251 if (validity.name) {
252 this.nameField_.setCustomValidity(''); 252 this.nameField_.setCustomValidity('');
253 } else { 253 } else {
254 this.nameField_.setCustomValidity( 254 this.nameField_.setCustomValidity(
255 templateData.editSearchEngineInvalidTitleToolTip); 255 loadTimeData.getString('editSearchEngineInvalidTitleToolTip'));
256 } 256 }
257 257
258 if (validity['keyword']) { 258 if (validity.keyword) {
259 this.keywordField_.setCustomValidity(''); 259 this.keywordField_.setCustomValidity('');
260 } else { 260 } else {
261 this.keywordField_.setCustomValidity( 261 this.keywordField_.setCustomValidity(
262 templateData.editSearchEngineInvalidKeywordToolTip); 262 loadTimeData.getString('editSearchEngineInvalidKeywordToolTip'));
263 } 263 }
264 264
265 if (validity['url']) { 265 if (validity.url) {
266 this.urlField_.setCustomValidity(''); 266 this.urlField_.setCustomValidity('');
267 } else { 267 } else {
268 this.urlField_.setCustomValidity( 268 this.urlField_.setCustomValidity(
269 templateData.editSearchEngineInvalidURLToolTip); 269 loadTimeData.getString('editSearchEngineInvalidURLToolTip'));
270 } 270 }
271 271
272 this.currentlyValid_ = validity['name'] && validity['keyword'] && 272 this.currentlyValid_ = validity.name && validity.keyword && validity.url;
273 validity['url'];
274 }, 273 },
275 }; 274 };
276 275
277 var SearchEngineList = cr.ui.define('list'); 276 var SearchEngineList = cr.ui.define('list');
278 277
279 SearchEngineList.prototype = { 278 SearchEngineList.prototype = {
280 __proto__: InlineEditableItemList.prototype, 279 __proto__: InlineEditableItemList.prototype,
281 280
282 /** @inheritDoc */ 281 /** @inheritDoc */
283 createItem: function(searchEngine) { 282 createItem: function(searchEngine) {
(...skipping 23 matching lines...) Expand all
307 }, 306 },
308 }; 307 };
309 308
310 // Export 309 // Export
311 return { 310 return {
312 SearchEngineList: SearchEngineList 311 SearchEngineList: SearchEngineList
313 }; 312 };
314 313
315 }); 314 });
316 315
OLDNEW
« no previous file with comments | « chrome/browser/resources/options2/search_engine_manager.js ('k') | chrome/browser/resources/options2/search_page.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698