OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 DeletableItemList = options.DeletableItemList; | 6 const DeletableItemList = options.DeletableItemList; |
7 const DeletableItem = options.DeletableItem; | 7 const DeletableItem = options.DeletableItem; |
8 const ArrayDataModel = cr.ui.ArrayDataModel; | 8 const ArrayDataModel = cr.ui.ArrayDataModel; |
9 const ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; | 9 const ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; |
10 | 10 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 | 94 |
95 /** @inheritDoc */ | 95 /** @inheritDoc */ |
96 decorate: function() { | 96 decorate: function() { |
97 this.siteChild = this.ownerDocument.createElement('div'); | 97 this.siteChild = this.ownerDocument.createElement('div'); |
98 this.siteChild.className = 'cookie-site'; | 98 this.siteChild.className = 'cookie-site'; |
99 this.dataChild = this.ownerDocument.createElement('div'); | 99 this.dataChild = this.ownerDocument.createElement('div'); |
100 this.dataChild.className = 'cookie-data'; | 100 this.dataChild.className = 'cookie-data'; |
101 this.itemsChild = this.ownerDocument.createElement('div'); | 101 this.itemsChild = this.ownerDocument.createElement('div'); |
102 this.itemsChild.className = 'cookie-items'; | 102 this.itemsChild.className = 'cookie-items'; |
103 this.infoChild = this.ownerDocument.createElement('div'); | 103 this.infoChild = this.ownerDocument.createElement('div'); |
104 this.infoChild.className = 'cookie-details hidden'; | 104 this.infoChild.className = 'cookie-details'; |
| 105 this.infoChild.hidden = true; |
105 var remove = this.ownerDocument.createElement('button'); | 106 var remove = this.ownerDocument.createElement('button'); |
106 remove.textContent = localStrings.getString('remove_cookie'); | 107 remove.textContent = localStrings.getString('remove_cookie'); |
107 remove.onclick = this.removeCookie_.bind(this); | 108 remove.onclick = this.removeCookie_.bind(this); |
108 this.infoChild.appendChild(remove); | 109 this.infoChild.appendChild(remove); |
109 var content = this.contentElement; | 110 var content = this.contentElement; |
110 content.appendChild(this.siteChild); | 111 content.appendChild(this.siteChild); |
111 content.appendChild(this.dataChild); | 112 content.appendChild(this.dataChild); |
112 content.appendChild(this.itemsChild); | 113 content.appendChild(this.itemsChild); |
113 this.itemsChild.appendChild(this.infoChild); | 114 this.itemsChild.appendChild(this.infoChild); |
114 if (this.origin && this.origin.data) { | 115 if (this.origin && this.origin.data) { |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 }, | 231 }, |
231 | 232 |
232 /** | 233 /** |
233 * Updates the items section to reflect changes, animating to the new state. | 234 * Updates the items section to reflect changes, animating to the new state. |
234 * Removes existing contents and calls @{code CookieTreeNode.createItems}. | 235 * Removes existing contents and calls @{code CookieTreeNode.createItems}. |
235 * @private | 236 * @private |
236 */ | 237 */ |
237 updateItems_: function() { | 238 updateItems_: function() { |
238 this.disableAnimation_(); | 239 this.disableAnimation_(); |
239 this.itemsChild.textContent = ''; | 240 this.itemsChild.textContent = ''; |
240 this.infoChild.classList.add('hidden'); | 241 this.infoChild.hidden = true; |
241 this.selectedIndex_ = -1; | 242 this.selectedIndex_ = -1; |
242 this.itemList_ = []; | 243 this.itemList_ = []; |
243 if (this.origin) | 244 if (this.origin) |
244 this.origin.createItems(this); | 245 this.origin.createItems(this); |
245 this.itemsChild.appendChild(this.infoChild); | 246 this.itemsChild.appendChild(this.infoChild); |
246 this.enableAnimation_(); | 247 this.enableAnimation_(); |
247 }, | 248 }, |
248 | 249 |
249 /** | 250 /** |
250 * Append a new cookie node "bubble" to this list item. | 251 * Append a new cookie node "bubble" to this list item. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 if (item && item.div) | 288 if (item && item.div) |
288 item.div.removeAttribute('selected'); | 289 item.div.removeAttribute('selected'); |
289 } | 290 } |
290 // Special case: decrementing -1 wraps around to the end of the list. | 291 // Special case: decrementing -1 wraps around to the end of the list. |
291 if (itemIndex == -2) | 292 if (itemIndex == -2) |
292 itemIndex = this.itemList_.length - 1; | 293 itemIndex = this.itemList_.length - 1; |
293 // Check if we're going out of bounds and hide the item details. | 294 // Check if we're going out of bounds and hide the item details. |
294 if (itemIndex < 0 || itemIndex >= this.itemList_.length) { | 295 if (itemIndex < 0 || itemIndex >= this.itemList_.length) { |
295 this.selectedIndex_ = -1; | 296 this.selectedIndex_ = -1; |
296 this.disableAnimation_(); | 297 this.disableAnimation_(); |
297 this.infoChild.classList.add('hidden'); | 298 this.infoChild.hidden = true; |
298 this.enableAnimation_(); | 299 this.enableAnimation_(); |
299 return; | 300 return; |
300 } | 301 } |
301 // Set the new selected item and show the item details for it. | 302 // Set the new selected item and show the item details for it. |
302 this.selectedIndex_ = itemIndex; | 303 this.selectedIndex_ = itemIndex; |
303 this.itemList_[itemIndex].div.setAttribute('selected', ''); | 304 this.itemList_[itemIndex].div.setAttribute('selected', ''); |
304 this.disableAnimation_(); | 305 this.disableAnimation_(); |
305 this.itemList_[itemIndex].node.setDetailText(this.infoChild, | 306 this.itemList_[itemIndex].node.setDetailText(this.infoChild, |
306 this.list.infoNodes); | 307 this.list.infoNodes); |
307 this.infoChild.classList.remove('hidden'); | 308 this.infoChild.hidden = false; |
308 this.enableAnimation_(); | 309 this.enableAnimation_(); |
309 // If we're near the bottom of the list this may cause the list item to go | 310 // If we're near the bottom of the list this may cause the list item to go |
310 // beyond the end of the visible area. Fix it after the animation is done. | 311 // beyond the end of the visible area. Fix it after the animation is done. |
311 var list = this.list; | 312 var list = this.list; |
312 window.setTimeout(function() { list.scrollIndexIntoView(index); }, 150); | 313 window.setTimeout(function() { list.scrollIndexIntoView(index); }, 150); |
313 }, | 314 }, |
314 }; | 315 }; |
315 | 316 |
316 /** | 317 /** |
317 * {@code CookieTreeNode}s mirror the structure of the cookie tree lazily, and | 318 * {@code CookieTreeNode}s mirror the structure of the cookie tree lazily, and |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 parent.clear(); | 810 parent.clear(); |
810 this.addByParent_(parent, 0, children); | 811 this.addByParent_(parent, 0, children); |
811 parent.endBatchUpdates(); | 812 parent.endBatchUpdates(); |
812 }, | 813 }, |
813 }; | 814 }; |
814 | 815 |
815 return { | 816 return { |
816 CookiesList: CookiesList | 817 CookiesList: CookiesList |
817 }; | 818 }; |
818 }); | 819 }); |
OLD | NEW |