| OLD | NEW |
| (Empty) |
| 1 <!-- | |
| 2 Copyright 2014 The Chromium Authors. All rights reserved. | |
| 3 Use of this source code is governed by a BSD-style license that can be | |
| 4 found in the LICENSE file. | |
| 5 --> | |
| 6 | |
| 7 <polymer-element name="ct-tree-select" attributes="tree treeList"> | |
| 8 <template> | |
| 9 <select id='treeSelect' on-change="{{ _updateTree }}" value="{{ tree }}"> | |
| 10 <template repeat="{{ s in treeList.trees }}"> | |
| 11 <option value="{{ s.name }}">{{ s.displayName }}</option> | |
| 12 </template> | |
| 13 </select> | |
| 14 </template> | |
| 15 <script> | |
| 16 (function() { | |
| 17 Polymer({ | |
| 18 publish: { | |
| 19 tree: { | |
| 20 reflect: true, | |
| 21 }, | |
| 22 }, | |
| 23 | |
| 24 _updateTree: function(event) { | |
| 25 this.asyncFire('navigate', { | |
| 26 url: event.target.value | |
| 27 }); | |
| 28 }, | |
| 29 | |
| 30 treeChanged: function() { | |
| 31 if (!this.tree.length) | |
| 32 return; | |
| 33 | |
| 34 // Enforce the tree list, so we don't show a blank select value. | |
| 35 var option = this.$.treeSelect.querySelector('option[value="' + this.tre
e + '"]'); | |
| 36 if (!option) { | |
| 37 // URL is incorrect. Replace with the root so we use the default tree. | |
| 38 this.asyncFire('navigate', { | |
| 39 url: '/', | |
| 40 replaceState: true | |
| 41 }); | |
| 42 } | |
| 43 }, | |
| 44 }); | |
| 45 })(); | |
| 46 </script> | |
| 47 </polymer-element> | |
| OLD | NEW |