| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 /** | 5 /** |
| 6 * @fileoverview Polymer element for displaying a collapsable list of networks. | 6 * @fileoverview Polymer element for displaying a collapsable list of networks. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Polymer class definition for 'cr-network-list'. | 10 * Polymer class definition for 'cr-network-list'. |
| 11 */ | 11 */ |
| 12 Polymer({ | 12 Polymer({ |
| 13 is: 'cr-network-list', | 13 is: 'cr-network-list', |
| 14 | 14 |
| 15 properties: { | 15 properties: { |
| 16 /** | 16 /** |
| 17 * The maximum height in pixels for the list. | 17 * The maximum height in pixels for the list. |
| 18 */ | 18 */ |
| 19 maxHeight: { | 19 maxHeight: { |
| 20 type: Number, | 20 type: Number, |
| 21 value: 1000, | 21 value: 1000, |
| 22 observer: 'maxHeightChanged_', | 22 observer: 'maxHeightChanged_', |
| 23 }, | 23 }, |
| 24 | 24 |
| 25 /** | 25 /** |
| 26 * The list of network state properties for the items to display. | 26 * The list of network state properties for the items to display. |
| 27 * @type {!Array<!CrOnc.NetworkStateProperties>} | 27 * @type {!Array<!CrOnc.NetworkStateProperties>} |
| 28 */ | 28 */ |
| 29 networks: {type: Array, value: function() { return []; }}, | 29 networks: { |
| 30 type: Array, |
| 31 value: function() { |
| 32 return []; |
| 33 } |
| 34 }, |
| 30 | 35 |
| 31 /** | 36 /** |
| 32 * The list of custom items to display after the list of networks. | 37 * The list of custom items to display after the list of networks. |
| 33 * @type {!Array<!CrNetworkList.CustomItemState>} | 38 * @type {!Array<!CrNetworkList.CustomItemState>} |
| 34 */ | 39 */ |
| 35 customItems: {type: Array, value: function() { return []; }}, | 40 customItems: { |
| 41 type: Array, |
| 42 value: function() { |
| 43 return []; |
| 44 } |
| 45 }, |
| 36 | 46 |
| 37 /** True if action buttons should be shown for the itmes. */ | 47 /** True if action buttons should be shown for the itmes. */ |
| 38 showButtons: { | 48 showButtons: { |
| 39 type: Boolean, | 49 type: Boolean, |
| 40 value: false, | 50 value: false, |
| 41 reflectToAttribute: true, | 51 reflectToAttribute: true, |
| 42 }, | 52 }, |
| 43 | 53 |
| 44 /** Whether to show separators between all items. */ | 54 /** Whether to show separators between all items. */ |
| 45 showSeparators: { | 55 showSeparators: { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 61 behaviors: [CrScrollableBehavior], | 71 behaviors: [CrScrollableBehavior], |
| 62 | 72 |
| 63 observers: ['listChanged_(networks, customItems)'], | 73 observers: ['listChanged_(networks, customItems)'], |
| 64 | 74 |
| 65 /** @private */ | 75 /** @private */ |
| 66 maxHeightChanged_: function() { | 76 maxHeightChanged_: function() { |
| 67 this.$.container.style.maxHeight = this.maxHeight + 'px'; | 77 this.$.container.style.maxHeight = this.maxHeight + 'px'; |
| 68 }, | 78 }, |
| 69 | 79 |
| 70 /** @private */ | 80 /** @private */ |
| 71 listChanged_: function() { this.updateScrollableContents(); }, | 81 listChanged_: function() { |
| 82 this.updateScrollableContents(); |
| 83 }, |
| 72 | 84 |
| 73 /** | 85 /** |
| 74 * Returns a combined list of networks and custom items. | 86 * Returns a combined list of networks and custom items. |
| 75 * @return {!Array<!CrNetworkList.CrNetworkListItemType>} | 87 * @return {!Array<!CrNetworkList.CrNetworkListItemType>} |
| 76 * @private | 88 * @private |
| 77 */ | 89 */ |
| 78 getItems_: function() { | 90 getItems_: function() { |
| 79 let customItems = this.customItems.slice(); | 91 let customItems = this.customItems.slice(); |
| 80 // Flag the first custom item with isFirstCustomItem = true. | 92 // Flag the first custom item with isFirstCustomItem = true. |
| 81 if (!this.showSeparators && customItems.length > 0) | 93 if (!this.showSeparators && customItems.length > 0) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 97 * @param {!CrNetworkList.CrNetworkListItemType} item | 109 * @param {!CrNetworkList.CrNetworkListItemType} item |
| 98 * @private | 110 * @private |
| 99 */ | 111 */ |
| 100 onItemAction_: function(item) { | 112 onItemAction_: function(item) { |
| 101 if (item.hasOwnProperty('customItemName')) | 113 if (item.hasOwnProperty('customItemName')) |
| 102 this.fire('custom-item-selected', item); | 114 this.fire('custom-item-selected', item); |
| 103 else | 115 else |
| 104 this.fire('selected', item); | 116 this.fire('selected', item); |
| 105 }, | 117 }, |
| 106 }); | 118 }); |
| OLD | NEW |