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_FOR_TEST, | |
291 this.onManipulateSettingsForTest_.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 this.nativeLayer_.previewReady(); | |
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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 |
892 /** | 896 /** |
897 * Called when the print preview settings need to be changed for testing. | |
898 * @param {Event} event Event object that contains that option that is to | |
899 * be changed and what to set that option. | |
Dan Beam
2014/06/20 02:45:17
@private
Aleksey Shlyapnikov
2014/06/20 17:27:22
* @param {Event} event Event object that contains
ivandavid
2014/06/20 21:31:45
Done.
ivandavid
2014/06/20 21:31:45
Done.
| |
900 */ | |
901 onManipulateSettingsForTest_: function(event) { | |
902 if ('SAVE_AS_PDF' in event.settings) { | |
Aleksey Shlyapnikov
2014/06/20 17:27:22
ALL_CAPS property names look awkward and misleadin
ivandavid
2014/06/20 21:31:45
Done.
| |
903 this.destinationStore_.selectDefaultDestination_(); | |
Aleksey Shlyapnikov
2014/06/20 17:27:22
Since you added the failure handling logic, check
ivandavid
2014/06/20 21:31:44
Done.
| |
904 } else if ('LAYOUT_SETTINGS' in event.settings) { | |
905 var element = document.querySelector( | |
906 event.settings['LAYOUT_SETTINGS'] ? | |
Aleksey Shlyapnikov
2014/06/20 17:27:22
var element = document.querySelector(event.setting
ivandavid
2014/06/20 21:31:45
Done.
| |
907 '.layout-settings-portrait-radio' : | |
908 '.layout-settings-landscape-radio'); | |
909 if (element) { | |
910 if (element.clicked) { | |
Aleksey Shlyapnikov
2014/06/20 17:27:22
Crash here will also fail the test, right? Why add
ivandavid
2014/06/20 21:31:45
I am not sure what you mean here. Is the problem t
Aleksey Shlyapnikov
2014/06/20 22:13:49
No, what I mean is the test will crash if you remo
| |
911 this.nativeLayer_.previewReady(); | |
912 } else { | |
913 element.click(); | |
914 } | |
915 } else { | |
916 this.nativeLayer_.previewFailed(); | |
917 } | |
918 } else if ('PAGE_NUMBERS' in event.settings) { | |
919 var textbox = document.querySelector('.page-settings-custom-input'); | |
920 if (textbox) { | |
921 if (textbox.value == event.settings['PAGE_NUMBERS']) { | |
Aleksey Shlyapnikov
2014/06/20 17:27:22
event.settings.pageRange
The same for all other s
ivandavid
2014/06/20 21:31:45
Done.
| |
922 this.nativeLayer_.previewReady(); | |
923 } else { | |
924 // Assuming that the string format is correct for now. | |
925 // TODO: Will need a way to validate it just so the test doesn't | |
926 // hang mysteriously if the string isn't correct. | |
927 textbox.value = event.settings['PAGE_NUMBERS']; | |
928 | |
929 // Triggers the re-rendering of the preview area as | |
930 // just setting the value isn't sufficient. | |
931 var radio = document.querySelector( | |
932 '.page-settings-custom-radio'); | |
Aleksey Shlyapnikov
2014/06/20 17:27:22
Fits one line.
ivandavid
2014/06/20 21:31:45
Done.
| |
933 if (radio) { | |
934 radio.click(); | |
935 } else { | |
936 this.nativeLayer_.previewFailed(); | |
937 } | |
938 } | |
939 } else { | |
940 this.nativeLayer_.previewFailed(); | |
941 } | |
942 } else if ('HEADERS_AND_FOOTERS' in event.settings) { | |
943 var checkbox = document.querySelector( | |
944 '.header-footer-checkbox'); | |
Aleksey Shlyapnikov
2014/06/20 17:27:22
It does fit into one line.
ivandavid
2014/06/20 21:31:45
Done.
| |
945 if (checkbox) { | |
946 if (event.settings['HEADERS_AND_FOOTERS'] == checkbox.checked) { | |
947 this.nativeLayer_.previewReady(); | |
948 } else { | |
949 checkbox.click(); | |
950 } | |
951 } else { | |
952 this.nativeLayer_.previewFailed(); | |
953 } | |
954 } else if ('BACKGROUND_COLORS_AND_IMAGES' in event.settings) { | |
955 var checkbox = document.querySelector( | |
956 '.css-background-checkbox'); | |
Aleksey Shlyapnikov
2014/06/20 17:27:22
Fits one line.
ivandavid
2014/06/20 21:31:45
Done.
| |
957 if (checkbox) { | |
958 if (event.settings['BACKGROUND_COLORS_AND_IMAGES'] == | |
959 checkbox.checked) { | |
960 this.nativeLayer_.previewReady(); | |
961 } else { | |
962 checkbox.click(); | |
963 } | |
964 } else { | |
965 this.nativeLayer_.previewFailed(); | |
966 } | |
967 } else if ('MARGINS' in event.settings) { | |
968 var element = | |
969 document.querySelector('.margin-settings-select'); | |
Aleksey Shlyapnikov
2014/06/20 17:27:22
Fits one line.
ivandavid
2014/06/20 21:31:45
Done.
| |
970 if (element) { | |
971 if (event.settings['MARGINS'] == element.selectedIndex) { | |
972 this.nativeLayer_.previewReady(); | |
973 } else if (event.settings['MARGINS'] >= 0 && | |
974 event.settings['MARGINS'] < element.length) { | |
975 element.selectedIndex = event.settings['MARGINS']; | |
976 this.marginSettings_.onSelectChange_(); | |
977 } else { | |
978 this.nativeLayer_.previewFailed(); | |
979 } | |
980 } else { | |
981 this.nativeLayer_.previewFailed(); | |
982 } | |
983 } | |
984 }, | |
985 | |
986 /** | |
893 * Called when the open-cloud-print-dialog link is clicked. Opens the Google | 987 * Called when the open-cloud-print-dialog link is clicked. Opens the Google |
894 * Cloud Print web dialog. | 988 * Cloud Print web dialog. |
895 * @private | 989 * @private |
896 */ | 990 */ |
897 onCloudPrintDialogLinkClick_: function() { | 991 onCloudPrintDialogLinkClick_: function() { |
898 assert(this.uiState_ == PrintPreview.UiState_.READY, | 992 assert(this.uiState_ == PrintPreview.UiState_.READY, |
899 'Opening Google Cloud Print dialog when not in ready state: ' + | 993 'Opening Google Cloud Print dialog when not in ready state: ' + |
900 this.uiState_); | 994 this.uiState_); |
901 setIsVisible($('cloud-print-dialog-throbber'), true); | 995 setIsVisible($('cloud-print-dialog-throbber'), true); |
902 this.setIsEnabled_(false); | 996 this.setIsEnabled_(false); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1034 <include src="search/recent_destination_list.js"/> | 1128 <include src="search/recent_destination_list.js"/> |
1035 <include src="search/destination_list_item.js"/> | 1129 <include src="search/destination_list_item.js"/> |
1036 <include src="search/destination_search.js"/> | 1130 <include src="search/destination_search.js"/> |
1037 <include src="search/search_box.js"/> | 1131 <include src="search/search_box.js"/> |
1038 <include src="search/fedex_tos.js"/> | 1132 <include src="search/fedex_tos.js"/> |
1039 | 1133 |
1040 window.addEventListener('DOMContentLoaded', function() { | 1134 window.addEventListener('DOMContentLoaded', function() { |
1041 printPreview = new print_preview.PrintPreview(); | 1135 printPreview = new print_preview.PrintPreview(); |
1042 printPreview.initialize(); | 1136 printPreview.initialize(); |
1043 }); | 1137 }); |
OLD | NEW |