OLD | NEW |
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 /** | 6 /** |
7 * @constructor | 7 * @constructor |
8 * @extends {HTMLDivElement} | 8 * @extends {HTMLDivElement} |
9 */ | 9 */ |
10 var EditableTextField = cr.ui.define('div'); | 10 var EditableTextField = cr.ui.define('div'); |
11 | 11 |
12 /** | |
13 * Decorates an element as an editable text field. | |
14 * @param {!HTMLElement} el The element to decorate. | |
15 */ | |
16 EditableTextField.decorate = function(el) { | |
17 el.__proto__ = EditableTextField.prototype; | |
18 el.decorate(); | |
19 }; | |
20 | |
21 EditableTextField.prototype = { | 12 EditableTextField.prototype = { |
22 __proto__: HTMLDivElement.prototype, | 13 __proto__: HTMLDivElement.prototype, |
23 | 14 |
24 /** | 15 /** |
25 * The actual input element in this field. | 16 * The actual input element in this field. |
26 * @type {?HTMLElement} | 17 * @type {?HTMLElement} |
27 * @private | 18 * @private |
28 */ | 19 */ |
29 editField_: null, | 20 editField_: null, |
30 | 21 |
(...skipping 12 matching lines...) Expand all Loading... |
43 model_: null, | 34 model_: null, |
44 | 35 |
45 /** | 36 /** |
46 * Whether or not the current edit should be considered canceled, rather | 37 * Whether or not the current edit should be considered canceled, rather |
47 * than committed, when editing ends. | 38 * than committed, when editing ends. |
48 * @type {boolean} | 39 * @type {boolean} |
49 * @private | 40 * @private |
50 */ | 41 */ |
51 editCanceled_: true, | 42 editCanceled_: true, |
52 | 43 |
53 /** @override */ | 44 /** @protected */ |
54 decorate: function() { | 45 decorate: function() { |
55 this.classList.add('editable-text-field'); | 46 this.classList.add('editable-text-field'); |
56 | 47 |
57 this.createEditableTextCell(''); | 48 this.createEditableTextCell(''); |
58 | 49 |
59 if (this.hasAttribute('i18n-placeholder-text')) { | 50 if (this.hasAttribute('i18n-placeholder-text')) { |
60 var identifier = this.getAttribute('i18n-placeholder-text'); | 51 var identifier = this.getAttribute('i18n-placeholder-text'); |
61 var localizedText = loadTimeData.getString(identifier); | 52 var localizedText = loadTimeData.getString(identifier); |
62 if (localizedText) | 53 if (localizedText) |
63 this.setAttribute('placeholder-text', localizedText); | 54 this.setAttribute('placeholder-text', localizedText); |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 return node instanceof EditableTextField; | 363 return node instanceof EditableTextField; |
373 }); | 364 }); |
374 if (itemAncestor) | 365 if (itemAncestor) |
375 document.activeElement.blur(); | 366 document.activeElement.blur(); |
376 }); | 367 }); |
377 | 368 |
378 return { | 369 return { |
379 EditableTextField: EditableTextField, | 370 EditableTextField: EditableTextField, |
380 }; | 371 }; |
381 }); | 372 }); |
OLD | NEW |