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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 278 print_preview.NativeLayer.EventType.SETTINGS_INVALID, | 278 print_preview.NativeLayer.EventType.SETTINGS_INVALID, |
| 279 this.onSettingsInvalid_.bind(this)); | 279 this.onSettingsInvalid_.bind(this)); |
| 280 this.tracker.add( | 280 this.tracker.add( |
| 281 this.nativeLayer_, | 281 this.nativeLayer_, |
| 282 print_preview.NativeLayer.EventType.DISABLE_SCALING, | 282 print_preview.NativeLayer.EventType.DISABLE_SCALING, |
| 283 this.onDisableScaling_.bind(this)); | 283 this.onDisableScaling_.bind(this)); |
| 284 this.tracker.add( | 284 this.tracker.add( |
| 285 this.nativeLayer_, | 285 this.nativeLayer_, |
| 286 print_preview.NativeLayer.EventType.PRIVET_PRINT_FAILED, | 286 print_preview.NativeLayer.EventType.PRIVET_PRINT_FAILED, |
| 287 this.onPrivetPrintFailed_.bind(this)); | 287 this.onPrivetPrintFailed_.bind(this)); |
| 288 | 288 this.tracker.add( |
| 289 this.nativeLayer_, | |
| 290 print_preview.NativeLayer.EventType.MANIPULATE_SETTINGS, | |
| 291 this.onManipulateSettings_.bind(this)); | |
| 289 | 292 |
| 290 this.tracker.add( | 293 this.tracker.add( |
| 291 $('system-dialog-link'), | 294 $('system-dialog-link'), |
| 292 'click', | 295 'click', |
| 293 this.openSystemPrintDialog_.bind(this)); | 296 this.openSystemPrintDialog_.bind(this)); |
| 294 this.tracker.add( | 297 this.tracker.add( |
| 295 $('cloud-print-dialog-link'), | 298 $('cloud-print-dialog-link'), |
| 296 'click', | 299 'click', |
| 297 this.onCloudPrintDialogLinkClick_.bind(this)); | 300 this.onCloudPrintDialogLinkClick_.bind(this)); |
| 298 this.tracker.add( | 301 this.tracker.add( |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 684 this.isPreviewGenerationInProgress_ = true; | 687 this.isPreviewGenerationInProgress_ = true; |
| 685 }, | 688 }, |
| 686 | 689 |
| 687 /** | 690 /** |
| 688 * Called when the preview area's preview generation is complete. | 691 * Called when the preview area's preview generation is complete. |
| 689 * @private | 692 * @private |
| 690 */ | 693 */ |
| 691 onPreviewGenerationDone_: function() { | 694 onPreviewGenerationDone_: function() { |
| 692 this.isPreviewGenerationInProgress_ = false; | 695 this.isPreviewGenerationInProgress_ = false; |
| 693 this.printHeader_.isPrintButtonEnabled = true; | 696 this.printHeader_.isPrintButtonEnabled = true; |
| 697 chrome.send('UILoaded'); | |
|
Lei Zhang
2014/06/17 21:57:33
You may want to rename "UiLoaded" to "UiLoadedForT
ivandavid
2014/06/17 22:59:16
Done.
| |
| 694 this.printIfReady_(); | 698 this.printIfReady_(); |
| 695 }, | 699 }, |
| 696 | 700 |
| 697 /** | 701 /** |
| 698 * Called when the preview area's preview failed to load. | 702 * Called when the preview area's preview failed to load. |
| 699 * @private | 703 * @private |
| 700 */ | 704 */ |
| 701 onPreviewGenerationFail_: function() { | 705 onPreviewGenerationFail_: function() { |
| 702 this.isPreviewGenerationInProgress_ = false; | 706 this.isPreviewGenerationInProgress_ = false; |
| 703 this.printHeader_.isPrintButtonEnabled = false; | 707 this.printHeader_.isPrintButtonEnabled = false; |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 882 * @param {Event} event Event object representing the failure. | 886 * @param {Event} event Event object representing the failure. |
| 883 * @private | 887 * @private |
| 884 */ | 888 */ |
| 885 onPrivetPrintFailed_: function(event) { | 889 onPrivetPrintFailed_: function(event) { |
| 886 console.error('Privet printing failed with error code ' + | 890 console.error('Privet printing failed with error code ' + |
| 887 event.httpError); | 891 event.httpError); |
| 888 this.printHeader_.setErrorMessage( | 892 this.printHeader_.setErrorMessage( |
| 889 localStrings.getString('couldNotPrint')); | 893 localStrings.getString('couldNotPrint')); |
| 890 }, | 894 }, |
| 891 | 895 |
| 896 onManipulateSettings_: function(event) { | |
| 897 if (event.messageName == 'SAVE_AS_PDF') { | |
| 898 this.destinationStore_.selectDefaultDestination_(); | |
| 899 } | |
| 900 else if (event.messageName == 'LAYOUT_SETTINGS') { | |
| 901 if (event.layoutSettings == 'LANDSCAPE') { | |
| 902 var landscape = document.getElementsByClassName( | |
| 903 'layout-settings-landscape-radio')[0]; | |
| 904 if (landscape) { | |
| 905 landscape.click(); | |
| 906 } | |
| 907 } else { | |
| 908 chrome.send('UILoaded'); | |
|
Lei Zhang
2014/06/17 21:57:33
Why not click the portrait button in this case? Th
ivandavid
2014/06/17 22:59:16
I didn't think it would work because its already s
| |
| 909 } | |
| 910 } | |
| 911 else if (event.messageName == 'PAGE_NUMBERS') { | |
| 912 if (event.pageNumbers != '') { | |
| 913 var pageSettingsCustomInput = document.getElementsByClassName( | |
| 914 'page-settings-custom-input')[0]; | |
| 915 if (pageSettingsCustomInput) { | |
| 916 pageSettingsCustomInput.value = event.pageSettings; | |
| 917 } | |
| 918 } else { | |
| 919 chrome.send('UILoaded'); | |
| 920 } | |
| 921 } | |
| 922 else if (event.messageName == 'HEADERS_AND_FOOTERS') { | |
| 923 if (event.headersAndFooters == false) { | |
| 924 var headerFooterCheckbox = document.getElementsByClassName( | |
| 925 'header-footer-checkbox'); | |
| 926 if (headerFooterCheckbox) { | |
| 927 this.otherOptionsSettings_.headerFooterCheckbox_.click(); | |
| 928 } | |
| 929 } else { | |
| 930 chrome.send('UILoaded'); | |
| 931 } | |
| 932 } | |
| 933 else if (event.messageName == 'BACKGROUND_COLORS_AND_IMAGES') { | |
| 934 if (event.backgroundColorsAndImages == true) { | |
| 935 var backgroundCheckbox = document.getElementsByClassName( | |
| 936 'css-background-checkbox')[0]; | |
| 937 if (backgroundCheckbox) { | |
| 938 this.otherOptionsSettings_.cssBackgroundCheckbox_.click(); | |
| 939 } | |
| 940 } else { | |
| 941 chrome.send('UILoaded'); | |
| 942 } | |
| 943 } | |
| 944 else if (event.messageName == 'MARGINS') { | |
| 945 var marginSettingsSelect = | |
| 946 document.getElementsByClassName('margin-settings-select')[0]; | |
| 947 var index = parseInt(event.margins, 10); | |
| 948 if (marginSettingsSelect && index != 0) { | |
| 949 marginSettingsSelect.selectedIndex = index; | |
| 950 chrome.send('UILoaded'); | |
| 951 } else { | |
| 952 chrome.send('UILoaded'); | |
| 953 } | |
| 954 } | |
| 955 }, | |
| 956 | |
| 892 /** | 957 /** |
| 893 * Called when the open-cloud-print-dialog link is clicked. Opens the Google | 958 * Called when the open-cloud-print-dialog link is clicked. Opens the Google |
| 894 * Cloud Print web dialog. | 959 * Cloud Print web dialog. |
| 895 * @private | 960 * @private |
| 896 */ | 961 */ |
| 897 onCloudPrintDialogLinkClick_: function() { | 962 onCloudPrintDialogLinkClick_: function() { |
| 898 assert(this.uiState_ == PrintPreview.UiState_.READY, | 963 assert(this.uiState_ == PrintPreview.UiState_.READY, |
| 899 'Opening Google Cloud Print dialog when not in ready state: ' + | 964 'Opening Google Cloud Print dialog when not in ready state: ' + |
| 900 this.uiState_); | 965 this.uiState_); |
| 901 setIsVisible($('cloud-print-dialog-throbber'), true); | 966 setIsVisible($('cloud-print-dialog-throbber'), true); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1034 <include src="search/recent_destination_list.js"/> | 1099 <include src="search/recent_destination_list.js"/> |
| 1035 <include src="search/destination_list_item.js"/> | 1100 <include src="search/destination_list_item.js"/> |
| 1036 <include src="search/destination_search.js"/> | 1101 <include src="search/destination_search.js"/> |
| 1037 <include src="search/search_box.js"/> | 1102 <include src="search/search_box.js"/> |
| 1038 <include src="search/fedex_tos.js"/> | 1103 <include src="search/fedex_tos.js"/> |
| 1039 | 1104 |
| 1040 window.addEventListener('DOMContentLoaded', function() { | 1105 window.addEventListener('DOMContentLoaded', function() { |
| 1041 printPreview = new print_preview.PrintPreview(); | 1106 printPreview = new print_preview.PrintPreview(); |
| 1042 printPreview.initialize(); | 1107 printPreview.initialize(); |
| 1043 }); | 1108 }); |
| OLD | NEW |