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 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 * Asks the browser to print the preview PDF based on current print | 428 * Asks the browser to print the preview PDF based on current print |
429 * settings. If the preview is still loading, printPendingFile() will get | 429 * settings. If the preview is still loading, printPendingFile() will get |
430 * called once the preview loads. | 430 * called once the preview loads. |
431 */ | 431 */ |
432 function requestToPrintDocument() { | 432 function requestToPrintDocument() { |
433 hasPendingPrintDocumentRequest = !isPrintReadyMetafileReady; | 433 hasPendingPrintDocumentRequest = !isPrintReadyMetafileReady; |
434 var printToPDF = getSelectedPrinterName() == PRINT_TO_PDF; | 434 var printToPDF = getSelectedPrinterName() == PRINT_TO_PDF; |
435 | 435 |
436 if (hasPendingPrintDocumentRequest) { | 436 if (hasPendingPrintDocumentRequest) { |
437 if (printToPDF) { | 437 if (printToPDF) { |
438 // TODO(thestig) disable controls here. | 438 sendPrintDocumentRequest(); |
439 } else { | 439 } else { |
440 isTabHidden = true; | 440 isTabHidden = true; |
441 chrome.send('hidePreview'); | 441 chrome.send('hidePreview'); |
442 } | 442 } |
443 return; | 443 return; |
444 } | 444 } |
445 | 445 |
446 if (printToPDF) { | 446 if (printToPDF) { |
447 sendPrintDocumentRequest(); | 447 sendPrintDocumentRequest(); |
448 } else { | 448 } else { |
449 window.setTimeout(function() { sendPrintDocumentRequest(); }, 1000); | 449 window.setTimeout(function() { sendPrintDocumentRequest(); }, 1000); |
450 } | 450 } |
451 } | 451 } |
452 | 452 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 | 532 |
533 /** | 533 /** |
534 * Called from PrintPreviewUI::OnFileSelectionCancelled to notify the print | 534 * Called from PrintPreviewUI::OnFileSelectionCancelled to notify the print |
535 * preview tab regarding the file selection cancel event. | 535 * preview tab regarding the file selection cancel event. |
536 */ | 536 */ |
537 function fileSelectionCancelled() { | 537 function fileSelectionCancelled() { |
538 // TODO(thestig) re-enable controls here. | 538 // TODO(thestig) re-enable controls here. |
539 } | 539 } |
540 | 540 |
541 /** | 541 /** |
| 542 * Called from PrintPreviewUI::OnFileSelectionCompleted to notify the print |
| 543 * preview tab regarding the file selection completed event. |
| 544 */ |
| 545 function fileSelectionCompleted() { |
| 546 // If the file selection is completed and the tab is not already closed it |
| 547 // means that a pending print to pdf request exists. |
| 548 disableInputElementsInSidebar(); |
| 549 showCustomMessage(localStrings.getString('printingToPDFInProgress')); |
| 550 } |
| 551 |
| 552 /** |
542 * Set the default printer. If there is one, generate a print preview. | 553 * Set the default printer. If there is one, generate a print preview. |
543 * @param {string} printer Name of the default printer. Empty if none. | 554 * @param {string} printer Name of the default printer. Empty if none. |
544 * @param {string} cloudPrintData Cloud print related data to restore if | 555 * @param {string} cloudPrintData Cloud print related data to restore if |
545 * the default printer is a cloud printer. | 556 * the default printer is a cloud printer. |
546 */ | 557 */ |
547 function setDefaultPrinter(printer_name, cloudPrintData) { | 558 function setDefaultPrinter(printer_name, cloudPrintData) { |
548 // Add a placeholder value so the printer list looks valid. | 559 // Add a placeholder value so the printer list looks valid. |
549 addDestinationListOption('', '', true, true, true); | 560 addDestinationListOption('', '', true, true, true); |
550 if (printer_name) { | 561 if (printer_name) { |
551 defaultOrLastUsedPrinterName = printer_name; | 562 defaultOrLastUsedPrinterName = printer_name; |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 cloudprint.setColor(printerList[printerList.selectedIndex], color); | 827 cloudprint.setColor(printerList[printerList.selectedIndex], color); |
817 } | 828 } |
818 | 829 |
819 /** | 830 /** |
820 * Display an error message in the center of the preview area. | 831 * Display an error message in the center of the preview area. |
821 * @param {string} errorMessage The error message to be displayed. | 832 * @param {string} errorMessage The error message to be displayed. |
822 */ | 833 */ |
823 function displayErrorMessage(errorMessage) { | 834 function displayErrorMessage(errorMessage) { |
824 $('print-button').disabled = true; | 835 $('print-button').disabled = true; |
825 $('overlay-layer').classList.remove('invisible'); | 836 $('overlay-layer').classList.remove('invisible'); |
826 $('dancing-dots-text').classList.add('hidden'); | 837 var customMessage = $('custom-message'); |
827 $('error-text').innerHTML = errorMessage; | 838 customMessage.textContent = errorMessage; |
828 $('error-text').classList.remove('hidden'); | 839 customMessage.hidden = false; |
| 840 var customMessageWithDots = $('custom-message-with-dots'); |
| 841 customMessageWithDots.innerHTML = ''; |
| 842 customMessageWithDots.hidden = true;; |
829 var pdfViewer = $('pdf-viewer'); | 843 var pdfViewer = $('pdf-viewer'); |
830 if (pdfViewer) | 844 if (pdfViewer) |
831 $('mainview').removeChild(pdfViewer); | 845 $('mainview').removeChild(pdfViewer); |
832 | 846 |
833 if (isTabHidden) | 847 if (isTabHidden) |
834 cancelPendingPrintRequest(); | 848 cancelPendingPrintRequest(); |
835 } | 849 } |
836 | 850 |
837 /** | 851 /** |
838 * Display an error message in the center of the preview area followed by a | 852 * Display an error message in the center of the preview area followed by a |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 | 888 |
875 /** | 889 /** |
876 * Called when the PDF plugin loads its document. | 890 * Called when the PDF plugin loads its document. |
877 */ | 891 */ |
878 function onPDFLoad() { | 892 function onPDFLoad() { |
879 if (previewModifiable) { | 893 if (previewModifiable) { |
880 setPluginPreviewPageCount(); | 894 setPluginPreviewPageCount(); |
881 } | 895 } |
882 $('pdf-viewer').fitToHeight(); | 896 $('pdf-viewer').fitToHeight(); |
883 cr.dispatchSimpleEvent(document, 'PDFLoaded'); | 897 cr.dispatchSimpleEvent(document, 'PDFLoaded'); |
884 hideLoadingAnimation(); | 898 hideOverlayLayer(); |
885 } | 899 } |
886 | 900 |
887 function setPluginPreviewPageCount() { | 901 function setPluginPreviewPageCount() { |
888 $('pdf-viewer').printPreviewPageCount( | 902 $('pdf-viewer').printPreviewPageCount( |
889 pageSettings.previouslySelectedPages.length); | 903 pageSettings.previouslySelectedPages.length); |
890 } | 904 } |
891 | 905 |
892 /** | 906 /** |
893 * Update the page count and check the page range. | 907 * Update the page count and check the page range. |
894 * Called from PrintPreviewUI::OnDidGetPreviewPageCount(). | 908 * Called from PrintPreviewUI::OnDidGetPreviewPageCount(). |
(...skipping 24 matching lines...) Expand all Loading... |
919 * @param {number} previewResponseId The preview request id that resulted in | 933 * @param {number} previewResponseId The preview request id that resulted in |
920 * this response. | 934 * this response. |
921 */ | 935 */ |
922 function reloadPreviewPages(previewUid, previewResponseId) { | 936 function reloadPreviewPages(previewUid, previewResponseId) { |
923 if (!isExpectedPreviewResponse(previewResponseId)) | 937 if (!isExpectedPreviewResponse(previewResponseId)) |
924 return; | 938 return; |
925 hasPendingPreviewRequest = false; | 939 hasPendingPreviewRequest = false; |
926 isPrintReadyMetafileReady = true; | 940 isPrintReadyMetafileReady = true; |
927 | 941 |
928 cr.dispatchSimpleEvent(document, 'updatePrintButton'); | 942 cr.dispatchSimpleEvent(document, 'updatePrintButton'); |
929 hideLoadingAnimation(); | 943 hideOverlayLayer(); |
930 var pageSet = pageSettings.previouslySelectedPages; | 944 var pageSet = pageSettings.previouslySelectedPages; |
931 for (var i = 0; i < pageSet.length; i++) | 945 for (var i = 0; i < pageSet.length; i++) |
932 $('pdf-viewer').loadPreviewPage(getPageSrcURL(previewUid, pageSet[i]-1), i); | 946 $('pdf-viewer').loadPreviewPage(getPageSrcURL(previewUid, pageSet[i]-1), i); |
933 // TODO(dpapad): handle pending print file requests. | 947 // TODO(dpapad): handle pending print file requests. |
934 } | 948 } |
935 | 949 |
936 /** | 950 /** |
937 * Notification that a print preview page has been rendered. | 951 * Notification that a print preview page has been rendered. |
938 * Check if the settings have changed and request a regeneration if needed. | 952 * Check if the settings have changed and request a regeneration if needed. |
939 * Called from PrintPreviewUI::OnDidPreviewPage(). | 953 * Called from PrintPreviewUI::OnDidPreviewPage(). |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 <include src="print_preview_animations.js"/> | 1115 <include src="print_preview_animations.js"/> |
1102 <include src="print_preview_cloud.js"/> | 1116 <include src="print_preview_cloud.js"/> |
1103 <include src="print_preview_utils.js"/> | 1117 <include src="print_preview_utils.js"/> |
1104 <include src="print_header.js"/> | 1118 <include src="print_header.js"/> |
1105 <include src="page_settings.js"/> | 1119 <include src="page_settings.js"/> |
1106 <include src="copies_settings.js"/> | 1120 <include src="copies_settings.js"/> |
1107 <include src="header_footer_settings.js"/> | 1121 <include src="header_footer_settings.js"/> |
1108 <include src="layout_settings.js"/> | 1122 <include src="layout_settings.js"/> |
1109 <include src="color_settings.js"/> | 1123 <include src="color_settings.js"/> |
1110 <include src="margin_settings.js"/> | 1124 <include src="margin_settings.js"/> |
OLD | NEW |