| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 cr.enablePlatformSpecificCSSRules(); | 142 cr.enablePlatformSpecificCSSRules(); |
| 143 initialPreviewRequestID = randomInteger(MIN_REQUEST_ID, MAX_REQUEST_ID); | 143 initialPreviewRequestID = randomInteger(MIN_REQUEST_ID, MAX_REQUEST_ID); |
| 144 lastPreviewRequestID = initialPreviewRequestID; | 144 lastPreviewRequestID = initialPreviewRequestID; |
| 145 | 145 |
| 146 previewArea = print_preview.PreviewArea.getInstance(); | 146 previewArea = print_preview.PreviewArea.getInstance(); |
| 147 printHeader = print_preview.PrintHeader.getInstance(); | 147 printHeader = print_preview.PrintHeader.getInstance(); |
| 148 document.addEventListener(customEvents.PDF_GENERATION_ERROR, | 148 document.addEventListener(customEvents.PDF_GENERATION_ERROR, |
| 149 cancelPendingPrintRequest); | 149 cancelPendingPrintRequest); |
| 150 | 150 |
| 151 if (!checkCompatiblePluginExists()) { | 151 if (!checkCompatiblePluginExists()) { |
| 152 disableInputElementsInSidebar(); | |
| 153 $('cancel-button').focus(); | 152 $('cancel-button').focus(); |
| 154 previewArea.displayErrorMessageWithButtonAndNotify( | 153 previewArea.displayErrorMessageWithButtonAndNotify( |
| 155 localStrings.getString('noPlugin'), | 154 localStrings.getString('noPlugin'), |
| 156 localStrings.getString('launchNativeDialog'), | 155 localStrings.getString('launchNativeDialog'), |
| 157 launchNativePrintDialog); | 156 launchNativePrintDialog); |
| 158 $('mainview').parentElement.removeChild($('dummy-viewer')); | 157 $('mainview').parentElement.removeChild($('dummy-viewer')); |
| 159 return; | 158 return; |
| 160 } | 159 } |
| 161 | 160 |
| 162 $('system-dialog-link').addEventListener('click', onSystemDialogLinkClicked); | 161 $('system-dialog-link').addEventListener('click', onSystemDialogLinkClicked); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 193 initialSettings['measurementSystem']); | 192 initialSettings['measurementSystem']); |
| 194 marginSettings.setLastUsedMargins(initialSettings); | 193 marginSettings.setLastUsedMargins(initialSettings); |
| 195 } | 194 } |
| 196 setDefaultPrinter(initialSettings['printerName'], | 195 setDefaultPrinter(initialSettings['printerName'], |
| 197 initialSettings['cloudPrintData']); | 196 initialSettings['cloudPrintData']); |
| 198 printAutomaticallyInKioskMode = | 197 printAutomaticallyInKioskMode = |
| 199 initialSettings['printAutomaticallyInKioskMode']; | 198 initialSettings['printAutomaticallyInKioskMode']; |
| 200 } | 199 } |
| 201 | 200 |
| 202 /** | 201 /** |
| 203 * Disables the input elements in the sidebar. | 202 * Shows the throbber and instructs the backend to open the native print dialog. |
| 204 */ | |
| 205 function disableInputElementsInSidebar() { | |
| 206 var els = $('navbar-container').querySelectorAll('input, button, select'); | |
| 207 for (var i = 0; i < els.length; i++) { | |
| 208 if (els[i] == printHeader.cancelButton) | |
| 209 continue; | |
| 210 els[i].disabled = true; | |
| 211 } | |
| 212 } | |
| 213 | |
| 214 /** | |
| 215 * Enables the input elements in the sidebar. | |
| 216 */ | |
| 217 function enableInputElementsInSidebar() { | |
| 218 var els = $('navbar-container').querySelectorAll('input, button, select'); | |
| 219 for (var i = 0; i < els.length; i++) | |
| 220 els[i].disabled = false; | |
| 221 } | |
| 222 | |
| 223 /** | |
| 224 * Disables the controls in the sidebar, shows the throbber and instructs the | |
| 225 * backend to open the native print dialog. | |
| 226 */ | 203 */ |
| 227 function onSystemDialogLinkClicked() { | 204 function onSystemDialogLinkClicked() { |
| 228 if (showingSystemDialog) | 205 if (showingSystemDialog) |
| 229 return; | 206 return; |
| 230 showingSystemDialog = true; | 207 showingSystemDialog = true; |
| 231 disableInputElementsInSidebar(); | |
| 232 printHeader.disableCancelButton(); | 208 printHeader.disableCancelButton(); |
| 233 $('system-dialog-throbber').hidden = false; | 209 $('system-dialog-throbber').hidden = false; |
| 234 chrome.send('showSystemDialog'); | 210 chrome.send('showSystemDialog'); |
| 235 } | 211 } |
| 236 | 212 |
| 237 /** | 213 /** |
| 238 * Disables the controls in the sidebar, shows the throbber and instructs the | 214 * Shows the throbber and instructs the backend to open the pdf in native |
| 239 * backend to open the pdf in native preview app. This is only for Mac. | 215 * preview app. This is only for Mac. |
| 240 */ | 216 */ |
| 241 function onOpenPdfInPreviewLinkClicked() { | 217 function onOpenPdfInPreviewLinkClicked() { |
| 242 if (previewAppRequested) | 218 if (previewAppRequested) |
| 243 return; | 219 return; |
| 244 previewAppRequested = true; | 220 previewAppRequested = true; |
| 245 disableInputElementsInSidebar(); | |
| 246 $('open-preview-app-throbber').hidden = false; | 221 $('open-preview-app-throbber').hidden = false; |
| 247 printHeader.disableCancelButton(); | 222 printHeader.disableCancelButton(); |
| 248 requestToPrintDocument(); | 223 requestToPrintDocument(); |
| 249 } | 224 } |
| 250 | 225 |
| 251 /** | 226 /** |
| 252 * Similar to onSystemDialogLinkClicked(), but specific to the | 227 * Similar to onSystemDialogLinkClicked(), but specific to the |
| 253 * 'Launch native print dialog' UI. | 228 * 'Launch native print dialog' UI. |
| 254 */ | 229 */ |
| 255 function launchNativePrintDialog() { | 230 function launchNativePrintDialog() { |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 var printWithCloudPrint = selectedPrinterName == PRINT_WITH_CLOUD_PRINT; | 477 var printWithCloudPrint = selectedPrinterName == PRINT_WITH_CLOUD_PRINT; |
| 503 if (hasPendingPrintDocumentRequest) { | 478 if (hasPendingPrintDocumentRequest) { |
| 504 if (previewAppRequested) { | 479 if (previewAppRequested) { |
| 505 previewArea.showCustomMessage( | 480 previewArea.showCustomMessage( |
| 506 localStrings.getString('openingPDFInPreview')); | 481 localStrings.getString('openingPDFInPreview')); |
| 507 } else if (printToPDF) { | 482 } else if (printToPDF) { |
| 508 sendPrintDocumentRequest(); | 483 sendPrintDocumentRequest(); |
| 509 } else if (printWithCloudPrint) { | 484 } else if (printWithCloudPrint) { |
| 510 previewArea.showCustomMessage( | 485 previewArea.showCustomMessage( |
| 511 localStrings.getString('printWithCloudPrintWait')); | 486 localStrings.getString('printWithCloudPrintWait')); |
| 512 disableInputElementsInSidebar(); | |
| 513 } else { | 487 } else { |
| 514 isTabHidden = true; | 488 isTabHidden = true; |
| 515 chrome.send('hidePreview'); | 489 chrome.send('hidePreview'); |
| 516 } | 490 } |
| 517 return; | 491 return; |
| 518 } | 492 } |
| 519 | 493 |
| 520 if (printToPDF || previewAppRequested) { | 494 if (printToPDF || previewAppRequested) { |
| 521 sendPrintDocumentRequest(); | 495 sendPrintDocumentRequest(); |
| 522 } else { | 496 } else { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 printHeader.enableCancelButton(); | 578 printHeader.enableCancelButton(); |
| 605 } | 579 } |
| 606 | 580 |
| 607 /** | 581 /** |
| 608 * Called from PrintPreviewUI::OnFileSelectionCompleted to notify the print | 582 * Called from PrintPreviewUI::OnFileSelectionCompleted to notify the print |
| 609 * preview tab regarding the file selection completed event. | 583 * preview tab regarding the file selection completed event. |
| 610 */ | 584 */ |
| 611 function fileSelectionCompleted() { | 585 function fileSelectionCompleted() { |
| 612 // If the file selection is completed and the tab is not already closed it | 586 // If the file selection is completed and the tab is not already closed it |
| 613 // means that a pending print to pdf request exists. | 587 // means that a pending print to pdf request exists. |
| 614 disableInputElementsInSidebar(); | |
| 615 previewArea.showCustomMessage( | 588 previewArea.showCustomMessage( |
| 616 localStrings.getString('printingToPDFInProgress')); | 589 localStrings.getString('printingToPDFInProgress')); |
| 617 } | 590 } |
| 618 | 591 |
| 619 /** | 592 /** |
| 620 * Set the default printer. If there is one, generate a print preview. | 593 * Set the default printer. If there is one, generate a print preview. |
| 621 * @param {string} printerName Name of the default printer. Empty if none. | 594 * @param {string} printerName Name of the default printer. Empty if none. |
| 622 * @param {string} cloudPrintData Cloud print related data to restore if | 595 * @param {string} cloudPrintData Cloud print related data to restore if |
| 623 * the default printer is a cloud printer. | 596 * the default printer is a cloud printer. |
| 624 */ | 597 */ |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 * Display an error message when encountered invalid printer settings. | 768 * Display an error message when encountered invalid printer settings. |
| 796 * Called from PrintPreviewMessageHandler::OnInvalidPrinterSettings(). | 769 * Called from PrintPreviewMessageHandler::OnInvalidPrinterSettings(). |
| 797 */ | 770 */ |
| 798 function invalidPrinterSettings() { | 771 function invalidPrinterSettings() { |
| 799 if (cr.isMac) { | 772 if (cr.isMac) { |
| 800 if (previewAppRequested) { | 773 if (previewAppRequested) { |
| 801 $('open-preview-app-throbber').hidden = true; | 774 $('open-preview-app-throbber').hidden = true; |
| 802 previewArea.clearCustomMessageWithDots(); | 775 previewArea.clearCustomMessageWithDots(); |
| 803 previewAppRequested = false; | 776 previewAppRequested = false; |
| 804 hasPendingPrintDocumentRequest = false; | 777 hasPendingPrintDocumentRequest = false; |
| 805 enableInputElementsInSidebar(); | |
| 806 } | 778 } |
| 807 $('open-pdf-in-preview-link').disabled = true; | 779 $('open-pdf-in-preview-link').disabled = true; |
| 808 } | 780 } |
| 809 previewArea.displayErrorMessageAndNotify( | 781 previewArea.displayErrorMessageAndNotify( |
| 810 localStrings.getString('invalidPrinterSettings')); | 782 localStrings.getString('invalidPrinterSettings')); |
| 811 } | 783 } |
| 812 | 784 |
| 813 /** | 785 /** |
| 814 * Called when the PDF plugin loads its document. | 786 * Called when the PDF plugin loads its document. |
| 815 */ | 787 */ |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1160 <include src="copies_settings.js"/> | 1132 <include src="copies_settings.js"/> |
| 1161 <include src="header_footer_settings.js"/> | 1133 <include src="header_footer_settings.js"/> |
| 1162 <include src="layout_settings.js"/> | 1134 <include src="layout_settings.js"/> |
| 1163 <include src="color_settings.js"/> | 1135 <include src="color_settings.js"/> |
| 1164 <include src="margin_settings.js"/> | 1136 <include src="margin_settings.js"/> |
| 1165 <include src="margin_textbox.js"/> | 1137 <include src="margin_textbox.js"/> |
| 1166 <include src="margin_utils.js"/> | 1138 <include src="margin_utils.js"/> |
| 1167 <include src="margins_ui.js"/> | 1139 <include src="margins_ui.js"/> |
| 1168 <include src="margins_ui_pair.js"/> | 1140 <include src="margins_ui_pair.js"/> |
| 1169 <include src="preview_area.js"/> | 1141 <include src="preview_area.js"/> |
| OLD | NEW |