| 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 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 // The name of the default or last used printer. | 30 // The name of the default or last used printer. |
| 31 var defaultOrLastUsedPrinterName = ''; | 31 var defaultOrLastUsedPrinterName = ''; |
| 32 | 32 |
| 33 // True when a pending print preview request exists. | 33 // True when a pending print preview request exists. |
| 34 var hasPendingPreviewRequest = false; | 34 var hasPendingPreviewRequest = false; |
| 35 | 35 |
| 36 // The ID of the last preview request. | 36 // The ID of the last preview request. |
| 37 var lastPreviewRequestID = -1; | 37 var lastPreviewRequestID = -1; |
| 38 | 38 |
| 39 // The ID of the initial preview request. |
| 40 var initialPreviewRequestID = -1; |
| 41 |
| 39 // True when a pending print file request exists. | 42 // True when a pending print file request exists. |
| 40 var hasPendingPrintDocumentRequest = false; | 43 var hasPendingPrintDocumentRequest = false; |
| 41 | 44 |
| 42 // True when preview tab is hidden. | 45 // True when preview tab is hidden. |
| 43 var isTabHidden = false; | 46 var isTabHidden = false; |
| 44 | 47 |
| 45 // Object holding all the pages related settings. | 48 // Object holding all the pages related settings. |
| 46 var pageSettings; | 49 var pageSettings; |
| 47 | 50 |
| 48 // Object holding all the copies related settings. | 51 // Object holding all the copies related settings. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 67 // made its way into this file. Refactor to create a cleaner boundary | 70 // made its way into this file. Refactor to create a cleaner boundary |
| 68 // between print preview and GCP code. Reference bug 88098 when fixing. | 71 // between print preview and GCP code. Reference bug 88098 when fixing. |
| 69 | 72 |
| 70 // A dictionary of cloud printers that have been added to the printer | 73 // A dictionary of cloud printers that have been added to the printer |
| 71 // dropdown. | 74 // dropdown. |
| 72 var addedCloudPrinters = {}; | 75 var addedCloudPrinters = {}; |
| 73 | 76 |
| 74 // The maximum number of cloud printers to allow in the dropdown. | 77 // The maximum number of cloud printers to allow in the dropdown. |
| 75 const maxCloudPrinters = 10; | 78 const maxCloudPrinters = 10; |
| 76 | 79 |
| 80 const MIN_REQUEST_ID = 0; |
| 81 const MAX_REQUEST_ID = 32000; |
| 82 |
| 77 /** | 83 /** |
| 78 * Window onload handler, sets up the page and starts print preview by getting | 84 * Window onload handler, sets up the page and starts print preview by getting |
| 79 * the printer list. | 85 * the printer list. |
| 80 */ | 86 */ |
| 81 function onLoad() { | 87 function onLoad() { |
| 82 cr.enablePlatformSpecificCSSRules(); | 88 cr.enablePlatformSpecificCSSRules(); |
| 89 initialPreviewRequestID = getRandomIntegerWithinRange(MIN_REQUEST_ID, |
| 90 MAX_REQUEST_ID); |
| 91 lastPreviewRequestID = initialPreviewRequestID; |
| 83 | 92 |
| 84 if (!checkCompatiblePluginExists()) { | 93 if (!checkCompatiblePluginExists()) { |
| 85 disableInputElementsInSidebar(); | 94 disableInputElementsInSidebar(); |
| 86 displayErrorMessageWithButton(localStrings.getString('noPlugin'), | 95 displayErrorMessageWithButton(localStrings.getString('noPlugin'), |
| 87 localStrings.getString('launchNativeDialog'), | 96 localStrings.getString('launchNativeDialog'), |
| 88 launchNativePrintDialog); | 97 launchNativePrintDialog); |
| 89 $('mainview').parentElement.removeChild($('dummy-viewer')); | 98 $('mainview').parentElement.removeChild($('dummy-viewer')); |
| 90 return; | 99 return; |
| 91 } | 100 } |
| 92 | 101 |
| 93 $('system-dialog-link').addEventListener('click', onSystemDialogLinkClicked); | 102 $('system-dialog-link').addEventListener('click', onSystemDialogLinkClicked); |
| 94 $('mainview').parentElement.removeChild($('dummy-viewer')); | 103 $('mainview').parentElement.removeChild($('dummy-viewer')); |
| 95 | 104 |
| 96 $('printer-list').disabled = true; | 105 $('printer-list').disabled = true; |
| 97 | 106 |
| 98 printHeader = print_preview.PrintHeader.getInstance(); | 107 printHeader = print_preview.PrintHeader.getInstance(); |
| 99 pageSettings = print_preview.PageSettings.getInstance(); | 108 pageSettings = print_preview.PageSettings.getInstance(); |
| 100 copiesSettings = print_preview.CopiesSettings.getInstance(); | 109 copiesSettings = print_preview.CopiesSettings.getInstance(); |
| 101 layoutSettings = print_preview.LayoutSettings.getInstance(); | 110 layoutSettings = print_preview.LayoutSettings.getInstance(); |
| 102 colorSettings = print_preview.ColorSettings.getInstance(); | 111 colorSettings = print_preview.ColorSettings.getInstance(); |
| 103 printHeader.addEventListeners(); | 112 printHeader.addEventListeners(); |
| 104 pageSettings.addEventListeners(); | 113 pageSettings.addEventListeners(); |
| 105 copiesSettings.addEventListeners(); | 114 copiesSettings.addEventListeners(); |
| 106 layoutSettings.addEventListeners(); | 115 layoutSettings.addEventListeners(); |
| 107 colorSettings.addEventListeners(); | 116 colorSettings.addEventListeners(); |
| 117 $('printer-list').onchange = updateControlsWithSelectedPrinterCapabilities; |
| 108 | 118 |
| 109 showLoadingAnimation(); | 119 showLoadingAnimation(); |
| 110 chrome.send('getDefaultPrinter'); | 120 chrome.send('getDefaultPrinter'); |
| 111 } | 121 } |
| 112 | 122 |
| 113 /** | 123 /** |
| 114 * Adds event listeners to the settings controls. | |
| 115 */ | |
| 116 function addEventListeners() { | |
| 117 // Controls that require preview rendering. | |
| 118 $('printer-list').onchange = updateControlsWithSelectedPrinterCapabilities; | |
| 119 } | |
| 120 | |
| 121 /** | |
| 122 * Removes event listeners from the settings controls. | |
| 123 */ | |
| 124 function removeEventListeners() { | |
| 125 if (pageSettings) | |
| 126 clearTimeout(pageSettings.timerId_); | |
| 127 | |
| 128 // Controls that require preview rendering | |
| 129 $('printer-list').onchange = null; | |
| 130 } | |
| 131 | |
| 132 /** | |
| 133 * Disables the input elements in the sidebar. | 124 * Disables the input elements in the sidebar. |
| 134 */ | 125 */ |
| 135 function disableInputElementsInSidebar() { | 126 function disableInputElementsInSidebar() { |
| 136 var els = $('sidebar').querySelectorAll('input, button, select'); | 127 var els = $('sidebar').querySelectorAll('input, button, select'); |
| 137 for (var i = 0; i < els.length; i++) | 128 for (var i = 0; i < els.length; i++) |
| 138 els[i].disabled = true; | 129 els[i].disabled = true; |
| 139 } | 130 } |
| 140 | 131 |
| 141 /** | 132 /** |
| 142 * Disables the controls in the sidebar, shows the throbber and instructs the | 133 * Disables the controls in the sidebar, shows the throbber and instructs the |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 * @return {boolean} true if settings are valid, false if not. | 278 * @return {boolean} true if settings are valid, false if not. |
| 288 */ | 279 */ |
| 289 function areSettingsValid() { | 280 function areSettingsValid() { |
| 290 return pageSettings.isPageSelectionValid() && | 281 return pageSettings.isPageSelectionValid() && |
| 291 (copiesSettings.isValid() || | 282 (copiesSettings.isValid() || |
| 292 getSelectedPrinterName() == PRINT_TO_PDF); | 283 getSelectedPrinterName() == PRINT_TO_PDF); |
| 293 } | 284 } |
| 294 | 285 |
| 295 /** | 286 /** |
| 296 * Creates an object based on the values in the printer settings. | 287 * Creates an object based on the values in the printer settings. |
| 288 * Note: |lastPreviewRequestID| is being modified every time this function is |
| 289 * called. |
| 297 * | 290 * |
| 298 * @return {Object} Object containing print job settings. | 291 * @return {Object} Object containing print job settings. |
| 299 */ | 292 */ |
| 300 function getSettings() { | 293 function getSettings() { |
| 301 var deviceName = getSelectedPrinterName(); | 294 var deviceName = getSelectedPrinterName(); |
| 302 var printToPDF = (deviceName == PRINT_TO_PDF); | 295 var printToPDF = (deviceName == PRINT_TO_PDF); |
| 303 | 296 |
| 304 var settings = | 297 var settings = |
| 305 {'deviceName': deviceName, | 298 {'deviceName': deviceName, |
| 306 'pageRange': pageSettings.selectedPageRanges, | 299 'pageRange': pageSettings.selectedPageRanges, |
| 307 'printAll': pageSettings.allPagesRadioButton.checked, | |
| 308 'duplex': copiesSettings.duplexMode, | 300 'duplex': copiesSettings.duplexMode, |
| 309 'copies': copiesSettings.numberOfCopies, | 301 'copies': copiesSettings.numberOfCopies, |
| 310 'collate': copiesSettings.isCollated(), | 302 'collate': copiesSettings.isCollated(), |
| 311 'landscape': layoutSettings.isLandscape(), | 303 'landscape': layoutSettings.isLandscape(), |
| 312 'color': colorSettings.isColor(), | 304 'color': colorSettings.isColor(), |
| 313 'printToPDF': printToPDF, | 305 'printToPDF': printToPDF, |
| 314 'requestID': 0}; | 306 'isFirstRequest' : isFirstPreviewRequest(), |
| 307 'requestID': generatePreviewRequestID()}; |
| 315 | 308 |
| 316 var printerList = $('printer-list'); | 309 var printerList = $('printer-list'); |
| 317 var selectedPrinter = printerList.selectedIndex; | 310 var selectedPrinter = printerList.selectedIndex; |
| 318 if (cloudprint.isCloudPrint(printerList.options[selectedPrinter])) { | 311 if (cloudprint.isCloudPrint(printerList.options[selectedPrinter])) { |
| 319 settings['cloudPrintID'] = | 312 settings['cloudPrintID'] = |
| 320 printerList.options[selectedPrinter].value; | 313 printerList.options[selectedPrinter].value; |
| 321 } | 314 } |
| 322 return settings; | 315 return settings; |
| 323 } | 316 } |
| 324 | 317 |
| 325 /** | 318 /** |
| 326 * @return {number} The next unused preview request id. | 319 * @return {number} The next unused preview request id. |
| 327 */ | 320 */ |
| 328 function generatePreviewRequestID() { | 321 function generatePreviewRequestID() { |
| 329 return ++lastPreviewRequestID; | 322 return ++lastPreviewRequestID; |
| 330 } | 323 } |
| 331 | 324 |
| 332 /** | 325 /** |
| 333 * @return {boolean} True iff a preview has been requested. | 326 * @return {boolean} True iff a preview has been requested. |
| 334 */ | 327 */ |
| 335 function hasRequestedPreview() { | 328 function hasRequestedPreview() { |
| 336 return lastPreviewRequestID > -1; | 329 return lastPreviewRequestID != initialPreviewRequestID; |
| 337 } | 330 } |
| 338 | 331 |
| 339 /** | 332 /** |
| 333 * @return {boolean} True if |lastPreviewRequestID| corresponds to the initial |
| 334 * preview request. |
| 335 */ |
| 336 function isFirstPreviewRequest() { |
| 337 return lastPreviewRequestID == initialPreviewRequestID + 1; |
| 338 } |
| 339 |
| 340 /** |
| 340 * Checks if |previewResponseId| matches |lastPreviewRequestId|. Used to ignore | 341 * Checks if |previewResponseId| matches |lastPreviewRequestId|. Used to ignore |
| 341 * obsolete preview data responses. | 342 * obsolete preview data responses. |
| 342 * @param {number} previewResponseId The id to check. | 343 * @param {number} previewResponseId The id to check. |
| 343 * @return {boolean} True if previewResponseId reffers to the expected response. | 344 * @return {boolean} True if previewResponseId reffers to the expected response. |
| 344 */ | 345 */ |
| 345 function isExpectedPreviewResponse(previewResponseId) { | 346 function isExpectedPreviewResponse(previewResponseId) { |
| 346 return lastPreviewRequestID == previewResponseId; | 347 return lastPreviewRequestID == previewResponseId; |
| 347 } | 348 } |
| 348 | 349 |
| 349 /** | 350 /** |
| (...skipping 24 matching lines...) Expand all Loading... |
| 374 } else { | 375 } else { |
| 375 isTabHidden = true; | 376 isTabHidden = true; |
| 376 chrome.send('hidePreview'); | 377 chrome.send('hidePreview'); |
| 377 } | 378 } |
| 378 return; | 379 return; |
| 379 } | 380 } |
| 380 | 381 |
| 381 if (printToPDF) { | 382 if (printToPDF) { |
| 382 sendPrintDocumentRequest(); | 383 sendPrintDocumentRequest(); |
| 383 } else { | 384 } else { |
| 384 removeEventListeners(); | |
| 385 window.setTimeout(function() { sendPrintDocumentRequest(); }, 1000); | 385 window.setTimeout(function() { sendPrintDocumentRequest(); }, 1000); |
| 386 } | 386 } |
| 387 } | 387 } |
| 388 | 388 |
| 389 /** | 389 /** |
| 390 * Asks the browser to print the pending preview PDF that just finished | 390 * Asks the browser to print the pending preview PDF that just finished |
| 391 * loading. | 391 * loading. |
| 392 */ | 392 */ |
| 393 function requestToPrintPendingDocument() { | 393 function requestToPrintPendingDocument() { |
| 394 hasPendingPrintDocumentRequest = false; | 394 hasPendingPrintDocumentRequest = false; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 418 cloudprint.getData(printer)]); | 418 cloudprint.getData(printer)]); |
| 419 chrome.send('print', [JSON.stringify(getSettings()), | 419 chrome.send('print', [JSON.stringify(getSettings()), |
| 420 cloudprint.getPrintTicketJSON(printer)]); | 420 cloudprint.getPrintTicketJSON(printer)]); |
| 421 } | 421 } |
| 422 | 422 |
| 423 /** | 423 /** |
| 424 * Asks the browser to generate a preview PDF based on current print settings. | 424 * Asks the browser to generate a preview PDF based on current print settings. |
| 425 */ | 425 */ |
| 426 function requestPrintPreview() { | 426 function requestPrintPreview() { |
| 427 hasPendingPreviewRequest = true; | 427 hasPendingPreviewRequest = true; |
| 428 removeEventListeners(); | |
| 429 printSettings.save(); | 428 printSettings.save(); |
| 430 if (!isTabHidden) | 429 if (!isTabHidden) |
| 431 showLoadingAnimation(); | 430 showLoadingAnimation(); |
| 432 | 431 |
| 433 var settings = getSettings(); | 432 chrome.send('getPreview', [JSON.stringify(getSettings())]); |
| 434 settings.requestID = generatePreviewRequestID(); | |
| 435 chrome.send('getPreview', [JSON.stringify(settings)]); | |
| 436 } | 433 } |
| 437 | 434 |
| 438 /** | 435 /** |
| 439 * Called from PrintPreviewUI::OnFileSelectionCancelled to notify the print | 436 * Called from PrintPreviewUI::OnFileSelectionCancelled to notify the print |
| 440 * preview tab regarding the file selection cancel event. | 437 * preview tab regarding the file selection cancel event. |
| 441 */ | 438 */ |
| 442 function fileSelectionCancelled() { | 439 function fileSelectionCancelled() { |
| 443 // TODO(thestig) re-enable controls here. | 440 // TODO(thestig) re-enable controls here. |
| 444 } | 441 } |
| 445 | 442 |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 /** | 721 /** |
| 725 * Display an error message in the center of the preview area. | 722 * Display an error message in the center of the preview area. |
| 726 * @param {string} errorMessage The error message to be displayed. | 723 * @param {string} errorMessage The error message to be displayed. |
| 727 */ | 724 */ |
| 728 function displayErrorMessage(errorMessage) { | 725 function displayErrorMessage(errorMessage) { |
| 729 $('print-button').disabled = true; | 726 $('print-button').disabled = true; |
| 730 $('overlay-layer').classList.remove('invisible'); | 727 $('overlay-layer').classList.remove('invisible'); |
| 731 $('dancing-dots-text').classList.add('hidden'); | 728 $('dancing-dots-text').classList.add('hidden'); |
| 732 $('error-text').innerHTML = errorMessage; | 729 $('error-text').innerHTML = errorMessage; |
| 733 $('error-text').classList.remove('hidden'); | 730 $('error-text').classList.remove('hidden'); |
| 734 removeEventListeners(); | |
| 735 var pdfViewer = $('pdf-viewer'); | 731 var pdfViewer = $('pdf-viewer'); |
| 736 if (pdfViewer) | 732 if (pdfViewer) |
| 737 $('mainview').removeChild(pdfViewer); | 733 $('mainview').removeChild(pdfViewer); |
| 738 | 734 |
| 739 if (isTabHidden) | 735 if (isTabHidden) |
| 740 cancelPendingPrintRequest(); | 736 cancelPendingPrintRequest(); |
| 741 } | 737 } |
| 742 | 738 |
| 743 /** | 739 /** |
| 744 * Display an error message in the center of the preview area followed by a | 740 * Display an error message in the center of the preview area followed by a |
| (...skipping 22 matching lines...) Expand all Loading... |
| 767 function printPreviewFailed() { | 763 function printPreviewFailed() { |
| 768 displayErrorMessage(localStrings.getString('previewFailed')); | 764 displayErrorMessage(localStrings.getString('previewFailed')); |
| 769 } | 765 } |
| 770 | 766 |
| 771 /** | 767 /** |
| 772 * Called when the PDF plugin loads its document. | 768 * Called when the PDF plugin loads its document. |
| 773 */ | 769 */ |
| 774 function onPDFLoad() { | 770 function onPDFLoad() { |
| 775 if (previewModifiable) { | 771 if (previewModifiable) { |
| 776 setPluginPreviewPageCount(); | 772 setPluginPreviewPageCount(); |
| 777 cr.dispatchSimpleEvent(document, 'updateSummary'); | |
| 778 } | 773 } |
| 779 $('pdf-viewer').fitToHeight(); | 774 $('pdf-viewer').fitToHeight(); |
| 780 cr.dispatchSimpleEvent(document, 'PDFLoaded'); | 775 cr.dispatchSimpleEvent(document, 'PDFLoaded'); |
| 781 hideLoadingAnimation(); | 776 hideLoadingAnimation(); |
| 782 } | 777 } |
| 783 | 778 |
| 784 function setPluginPreviewPageCount() { | 779 function setPluginPreviewPageCount() { |
| 785 $('pdf-viewer').printPreviewPageCount( | 780 $('pdf-viewer').printPreviewPageCount( |
| 786 pageSettings.previouslySelectedPages.length); | 781 pageSettings.previouslySelectedPages.length); |
| 787 } | 782 } |
| 788 | 783 |
| 789 /** | 784 /** |
| 790 * Update the page count and check the page range. | 785 * Update the page count and check the page range. |
| 791 * Called from PrintPreviewUI::OnDidGetPreviewPageCount(). | 786 * Called from PrintPreviewUI::OnDidGetPreviewPageCount(). |
| 792 * @param {number} pageCount The number of pages. | 787 * @param {number} pageCount The number of pages. |
| 793 * @param {boolean} isModifiable Indicates whether the previewed document can be | 788 * @param {boolean} isModifiable Indicates whether the previewed document can be |
| 794 * modified. | 789 * modified. |
| 790 * @param {number} previewResponseId The preview request id that resulted in |
| 791 * this response. |
| 795 */ | 792 */ |
| 796 function onDidGetPreviewPageCount(pageCount, isModifiable) { | 793 function onDidGetPreviewPageCount(pageCount, isModifiable, previewResponseId) { |
| 794 if (!isExpectedPreviewResponse(previewResponseId)) |
| 795 return; |
| 797 pageSettings.updateState(pageCount); | 796 pageSettings.updateState(pageCount); |
| 798 previewModifiable = isModifiable; | 797 previewModifiable = isModifiable; |
| 798 cr.dispatchSimpleEvent(document, 'updateSummary'); |
| 799 } | 799 } |
| 800 | 800 |
| 801 /** | 801 /** |
| 802 * Called when no pipelining previewed pages. | 802 * Called when no pipelining previewed pages. |
| 803 * @param {string} previewUid Preview unique identifier. |
| 804 * @param {number} previewResponseId The preview request id that resulted in |
| 805 * this response. |
| 803 */ | 806 */ |
| 804 function reloadPreviewPages(previewUid, previewResponseId) { | 807 function reloadPreviewPages(previewUid, previewResponseId) { |
| 805 if (!isExpectedPreviewResponse(previewResponseId)) | 808 if (!isExpectedPreviewResponse(previewResponseId)) |
| 806 return; | 809 return; |
| 807 hasPendingPreviewRequest = false; | 810 hasPendingPreviewRequest = false; |
| 808 | 811 |
| 809 if (checkIfSettingsChangedAndRegeneratePreview()) | 812 if (checkIfSettingsChangedAndRegeneratePreview()) |
| 810 return; | 813 return; |
| 811 cr.dispatchSimpleEvent(document, 'updateSummary'); | |
| 812 cr.dispatchSimpleEvent(document, 'updatePrintButton'); | 814 cr.dispatchSimpleEvent(document, 'updatePrintButton'); |
| 813 addEventListeners(); | |
| 814 hideLoadingAnimation(); | 815 hideLoadingAnimation(); |
| 815 var pageSet = pageSettings.previouslySelectedPages; | 816 var pageSet = pageSettings.previouslySelectedPages; |
| 816 for (var i = 0; i < pageSet.length; i++) | 817 for (var i = 0; i < pageSet.length; i++) |
| 817 $('pdf-viewer').loadPreviewPage(getPageSrcURL(previewUid, pageSet[i]-1), i); | 818 $('pdf-viewer').loadPreviewPage(getPageSrcURL(previewUid, pageSet[i]-1), i); |
| 818 // TODO(dpapad): handle pending print file requests. | 819 // TODO(dpapad): handle pending print file requests. |
| 819 } | 820 } |
| 820 | 821 |
| 821 /** | 822 /** |
| 822 * Notification that a print preview page has been rendered. | 823 * Notification that a print preview page has been rendered. |
| 823 * Check if the settings have changed and request a regeneration if needed. | 824 * Check if the settings have changed and request a regeneration if needed. |
| 824 * Called from PrintPreviewUI::OnDidPreviewPage(). | 825 * Called from PrintPreviewUI::OnDidPreviewPage(). |
| 825 * @param {number} pageNumber The page number, 0-based. | 826 * @param {number} pageNumber The page number, 0-based. |
| 827 * @param {string} previewUid Preview unique identifier. |
| 828 * @param {number} previewResponseId The preview request id that resulted in |
| 829 * this response. |
| 826 */ | 830 */ |
| 827 function onDidPreviewPage(pageNumber, previewUid) { | 831 function onDidPreviewPage(pageNumber, previewUid, previewResponseId) { |
| 832 if (!isExpectedPreviewResponse(previewResponseId)) |
| 833 return; |
| 834 |
| 828 // Refactor | 835 // Refactor |
| 829 if (!previewModifiable) | 836 if (!previewModifiable) |
| 830 return; | 837 return; |
| 831 | 838 |
| 832 var pageIndex = pageSettings.previouslySelectedPages.indexOf(pageNumber + 1); | 839 var pageIndex = pageSettings.previouslySelectedPages.indexOf(pageNumber + 1); |
| 833 | 840 |
| 834 if (checkIfSettingsChangedAndRegeneratePreview()) | 841 if (checkIfSettingsChangedAndRegeneratePreview()) |
| 835 return; | 842 return; |
| 836 if (pageIndex == 0) | 843 if (pageIndex == 0) |
| 837 createPDFPlugin(previewUid); | 844 createPDFPlugin(previewUid); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 860 if (checkIfSettingsChangedAndRegeneratePreview()) | 867 if (checkIfSettingsChangedAndRegeneratePreview()) |
| 861 return; | 868 return; |
| 862 | 869 |
| 863 document.title = localStrings.getStringF('printPreviewTitleFormat', jobTitle); | 870 document.title = localStrings.getStringF('printPreviewTitleFormat', jobTitle); |
| 864 | 871 |
| 865 if (!previewModifiable) { | 872 if (!previewModifiable) { |
| 866 // If the preview is not modifiable the plugin has not been created yet. | 873 // If the preview is not modifiable the plugin has not been created yet. |
| 867 createPDFPlugin(previewUid); | 874 createPDFPlugin(previewUid); |
| 868 } | 875 } |
| 869 | 876 |
| 870 cr.dispatchSimpleEvent(document, 'updateSummary'); | |
| 871 cr.dispatchSimpleEvent(document, 'updatePrintButton'); | 877 cr.dispatchSimpleEvent(document, 'updatePrintButton'); |
| 872 addEventListeners(); | |
| 873 | 878 |
| 874 if (hasPendingPrintDocumentRequest) | 879 if (hasPendingPrintDocumentRequest) |
| 875 requestToPrintPendingDocument(); | 880 requestToPrintPendingDocument(); |
| 876 } | 881 } |
| 877 | 882 |
| 878 /** | 883 /** |
| 879 * Check if any print settings changed and regenerate the preview if needed. | 884 * Check if any print settings changed and regenerate the preview if needed. |
| 880 * @return {boolean} true if a new preview is required. | 885 * @return {boolean} true if a new preview is required. |
| 881 */ | 886 */ |
| 882 function checkIfSettingsChangedAndRegeneratePreview() { | 887 function checkIfSettingsChangedAndRegeneratePreview() { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 968 | 973 |
| 969 /// Pull in all other scripts in a single shot. | 974 /// Pull in all other scripts in a single shot. |
| 970 <include src="print_preview_animations.js"/> | 975 <include src="print_preview_animations.js"/> |
| 971 <include src="print_preview_cloud.js"/> | 976 <include src="print_preview_cloud.js"/> |
| 972 <include src="print_preview_utils.js"/> | 977 <include src="print_preview_utils.js"/> |
| 973 <include src="print_header.js"/> | 978 <include src="print_header.js"/> |
| 974 <include src="page_settings.js"/> | 979 <include src="page_settings.js"/> |
| 975 <include src="copies_settings.js"/> | 980 <include src="copies_settings.js"/> |
| 976 <include src="layout_settings.js"/> | 981 <include src="layout_settings.js"/> |
| 977 <include src="color_settings.js"/> | 982 <include src="color_settings.js"/> |
| OLD | NEW |