| OLD | NEW |
| 1 // Copyright (c) 2011 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 // TODO(gbillock): refactor this together with CookiesList once we have | 5 // TODO(gbillock): refactor this together with CookiesList once we have |
| 6 // a better sense from UX design what it'll look like and so what'll be shared. | 6 // a better sense from UX design what it'll look like and so what'll be shared. |
| 7 cr.define('options', function() { | 7 cr.define('options', function() { |
| 8 const DeletableItemList = options.DeletableItemList; | 8 const DeletableItemList = options.DeletableItemList; |
| 9 const DeletableItem = options.DeletableItem; | 9 const DeletableItem = options.DeletableItem; |
| 10 const ArrayDataModel = cr.ui.ArrayDataModel; | 10 const ArrayDataModel = cr.ui.ArrayDataModel; |
| 11 const ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; | 11 const ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 * @type {number} | 230 * @type {number} |
| 231 */ | 231 */ |
| 232 get selectedIndex() { | 232 get selectedIndex() { |
| 233 return this.selectedIndex_; | 233 return this.selectedIndex_; |
| 234 }, | 234 }, |
| 235 | 235 |
| 236 /** | 236 /** |
| 237 * Set the currently selected intents node ("intents bubble") index to | 237 * Set the currently selected intents node ("intents bubble") index to |
| 238 * @{code itemIndex}, unselecting any previously selected node first. | 238 * @{code itemIndex}, unselecting any previously selected node first. |
| 239 * @param {number} itemIndex The index to set as the selected index. | 239 * @param {number} itemIndex The index to set as the selected index. |
| 240 * TODO: KILL THIS | |
| 241 */ | 240 */ |
| 241 // TODO: KILL THIS |
| 242 set selectedIndex(itemIndex) { | 242 set selectedIndex(itemIndex) { |
| 243 // Get the list index up front before we change anything. | 243 // Get the list index up front before we change anything. |
| 244 var index = this.list.getIndexOfListItem(this); | 244 var index = this.list.getIndexOfListItem(this); |
| 245 // Unselect any previously selected item. | 245 // Unselect any previously selected item. |
| 246 if (this.selectedIndex_ >= 0) { | 246 if (this.selectedIndex_ >= 0) { |
| 247 var item = this.itemList_[this.selectedIndex_]; | 247 var item = this.itemList_[this.selectedIndex_]; |
| 248 if (item && item.div) | 248 if (item && item.div) |
| 249 item.div.removeAttribute('selected'); | 249 item.div.removeAttribute('selected'); |
| 250 } | 250 } |
| 251 // Special case: decrementing -1 wraps around to the end of the list. | 251 // Special case: decrementing -1 wraps around to the end of the list. |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 // Help out screen readers and such: this is a clickable thing. | 370 // Help out screen readers and such: this is a clickable thing. |
| 371 div.setAttribute('role', 'button'); | 371 div.setAttribute('role', 'button'); |
| 372 | 372 |
| 373 var divAction = item.ownerDocument.createElement('div'); | 373 var divAction = item.ownerDocument.createElement('div'); |
| 374 divAction.className = 'intents-item-action'; | 374 divAction.className = 'intents-item-action'; |
| 375 divAction.textContent = this.data.action; | 375 divAction.textContent = this.data.action; |
| 376 div.appendChild(divAction); | 376 div.appendChild(divAction); |
| 377 | 377 |
| 378 var divTypes = item.ownerDocument.createElement('div'); | 378 var divTypes = item.ownerDocument.createElement('div'); |
| 379 divTypes.className = 'intents-item-types'; | 379 divTypes.className = 'intents-item-types'; |
| 380 var text = ""; | 380 divTypes.textContent = this.data.types.join(', '); |
| 381 for (var i = 0; i < this.data.types.length; ++i) { | |
| 382 if (text != "") | |
| 383 text += ", "; | |
| 384 text += this.data.types[i]; | |
| 385 } | |
| 386 divTypes.textContent = text; | |
| 387 div.appendChild(divTypes); | 381 div.appendChild(divTypes); |
| 388 | 382 |
| 389 var divUrl = item.ownerDocument.createElement('div'); | 383 var divUrl = item.ownerDocument.createElement('div'); |
| 390 divUrl.className = 'intents-item-url'; | 384 divUrl.className = 'intents-item-url'; |
| 391 divUrl.textContent = this.data.url; | 385 divUrl.textContent = this.data.url; |
| 392 div.appendChild(divUrl); | 386 div.appendChild(divUrl); |
| 393 | 387 |
| 394 var index = item.appendItem(this, div); | 388 var index = item.appendItem(this, div); |
| 395 div.onclick = function() { | 389 div.onclick = function() { |
| 396 if (item.selectedIndex == index) | 390 if (item.selectedIndex == index) |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 parent.clear(); | 692 parent.clear(); |
| 699 this.addByParent_(parent, 0, children); | 693 this.addByParent_(parent, 0, children); |
| 700 parent.endBatchUpdates(); | 694 parent.endBatchUpdates(); |
| 701 }, | 695 }, |
| 702 }; | 696 }; |
| 703 | 697 |
| 704 return { | 698 return { |
| 705 IntentsList: IntentsList | 699 IntentsList: IntentsList |
| 706 }; | 700 }; |
| 707 }); | 701 }); |
| OLD | NEW |