| 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 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 } | 889 } |
| 889 | 890 |
| 890 /** | 891 /** |
| 891 * Update the page count and check the page range. | 892 * Update the page count and check the page range. |
| 892 * Called from PrintPreviewUI::OnDidGetPreviewPageCount(). | 893 * Called from PrintPreviewUI::OnDidGetPreviewPageCount(). |
| 893 * @param {number} pageCount The number of pages. | 894 * @param {number} pageCount The number of pages. |
| 894 * @param {boolean} isModifiable Indicates whether the previewed document can be | 895 * @param {boolean} isModifiable Indicates whether the previewed document can be |
| 895 * modified. | 896 * modified. |
| 896 * @param {number} previewResponseId The preview request id that resulted in | 897 * @param {number} previewResponseId The preview request id that resulted in |
| 897 * this response. | 898 * this response. |
| 898 * @param {string} jobTitle The print job title | |
| 899 */ | 899 */ |
| 900 function onDidGetPreviewPageCount(pageCount, isModifiable, previewResponseId, | 900 function onDidGetPreviewPageCount(pageCount, isModifiable, previewResponseId) { |
| 901 jobTitle) { | |
| 902 if (!isExpectedPreviewResponse(previewResponseId)) | 901 if (!isExpectedPreviewResponse(previewResponseId)) |
| 903 return; | 902 return; |
| 904 pageSettings.updateState(pageCount); | 903 pageSettings.updateState(pageCount); |
| 905 previewModifiable = isModifiable; | 904 previewModifiable = isModifiable; |
| 906 document.title = localStrings.getStringF('printPreviewTitleFormat', jobTitle); | |
| 907 if (!previewModifiable && pageSettings.requestPrintPreviewIfNeeded()) | 905 if (!previewModifiable && pageSettings.requestPrintPreviewIfNeeded()) |
| 908 return; | 906 return; |
| 909 | 907 |
| 910 cr.dispatchSimpleEvent(document, 'updateSummary'); | 908 cr.dispatchSimpleEvent(document, 'updateSummary'); |
| 911 } | 909 } |
| 912 | 910 |
| 913 function onDidGetDefaultPageLayout(pageLayout) { | 911 function onDidGetDefaultPageLayout(pageLayout) { |
| 914 // TODO(aayushkumar): Do something here! | 912 // TODO(aayushkumar): Do something here! |
| 915 } | 913 } |
| 916 | 914 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 | 1075 |
| 1078 /** | 1076 /** |
| 1079 * Takes a snapshot of the print settings. | 1077 * Takes a snapshot of the print settings. |
| 1080 */ | 1078 */ |
| 1081 PrintSettings.prototype.save = function() { | 1079 PrintSettings.prototype.save = function() { |
| 1082 this.deviceName = getSelectedPrinterName(); | 1080 this.deviceName = getSelectedPrinterName(); |
| 1083 this.isLandscape = layoutSettings.isLandscape(); | 1081 this.isLandscape = layoutSettings.isLandscape(); |
| 1084 this.hasHeaderFooter = headerFooterSettings.hasHeaderFooter(); | 1082 this.hasHeaderFooter = headerFooterSettings.hasHeaderFooter(); |
| 1085 } | 1083 } |
| 1086 | 1084 |
| 1085 /** |
| 1086 * Updates the title of the print preview tab according to |initiatorTabTitle|. |
| 1087 * Called from PrintPreviewUI::OnGetInitiatorTabTitle as a result of sending a |
| 1088 * 'getInitiatorTabTitle' message. |
| 1089 * @param {string} initiatorTabTitle The title of the initiator tab. |
| 1090 */ |
| 1091 function setInitiatorTabTitle(initiatorTabTitle) { |
| 1092 if (initiatorTabTitle == '') |
| 1093 return; |
| 1094 document.title = localStrings.getStringF( |
| 1095 'printPreviewTitleFormat', initiatorTabTitle); |
| 1096 } |
| 1097 |
| 1087 /// Pull in all other scripts in a single shot. | 1098 /// Pull in all other scripts in a single shot. |
| 1088 <include src="print_preview_animations.js"/> | 1099 <include src="print_preview_animations.js"/> |
| 1089 <include src="print_preview_cloud.js"/> | 1100 <include src="print_preview_cloud.js"/> |
| 1090 <include src="print_preview_utils.js"/> | 1101 <include src="print_preview_utils.js"/> |
| 1091 <include src="print_header.js"/> | 1102 <include src="print_header.js"/> |
| 1092 <include src="page_settings.js"/> | 1103 <include src="page_settings.js"/> |
| 1093 <include src="copies_settings.js"/> | 1104 <include src="copies_settings.js"/> |
| 1094 <include src="header_footer_settings.js"/> | 1105 <include src="header_footer_settings.js"/> |
| 1095 <include src="layout_settings.js"/> | 1106 <include src="layout_settings.js"/> |
| 1096 <include src="color_settings.js"/> | 1107 <include src="color_settings.js"/> |
| 1097 <include src="margin_settings.js"/> | 1108 <include src="margin_settings.js"/> |
| OLD | NEW |