| 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 /** @const */ var DeletableItem = options.DeletableItem; | 6 /** @const */ var DeletableItem = options.DeletableItem; |
| 7 /** @const */ var DeletableItemList = options.DeletableItemList; | 7 /** @const */ var DeletableItemList = options.DeletableItemList; |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Creates a new list item with support for inline editing. | 10 * Creates a new list item with support for inline editing. |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 }, | 229 }, |
| 230 | 230 |
| 231 /** | 231 /** |
| 232 * Returns a div containing an <input>, as well as static text if | 232 * Returns a div containing an <input>, as well as static text if |
| 233 * isPlaceholder is not true. | 233 * isPlaceholder is not true. |
| 234 * @param {string} text The text of the cell. | 234 * @param {string} text The text of the cell. |
| 235 * @return {HTMLElement} The HTML element for the cell. | 235 * @return {HTMLElement} The HTML element for the cell. |
| 236 * @private | 236 * @private |
| 237 */ | 237 */ |
| 238 createEditableTextCell: function(text) { | 238 createEditableTextCell: function(text) { |
| 239 var container = this.ownerDocument.createElement('div'); | 239 var container = /** @type {HTMLElement} */( |
| 240 var textEl; | 240 this.ownerDocument.createElement('div')); |
| 241 var textEl = null; |
| 241 if (!this.isPlaceholder) { | 242 if (!this.isPlaceholder) { |
| 242 textEl = this.ownerDocument.createElement('div'); | 243 textEl = this.ownerDocument.createElement('div'); |
| 243 textEl.className = 'static-text'; | 244 textEl.className = 'static-text'; |
| 244 textEl.textContent = text; | 245 textEl.textContent = text; |
| 245 textEl.setAttribute('displaymode', 'static'); | 246 textEl.setAttribute('displaymode', 'static'); |
| 246 container.appendChild(textEl); | 247 container.appendChild(textEl); |
| 247 } | 248 } |
| 248 | 249 |
| 249 var inputEl = this.ownerDocument.createElement('input'); | 250 var inputEl = this.ownerDocument.createElement('input'); |
| 250 inputEl.type = 'text'; | 251 inputEl.type = 'text'; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 window.addEventListener('blur', function(e) { | 400 window.addEventListener('blur', function(e) { |
| 400 var itemAncestor = findAncestor(document.activeElement, function(node) { | 401 var itemAncestor = findAncestor(document.activeElement, function(node) { |
| 401 return node instanceof InlineEditableItem; | 402 return node instanceof InlineEditableItem; |
| 402 }); | 403 }); |
| 403 if (itemAncestor) | 404 if (itemAncestor) |
| 404 document.activeElement.blur(); | 405 document.activeElement.blur(); |
| 405 }); | 406 }); |
| 406 } | 407 } |
| 407 handleWindowBlurs(); | 408 handleWindowBlurs(); |
| 408 | 409 |
| 410 /** |
| 411 * @constructor |
| 412 * @extends {options.DeletableItemList} |
| 413 */ |
| 409 var InlineEditableItemList = cr.ui.define('list'); | 414 var InlineEditableItemList = cr.ui.define('list'); |
| 410 | 415 |
| 411 InlineEditableItemList.prototype = { | 416 InlineEditableItemList.prototype = { |
| 412 __proto__: DeletableItemList.prototype, | 417 __proto__: DeletableItemList.prototype, |
| 413 | 418 |
| 414 /** | 419 /** |
| 415 * Focuses the input element of the placeholder if true. | 420 * Focuses the input element of the placeholder if true. |
| 416 * @type {boolean} | 421 * @type {boolean} |
| 417 */ | 422 */ |
| 418 focusPlaceholder: false, | 423 focusPlaceholder: false, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 return true; | 455 return true; |
| 451 }, | 456 }, |
| 452 }; | 457 }; |
| 453 | 458 |
| 454 // Export | 459 // Export |
| 455 return { | 460 return { |
| 456 InlineEditableItem: InlineEditableItem, | 461 InlineEditableItem: InlineEditableItem, |
| 457 InlineEditableItemList: InlineEditableItemList, | 462 InlineEditableItemList: InlineEditableItemList, |
| 458 }; | 463 }; |
| 459 }); | 464 }); |
| OLD | NEW |