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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 printHeader.addEventListeners(); | 130 printHeader.addEventListeners(); |
131 pageSettings.addEventListeners(); | 131 pageSettings.addEventListeners(); |
132 copiesSettings.addEventListeners(); | 132 copiesSettings.addEventListeners(); |
133 headerFooterSettings.addEventListeners(); | 133 headerFooterSettings.addEventListeners(); |
134 layoutSettings.addEventListeners(); | 134 layoutSettings.addEventListeners(); |
135 marginSettings.addEventListeners(); | 135 marginSettings.addEventListeners(); |
136 colorSettings.addEventListeners(); | 136 colorSettings.addEventListeners(); |
137 $('printer-list').onchange = updateControlsWithSelectedPrinterCapabilities; | 137 $('printer-list').onchange = updateControlsWithSelectedPrinterCapabilities; |
138 | 138 |
139 showLoadingAnimation(); | 139 showLoadingAnimation(); |
| 140 chrome.send('getInitiatorTabTitle'); |
140 chrome.send('getDefaultPrinter'); | 141 chrome.send('getDefaultPrinter'); |
141 } | 142 } |
142 | 143 |
143 /** | 144 /** |
144 * Disables the input elements in the sidebar. | 145 * Disables the input elements in the sidebar. |
145 */ | 146 */ |
146 function disableInputElementsInSidebar() { | 147 function disableInputElementsInSidebar() { |
147 var els = $('sidebar').querySelectorAll('input, button, select'); | 148 var els = $('sidebar').querySelectorAll('input, button, select'); |
148 for (var i = 0; i < els.length; i++) | 149 for (var i = 0; i < els.length; i++) |
149 els[i].disabled = true; | 150 els[i].disabled = true; |
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 } | 890 } |
890 | 891 |
891 /** | 892 /** |
892 * Update the page count and check the page range. | 893 * Update the page count and check the page range. |
893 * Called from PrintPreviewUI::OnDidGetPreviewPageCount(). | 894 * Called from PrintPreviewUI::OnDidGetPreviewPageCount(). |
894 * @param {number} pageCount The number of pages. | 895 * @param {number} pageCount The number of pages. |
895 * @param {boolean} isModifiable Indicates whether the previewed document can be | 896 * @param {boolean} isModifiable Indicates whether the previewed document can be |
896 * modified. | 897 * modified. |
897 * @param {number} previewResponseId The preview request id that resulted in | 898 * @param {number} previewResponseId The preview request id that resulted in |
898 * this response. | 899 * this response. |
899 * @param {string} jobTitle The print job title | |
900 */ | 900 */ |
901 function onDidGetPreviewPageCount(pageCount, isModifiable, previewResponseId, | 901 function onDidGetPreviewPageCount(pageCount, isModifiable, previewResponseId) { |
902 jobTitle) { | |
903 if (!isExpectedPreviewResponse(previewResponseId)) | 902 if (!isExpectedPreviewResponse(previewResponseId)) |
904 return; | 903 return; |
905 pageSettings.updateState(pageCount); | 904 pageSettings.updateState(pageCount); |
906 previewModifiable = isModifiable; | 905 previewModifiable = isModifiable; |
907 document.title = localStrings.getStringF('printPreviewTitleFormat', jobTitle); | |
908 if (!previewModifiable && pageSettings.requestPrintPreviewIfNeeded()) | 906 if (!previewModifiable && pageSettings.requestPrintPreviewIfNeeded()) |
909 return; | 907 return; |
910 | 908 |
911 cr.dispatchSimpleEvent(document, 'updateSummary'); | 909 cr.dispatchSimpleEvent(document, 'updateSummary'); |
912 } | 910 } |
913 | 911 |
914 function onDidGetDefaultPageLayout(pageLayout) { | 912 function onDidGetDefaultPageLayout(pageLayout) { |
915 // TODO(aayushkumar): Do something here! | 913 // TODO(aayushkumar): Do something here! |
916 } | 914 } |
917 | 915 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1079 | 1077 |
1080 /** | 1078 /** |
1081 * Takes a snapshot of the print settings. | 1079 * Takes a snapshot of the print settings. |
1082 */ | 1080 */ |
1083 PrintSettings.prototype.save = function() { | 1081 PrintSettings.prototype.save = function() { |
1084 this.deviceName = getSelectedPrinterName(); | 1082 this.deviceName = getSelectedPrinterName(); |
1085 this.isLandscape = layoutSettings.isLandscape(); | 1083 this.isLandscape = layoutSettings.isLandscape(); |
1086 this.hasHeaderFooter = headerFooterSettings.hasHeaderFooter(); | 1084 this.hasHeaderFooter = headerFooterSettings.hasHeaderFooter(); |
1087 } | 1085 } |
1088 | 1086 |
| 1087 /** |
| 1088 * Updates the title of the print preview tab according to |initiatorTabTitle|. |
| 1089 * Called from PrintPreviewUI::OnGetInitiatorTabTitle as a result of sending a |
| 1090 * 'getInitiatorTabTitle' message. |
| 1091 * @param {string} initiatorTabTitle The title of the initiator tab. |
| 1092 */ |
| 1093 function setInitiatorTabTitle(initiatorTabTitle) { |
| 1094 if (initiatorTabTitle == '') |
| 1095 return; |
| 1096 document.title = localStrings.getStringF( |
| 1097 'printPreviewTitleFormat', initiatorTabTitle); |
| 1098 } |
| 1099 |
1089 /// Pull in all other scripts in a single shot. | 1100 /// Pull in all other scripts in a single shot. |
1090 <include src="print_preview_animations.js"/> | 1101 <include src="print_preview_animations.js"/> |
1091 <include src="print_preview_cloud.js"/> | 1102 <include src="print_preview_cloud.js"/> |
1092 <include src="print_preview_utils.js"/> | 1103 <include src="print_preview_utils.js"/> |
1093 <include src="print_header.js"/> | 1104 <include src="print_header.js"/> |
1094 <include src="page_settings.js"/> | 1105 <include src="page_settings.js"/> |
1095 <include src="copies_settings.js"/> | 1106 <include src="copies_settings.js"/> |
1096 <include src="header_footer_settings.js"/> | 1107 <include src="header_footer_settings.js"/> |
1097 <include src="layout_settings.js"/> | 1108 <include src="layout_settings.js"/> |
1098 <include src="color_settings.js"/> | 1109 <include src="color_settings.js"/> |
1099 <include src="margin_settings.js"/> | 1110 <include src="margin_settings.js"/> |
OLD | NEW |