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

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: do not listen for F1 key in JS 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) {
vandebo (ex-Chrome) 2011/10/14 07:14:05 The initiator tab can still crash. What happens n
Lei Zhang 2011/10/14 20:31:27 Sad tab takes over the tab and we lose the constra
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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 chrome.send('getPreview', [JSON.stringify(getSettingsWithRequestID()), 492 chrome.send('getPreview', [JSON.stringify(getSettingsWithRequestID()),
526 pageCount, 493 pageCount,
527 previewModifiable]); 494 previewModifiable]);
528 } 495 }
529 496
530 /** 497 /**
531 * Called from PrintPreviewUI::OnFileSelectionCancelled to notify the print 498 * Called from PrintPreviewUI::OnFileSelectionCancelled to notify the print
532 * preview tab regarding the file selection cancel event. 499 * preview tab regarding the file selection cancel event.
533 */ 500 */
534 function fileSelectionCancelled() { 501 function fileSelectionCancelled() {
535 // TODO(thestig) re-enable controls here. 502 printHeader.enableCancelButton();
536 } 503 }
537 504
538 /** 505 /**
539 * Called from PrintPreviewUI::OnFileSelectionCompleted to notify the print 506 * Called from PrintPreviewUI::OnFileSelectionCompleted to notify the print
540 * preview tab regarding the file selection completed event. 507 * preview tab regarding the file selection completed event.
541 */ 508 */
542 function fileSelectionCompleted() { 509 function fileSelectionCompleted() {
543 // If the file selection is completed and the tab is not already closed it 510 // If the file selection is completed and the tab is not already closed it
544 // means that a pending print to pdf request exists. 511 // means that a pending print to pdf request exists.
545 disableInputElementsInSidebar(); 512 disableInputElementsInSidebar();
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 if (initiatorTabTitle == '') 1041 if (initiatorTabTitle == '')
1075 return; 1042 return;
1076 document.title = localStrings.getStringF( 1043 document.title = localStrings.getStringF(
1077 'printPreviewTitleFormat', initiatorTabTitle); 1044 'printPreviewTitleFormat', initiatorTabTitle);
1078 } 1045 }
1079 1046
1080 /** 1047 /**
1081 * Closes this print preview tab. 1048 * Closes this print preview tab.
1082 */ 1049 */
1083 function closePrintPreviewTab() { 1050 function closePrintPreviewTab() {
1084 chrome.send('closePrintPreviewTab'); 1051 chrome.send('DialogClose', []);
1085 } 1052 }
1086 1053
1087 /** 1054 /**
1088 * Handle keyboard events. 1055 * Handle keyboard events.
1089 * @param {KeyboardEvent} e The keyboard event. 1056 * @param {KeyboardEvent} e The keyboard event.
1090 */ 1057 */
1091 function onKeyDown(e) { 1058 function onKeyDown(e) {
1092 // Escape key closes the dialog. 1059 // Escape key closes the dialog.
1093 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) {
kmadhusu 2011/10/14 01:11:38 Several times, I tried to close the preview tab an
Lei Zhang 2011/10/14 20:31:27 I'd prefer not too. This starts us down a slippery
1094 printHeader.disableCancelButton(); 1061 printHeader.disableCancelButton();
1095 closePrintPreviewTab(); 1062 closePrintPreviewTab();
1096 } 1063 }
1064 if (e.keyCode == 80) {
1065 if ((cr.isMac && e.shiftKey && e.metaKey && !e.ctrlKey && !e.altKey) ||
kmadhusu 2011/10/14 00:21:09 On mac, we use cmd+opt+P and not cmd+shift+p
Lei Zhang 2011/10/14 20:31:27 Shows you how much I know about macs. :) _ \_ is
1066 (!cr.isMac && e.shiftKey && e.ctrlKey && !e.altKey && !e.metaKey)) {
1067 window.onkeydown = null;
1068 onSystemDialogLinkClicked();
1069 }
1070 }
1097 } 1071 }
1098 1072
1099 window.addEventListener('DOMContentLoaded', onLoad); 1073 window.addEventListener('DOMContentLoaded', onLoad);
1100 window.onkeydown = onKeyDown; 1074 window.onkeydown = onKeyDown;
1101 1075
1102 /// Pull in all other scripts in a single shot. 1076 /// Pull in all other scripts in a single shot.
1103 <include src="print_preview_animations.js"/> 1077 <include src="print_preview_animations.js"/>
1104 <include src="print_preview_cloud.js"/> 1078 <include src="print_preview_cloud.js"/>
1105 <include src="print_preview_utils.js"/> 1079 <include src="print_preview_utils.js"/>
1106 <include src="print_header.js"/> 1080 <include src="print_header.js"/>
1107 <include src="page_settings.js"/> 1081 <include src="page_settings.js"/>
1108 <include src="copies_settings.js"/> 1082 <include src="copies_settings.js"/>
1109 <include src="header_footer_settings.js"/> 1083 <include src="header_footer_settings.js"/>
1110 <include src="layout_settings.js"/> 1084 <include src="layout_settings.js"/>
1111 <include src="color_settings.js"/> 1085 <include src="color_settings.js"/>
1112 <include src="margin_settings.js"/> 1086 <include src="margin_settings.js"/>
1113 <include src="margin_textbox.js"/> 1087 <include src="margin_textbox.js"/>
1114 <include src="margin_line.js"/> 1088 <include src="margin_line.js"/>
1115 <include src="margin_utils.js"/> 1089 <include src="margin_utils.js"/>
1116 <include src="margins_ui.js"/> 1090 <include src="margins_ui.js"/>
1117 <include src="preview_area.js"/> 1091 <include src="preview_area.js"/>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698