// Copyright (c) 2012 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 */ var List = cr.ui.List; /** @const */ var ListItem = cr.ui.ListItem; /** * Creates a deletable list item, which has a button that will trigger a call * to deleteItemAtIndex(index) in the list. * @constructor * @extends {cr.ui.ListItem} */ var DeletableItem = cr.ui.define('li'); DeletableItem.prototype = { __proto__: ListItem.prototype, /** * The element subclasses should populate with content. * @type {HTMLElement} * @private */ contentElement_: null, /** * The close button element. * @type {HTMLElement} * @private */ closeButtonElement_: null, /** * Whether or not this item can be deleted. * @type {boolean} * @private */ deletable_: true, /** * Whether or not the close button can ever be navigated to using the * keyboard. * @type {boolean} * @protected */ closeButtonFocusAllowed: false, /** @override */ decorate: function() { ListItem.prototype.decorate.call(this); this.classList.add('deletable-item'); this.contentElement_ = /** @type {HTMLElement} */( this.ownerDocument.createElement('div')); this.appendChild(this.contentElement_); this.closeButtonElement_ = /** @type {HTMLElement} */( this.ownerDocument.createElement('button')); this.closeButtonElement_.className = 'raw-button row-delete-button custom-appearance'; this.closeButtonElement_.addEventListener('mousedown', this.handleMouseDownUpOnClose_); this.closeButtonElement_.addEventListener('mouseup', this.handleMouseDownUpOnClose_); this.closeButtonElement_.addEventListener('focus', this.handleFocus.bind(this)); this.closeButtonElement_.tabIndex = -1; this.closeButtonElement_.title = loadTimeData.getString('deletableItemDeleteButtonTitle'); this.appendChild(this.closeButtonElement_); }, /** * Returns the element subclasses should add content to. * @return {HTMLElement} The element subclasses should popuplate. */ get contentElement() { return this.contentElement_; }, /** * Returns the close button element. * @return {HTMLElement} The close |