Chromium Code Reviews| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 | 164 |
| 165 /** | 165 /** |
| 166 * Disables the controls in the sidebar, shows the throbber and instructs the | 166 * Disables the controls in the sidebar, shows the throbber and instructs the |
| 167 * backend to open the native print dialog. | 167 * backend to open the native print dialog. |
| 168 */ | 168 */ |
| 169 function onSystemDialogLinkClicked() { | 169 function onSystemDialogLinkClicked() { |
| 170 if (showingSystemDialog) | 170 if (showingSystemDialog) |
| 171 return; | 171 return; |
| 172 showingSystemDialog = true; | 172 showingSystemDialog = true; |
| 173 disableInputElementsInSidebar(); | 173 disableInputElementsInSidebar(); |
| 174 printHeader.disableCancelButton(); | |
| 174 $('system-dialog-throbber').classList.remove('hidden'); | 175 $('system-dialog-throbber').classList.remove('hidden'); |
| 175 chrome.send('showSystemDialog'); | 176 chrome.send('showSystemDialog'); |
| 176 } | 177 } |
| 177 | 178 |
| 178 /** | 179 /** |
| 179 * Similar to onSystemDialogLinkClicked(), but specific to the | 180 * Similar to onSystemDialogLinkClicked(), but specific to the |
| 180 * 'Launch native print dialog' UI. | 181 * 'Launch native print dialog' UI. |
| 181 */ | 182 */ |
| 182 function launchNativePrintDialog() { | 183 function launchNativePrintDialog() { |
| 183 if (showingSystemDialog) | 184 if (showingSystemDialog) |
| 184 return; | 185 return; |
| 185 showingSystemDialog = true; | 186 showingSystemDialog = true; |
| 186 $('error-button').disabled = true; | 187 $('error-button').disabled = true; |
| 187 printHeader.disableCancelButton(); | 188 printHeader.disableCancelButton(); |
| 188 $('native-print-dialog-throbber').classList.remove('hidden'); | 189 $('native-print-dialog-throbber').classList.remove('hidden'); |
| 189 chrome.send('showSystemDialog'); | 190 chrome.send('showSystemDialog'); |
| 190 } | 191 } |
| 191 | 192 |
| 192 /** | 193 /** |
| 193 * Disables the controls which need the initiator tab to generate preview | |
| 194 * data. This function is called when the initiator tab has crashed. | |
| 195 * @param {string} initiatorTabURL The URL of the initiator tab. | |
| 196 */ | |
| 197 function onInitiatorTabCrashed(initiatorTabURL) { | |
| 198 disableInputElementsInSidebar(); | |
| 199 if (initiatorTabURL) { | |
| 200 displayErrorMessageWithButton( | |
| 201 localStrings.getString('initiatorTabCrashed'), | |
| 202 localStrings.getString('reopenPage'), | |
| 203 function() { chrome.send('reloadCrashedInitiatorTab'); }); | |
| 204 } else { | |
| 205 displayErrorMessage(localStrings.getString('initiatorTabCrashed')); | |
| 206 } | |
| 207 } | |
| 208 | |
| 209 /** | |
| 210 * Disables the controls which need the initiator tab to generate preview | |
| 211 * data. This function is called when the initiator tab is closed. | |
| 212 * @param {string} initiatorTabURL The URL of the initiator tab. | |
| 213 */ | |
| 214 function onInitiatorTabClosed(initiatorTabURL) { | |
| 215 disableInputElementsInSidebar(); | |
| 216 if (initiatorTabURL) { | |
| 217 displayErrorMessageWithButton( | |
| 218 localStrings.getString('initiatorTabClosed'), | |
| 219 localStrings.getString('reopenPage'), | |
| 220 function() { window.location = initiatorTabURL; }); | |
| 221 } else { | |
| 222 displayErrorMessage(localStrings.getString('initiatorTabClosed')); | |
| 223 } | |
| 224 } | |
| 225 | |
| 226 /** | |
| 227 * Gets the selected printer capabilities and updates the controls accordingly. | 194 * Gets the selected printer capabilities and updates the controls accordingly. |
| 228 */ | 195 */ |
| 229 function updateControlsWithSelectedPrinterCapabilities() { | 196 function updateControlsWithSelectedPrinterCapabilities() { |
| 230 var printerList = $('printer-list'); | 197 var printerList = $('printer-list'); |
| 231 var selectedIndex = printerList.selectedIndex; | 198 var selectedIndex = printerList.selectedIndex; |
| 232 if (selectedIndex < 0) | 199 if (selectedIndex < 0) |
| 233 return; | 200 return; |
| 234 var skip_refresh = false; | 201 var skip_refresh = false; |
| 235 var selectedValue = printerList.options[selectedIndex].value; | 202 var selectedValue = printerList.options[selectedIndex].value; |
| 236 if (cloudprint.isCloudPrint(printerList.options[selectedIndex])) { | 203 if (cloudprint.isCloudPrint(printerList.options[selectedIndex])) { |
| (...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1072 if (initiatorTabTitle == '') | 1039 if (initiatorTabTitle == '') |
| 1073 return; | 1040 return; |
| 1074 document.title = localStrings.getStringF( | 1041 document.title = localStrings.getStringF( |
| 1075 'printPreviewTitleFormat', initiatorTabTitle); | 1042 'printPreviewTitleFormat', initiatorTabTitle); |
| 1076 } | 1043 } |
| 1077 | 1044 |
| 1078 /** | 1045 /** |
| 1079 * Closes this print preview tab. | 1046 * Closes this print preview tab. |
| 1080 */ | 1047 */ |
| 1081 function closePrintPreviewTab() { | 1048 function closePrintPreviewTab() { |
| 1082 chrome.send('closePrintPreviewTab'); | 1049 chrome.send('DialogClose', []); |
| 1083 } | 1050 } |
| 1084 | 1051 |
| 1085 /** | 1052 /** |
| 1086 * Handle keyboard events. | 1053 * Handle keyboard events. |
| 1087 * @param {KeyboardEvent} e The keyboard event. | 1054 * @param {KeyboardEvent} e The keyboard event. |
| 1088 */ | 1055 */ |
| 1089 function onKeyDown(e) { | 1056 function onKeyDown(e) { |
| 1090 // Escape key closes the dialog. | 1057 // Escape key closes the dialog. |
| 1091 if (e.keyCode == 27 && !e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) { | 1058 if (e.keyCode == 27 && !e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) { |
| 1092 printHeader.disableCancelButton(); | 1059 printHeader.disableCancelButton(); |
| 1093 closePrintPreviewTab(); | 1060 closePrintPreviewTab(); |
| 1094 } | 1061 } |
| 1062 if (e.keyCode == 80 || e.keyCode == 112) { | |
| 1063 if ((cr.isMac && e.shiftKey && e.metaKey && !e.ctrlKey && !e.altKey) || | |
|
kmadhusu
2011/10/13 18:52:18
Why do you need this? If we press the key combinat
Lei Zhang
2011/10/13 21:12:12
When the constrained window has focus, the browser
| |
| 1064 (!cr.isMac && e.shiftKey && e.ctrlKey && !e.altKey && !e.metaKey)) { | |
| 1065 window.onkeydown = null; | |
| 1066 onSystemDialogLinkClicked(); | |
| 1067 } | |
| 1068 } | |
| 1095 } | 1069 } |
| 1096 | 1070 |
| 1097 window.addEventListener('DOMContentLoaded', onLoad); | 1071 window.addEventListener('DOMContentLoaded', onLoad); |
| 1098 window.onkeydown = onKeyDown; | 1072 window.onkeydown = onKeyDown; |
| 1099 | 1073 |
| 1100 /// Pull in all other scripts in a single shot. | 1074 /// Pull in all other scripts in a single shot. |
| 1101 <include src="print_preview_animations.js"/> | 1075 <include src="print_preview_animations.js"/> |
| 1102 <include src="print_preview_cloud.js"/> | 1076 <include src="print_preview_cloud.js"/> |
| 1103 <include src="print_preview_utils.js"/> | 1077 <include src="print_preview_utils.js"/> |
| 1104 <include src="print_header.js"/> | 1078 <include src="print_header.js"/> |
| 1105 <include src="page_settings.js"/> | 1079 <include src="page_settings.js"/> |
| 1106 <include src="copies_settings.js"/> | 1080 <include src="copies_settings.js"/> |
| 1107 <include src="header_footer_settings.js"/> | 1081 <include src="header_footer_settings.js"/> |
| 1108 <include src="layout_settings.js"/> | 1082 <include src="layout_settings.js"/> |
| 1109 <include src="color_settings.js"/> | 1083 <include src="color_settings.js"/> |
| 1110 <include src="margin_settings.js"/> | 1084 <include src="margin_settings.js"/> |
| 1111 <include src="margin_textbox.js"/> | 1085 <include src="margin_textbox.js"/> |
| 1112 <include src="margin_line.js"/> | 1086 <include src="margin_line.js"/> |
| 1113 <include src="margin_utils.js"/> | 1087 <include src="margin_utils.js"/> |
| 1114 <include src="margins_ui.js"/> | 1088 <include src="margins_ui.js"/> |
| 1115 <include src="preview_area.js"/> | 1089 <include src="preview_area.js"/> |
| OLD | NEW |