| <link rel="import" href="../../third-party/polymer/polymer.html"> |
| <link rel="import" href="../../third-party/core-list/core-list.html"> |
| <link rel="import" href="../../third-party/core-item/core-item.html"> |
| <polymer-element name="p2b-namespace-list" attributes="names selectable"> |
| <link rel="stylesheet" href="component.css"> |
| <template if="{{_items.length > 0}}"> |
| <core-list selectable?="{{selectable}}" height="40" on-core-activate="{{fireSelectEvent}}" data="{{_items}}" height="20"> |
| <core-item class="{{ {selected: selected} | tokenList }}" label="{{name}}"></core-item> |
| Polymer('p2b-namespace-list', { |
| * List of names to be displayed |
| * Whether the names displayed are selectable |
| * if selectable, 'select' event will fire with the name of the selected item |
| * transformed collection of names to objects |
| namesChanged: function() { |
| // transform from [string] to [object] since core-items expects array of objects |
| this._items = this.names.map( function(n) { |
| * fires the select event pass the name as event argument |
| fireSelectEvent: function(e) { |
| this.fire('select', e.detail.data.name); |