Chromium Code Reviews| 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 var text = ''; |
| 381 for (var i = 0; i < this.data.types.length; ++i) { | 381 for (var i = 0; i < this.data.types.length; ++i) { |
| 382 if (text != "") | 382 if (text != '') |
| 383 text += ", "; | 383 text += ', '; |
| 384 text += this.data.types[i]; | 384 text += this.data.types[i]; |
| 385 } | 385 } |
| 386 divTypes.textContent = text; | 386 divTypes.textContent = text; |
| 387 div.appendChild(divTypes); | 387 div.appendChild(divTypes); |
| 388 | 388 |
| 389 var divUrl = item.ownerDocument.createElement('div'); | 389 var divUrl = item.ownerDocument.createElement('div'); |
| 390 divUrl.className = 'intents-item-url'; | 390 divUrl.className = 'intents-item-url'; |
| 391 divUrl.textContent = this.data.url; | 391 divUrl.textContent = this.data.url; |
| 392 div.appendChild(divUrl); | 392 div.appendChild(divUrl); |
| 393 | 393 |
| 394 var index = item.appendItem(this, div); | 394 var index = item.appendItem(this, div); |
| 395 div.onclick = function() { | 395 div.onclick = function() { |
| 396 if (item.selectedIndex == index) | 396 if (item.selectedIndex == index) |
| 397 item.selectedIndex = -1; | 397 item.selectedIndex = -1; |
| 398 else | 398 else |
| 399 item.selectedIndex = index; | 399 item.selectedIndex = index; |
| 400 }; | 400 }; |
| 401 } | 401 } |
| 402 }, | 402 }, |
| 403 | 403 |
| 404 /** | 404 /** |
| 405 * The parent of this intents tree node. | 405 * The parent of this intents tree node. |
| 406 * @type {?IntentsTreeNode|IntentsListItem} | 406 * @type {?IntentsTreeNode|IntentsListItem} |
|
Tyler Breisacher (Chromium)
2012/02/03 01:23:18
Got E0231 here too.
| |
| 407 */ | 407 */ |
| 408 get parent(parent) { | 408 get parent(parent) { |
| 409 // See below for an explanation of this special case. | 409 // See below for an explanation of this special case. |
| 410 if (typeof this.parent_ == 'number') | 410 if (typeof this.parent_ == 'number') |
| 411 return this.list_.getListItemByIndex(this.parent_); | 411 return this.list_.getListItemByIndex(this.parent_); |
| 412 return this.parent_; | 412 return this.parent_; |
| 413 }, | 413 }, |
| 414 set parent(parent) { | 414 set parent(parent) { |
| 415 if (parent == this.parent) | 415 if (parent == this.parent) |
| 416 return; | 416 return; |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 698 parent.clear(); | 698 parent.clear(); |
| 699 this.addByParent_(parent, 0, children); | 699 this.addByParent_(parent, 0, children); |
| 700 parent.endBatchUpdates(); | 700 parent.endBatchUpdates(); |
| 701 }, | 701 }, |
| 702 }; | 702 }; |
| 703 | 703 |
| 704 return { | 704 return { |
| 705 IntentsList: IntentsList | 705 IntentsList: IntentsList |
| 706 }; | 706 }; |
| 707 }); | 707 }); |
| OLD | NEW |