Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(373)

Side by Side Diff: chrome/browser/resources/print_preview/print_preview.js

Issue 8136027: Print Preview: Make print preview tab modal. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: address comments Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 chrome.send('getPreview', [JSON.stringify(getSettingsWithRequestID()), 491 chrome.send('getPreview', [JSON.stringify(getSettingsWithRequestID()),
525 pageCount, 492 pageCount,
526 previewModifiable]); 493 previewModifiable]);
527 } 494 }
528 495
529 /** 496 /**
530 * Called from PrintPreviewUI::OnFileSelectionCancelled to notify the print 497 * Called from PrintPreviewUI::OnFileSelectionCancelled to notify the print
531 * preview tab regarding the file selection cancel event. 498 * preview tab regarding the file selection cancel event.
532 */ 499 */
533 function fileSelectionCancelled() { 500 function fileSelectionCancelled() {
534 // TODO(thestig) re-enable controls here. 501 printHeader.enableCancelButton();
535 } 502 }
536 503
537 /** 504 /**
538 * Called from PrintPreviewUI::OnFileSelectionCompleted to notify the print 505 * Called from PrintPreviewUI::OnFileSelectionCompleted to notify the print
539 * preview tab regarding the file selection completed event. 506 * preview tab regarding the file selection completed event.
540 */ 507 */
541 function fileSelectionCompleted() { 508 function fileSelectionCompleted() {
542 // If the file selection is completed and the tab is not already closed it 509 // If the file selection is completed and the tab is not already closed it
543 // means that a pending print to pdf request exists. 510 // means that a pending print to pdf request exists.
544 disableInputElementsInSidebar(); 511 disableInputElementsInSidebar();
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 return; 1041 return;
1075 document.title = localStrings.getStringF( 1042 document.title = localStrings.getStringF(
1076 'printPreviewTitleFormat', initiatorTabTitle); 1043 'printPreviewTitleFormat', initiatorTabTitle);
1077 } 1044 }
1078 1045
1079 /** 1046 /**
1080 * Closes this print preview tab. 1047 * Closes this print preview tab.
1081 */ 1048 */
1082 function closePrintPreviewTab() { 1049 function closePrintPreviewTab() {
1083 chrome.send('closePrintPreviewTab'); 1050 chrome.send('closePrintPreviewTab');
1051 chrome.send('DialogClose');
1084 } 1052 }
1085 1053
1086 /** 1054 /**
1087 * Handle keyboard events. 1055 * Handle keyboard events.
1088 * @param {KeyboardEvent} e The keyboard event. 1056 * @param {KeyboardEvent} e The keyboard event.
1089 */ 1057 */
1090 function onKeyDown(e) { 1058 function onKeyDown(e) {
1091 // Escape key closes the dialog. 1059 // Escape key closes the dialog.
1092 if (e.keyCode == 27 && !e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) { 1060 if (e.keyCode == 27 && !e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) {
1093 printHeader.disableCancelButton(); 1061 printHeader.disableCancelButton();
1094 closePrintPreviewTab(); 1062 closePrintPreviewTab();
1095 } 1063 }
1064 if (e.keyCode == 80) {
1065 if ((cr.isMac && e.metaKey && e.altKey && !e.shiftKey && !e.ctrlKey) ||
1066 (!cr.isMac && e.shiftKey && e.ctrlKey && !e.altKey && !e.metaKey)) {
1067 window.onkeydown = null;
1068 onSystemDialogLinkClicked();
1069 }
1070 }
1096 } 1071 }
1097 1072
1098 window.addEventListener('DOMContentLoaded', onLoad); 1073 window.addEventListener('DOMContentLoaded', onLoad);
1099 window.onkeydown = onKeyDown; 1074 window.onkeydown = onKeyDown;
1100 1075
1101 /// Pull in all other scripts in a single shot. 1076 /// Pull in all other scripts in a single shot.
1102 <include src="print_preview_animations.js"/> 1077 <include src="print_preview_animations.js"/>
1103 <include src="print_preview_cloud.js"/> 1078 <include src="print_preview_cloud.js"/>
1104 <include src="print_preview_utils.js"/> 1079 <include src="print_preview_utils.js"/>
1105 <include src="print_header.js"/> 1080 <include src="print_header.js"/>
1106 <include src="page_settings.js"/> 1081 <include src="page_settings.js"/>
1107 <include src="copies_settings.js"/> 1082 <include src="copies_settings.js"/>
1108 <include src="header_footer_settings.js"/> 1083 <include src="header_footer_settings.js"/>
1109 <include src="layout_settings.js"/> 1084 <include src="layout_settings.js"/>
1110 <include src="color_settings.js"/> 1085 <include src="color_settings.js"/>
1111 <include src="margin_settings.js"/> 1086 <include src="margin_settings.js"/>
1112 <include src="margin_textbox.js"/> 1087 <include src="margin_textbox.js"/>
1113 <include src="margin_line.js"/> 1088 <include src="margin_line.js"/>
1114 <include src="margin_utils.js"/> 1089 <include src="margin_utils.js"/>
1115 <include src="margins_ui.js"/> 1090 <include src="margins_ui.js"/>
1116 <include src="preview_area.js"/> 1091 <include src="preview_area.js"/>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698