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

Side by Side Diff: chrome/browser/resources/options/editable_text_field.js

Issue 543493002: Compile chrome://settings, part 2: reduce from 950 to 400 errors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@F_settings
Patch Set: rebase? rebase! Created 6 years, 3 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
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', function() { 5 cr.define('options', function() {
6 /**
7 * @constructor
8 * @extends {HTMLDivElement}
9 */
6 var EditableTextField = cr.ui.define('div'); 10 var EditableTextField = cr.ui.define('div');
7 11
8 /** 12 /**
9 * Decorates an element as an editable text field. 13 * Decorates an element as an editable text field.
10 * @param {!HTMLElement} el The element to decorate. 14 * @param {!HTMLElement} el The element to decorate.
11 */ 15 */
12 EditableTextField.decorate = function(el) { 16 EditableTextField.decorate = function(el) {
13 el.__proto__ = EditableTextField.prototype; 17 el.__proto__ = EditableTextField.prototype;
14 el.decorate(); 18 el.decorate();
15 }; 19 };
(...skipping 27 matching lines...) Expand all
43 * than committed, when editing ends. 47 * than committed, when editing ends.
44 * @type {boolean} 48 * @type {boolean}
45 * @private 49 * @private
46 */ 50 */
47 editCanceled_: true, 51 editCanceled_: true,
48 52
49 /** @override */ 53 /** @override */
50 decorate: function() { 54 decorate: function() {
51 this.classList.add('editable-text-field'); 55 this.classList.add('editable-text-field');
52 56
53 this.createEditableTextCell(); 57 this.createEditableTextCell('');
54 58
55 if (this.hasAttribute('i18n-placeholder-text')) { 59 if (this.hasAttribute('i18n-placeholder-text')) {
56 var identifier = this.getAttribute('i18n-placeholder-text'); 60 var identifier = this.getAttribute('i18n-placeholder-text');
57 var localizedText = loadTimeData.getString(identifier); 61 var localizedText = loadTimeData.getString(identifier);
58 if (localizedText) 62 if (localizedText)
59 this.setAttribute('placeholder-text', localizedText); 63 this.setAttribute('placeholder-text', localizedText);
60 } 64 }
61 65
62 this.addEventListener('keydown', this.handleKeyDown_); 66 this.addEventListener('keydown', this.handleKeyDown_);
63 this.editField_.addEventListener('focus', this.handleFocus_.bind(this)); 67 this.editField_.addEventListener('focus', this.handleFocus_.bind(this));
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 * @param {string} text The text of the cell. 224 * @param {string} text The text of the cell.
221 * @private 225 * @private
222 */ 226 */
223 createEditableTextCell: function(text) { 227 createEditableTextCell: function(text) {
224 // This function should only be called once. 228 // This function should only be called once.
225 if (this.editField_) 229 if (this.editField_)
226 return; 230 return;
227 231
228 var container = this.ownerDocument.createElement('div'); 232 var container = this.ownerDocument.createElement('div');
229 233
230 var textEl = this.ownerDocument.createElement('div'); 234 var textEl = /** @type {HTMLElement} */(
235 this.ownerDocument.createElement('div'));
231 textEl.className = 'static-text'; 236 textEl.className = 'static-text';
232 textEl.textContent = text; 237 textEl.textContent = text;
233 textEl.setAttribute('displaymode', 'static'); 238 textEl.setAttribute('displaymode', 'static');
234 this.appendChild(textEl); 239 this.appendChild(textEl);
235 this.staticText_ = textEl; 240 this.staticText_ = textEl;
236 241
237 var inputEl = this.ownerDocument.createElement('input'); 242 var inputEl = /** @type {HTMLElement} */(
243 this.ownerDocument.createElement('input'));
238 inputEl.className = 'editable-text'; 244 inputEl.className = 'editable-text';
239 inputEl.type = 'text'; 245 inputEl.type = 'text';
240 inputEl.value = text; 246 inputEl.value = text;
241 inputEl.setAttribute('displaymode', 'edit'); 247 inputEl.setAttribute('displaymode', 'edit');
242 inputEl.staticVersion = textEl; 248 inputEl.staticVersion = textEl;
243 this.appendChild(inputEl); 249 this.appendChild(inputEl);
244 this.editField_ = inputEl; 250 this.editField_ = inputEl;
245 }, 251 },
246 252
247 /** 253 /**
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 return node instanceof EditableTextField; 372 return node instanceof EditableTextField;
367 }); 373 });
368 if (itemAncestor) 374 if (itemAncestor)
369 document.activeElement.blur(); 375 document.activeElement.blur();
370 }); 376 });
371 377
372 return { 378 return {
373 EditableTextField: EditableTextField, 379 EditableTextField: EditableTextField,
374 }; 380 };
375 }); 381 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/deletable_item_list.js ('k') | chrome/browser/resources/options/font_settings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698