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 * The |name| is shown in the gui. The |value| us use to set or compare with | 6 * The |name| is shown in the gui. The |value| us use to set or compare with |
7 * the preference value. | 7 * the preference value. |
8 * @typedef {{ | 8 * @typedef {{ |
9 * name: string, | 9 * name: string, |
10 * value: (number|string) | 10 * value: (number|string) |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 if (this.menuOptions === null || !this.menuOptions.length) | 90 if (this.menuOptions === null || !this.menuOptions.length) |
91 return; | 91 return; |
92 | 92 |
93 var prefValue = this.pref.value; | 93 var prefValue = this.pref.value; |
94 var option = this.menuOptions.find(function(menuItem) { | 94 var option = this.menuOptions.find(function(menuItem) { |
95 return menuItem.value == prefValue; | 95 return menuItem.value == prefValue; |
96 }); | 96 }); |
97 | 97 |
98 // Wait for the dom-repeat to populate the <select> before setting | 98 // Wait for the dom-repeat to populate the <select> before setting |
99 // <select>#value so the correct option gets selected. | 99 // <select>#value so the correct option gets selected. |
100 this.async(function() { | 100 this.async(() => { |
101 this.$.dropdownMenu.value = option == undefined ? | 101 this.$.dropdownMenu.value = option == undefined ? |
102 this.notFoundValue_ : | 102 this.notFoundValue_ : |
103 Settings.PrefUtil.prefToString(assert(this.pref)); | 103 Settings.PrefUtil.prefToString(assert(this.pref)); |
104 }.bind(this)); | 104 }); |
105 }, | 105 }, |
106 | 106 |
107 /** | 107 /** |
108 * @param {?DropdownMenuOptionList} menuOptions | 108 * @param {?DropdownMenuOptionList} menuOptions |
109 * @param {string} prefValue | 109 * @param {string} prefValue |
110 * @return {boolean} | 110 * @return {boolean} |
111 * @private | 111 * @private |
112 */ | 112 */ |
113 showNotFoundValue_: function(menuOptions, prefValue) { | 113 showNotFoundValue_: function(menuOptions, prefValue) { |
114 // Don't show "Custom" before the options load. | 114 // Don't show "Custom" before the options load. |
115 if (!menuOptions || !menuOptions.length) | 115 if (!menuOptions || !menuOptions.length) |
116 return false; | 116 return false; |
117 | 117 |
118 var option = menuOptions.find(function(menuItem) { | 118 var option = menuOptions.find(function(menuItem) { |
119 return menuItem.value == prefValue; | 119 return menuItem.value == prefValue; |
120 }); | 120 }); |
121 return !option; | 121 return !option; |
122 }, | 122 }, |
123 | 123 |
124 /** | 124 /** |
125 * @return {boolean} | 125 * @return {boolean} |
126 * @private | 126 * @private |
127 */ | 127 */ |
128 shouldDisableMenu_: function() { | 128 shouldDisableMenu_: function() { |
129 return this.disabled || this.isPrefEnforced() || | 129 return this.disabled || this.isPrefEnforced() || |
130 this.menuOptions === null || this.menuOptions.length == 0; | 130 this.menuOptions === null || this.menuOptions.length == 0; |
131 }, | 131 }, |
132 }); | 132 }); |
OLD | NEW |