Chromium Code Reviews| 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 this.tracker.add( | |
|
ydolgov1
2012/10/16 21:44:54
Why don't you wanna create CloudPrintPromo class t
Toscano
2012/10/16 22:24:14
Tempting. The first iteration wasn't very complex
ydolgov1
2012/10/16 22:43:17
O.k. sounds good, can you add a TODO for now?
On
Toscano
2012/10/16 22:58:44
Done.
| |
| 324 this.getChildElement('#no-destinations-promo .close-button'), | |
| 325 'click', | |
| 326 this.onNoDestinationsPromoClose_.bind(this)); | |
| 327 this.tracker.add( | |
| 328 this.getChildElement('#no-destinations-promo .not-now-button'), | |
| 329 'click', | |
| 330 this.onNoDestinationsPromoClose_.bind(this)); | |
| 331 this.tracker.add( | |
| 332 this.getChildElement('#no-destinations-promo .add-printer-button'), | |
| 333 'click', | |
| 334 this.onNoDestinationsPromoClick_.bind(this)); | |
| 318 }, | 335 }, |
| 319 | 336 |
| 320 /** @override */ | 337 /** @override */ |
| 321 decorateInternal: function() { | 338 decorateInternal: function() { |
| 322 this.printHeader_.decorate($('print-header')); | 339 this.printHeader_.decorate($('print-header')); |
| 323 this.destinationSearch_.decorate($('destination-search')); | 340 this.destinationSearch_.decorate($('destination-search')); |
| 324 this.destinationSettings_.decorate($('destination-settings')); | 341 this.destinationSettings_.decorate($('destination-settings')); |
| 325 this.pageSettings_.decorate($('page-settings')); | 342 this.pageSettings_.decorate($('page-settings')); |
| 326 this.copiesSettings_.decorate($('copies-settings')); | 343 this.copiesSettings_.decorate($('copies-settings')); |
| 327 this.layoutSettings_.decorate($('layout-settings')); | 344 this.layoutSettings_.decorate($('layout-settings')); |
| 328 this.colorSettings_.decorate($('color-settings')); | 345 this.colorSettings_.decorate($('color-settings')); |
| 329 this.marginSettings_.decorate($('margin-settings')); | 346 this.marginSettings_.decorate($('margin-settings')); |
| 330 this.otherOptionsSettings_.decorate($('other-options-settings')); | 347 this.otherOptionsSettings_.decorate($('other-options-settings')); |
| 331 this.previewArea_.decorate($('preview-area')); | 348 this.previewArea_.decorate($('preview-area')); |
| 332 | 349 |
| 350 // Set some of the parameterized text in the no-destinations promotion. | |
| 351 var noDestsPromoGcpDescription = | |
| 352 this.getChildElement('#no-destinations-promo .gcp-description'); | |
| 353 noDestsPromoGcpDescription.innerHTML = localStrings.getStringF( | |
| 354 'noDestsPromoGcpDesc', | |
| 355 '<a target="_blank" href="http://www.google.com/cloudprint/learn/">', | |
| 356 '</a>'); | |
| 357 | |
| 333 setIsVisible($('open-pdf-in-preview-link'), cr.isMac); | 358 setIsVisible($('open-pdf-in-preview-link'), cr.isMac); |
| 334 }, | 359 }, |
| 335 | 360 |
| 336 /** | 361 /** |
| 337 * Sets whether the controls in the print preview are enabled. | 362 * Sets whether the controls in the print preview are enabled. |
| 338 * @param {boolean} isEnabled Whether the controls in the print preview are | 363 * @param {boolean} isEnabled Whether the controls in the print preview are |
| 339 * enabled. | 364 * enabled. |
| 340 * @private | 365 * @private |
| 341 */ | 366 */ |
| 342 setIsEnabled_: function(isEnabled) { | 367 setIsEnabled_: function(isEnabled) { |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 773 | 798 |
| 774 /** | 799 /** |
| 775 * Called when a print destination is selected. Shows/hides the "Print with | 800 * Called when a print destination is selected. Shows/hides the "Print with |
| 776 * Cloud Print" link in the navbar. | 801 * Cloud Print" link in the navbar. |
| 777 * @private | 802 * @private |
| 778 */ | 803 */ |
| 779 onDestinationSelect_: function() { | 804 onDestinationSelect_: function() { |
| 780 var selectedDest = this.destinationStore_.selectedDestination; | 805 var selectedDest = this.destinationStore_.selectedDestination; |
| 781 setIsVisible($('cloud-print-dialog-link'), | 806 setIsVisible($('cloud-print-dialog-link'), |
| 782 !cr.isChromeOS && !selectedDest.isLocal); | 807 !cr.isChromeOS && !selectedDest.isLocal); |
| 808 }, | |
| 809 | |
| 810 /** | |
| 811 * Called when the destination store loads a group of destinations. Shows | |
| 812 * a promo on Chrome OS if the user has no print destinations promoting | |
| 813 * Google Cloud Print. | |
| 814 * @private | |
| 815 */ | |
| 816 onDestinationSearchDone_: function() { | |
| 817 var isPromoVisible = cr.isChromeOS && | |
| 818 this.cloudPrintInterface_ && | |
| 819 this.userInfo_.getUserEmail() && | |
| 820 !this.appState_.isGcpPromoDismissed && | |
| 821 !this.destinationStore_.isLocalDestinationsSearchInProgress && | |
| 822 !this.destinationStore_.isCloudDestinationsSearchInProgress && | |
| 823 this.destinationStore_.hasOnlyDefaultCloudDestinations(); | |
| 824 setIsVisible(this.getChildElement('#no-destinations-promo'), | |
| 825 isPromoVisible); | |
| 826 if (isPromoVisible) { | |
| 827 this.metrics_.incrementGcpPromoBucket( | |
| 828 print_preview.Metrics.GcpPromoBucket.SHOWN); | |
| 829 } | |
| 830 }, | |
| 831 | |
| 832 /** | |
| 833 * Called when the close button on the no-destinations-promotion is clicked. | |
| 834 * Hides the promotion. | |
| 835 * @private | |
| 836 */ | |
| 837 onNoDestinationsPromoClose_: function() { | |
| 838 this.metrics_.incrementGcpPromoBucket( | |
| 839 print_preview.Metrics.GcpPromoBucket.DISMISSED); | |
| 840 setIsVisible(this.getChildElement('#no-destinations-promo'), false); | |
| 841 this.appState_.persistIsGcpPromoDismissed(true); | |
| 842 }, | |
| 843 | |
| 844 /** | |
| 845 * Called when the no-destinations promotion link is clicked. Opens the | |
| 846 * Google Cloud Print management page and closes the print preview. | |
| 847 * @private | |
| 848 */ | |
| 849 onNoDestinationsPromoClick_: function() { | |
| 850 this.metrics_.incrementGcpPromoBucket( | |
| 851 print_preview.Metrics.GcpPromoBucket.CLICKED); | |
| 852 this.appState_.persistIsGcpPromoDismissed(true); | |
| 853 window.open(this.cloudPrintInterface_.baseUrl + '?user=' + | |
| 854 this.userInfo_.getUserEmail() + '#printers'); | |
| 855 this.close_(); | |
| 783 } | 856 } |
| 784 }; | 857 }; |
| 785 | 858 |
| 786 // Export | 859 // Export |
| 787 return { | 860 return { |
| 788 PrintPreview: PrintPreview | 861 PrintPreview: PrintPreview |
| 789 }; | 862 }; |
| 790 }); | 863 }); |
| 791 | 864 |
| 792 // Pull in all other scripts in a single shot. | 865 // 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"/> | 919 <include src="search/recent_destination_list.js"/> |
| 847 <include src="search/destination_list_item.js"/> | 920 <include src="search/destination_list_item.js"/> |
| 848 <include src="search/destination_search.js"/> | 921 <include src="search/destination_search.js"/> |
| 849 <include src="search/search_box.js"/> | 922 <include src="search/search_box.js"/> |
| 850 <include src="search/fedex_tos.js"/> | 923 <include src="search/fedex_tos.js"/> |
| 851 | 924 |
| 852 window.addEventListener('DOMContentLoaded', function() { | 925 window.addEventListener('DOMContentLoaded', function() { |
| 853 printPreview = new print_preview.PrintPreview(); | 926 printPreview = new print_preview.PrintPreview(); |
| 854 printPreview.initialize(); | 927 printPreview.initialize(); |
| 855 }); | 928 }); |
| OLD | NEW |