OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 cr.define('options', function() { | 5 cr.define('options', function() { |
6 | 6 |
7 var OptionsPage = options.OptionsPage; | 7 var OptionsPage = options.OptionsPage; |
8 var Preferences = options.Preferences; | 8 var Preferences = options.Preferences; |
9 | 9 |
10 ///////////////////////////////////////////////////////////////////////////// | 10 ///////////////////////////////////////////////////////////////////////////// |
(...skipping 25 matching lines...) Expand all Loading... | |
36 } | 36 } |
37 | 37 |
38 ProxyOptions.prototype = { | 38 ProxyOptions.prototype = { |
39 // Inherit ProxyOptions from OptionsPage. | 39 // Inherit ProxyOptions from OptionsPage. |
40 __proto__: OptionsPage.prototype, | 40 __proto__: OptionsPage.prototype, |
41 | 41 |
42 /** | 42 /** |
43 * Initializes ProxyOptions page. | 43 * Initializes ProxyOptions page. |
44 */ | 44 */ |
45 initializePage: function() { | 45 initializePage: function() { |
46 // Call base class implementation to starts preference initialization. | 46 // Call base class implementation to start preference initialization. |
47 OptionsPage.prototype.initializePage.call(this); | 47 OptionsPage.prototype.initializePage.call(this); |
48 | 48 |
49 // Set up ignored page. | 49 // Set up ignored page. |
50 options.proxyexceptions.ProxyExceptions.decorate($('ignoredHostList')); | 50 options.proxyexceptions.ProxyExceptions.decorate($('ignoredHostList')); |
51 | 51 |
52 this.addEventListener('visibleChange', this.handleVisibleChange_); | 52 this.addEventListener('visibleChange', this.handleVisibleChange_); |
53 $('removeHost').addEventListener('click', this.handleRemoveExceptions_); | 53 $('removeHost').addEventListener('click', this.handleRemoveExceptions_); |
54 $('addHost').addEventListener('click', this.handleAddException_); | 54 $('addHost').addEventListener('click', this.handleAddException_); |
55 $('directProxy').addEventListener('click', this.disableManual_); | 55 $('directProxy').addEventListener('click', this.disableManual_); |
56 $('manualProxy').addEventListener('click', this.enableManual_); | 56 $('manualProxy').addEventListener('click', this.enableManual_); |
57 $('autoProxy').addEventListener('click', this.disableManual_); | 57 $('autoProxy').addEventListener('click', this.disableManual_); |
58 $('proxyAllProtocols').addEventListener('click', this.toggleSingle_); | 58 $('proxyAllProtocols').addEventListener('click', this.toggleSingle_); |
59 | 59 |
60 observePrefsUI($('directProxy')); | 60 observePrefsUI($('directProxy')); |
61 observePrefsUI($('manualProxy')); | 61 observePrefsUI($('manualProxy')); |
62 observePrefsUI($('autoProxy')); | 62 observePrefsUI($('autoProxy')); |
63 observePrefsUI($('proxyAllProtocols')); | 63 observePrefsUI($('proxyAllProtocols')); |
64 }, | 64 }, |
65 | 65 |
66 proxyListInitalized_: false, | 66 proxyListInitialized_: false, |
67 | 67 |
68 /** | 68 /** |
69 * Update controls state. | 69 * Update controls state. |
70 * @public | 70 * @public |
71 */ | 71 */ |
72 updateControls: function() { | 72 updateControls: function() { |
73 this.updateBannerVisibility_(); | |
73 this.toggleSingle_(); | 74 this.toggleSingle_(); |
74 if ($('manualProxy').checked) { | 75 if ($('manualProxy').checked) { |
75 this.enableManual_(); | 76 this.enableManual_(); |
76 } else { | 77 } else { |
77 this.disableManual_(); | 78 this.disableManual_(); |
78 } | 79 } |
79 if (!this.proxyListInitalized_ && this.visible) { | 80 if (!this.proxyListInitialized_ && this.visible) { |
80 this.proxyListInitalized_ = true; | 81 this.proxyListInitialized_ = true; |
81 $('ignoredHostList').redraw(); | 82 $('ignoredHostList').redraw(); |
82 } | 83 } |
83 }, | 84 }, |
84 | 85 |
85 /** | 86 /** |
86 * Handler for OptionsPage's visible property change event. | 87 * Handler for OptionsPage's visible property change event. |
87 * @private | 88 * @private |
88 * @param {Event} e Property change event. | 89 * @param {Event} e Property change event. |
89 */ | 90 */ |
90 handleVisibleChange_: function(e) { | 91 handleVisibleChange_: function(e) { |
91 this.updateControls(); | 92 this.updateControls(); |
92 }, | 93 }, |
93 | 94 |
94 /** | 95 /** |
96 * Updates info banner visibility state. This function shows the banner | |
97 * if proxy is managed or shared-proxies is off for shared network. | |
98 * @private | |
99 */ | |
100 updateBannerVisibility_: function() { | |
101 var bannerDiv = $('info-banner'); | |
102 var controlledBy = $('directProxy').controlledBy; | |
103 var clickable = false; | |
104 if (controlledBy == '') { | |
105 bannerDiv.hidden = true; | |
106 } else { | |
107 bannerDiv.hidden = false; | |
108 $('banner-text').textContent = | |
109 localStrings.getString(controlledBy); | |
xiyuan
2011/10/04 20:28:25
Let's put some comments here that controlledBy mus
kuan
2011/10/04 21:45:50
Done.
| |
110 clickable = controlledBy == "enableSharedProxiesBannerText"; | |
111 } | |
112 if (clickable) { | |
113 bannerDiv.classList.add("clickable"); | |
114 bannerDiv.addEventListener('click', this.handleSharedProxiesHint_); | |
115 } else { | |
116 bannerDiv.classList.remove("clickable"); | |
117 bannerDiv.removeEventListener('click', this.handleSharedProxiesHint_); | |
xiyuan
2011/10/04 20:28:25
Let's do this block before we add class/event list
kuan
2011/10/04 21:45:50
Done.
| |
118 } | |
119 }, | |
120 | |
121 /** | |
122 * Handler for "click" event on yellow banner with enable-shared-proxies | |
123 * hint. | |
124 * @private | |
125 * @param {Event} e Click event fired from info-banner. | |
126 */ | |
127 handleSharedProxiesHint_: function(e) { | |
128 OptionsPage.navigateToPage("internet"); | |
129 }, | |
130 | |
131 /** | |
95 * Handler for when the user clicks on the checkbox to allow a | 132 * Handler for when the user clicks on the checkbox to allow a |
96 * single proxy usage. | 133 * single proxy usage. |
97 * @private | 134 * @private |
98 * @param {Event} e Click Event. | 135 * @param {Event} e Click Event. |
99 */ | 136 */ |
100 toggleSingle_: function(e) { | 137 toggleSingle_: function(e) { |
101 if ($('proxyAllProtocols').checked) { | 138 if ($('proxyAllProtocols').checked) { |
102 $('multiProxy').style.display = 'none'; | 139 $('multiProxy').style.display = 'none'; |
103 $('singleProxy').style.display = 'block'; | 140 $('singleProxy').style.display = 'block'; |
104 } else { | 141 } else { |
105 $('multiProxy').style.display = 'block'; | 142 $('multiProxy').style.display = 'block'; |
106 $('singleProxy').style.display = 'none'; | 143 $('singleProxy').style.display = 'none'; |
107 } | 144 } |
108 }, | 145 }, |
109 | 146 |
110 /** | 147 /** |
111 * Handler for selecting a radio button that will disable the manual | 148 * Handler for selecting a radio button that will disable the manual |
112 * controls. | 149 * controls. |
113 * @private | 150 * @private |
114 * @param {Event} e Click event. | 151 * @param {Event} e Click event. |
115 */ | 152 */ |
116 disableManual_: function(e) { | 153 disableManual_: function(e) { |
154 $('advancedConfig').style.display = 'none'; | |
xiyuan
2011/10/04 20:28:25
nit: $('advancedConfig').hidden = true;
kuan
2011/10/04 21:45:50
Done.
| |
117 $('proxyAllProtocols').disabled = true; | 155 $('proxyAllProtocols').disabled = true; |
118 $('proxyHostName').disabled = true; | 156 $('proxyHostName').disabled = true; |
119 $('proxyHostPort').disabled = true; | 157 $('proxyHostPort').disabled = true; |
120 $('proxyHostSingleName').disabled = true; | 158 $('proxyHostSingleName').disabled = true; |
121 $('proxyHostSinglePort').disabled = true; | 159 $('proxyHostSinglePort').disabled = true; |
122 $('secureProxyHostName').disabled = true; | 160 $('secureProxyHostName').disabled = true; |
123 $('secureProxyPort').disabled = true; | 161 $('secureProxyPort').disabled = true; |
124 $('ftpProxy').disabled = true; | 162 $('ftpProxy').disabled = true; |
125 $('ftpProxyPort').disabled = true; | 163 $('ftpProxyPort').disabled = true; |
126 $('socksHost').disabled = true; | 164 $('socksHost').disabled = true; |
127 $('socksPort').disabled = true; | 165 $('socksPort').disabled = true; |
128 $('newHost').disabled = true; | 166 $('proxyConfig').disabled = $('autoProxy').disabled || |
129 $('removeHost').disabled = true; | 167 !$('autoProxy').checked; |
130 $('addHost').disabled = true; | |
131 $('advancedConfig').style.display = 'none'; | |
132 $('proxyConfig').disabled = !$('autoProxy').checked; | |
133 }, | 168 }, |
134 | 169 |
135 /** | 170 /** |
136 * Handler for selecting a radio button that will enable the manual | 171 * Handler for selecting a radio button that will enable the manual |
137 * controls. | 172 * controls. |
138 * @private | 173 * @private |
139 * @param {Event} e Click event. | 174 * @param {Event} e Click event. |
140 */ | 175 */ |
141 enableManual_: function(e) { | 176 enableManual_: function(e) { |
142 $('proxyAllProtocols').disabled = false; | |
143 $('proxyHostName').disabled = false; | |
144 $('proxyHostPort').disabled = false; | |
145 $('proxyHostSingleName').disabled = false; | |
146 $('proxyHostSinglePort').disabled = false; | |
147 $('secureProxyHostName').disabled = false; | |
148 $('secureProxyPort').disabled = false; | |
149 $('ftpProxy').disabled = false; | |
150 $('ftpProxyPort').disabled = false; | |
151 $('socksHost').disabled = false; | |
152 $('socksPort').disabled = false; | |
153 $('newHost').disabled = false; | |
154 $('removeHost').disabled = false; | |
155 $('addHost').disabled = false; | |
156 $('advancedConfig').style.display = '-webkit-box'; | 177 $('advancedConfig').style.display = '-webkit-box'; |
xiyuan
2011/10/04 20:28:25
nit: $('advancedConfig').hidden = false;
kuan
2011/10/04 21:45:50
Done.
| |
157 $('ignoredHostList').redraw(); | 178 $('ignoredHostList').redraw(); |
179 var all_disabled = $('manualProxy').disabled; | |
180 $('newHost').disabled = all_disabled; | |
181 $('removeHost').disabled = all_disabled; | |
182 $('addHost').disabled = all_disabled; | |
183 $('proxyAllProtocols').disabled = all_disabled; | |
184 $('proxyHostName').disabled = all_disabled; | |
185 $('proxyHostPort').disabled = all_disabled; | |
186 $('proxyHostSingleName').disabled = all_disabled; | |
187 $('proxyHostSinglePort').disabled = all_disabled; | |
188 $('secureProxyHostName').disabled = all_disabled; | |
189 $('secureProxyPort').disabled = all_disabled; | |
190 $('ftpProxy').disabled = all_disabled; | |
191 $('ftpProxyPort').disabled = all_disabled; | |
192 $('socksHost').disabled = all_disabled; | |
193 $('socksPort').disabled = all_disabled; | |
158 $('proxyConfig').disabled = true; | 194 $('proxyConfig').disabled = true; |
159 }, | 195 }, |
160 | 196 |
161 /** | 197 /** |
162 * Handler for "add" event fired from userNameEdit. | 198 * Handler for "add" event fired from userNameEdit. |
163 * @private | 199 * @private |
164 * @param {Event} e Add event fired from userNameEdit. | 200 * @param {Event} e Add event fired from userNameEdit. |
165 */ | 201 */ |
166 handleAddException_: function(e) { | 202 handleAddException_: function(e) { |
167 var exception = $('newHost').value; | 203 var exception = $('newHost').value; |
(...skipping 29 matching lines...) Expand all Loading... | |
197 ProxyOptions.setNetworkName = function(network) { | 233 ProxyOptions.setNetworkName = function(network) { |
198 ProxyOptions.getInstance().setNetworkName(network); | 234 ProxyOptions.getInstance().setNetworkName(network); |
199 }; | 235 }; |
200 | 236 |
201 // Export | 237 // Export |
202 return { | 238 return { |
203 ProxyOptions: ProxyOptions | 239 ProxyOptions: ProxyOptions |
204 }; | 240 }; |
205 | 241 |
206 }); | 242 }); |
OLD | NEW |