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 // TODO(rltoscano): Move data/* into print_preview.data namespace | 5 // TODO(rltoscano): Move data/* into print_preview.data namespace |
6 | 6 |
7 var localStrings = new LocalStrings(templateData); | 7 var localStrings = new LocalStrings(templateData); |
8 | 8 |
9 <include src="component.js"/> | 9 <include src="component.js"/> |
10 | 10 |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 | 279 |
280 this.tracker.add( | 280 this.tracker.add( |
281 this.destinationStore_, | 281 this.destinationStore_, |
282 print_preview.DestinationStore.EventType. | 282 print_preview.DestinationStore.EventType. |
283 SELECTED_DESTINATION_CAPABILITIES_READY, | 283 SELECTED_DESTINATION_CAPABILITIES_READY, |
284 this.printIfReady_.bind(this)); | 284 this.printIfReady_.bind(this)); |
285 this.tracker.add( | 285 this.tracker.add( |
286 this.destinationStore_, | 286 this.destinationStore_, |
287 print_preview.DestinationStore.EventType.DESTINATION_SELECT, | 287 print_preview.DestinationStore.EventType.DESTINATION_SELECT, |
288 this.onDestinationSelect_.bind(this)); | 288 this.onDestinationSelect_.bind(this)); |
| 289 this.tracker.add( |
| 290 this.destinationStore_, |
| 291 print_preview.DestinationStore.EventType.DESTINATION_SEARCH_DONE, |
| 292 this.onDestinationSearchDone_.bind(this)); |
289 | 293 |
290 this.tracker.add( | 294 this.tracker.add( |
291 this.printHeader_, | 295 this.printHeader_, |
292 print_preview.PrintHeader.EventType.PRINT_BUTTON_CLICK, | 296 print_preview.PrintHeader.EventType.PRINT_BUTTON_CLICK, |
293 this.onPrintButtonClick_.bind(this)); | 297 this.onPrintButtonClick_.bind(this)); |
294 this.tracker.add( | 298 this.tracker.add( |
295 this.printHeader_, | 299 this.printHeader_, |
296 print_preview.PrintHeader.EventType.CANCEL_BUTTON_CLICK, | 300 print_preview.PrintHeader.EventType.CANCEL_BUTTON_CLICK, |
297 this.onCancelButtonClick_.bind(this)); | 301 this.onCancelButtonClick_.bind(this)); |
298 | 302 |
299 this.tracker.add(window, 'keydown', this.onKeyDown_.bind(this)); | 303 this.tracker.add(window, 'keydown', this.onKeyDown_.bind(this)); |
300 | 304 |
301 this.tracker.add( | 305 this.tracker.add( |
302 this.destinationSettings_, | 306 this.destinationSettings_, |
303 print_preview.DestinationSettings.EventType.CHANGE_BUTTON_ACTIVATE, | 307 print_preview.DestinationSettings.EventType.CHANGE_BUTTON_ACTIVATE, |
304 this.onDestinationChangeButtonActivate_.bind(this)); | 308 this.onDestinationChangeButtonActivate_.bind(this)); |
305 | 309 |
306 this.tracker.add( | 310 this.tracker.add( |
307 this.destinationSearch_, | 311 this.destinationSearch_, |
308 print_preview.DestinationSearch.EventType.MANAGE_CLOUD_DESTINATIONS, | 312 print_preview.DestinationSearch.EventType.MANAGE_CLOUD_DESTINATIONS, |
309 this.onManageCloudDestinationsActivated_.bind(this)); | 313 this.onManageCloudDestinationsActivated_.bind(this)); |
310 this.tracker.add( | 314 this.tracker.add( |
311 this.destinationSearch_, | 315 this.destinationSearch_, |
312 print_preview.DestinationSearch.EventType.MANAGE_LOCAL_DESTINATIONS, | 316 print_preview.DestinationSearch.EventType.MANAGE_LOCAL_DESTINATIONS, |
313 this.onManageLocalDestinationsActivated_.bind(this)); | 317 this.onManageLocalDestinationsActivated_.bind(this)); |
314 this.tracker.add( | 318 this.tracker.add( |
315 this.destinationSearch_, | 319 this.destinationSearch_, |
316 print_preview.DestinationSearch.EventType.SIGN_IN, | 320 print_preview.DestinationSearch.EventType.SIGN_IN, |
317 this.onCloudPrintSignInActivated_.bind(this)); | 321 this.onCloudPrintSignInActivated_.bind(this)); |
| 322 |
| 323 // TODO(rltoscano): Move no-destinations-promo into its own component |
| 324 // instead being part of PrintPreview. |
| 325 this.tracker.add( |
| 326 this.getChildElement('#no-destinations-promo .close-button'), |
| 327 'click', |
| 328 this.onNoDestinationsPromoClose_.bind(this)); |
| 329 this.tracker.add( |
| 330 this.getChildElement('#no-destinations-promo .not-now-button'), |
| 331 'click', |
| 332 this.onNoDestinationsPromoClose_.bind(this)); |
| 333 this.tracker.add( |
| 334 this.getChildElement('#no-destinations-promo .add-printer-button'), |
| 335 'click', |
| 336 this.onNoDestinationsPromoClick_.bind(this)); |
318 }, | 337 }, |
319 | 338 |
320 /** @override */ | 339 /** @override */ |
321 decorateInternal: function() { | 340 decorateInternal: function() { |
322 this.printHeader_.decorate($('print-header')); | 341 this.printHeader_.decorate($('print-header')); |
323 this.destinationSearch_.decorate($('destination-search')); | 342 this.destinationSearch_.decorate($('destination-search')); |
324 this.destinationSettings_.decorate($('destination-settings')); | 343 this.destinationSettings_.decorate($('destination-settings')); |
325 this.pageSettings_.decorate($('page-settings')); | 344 this.pageSettings_.decorate($('page-settings')); |
326 this.copiesSettings_.decorate($('copies-settings')); | 345 this.copiesSettings_.decorate($('copies-settings')); |
327 this.layoutSettings_.decorate($('layout-settings')); | 346 this.layoutSettings_.decorate($('layout-settings')); |
328 this.colorSettings_.decorate($('color-settings')); | 347 this.colorSettings_.decorate($('color-settings')); |
329 this.marginSettings_.decorate($('margin-settings')); | 348 this.marginSettings_.decorate($('margin-settings')); |
330 this.otherOptionsSettings_.decorate($('other-options-settings')); | 349 this.otherOptionsSettings_.decorate($('other-options-settings')); |
331 this.previewArea_.decorate($('preview-area')); | 350 this.previewArea_.decorate($('preview-area')); |
332 | 351 |
| 352 // Set some of the parameterized text in the no-destinations promotion. |
| 353 var noDestsPromoGcpDescription = |
| 354 this.getChildElement('#no-destinations-promo .gcp-description'); |
| 355 noDestsPromoGcpDescription.innerHTML = localStrings.getStringF( |
| 356 'noDestsPromoGcpDesc', |
| 357 '<a target="_blank" href="http://www.google.com/cloudprint/learn/">', |
| 358 '</a>'); |
| 359 |
333 setIsVisible($('open-pdf-in-preview-link'), cr.isMac); | 360 setIsVisible($('open-pdf-in-preview-link'), cr.isMac); |
334 }, | 361 }, |
335 | 362 |
336 /** | 363 /** |
337 * Sets whether the controls in the print preview are enabled. | 364 * Sets whether the controls in the print preview are enabled. |
338 * @param {boolean} isEnabled Whether the controls in the print preview are | 365 * @param {boolean} isEnabled Whether the controls in the print preview are |
339 * enabled. | 366 * enabled. |
340 * @private | 367 * @private |
341 */ | 368 */ |
342 setIsEnabled_: function(isEnabled) { | 369 setIsEnabled_: function(isEnabled) { |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 | 800 |
774 /** | 801 /** |
775 * Called when a print destination is selected. Shows/hides the "Print with | 802 * Called when a print destination is selected. Shows/hides the "Print with |
776 * Cloud Print" link in the navbar. | 803 * Cloud Print" link in the navbar. |
777 * @private | 804 * @private |
778 */ | 805 */ |
779 onDestinationSelect_: function() { | 806 onDestinationSelect_: function() { |
780 var selectedDest = this.destinationStore_.selectedDestination; | 807 var selectedDest = this.destinationStore_.selectedDestination; |
781 setIsVisible($('cloud-print-dialog-link'), | 808 setIsVisible($('cloud-print-dialog-link'), |
782 !cr.isChromeOS && !selectedDest.isLocal); | 809 !cr.isChromeOS && !selectedDest.isLocal); |
| 810 }, |
| 811 |
| 812 /** |
| 813 * Called when the destination store loads a group of destinations. Shows |
| 814 * a promo on Chrome OS if the user has no print destinations promoting |
| 815 * Google Cloud Print. |
| 816 * @private |
| 817 */ |
| 818 onDestinationSearchDone_: function() { |
| 819 var isPromoVisible = cr.isChromeOS && |
| 820 this.cloudPrintInterface_ && |
| 821 this.userInfo_.getUserEmail() && |
| 822 !this.appState_.isGcpPromoDismissed && |
| 823 !this.destinationStore_.isLocalDestinationsSearchInProgress && |
| 824 !this.destinationStore_.isCloudDestinationsSearchInProgress && |
| 825 this.destinationStore_.hasOnlyDefaultCloudDestinations(); |
| 826 setIsVisible(this.getChildElement('#no-destinations-promo'), |
| 827 isPromoVisible); |
| 828 if (isPromoVisible) { |
| 829 this.metrics_.incrementGcpPromoBucket( |
| 830 print_preview.Metrics.GcpPromoBucket.SHOWN); |
| 831 } |
| 832 }, |
| 833 |
| 834 /** |
| 835 * Called when the close button on the no-destinations-promotion is clicked. |
| 836 * Hides the promotion. |
| 837 * @private |
| 838 */ |
| 839 onNoDestinationsPromoClose_: function() { |
| 840 this.metrics_.incrementGcpPromoBucket( |
| 841 print_preview.Metrics.GcpPromoBucket.DISMISSED); |
| 842 setIsVisible(this.getChildElement('#no-destinations-promo'), false); |
| 843 this.appState_.persistIsGcpPromoDismissed(true); |
| 844 }, |
| 845 |
| 846 /** |
| 847 * Called when the no-destinations promotion link is clicked. Opens the |
| 848 * Google Cloud Print management page and closes the print preview. |
| 849 * @private |
| 850 */ |
| 851 onNoDestinationsPromoClick_: function() { |
| 852 this.metrics_.incrementGcpPromoBucket( |
| 853 print_preview.Metrics.GcpPromoBucket.CLICKED); |
| 854 this.appState_.persistIsGcpPromoDismissed(true); |
| 855 window.open(this.cloudPrintInterface_.baseUrl + '?user=' + |
| 856 this.userInfo_.getUserEmail() + '#printers'); |
| 857 this.close_(); |
783 } | 858 } |
784 }; | 859 }; |
785 | 860 |
786 // Export | 861 // Export |
787 return { | 862 return { |
788 PrintPreview: PrintPreview | 863 PrintPreview: PrintPreview |
789 }; | 864 }; |
790 }); | 865 }); |
791 | 866 |
792 // Pull in all other scripts in a single shot. | 867 // Pull in all other scripts in a single shot. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 <include src="search/recent_destination_list.js"/> | 921 <include src="search/recent_destination_list.js"/> |
847 <include src="search/destination_list_item.js"/> | 922 <include src="search/destination_list_item.js"/> |
848 <include src="search/destination_search.js"/> | 923 <include src="search/destination_search.js"/> |
849 <include src="search/search_box.js"/> | 924 <include src="search/search_box.js"/> |
850 <include src="search/fedex_tos.js"/> | 925 <include src="search/fedex_tos.js"/> |
851 | 926 |
852 window.addEventListener('DOMContentLoaded', function() { | 927 window.addEventListener('DOMContentLoaded', function() { |
853 printPreview = new print_preview.PrintPreview(); | 928 printPreview = new print_preview.PrintPreview(); |
854 printPreview.initialize(); | 929 printPreview.initialize(); |
855 }); | 930 }); |
OLD | NEW |