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 and editing a single | 6 * @fileoverview Polymer element for displaying and editing a single |
7 * network proxy value. When the URL or port changes, a 'proxy-change' event is | 7 * network proxy value. When the URL or port changes, a 'proxy-change' event is |
8 * fired with the combined url and port values passed as a single string, | 8 * fired with the combined url and port values passed as a single string, |
9 * url:port. | 9 * url:port. |
10 */ | 10 */ |
11 Polymer({ | 11 Polymer({ |
12 is: 'network-proxy-input', | 12 is: 'network-proxy-input', |
13 | 13 |
14 properties: { | 14 properties: { |
15 /** | 15 /** |
16 * Whether or not the proxy value can be edited. | 16 * Whether or not the proxy value can be edited. |
17 */ | 17 */ |
18 editable: { | 18 editable: { |
19 type: Boolean, | 19 type: Boolean, |
20 value: false | 20 value: false, |
21 }, | 21 }, |
22 | 22 |
23 /** | 23 /** |
24 * A label for the proxy value. | 24 * A label for the proxy value. |
25 */ | 25 */ |
26 label: { | 26 label: { |
27 type: String, | 27 type: String, |
28 value: 'Proxy' | 28 value: 'Proxy', |
29 }, | 29 }, |
30 | 30 |
31 /** | 31 /** |
32 * The proxy object. | 32 * The proxy object. |
33 * @type {!CrOnc.ProxyLocation} | 33 * @type {!CrOnc.ProxyLocation} |
34 */ | 34 */ |
35 value: { | 35 value: { |
36 type: Object, | 36 type: Object, |
37 value: function() { return {Host: '', Port: 80}; }, | 37 value: function() { |
38 notify: true | 38 return {Host: '', Port: 80}; |
| 39 }, |
| 40 notify: true, |
39 }, | 41 }, |
40 }, | 42 }, |
41 | 43 |
42 /** | 44 /** |
43 * Event triggered when an input value changes. | 45 * Event triggered when an input value changes. |
44 * @private | 46 * @private |
45 */ | 47 */ |
46 onValueChange_: function() { | 48 onValueChange_: function() { |
| 49 if (!this.value.Host) |
| 50 return; |
47 var port = parseInt(this.value.Port, 10); | 51 var port = parseInt(this.value.Port, 10); |
48 if (isNaN(port)) | 52 if (isNaN(port)) |
49 port = 80; | 53 port = 80; |
50 this.value.Port = port; | 54 this.value.Port = port; |
51 this.fire('proxy-change', {value: this.value}); | 55 this.fire('proxy-change', {value: this.value}); |
52 } | 56 } |
53 }); | 57 }); |
OLD | NEW |