OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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('print_preview', function() { | 5 cr.define('print_preview', function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 /** | 8 /** |
9 * Component that renders a destination item in a destination list. | 9 * Component that renders a destination item in a destination list. |
10 * @param {!cr.EventTarget} eventTarget Event target to dispatch selection | 10 * @param {!cr.EventTarget} eventTarget Event target to dispatch selection |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 this.updateUi_(); | 92 this.updateUi_(); |
93 }, | 93 }, |
94 | 94 |
95 /** | 95 /** |
96 * Called if the printer configuration request is accepted. Show the waiting | 96 * Called if the printer configuration request is accepted. Show the waiting |
97 * message to the user as the configuration might take longer than expected. | 97 * message to the user as the configuration might take longer than expected. |
98 */ | 98 */ |
99 onConfigureRequestAccepted: function() { | 99 onConfigureRequestAccepted: function() { |
100 // It must be a Chrome OS CUPS printer which hasn't been set up before. | 100 // It must be a Chrome OS CUPS printer which hasn't been set up before. |
101 assert( | 101 assert( |
102 this.destination_.origin == print_preview.Destination.Origin.CROS && | 102 this.destination_.origin == print_preview.DestinationOrigin.CROS && |
103 !this.destination_.capabilities); | 103 !this.destination_.capabilities); |
104 this.updateConfiguringMessage_(true); | 104 this.updateConfiguringMessage_(true); |
105 }, | 105 }, |
106 | 106 |
107 /** | 107 /** |
108 * Called if the printer configuration request is rejected. The request is | 108 * Called if the printer configuration request is rejected. The request is |
109 * rejected if another printer is setting up in process or the current | 109 * rejected if another printer is setting up in process or the current |
110 * printer doesn't need to be setup. | 110 * printer doesn't need to be setup. |
111 * @param {boolean} otherPrinterSetupInProgress | 111 * @param {boolean} otherPrinterSetupInProgress |
112 */ | 112 */ |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 // Initialize the element which renders the destination's offline status. | 200 // Initialize the element which renders the destination's offline status. |
201 this.getElement().classList.toggle('stale', this.destination_.isOffline); | 201 this.getElement().classList.toggle('stale', this.destination_.isOffline); |
202 var offlineStatusEl = this.getChildElement('.offline-status'); | 202 var offlineStatusEl = this.getChildElement('.offline-status'); |
203 offlineStatusEl.textContent = this.destination_.offlineStatusText; | 203 offlineStatusEl.textContent = this.destination_.offlineStatusText; |
204 setIsVisible(offlineStatusEl, this.destination_.isOffline); | 204 setIsVisible(offlineStatusEl, this.destination_.isOffline); |
205 | 205 |
206 // Initialize registration promo element for Privet unregistered printers. | 206 // Initialize registration promo element for Privet unregistered printers. |
207 setIsVisible( | 207 setIsVisible( |
208 this.getChildElement('.register-promo'), | 208 this.getChildElement('.register-promo'), |
209 this.destination_.connectionStatus == | 209 this.destination_.connectionStatus == |
210 print_preview.Destination.ConnectionStatus.UNREGISTERED); | 210 print_preview.DestinationConnectionStatus.UNREGISTERED); |
211 | 211 |
212 if (cr.isChromeOS) { | 212 if (cr.isChromeOS) { |
213 // Reset the configuring messages for CUPS printers. | 213 // Reset the configuring messages for CUPS printers. |
214 this.updateConfiguringMessage_(false); | 214 this.updateConfiguringMessage_(false); |
215 setIsVisible( | 215 setIsVisible( |
216 this.getChildElement('.configuring-failed-text'), false); | 216 this.getChildElement('.configuring-failed-text'), false); |
217 } | 217 } |
218 }, | 218 }, |
219 | 219 |
220 /** | 220 /** |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 this.eventTarget_.dispatchEvent(configureEvent); | 270 this.eventTarget_.dispatchEvent(configureEvent); |
271 }, | 271 }, |
272 | 272 |
273 /** | 273 /** |
274 * Called when the destination has been resolved successfully and needs to | 274 * Called when the destination has been resolved successfully and needs to |
275 * be activated. Dispatches a SELECT event on the given event target. | 275 * be activated. Dispatches a SELECT event on the given event target. |
276 * @private | 276 * @private |
277 */ | 277 */ |
278 onDestinationActivated_: function() { | 278 onDestinationActivated_: function() { |
279 if (this.destination_.connectionStatus != | 279 if (this.destination_.connectionStatus != |
280 print_preview.Destination.ConnectionStatus.UNREGISTERED) { | 280 print_preview.DestinationConnectionStatus.UNREGISTERED) { |
281 var selectEvt = new Event(DestinationListItem.EventType.SELECT); | 281 var selectEvt = new Event(DestinationListItem.EventType.SELECT); |
282 selectEvt.destination = this.destination_; | 282 selectEvt.destination = this.destination_; |
283 this.eventTarget_.dispatchEvent(selectEvt); | 283 this.eventTarget_.dispatchEvent(selectEvt); |
284 } | 284 } |
285 }, | 285 }, |
286 | 286 |
287 /** | 287 /** |
288 * Called when the key is pressed on the destination item. Dispatches a | 288 * Called when the key is pressed on the destination item. Dispatches a |
289 * SELECT event when Enter is pressed. | 289 * SELECT event when Enter is pressed. |
290 * @param {KeyboardEvent} e Keyboard event to process. | 290 * @param {KeyboardEvent} e Keyboard event to process. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 return; | 340 return; |
341 this.onExtensionIconClicked_(event); | 341 this.onExtensionIconClicked_(event); |
342 } | 342 } |
343 }; | 343 }; |
344 | 344 |
345 // Export | 345 // Export |
346 return { | 346 return { |
347 DestinationListItem: DestinationListItem | 347 DestinationListItem: DestinationListItem |
348 }; | 348 }; |
349 }); | 349 }); |
OLD | NEW |