| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| 11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
| 12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
| 13 * | 13 * |
| 14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | 14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 /** | 27 /** |
| 28 * @unrestricted | 28 * @unrestricted |
| 29 */ | 29 */ |
| 30 WebInspector.UIList = class extends WebInspector.VBox { | 30 Sources.UIList = class extends UI.VBox { |
| 31 constructor() { | 31 constructor() { |
| 32 super(true); | 32 super(true); |
| 33 this.registerRequiredCSS('sources/uiList.css'); | 33 this.registerRequiredCSS('sources/uiList.css'); |
| 34 | 34 |
| 35 /** @type {!Array.<!WebInspector.UIList.Item>} */ | 35 /** @type {!Array.<!Sources.UIList.Item>} */ |
| 36 this._items = []; | 36 this._items = []; |
| 37 } | 37 } |
| 38 | 38 |
| 39 /** | 39 /** |
| 40 * @param {!WebInspector.UIList.Item} item | 40 * @param {!Sources.UIList.Item} item |
| 41 * @param {?WebInspector.UIList.Item=} beforeItem | 41 * @param {?Sources.UIList.Item=} beforeItem |
| 42 */ | 42 */ |
| 43 addItem(item, beforeItem) { | 43 addItem(item, beforeItem) { |
| 44 item[WebInspector.UIList._Key] = this; | 44 item[Sources.UIList._Key] = this; |
| 45 var beforeElement = beforeItem ? beforeItem.element : null; | 45 var beforeElement = beforeItem ? beforeItem.element : null; |
| 46 this.contentElement.insertBefore(item.element, beforeElement); | 46 this.contentElement.insertBefore(item.element, beforeElement); |
| 47 | 47 |
| 48 var index = beforeItem ? this._items.indexOf(beforeItem) : this._items.lengt
h; | 48 var index = beforeItem ? this._items.indexOf(beforeItem) : this._items.lengt
h; |
| 49 console.assert(index >= 0, 'Anchor item not found in UIList'); | 49 console.assert(index >= 0, 'Anchor item not found in UIList'); |
| 50 this._items.splice(index, 0, item); | 50 this._items.splice(index, 0, item); |
| 51 } | 51 } |
| 52 | 52 |
| 53 /** | 53 /** |
| 54 * @param {!WebInspector.UIList.Item} item | 54 * @param {!Sources.UIList.Item} item |
| 55 */ | 55 */ |
| 56 removeItem(item) { | 56 removeItem(item) { |
| 57 var index = this._items.indexOf(item); | 57 var index = this._items.indexOf(item); |
| 58 console.assert(index >= 0); | 58 console.assert(index >= 0); |
| 59 this._items.splice(index, 1); | 59 this._items.splice(index, 1); |
| 60 item.element.remove(); | 60 item.element.remove(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 clear() { | 63 clear() { |
| 64 this.contentElement.removeChildren(); | 64 this.contentElement.removeChildren(); |
| 65 this._items = []; | 65 this._items = []; |
| 66 } | 66 } |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 WebInspector.UIList._Key = Symbol('ownerList'); | 69 Sources.UIList._Key = Symbol('ownerList'); |
| 70 | 70 |
| 71 /** | 71 /** |
| 72 * @unrestricted | 72 * @unrestricted |
| 73 */ | 73 */ |
| 74 WebInspector.UIList.Item = class { | 74 Sources.UIList.Item = class { |
| 75 /** | 75 /** |
| 76 * @param {string} title | 76 * @param {string} title |
| 77 * @param {string} subtitle | 77 * @param {string} subtitle |
| 78 * @param {boolean=} isLabel | 78 * @param {boolean=} isLabel |
| 79 */ | 79 */ |
| 80 constructor(title, subtitle, isLabel) { | 80 constructor(title, subtitle, isLabel) { |
| 81 this.element = createElementWithClass('div', 'list-item'); | 81 this.element = createElementWithClass('div', 'list-item'); |
| 82 if (isLabel) | 82 if (isLabel) |
| 83 this.element.classList.add('label'); | 83 this.element.classList.add('label'); |
| 84 | 84 |
| 85 this.titleElement = this.element.createChild('div', 'title'); | 85 this.titleElement = this.element.createChild('div', 'title'); |
| 86 this.subtitleElement = this.element.createChild('div', 'subtitle'); | 86 this.subtitleElement = this.element.createChild('div', 'subtitle'); |
| 87 /** @type {?Element} */ | 87 /** @type {?Element} */ |
| 88 this._actionElement = null; | 88 this._actionElement = null; |
| 89 this._hidden = false; | 89 this._hidden = false; |
| 90 this._isLabel = !!isLabel; | 90 this._isLabel = !!isLabel; |
| 91 /** @type {?HTMLElement} */ | 91 /** @type {?HTMLElement} */ |
| 92 this._icon = null; | 92 this._icon = null; |
| 93 this.setTitle(title); | 93 this.setTitle(title); |
| 94 this.setSubtitle(subtitle); | 94 this.setSubtitle(subtitle); |
| 95 this.setSelected(false); | 95 this.setSelected(false); |
| 96 } | 96 } |
| 97 | 97 |
| 98 /** | 98 /** |
| 99 * @return {?WebInspector.UIList.Item} | 99 * @return {?Sources.UIList.Item} |
| 100 */ | 100 */ |
| 101 nextSibling() { | 101 nextSibling() { |
| 102 var list = this[WebInspector.UIList._Key]; | 102 var list = this[Sources.UIList._Key]; |
| 103 var index = list._items.indexOf(this); | 103 var index = list._items.indexOf(this); |
| 104 console.assert(index >= 0); | 104 console.assert(index >= 0); |
| 105 return list._items[index + 1] || null; | 105 return list._items[index + 1] || null; |
| 106 } | 106 } |
| 107 | 107 |
| 108 /** | 108 /** |
| 109 * @return {string} | 109 * @return {string} |
| 110 */ | 110 */ |
| 111 title() { | 111 title() { |
| 112 return this._title; | 112 return this._title; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 if (x) | 153 if (x) |
| 154 this.select(); | 154 this.select(); |
| 155 else | 155 else |
| 156 this.deselect(); | 156 this.deselect(); |
| 157 } | 157 } |
| 158 | 158 |
| 159 select() { | 159 select() { |
| 160 if (this._selected) | 160 if (this._selected) |
| 161 return; | 161 return; |
| 162 this._selected = true; | 162 this._selected = true; |
| 163 this._icon = WebInspector.Icon.create('smallicon-thick-right-arrow', 'select
ed-icon'); | 163 this._icon = UI.Icon.create('smallicon-thick-right-arrow', 'selected-icon'); |
| 164 this.element.appendChild(this._icon); | 164 this.element.appendChild(this._icon); |
| 165 } | 165 } |
| 166 | 166 |
| 167 deselect() { | 167 deselect() { |
| 168 if (!this._selected) | 168 if (!this._selected) |
| 169 return; | 169 return; |
| 170 this._selected = false; | 170 this._selected = false; |
| 171 this._icon.remove(); | 171 this._icon.remove(); |
| 172 this._icon = null; | 172 this._icon = null; |
| 173 } | 173 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 this._actionElement = this.element.createChild('div', 'action'); | 229 this._actionElement = this.element.createChild('div', 'action'); |
| 230 var link = this._actionElement.createChild('a', 'action-link'); | 230 var link = this._actionElement.createChild('a', 'action-link'); |
| 231 link.textContent = title; | 231 link.textContent = title; |
| 232 link.addEventListener('click', (event) => { | 232 link.addEventListener('click', (event) => { |
| 233 link.disabled = true; | 233 link.disabled = true; |
| 234 handler(event).then(() => link.disabled = false); | 234 handler(event).then(() => link.disabled = false); |
| 235 event.stopPropagation(); | 235 event.stopPropagation(); |
| 236 }); | 236 }); |
| 237 } | 237 } |
| 238 }; | 238 }; |
| OLD | NEW |