OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // require: cr/ui/print_preview_cloud.js | 5 // require: cr/ui/print_preview_cloud.js |
6 | 6 |
7 var localStrings = new LocalStrings(); | 7 var localStrings = new LocalStrings(); |
8 | 8 |
9 // If useCloudPrint is true we attempt to connect to cloud print | 9 // If useCloudPrint is true we attempt to connect to cloud print |
10 // and populate the list of printers with cloud print printers. | 10 // and populate the list of printers with cloud print printers. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 | 44 |
45 // Object holding all the pages related settings. | 45 // Object holding all the pages related settings. |
46 var pageSettings; | 46 var pageSettings; |
47 | 47 |
48 // Object holding all the copies related settings. | 48 // Object holding all the copies related settings. |
49 var copiesSettings; | 49 var copiesSettings; |
50 | 50 |
51 // Object holding all the layout related settings. | 51 // Object holding all the layout related settings. |
52 var layoutSettings; | 52 var layoutSettings; |
53 | 53 |
54 // Object holding all the header footer related settings. | |
55 var headerFooterSettings; | |
56 | |
54 // Object holding all the color related settings. | 57 // Object holding all the color related settings. |
55 var colorSettings; | 58 var colorSettings; |
56 | 59 |
57 // True if the user has click 'Advanced...' in order to open the system print | 60 // True if the user has click 'Advanced...' in order to open the system print |
58 // dialog. | 61 // dialog. |
59 var showingSystemDialog = false; | 62 var showingSystemDialog = false; |
60 | 63 |
61 // The range of options in the printer dropdown controlled by cloud print. | 64 // The range of options in the printer dropdown controlled by cloud print. |
62 var firstCloudPrintOptionPos = 0; | 65 var firstCloudPrintOptionPos = 0; |
63 var lastCloudPrintOptionPos = firstCloudPrintOptionPos; | 66 var lastCloudPrintOptionPos = firstCloudPrintOptionPos; |
(...skipping 28 matching lines...) Expand all Loading... | |
92 | 95 |
93 $('system-dialog-link').addEventListener('click', onSystemDialogLinkClicked); | 96 $('system-dialog-link').addEventListener('click', onSystemDialogLinkClicked); |
94 $('mainview').parentElement.removeChild($('dummy-viewer')); | 97 $('mainview').parentElement.removeChild($('dummy-viewer')); |
95 | 98 |
96 $('printer-list').disabled = true; | 99 $('printer-list').disabled = true; |
97 | 100 |
98 printHeader = print_preview.PrintHeader.getInstance(); | 101 printHeader = print_preview.PrintHeader.getInstance(); |
99 pageSettings = print_preview.PageSettings.getInstance(); | 102 pageSettings = print_preview.PageSettings.getInstance(); |
100 copiesSettings = print_preview.CopiesSettings.getInstance(); | 103 copiesSettings = print_preview.CopiesSettings.getInstance(); |
101 layoutSettings = print_preview.LayoutSettings.getInstance(); | 104 layoutSettings = print_preview.LayoutSettings.getInstance(); |
105 headerFooterSettings = print_preview.HeaderFooterSettings.getInstance(); | |
102 colorSettings = print_preview.ColorSettings.getInstance(); | 106 colorSettings = print_preview.ColorSettings.getInstance(); |
103 printHeader.addEventListeners(); | 107 printHeader.addEventListeners(); |
104 pageSettings.addEventListeners(); | 108 pageSettings.addEventListeners(); |
105 copiesSettings.addEventListeners(); | 109 copiesSettings.addEventListeners(); |
110 headerFooterSettings.addEventListeners(); | |
106 layoutSettings.addEventListeners(); | 111 layoutSettings.addEventListeners(); |
107 colorSettings.addEventListeners(); | 112 colorSettings.addEventListeners(); |
108 | 113 |
109 showLoadingAnimation(); | 114 showLoadingAnimation(); |
110 chrome.send('getDefaultPrinter'); | 115 chrome.send('getDefaultPrinter'); |
111 } | 116 } |
112 | 117 |
113 /** | 118 /** |
114 * Adds event listeners to the settings controls. | 119 * Adds event listeners to the settings controls. |
115 */ | 120 */ |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
304 var settings = | 309 var settings = |
305 {'deviceName': deviceName, | 310 {'deviceName': deviceName, |
306 'pageRange': pageSettings.selectedPageRanges, | 311 'pageRange': pageSettings.selectedPageRanges, |
307 'printAll': pageSettings.allPagesRadioButton.checked, | 312 'printAll': pageSettings.allPagesRadioButton.checked, |
308 'duplex': copiesSettings.duplexMode, | 313 'duplex': copiesSettings.duplexMode, |
309 'copies': copiesSettings.numberOfCopies, | 314 'copies': copiesSettings.numberOfCopies, |
310 'collate': copiesSettings.isCollated(), | 315 'collate': copiesSettings.isCollated(), |
311 'landscape': layoutSettings.isLandscape(), | 316 'landscape': layoutSettings.isLandscape(), |
312 'color': colorSettings.isColor(), | 317 'color': colorSettings.isColor(), |
313 'printToPDF': printToPDF, | 318 'printToPDF': printToPDF, |
319 'headerFooterEnabled': headerFooterSettings.hasHeaderFooter(), | |
314 'requestID': 0}; | 320 'requestID': 0}; |
315 | 321 |
316 var printerList = $('printer-list'); | 322 var printerList = $('printer-list'); |
317 var selectedPrinter = printerList.selectedIndex; | 323 var selectedPrinter = printerList.selectedIndex; |
318 if (cloudprint.isCloudPrint(printerList.options[selectedPrinter])) { | 324 if (cloudprint.isCloudPrint(printerList.options[selectedPrinter])) { |
319 settings['cloudPrintID'] = | 325 settings['cloudPrintID'] = |
320 printerList.options[selectedPrinter].value; | 326 printerList.options[selectedPrinter].value; |
321 } | 327 } |
322 return settings; | 328 return settings; |
323 } | 329 } |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
884 tempPrintSettings.save(); | 890 tempPrintSettings.save(); |
885 | 891 |
886 if (printSettings.deviceName != tempPrintSettings.deviceName) { | 892 if (printSettings.deviceName != tempPrintSettings.deviceName) { |
887 updateControlsWithSelectedPrinterCapabilities(); | 893 updateControlsWithSelectedPrinterCapabilities(); |
888 return true; | 894 return true; |
889 } | 895 } |
890 if (printSettings.isLandscape != tempPrintSettings.isLandscape) { | 896 if (printSettings.isLandscape != tempPrintSettings.isLandscape) { |
891 setDefaultValuesAndRegeneratePreview(); | 897 setDefaultValuesAndRegeneratePreview(); |
892 return true; | 898 return true; |
893 } | 899 } |
900 if (printSettings.hasHeaderFooter != tempPrintSettings.hasHeaderFooter) { | |
901 requestPrintPreview(); | |
902 return true; | |
903 } | |
894 if (pageSettings.requestPrintPreviewIfNeeded()) | 904 if (pageSettings.requestPrintPreviewIfNeeded()) |
895 return true; | 905 return true; |
896 | 906 |
897 return false; | 907 return false; |
898 } | 908 } |
899 | 909 |
900 /** | 910 /** |
901 * Create the PDF plugin or reload the existing one. | 911 * Create the PDF plugin or reload the existing one. |
902 * @param {string} previewUid Preview unique identifier. | 912 * @param {string} previewUid Preview unique identifier. |
903 */ | 913 */ |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
949 pageSettings.resetState(); | 959 pageSettings.resetState(); |
950 requestPrintPreview(); | 960 requestPrintPreview(); |
951 } | 961 } |
952 | 962 |
953 /** | 963 /** |
954 * Class that represents the state of the print settings. | 964 * Class that represents the state of the print settings. |
955 */ | 965 */ |
956 function PrintSettings() { | 966 function PrintSettings() { |
957 this.deviceName = ''; | 967 this.deviceName = ''; |
958 this.isLandscape = ''; | 968 this.isLandscape = ''; |
969 this.hasHeaderFooter = ''; | |
James Hawkins
2011/08/15 19:39:35
This is a boolean var, is it not?
Aayush Kumar
2011/08/15 21:37:37
Rebased and this section has now disappeared :)
| |
959 } | 970 } |
960 | 971 |
961 /** | 972 /** |
962 * Takes a snapshot of the print settings. | 973 * Takes a snapshot of the print settings. |
963 */ | 974 */ |
964 PrintSettings.prototype.save = function() { | 975 PrintSettings.prototype.save = function() { |
965 this.deviceName = getSelectedPrinterName(); | 976 this.deviceName = getSelectedPrinterName(); |
966 this.isLandscape = layoutSettings.isLandscape(); | 977 this.isLandscape = layoutSettings.isLandscape(); |
978 this.hasHeaderFooter = headerFooterSettings.hasHeaderFooter(); | |
967 } | 979 } |
968 | 980 |
969 /// Pull in all other scripts in a single shot. | 981 /// Pull in all other scripts in a single shot. |
970 <include src="print_preview_animations.js"/> | 982 <include src="print_preview_animations.js"/> |
971 <include src="print_preview_cloud.js"/> | 983 <include src="print_preview_cloud.js"/> |
972 <include src="print_preview_utils.js"/> | 984 <include src="print_preview_utils.js"/> |
973 <include src="print_header.js"/> | 985 <include src="print_header.js"/> |
974 <include src="page_settings.js"/> | 986 <include src="page_settings.js"/> |
975 <include src="copies_settings.js"/> | 987 <include src="copies_settings.js"/> |
988 <include src="header_footer_settings.js"/> | |
976 <include src="layout_settings.js"/> | 989 <include src="layout_settings.js"/> |
977 <include src="color_settings.js"/> | 990 <include src="color_settings.js"/> |
OLD | NEW |