OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * @fileoverview Polymer element for network configuration selection menus. |
| 7 */ |
| 8 Polymer({ |
| 9 is: 'network-config-select', |
| 10 |
| 11 behaviors: [I18nBehavior], |
| 12 |
| 13 properties: { |
| 14 label: String, |
| 15 |
| 16 disabled: Boolean, |
| 17 |
| 18 /** |
| 19 * Array of item values to select from. |
| 20 * @type {!Array<string>} |
| 21 */ |
| 22 items: Array, |
| 23 |
| 24 /** Prefix used to look up ONC property names. */ |
| 25 oncPrefix: String, |
| 26 |
| 27 /** Select item value */ |
| 28 value: { |
| 29 type: String, |
| 30 notify: true, |
| 31 }, |
| 32 }, |
| 33 |
| 34 observers: ['updateSelected_(items, value)'], |
| 35 |
| 36 /** |
| 37 * Ensure that the <select> value is updated when |items| or |value| changes. |
| 38 * @private |
| 39 */ |
| 40 updateSelected_: function() { |
| 41 // Wait for the dom-repeat to populate the <option> entries. |
| 42 this.async(function() { |
| 43 var select = this.$$('select'); |
| 44 if (select.value != this.value) |
| 45 select.value = this.value; |
| 46 }); |
| 47 }, |
| 48 |
| 49 /** |
| 50 * @param {string} key |
| 51 * @param {string} prefix |
| 52 * @return {string} The text to display for the onc value. |
| 53 * @private |
| 54 */ |
| 55 getOncLabel_: function(key, prefix) { |
| 56 var oncKey = 'Onc' + prefix.replace(/\./g, '-') + '_' + key; |
| 57 if (this.i18nExists(oncKey)) |
| 58 return this.i18n(oncKey); |
| 59 assertNotReached(); |
| 60 return key; |
| 61 }, |
| 62 }); |
OLD | NEW |