OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 // @type {print_preview.LayoutSettings} Holds all the layout related settings. | 73 // @type {print_preview.LayoutSettings} Holds all the layout related settings. |
74 var layoutSettings; | 74 var layoutSettings; |
75 | 75 |
76 // @type {print_preview.MarginSettings} Holds all the margin related settings. | 76 // @type {print_preview.MarginSettings} Holds all the margin related settings. |
77 var marginSettings; | 77 var marginSettings; |
78 | 78 |
79 // @type {print_preview.HeaderFooterSettings} Holds all the header footer | 79 // @type {print_preview.HeaderFooterSettings} Holds all the header footer |
80 // related settings. | 80 // related settings. |
81 var headerFooterSettings; | 81 var headerFooterSettings; |
82 | 82 |
| 83 // @type {print_preview.FitToPageSettings} Holds all the fit to page related |
| 84 // settings. |
| 85 var fitToPageSettings; |
| 86 |
| 87 // @type {print_preview.MoreOptions} Holds the more options implementation. |
| 88 var moreOptions; |
| 89 |
83 // @type {print_preview.ColorSettings} Holds all the color related settings. | 90 // @type {print_preview.ColorSettings} Holds all the color related settings. |
84 var colorSettings; | 91 var colorSettings; |
85 | 92 |
86 // @type {print_preview.PreviewArea} Holds information related to the preview | 93 // @type {print_preview.PreviewArea} Holds information related to the preview |
87 // area (on the right). | 94 // area (on the right). |
88 var previewArea; | 95 var previewArea; |
89 | 96 |
90 // True if the user has click 'Advanced...' in order to open the system print | 97 // True if the user has click 'Advanced...' in order to open the system print |
91 // dialog. | 98 // dialog. |
92 var showingSystemDialog = false; | 99 var showingSystemDialog = false; |
(...skipping 19 matching lines...) Expand all Loading... |
112 var addedCloudPrinters = {}; | 119 var addedCloudPrinters = {}; |
113 | 120 |
114 // The maximum number of cloud printers to allow in the dropdown. | 121 // The maximum number of cloud printers to allow in the dropdown. |
115 /** @const */ var maxCloudPrinters = 10; | 122 /** @const */ var maxCloudPrinters = 10; |
116 | 123 |
117 /** @const */ var MIN_REQUEST_ID = 0; | 124 /** @const */ var MIN_REQUEST_ID = 0; |
118 /** @const */ var MAX_REQUEST_ID = 32000; | 125 /** @const */ var MAX_REQUEST_ID = 32000; |
119 | 126 |
120 // Names of all the custom events used. | 127 // Names of all the custom events used. |
121 var customEvents = { | 128 var customEvents = { |
| 129 // Fired when the header footer option visibility changed. |
| 130 HEADER_FOOTER_VISIBILITY_CHANGED: 'headerFooterVisibilityChanged', |
122 // Fired when the mouse moves while a margin line is being dragged. | 131 // Fired when the mouse moves while a margin line is being dragged. |
123 MARGIN_LINE_DRAG: 'marginLineDrag', | 132 MARGIN_LINE_DRAG: 'marginLineDrag', |
124 // Fired when a mousedown event occurs on a margin line. | 133 // Fired when a mousedown event occurs on a margin line. |
125 MARGIN_LINE_MOUSE_DOWN: 'marginLineMouseDown', | 134 MARGIN_LINE_MOUSE_DOWN: 'marginLineMouseDown', |
126 // Fired when a margin textbox gains focus. | 135 // Fired when a margin textbox gains focus. |
127 MARGIN_TEXTBOX_FOCUSED: 'marginTextboxFocused', | 136 MARGIN_TEXTBOX_FOCUSED: 'marginTextboxFocused', |
128 // Fired when a new preview might be needed because of margin changes. | 137 // Fired when a new preview might be needed because of margin changes. |
129 MARGINS_MAY_HAVE_CHANGED: 'marginsMayHaveChanged', | 138 MARGINS_MAY_HAVE_CHANGED: 'marginsMayHaveChanged', |
130 // Fired when a pdf generation related error occurs. | 139 // Fired when a pdf generation related error occurs. |
131 PDF_GENERATION_ERROR: 'PDFGenerationError', | 140 PDF_GENERATION_ERROR: 'PDFGenerationError', |
132 // Fired once the first page of the pdf document is loaded in the plugin. | 141 // Fired once the first page of the pdf document is loaded in the plugin. |
133 PDF_LOADED: 'PDFLoaded', | 142 PDF_LOADED: 'PDFLoaded', |
134 // Fired when the selected printer capabilities change. | 143 // Fired when the selected printer capabilities change. |
135 PRINTER_CAPABILITIES_UPDATED: 'printerCapabilitiesUpdated', | 144 PRINTER_CAPABILITIES_UPDATED: 'printerCapabilitiesUpdated', |
| 145 // Fired when the destination printer is changed. |
| 146 PRINTER_SELECTION_CHANGED: 'printerSelectionChanged', |
136 // Fired when the print button needs to be updated. | 147 // Fired when the print button needs to be updated. |
137 UPDATE_PRINT_BUTTON: 'updatePrintButton', | 148 UPDATE_PRINT_BUTTON: 'updatePrintButton', |
138 // Fired when the print summary needs to be updated. | 149 // Fired when the print summary needs to be updated. |
139 UPDATE_SUMMARY: 'updateSummary' | 150 UPDATE_SUMMARY: 'updateSummary' |
140 }; | 151 }; |
141 | 152 |
142 /** | 153 /** |
143 * Window onload handler, sets up the page and starts print preview by getting | 154 * Window onload handler, sets up the page and starts print preview by getting |
144 * the printer list. | 155 * the printer list. |
145 */ | 156 */ |
(...skipping 25 matching lines...) Expand all Loading... |
171 } | 182 } |
172 $('mainview').parentElement.removeChild($('dummy-viewer')); | 183 $('mainview').parentElement.removeChild($('dummy-viewer')); |
173 | 184 |
174 $('printer-list').disabled = true; | 185 $('printer-list').disabled = true; |
175 | 186 |
176 pageSettings = print_preview.PageSettings.getInstance(); | 187 pageSettings = print_preview.PageSettings.getInstance(); |
177 copiesSettings = print_preview.CopiesSettings.getInstance(); | 188 copiesSettings = print_preview.CopiesSettings.getInstance(); |
178 layoutSettings = print_preview.LayoutSettings.getInstance(); | 189 layoutSettings = print_preview.LayoutSettings.getInstance(); |
179 marginSettings = print_preview.MarginSettings.getInstance(); | 190 marginSettings = print_preview.MarginSettings.getInstance(); |
180 headerFooterSettings = print_preview.HeaderFooterSettings.getInstance(); | 191 headerFooterSettings = print_preview.HeaderFooterSettings.getInstance(); |
| 192 fitToPageSettings = print_preview.FitToPageSettings.getInstance(); |
| 193 moreOptions = print_preview.MoreOptions.getInstance(); |
181 colorSettings = print_preview.ColorSettings.getInstance(); | 194 colorSettings = print_preview.ColorSettings.getInstance(); |
182 $('printer-list').onchange = updateControlsWithSelectedPrinterCapabilities; | 195 $('printer-list').onchange = updateControlsWithSelectedPrinterCapabilities; |
183 | 196 |
184 previewArea.showLoadingAnimation(); | 197 previewArea.showLoadingAnimation(); |
185 chrome.send('getInitialSettings'); | 198 chrome.send('getInitialSettings'); |
186 } | 199 } |
187 | 200 |
188 /** | 201 /** |
189 * @param {object} initialSettings An object containing all the initial | 202 * @param {object} initialSettings An object containing all the initial |
190 * settings. | 203 * settings. |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 if (showingSystemDialog) | 284 if (showingSystemDialog) |
272 return; | 285 return; |
273 showingSystemDialog = true; | 286 showingSystemDialog = true; |
274 previewArea.errorButton.disabled = true; | 287 previewArea.errorButton.disabled = true; |
275 printHeader.disableCancelButton(); | 288 printHeader.disableCancelButton(); |
276 $('native-print-dialog-throbber').hidden = false; | 289 $('native-print-dialog-throbber').hidden = false; |
277 chrome.send('showSystemDialog'); | 290 chrome.send('showSystemDialog'); |
278 } | 291 } |
279 | 292 |
280 /** | 293 /** |
| 294 * Notifies listeners of |customEvents.PRINTER_SELECTION_CHANGED| event about |
| 295 * the current selected printer. |
| 296 */ |
| 297 function dispatchPrinterSelectionChangedEvent() { |
| 298 var customEvent = cr.Event(customEvents.PRINTER_SELECTION_CHANGED); |
| 299 customEvent.selectedPrinter = getSelectedPrinterName(); |
| 300 document.dispatchEvent(customEvent); |
| 301 } |
| 302 |
| 303 /** |
281 * Gets the selected printer capabilities and updates the controls accordingly. | 304 * Gets the selected printer capabilities and updates the controls accordingly. |
282 */ | 305 */ |
283 function updateControlsWithSelectedPrinterCapabilities() { | 306 function updateControlsWithSelectedPrinterCapabilities() { |
284 var printerList = $('printer-list'); | 307 var printerList = $('printer-list'); |
285 var selectedIndex = printerList.selectedIndex; | 308 var selectedIndex = printerList.selectedIndex; |
286 if (selectedIndex < 0) | 309 if (selectedIndex < 0) |
287 return; | 310 return; |
288 if (cr.isMac) | 311 if (cr.isMac) |
289 $('open-pdf-in-preview-link').disabled = false; | 312 $('open-pdf-in-preview-link').disabled = false; |
290 | 313 |
291 var skip_refresh = false; | 314 var skip_refresh = false; |
| 315 var selectedPrinterChanged = true; |
292 var selectedValue = printerList.options[selectedIndex].value; | 316 var selectedValue = printerList.options[selectedIndex].value; |
293 if (cloudprint.isCloudPrint(printerList.options[selectedIndex])) { | 317 if (cloudprint.isCloudPrint(printerList.options[selectedIndex])) { |
294 cloudprint.updatePrinterCaps(printerList.options[selectedIndex], | 318 cloudprint.updatePrinterCaps(printerList.options[selectedIndex], |
295 doUpdateCloudPrinterCapabilities); | 319 doUpdateCloudPrinterCapabilities); |
296 skip_refresh = true; | 320 skip_refresh = true; |
297 } else if (selectedValue == SIGN_IN || | 321 } else if (selectedValue == SIGN_IN || |
298 selectedValue == MANAGE_CLOUD_PRINTERS || | 322 selectedValue == MANAGE_CLOUD_PRINTERS || |
299 selectedValue == MANAGE_LOCAL_PRINTERS) { | 323 selectedValue == MANAGE_LOCAL_PRINTERS) { |
300 printerList.selectedIndex = lastSelectedPrinterIndex; | 324 printerList.selectedIndex = lastSelectedPrinterIndex; |
301 chrome.send(selectedValue); | 325 chrome.send(selectedValue); |
302 skip_refresh = true; | 326 skip_refresh = true; |
| 327 selectedPrinterChanged = false; |
303 } else if (selectedValue == PRINT_TO_PDF || | 328 } else if (selectedValue == PRINT_TO_PDF || |
304 selectedValue == PRINT_WITH_CLOUD_PRINT) { | 329 selectedValue == PRINT_WITH_CLOUD_PRINT) { |
305 updateWithPrinterCapabilities({ | 330 updateWithPrinterCapabilities({ |
306 'disableColorOption': true, | 331 'disableColorOption': true, |
307 'setColorAsDefault': true, | 332 'setColorAsDefault': true, |
308 'setDuplexAsDefault': false, | 333 'setDuplexAsDefault': false, |
309 'printerColorModelForColor': print_preview.ColorSettings.COLOR, | 334 'printerColorModelForColor': print_preview.ColorSettings.COLOR, |
310 'printerDefaultDuplexValue': copiesSettings.UNKNOWN_DUPLEX_MODE, | 335 'printerDefaultDuplexValue': copiesSettings.UNKNOWN_DUPLEX_MODE, |
311 'disableCopiesOption': true}); | 336 'disableCopiesOption': true}); |
312 if (cr.isChromeOS && selectedValue == PRINT_WITH_CLOUD_PRINT) | 337 if (cr.isChromeOS && selectedValue == PRINT_WITH_CLOUD_PRINT) |
313 requestToPrintDocument(); | 338 requestToPrintDocument(); |
314 } else { | 339 } else { |
315 // This message will call back to 'updateWithPrinterCapabilities' | 340 // This message will call back to 'updateWithPrinterCapabilities' |
316 // function. | 341 // function. |
317 chrome.send('getPrinterCapabilities', [selectedValue]); | 342 chrome.send('getPrinterCapabilities', [selectedValue]); |
318 } | 343 } |
| 344 if (selectedPrinterChanged) |
| 345 dispatchPrinterSelectionChangedEvent(); |
| 346 |
319 if (!skip_refresh) { | 347 if (!skip_refresh) { |
320 lastSelectedPrinterIndex = selectedIndex; | 348 lastSelectedPrinterIndex = selectedIndex; |
321 | 349 |
322 // Regenerate the preview data based on selected printer settings. | 350 // Regenerate the preview data based on selected printer settings. |
323 // Do not reset the margins if no preview request has been made. | 351 // Do not reset the margins if no preview request has been made. |
324 var resetMargins = lastPreviewRequestID != initialPreviewRequestID; | 352 var resetMargins = lastPreviewRequestID != initialPreviewRequestID; |
325 setDefaultValuesAndRegeneratePreview(resetMargins); | 353 setDefaultValuesAndRegeneratePreview(resetMargins); |
326 } | 354 } |
327 } | 355 } |
328 | 356 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 } | 415 } |
388 | 416 |
389 /** | 417 /** |
390 * Cloud print upload of the PDF file is finished, time to close the dialog. | 418 * Cloud print upload of the PDF file is finished, time to close the dialog. |
391 */ | 419 */ |
392 function finishedCloudPrinting() { | 420 function finishedCloudPrinting() { |
393 closePrintPreviewTab(); | 421 closePrintPreviewTab(); |
394 } | 422 } |
395 | 423 |
396 /** | 424 /** |
| 425 * Updates the fit to page option state based on the print scaling option of |
| 426 * source pdf. PDF's have an option to enable/disable print scaling. When we |
| 427 * find out that the print scaling option is disabled for the source pdf, we |
| 428 * uncheck the fit to page checkbox. This function is called from C++ code. |
| 429 */ |
| 430 function printScalingDisabledForSourcePDF() { |
| 431 fitToPageSettings.onPrintScalingDisabled(); |
| 432 } |
| 433 |
| 434 /** |
397 * Checks whether the specified settings are valid. | 435 * Checks whether the specified settings are valid. |
398 * | 436 * |
399 * @return {boolean} true if settings are valid, false if not. | 437 * @return {boolean} true if settings are valid, false if not. |
400 */ | 438 */ |
401 function areSettingsValid() { | 439 function areSettingsValid() { |
402 var selectedPrinter = getSelectedPrinterName(); | 440 var selectedPrinter = getSelectedPrinterName(); |
403 return pageSettings.isPageSelectionValid() && | 441 return pageSettings.isPageSelectionValid() && |
404 marginSettings.areMarginSettingsValid() && | 442 marginSettings.areMarginSettingsValid() && |
405 (copiesSettings.isValid() || selectedPrinter == PRINT_TO_PDF || | 443 (copiesSettings.isValid() || selectedPrinter == PRINT_TO_PDF || |
406 selectedPrinter == PRINT_WITH_CLOUD_PRINT); | 444 selectedPrinter == PRINT_WITH_CLOUD_PRINT); |
(...skipping 17 matching lines...) Expand all Loading... |
424 'collate': copiesSettings.isCollated(), | 462 'collate': copiesSettings.isCollated(), |
425 'landscape': layoutSettings.isLandscape(), | 463 'landscape': layoutSettings.isLandscape(), |
426 'color': colorSettings.colorMode, | 464 'color': colorSettings.colorMode, |
427 'printToPDF': printToPDF, | 465 'printToPDF': printToPDF, |
428 'printWithCloudPrint': printWithCloudPrint, | 466 'printWithCloudPrint': printWithCloudPrint, |
429 'isFirstRequest' : false, | 467 'isFirstRequest' : false, |
430 'headerFooterEnabled': headerFooterSettings.hasHeaderFooter(), | 468 'headerFooterEnabled': headerFooterSettings.hasHeaderFooter(), |
431 'marginsType': marginSettings.selectedMarginsValue, | 469 'marginsType': marginSettings.selectedMarginsValue, |
432 'requestID': -1, | 470 'requestID': -1, |
433 'generateDraftData': generateDraftData, | 471 'generateDraftData': generateDraftData, |
| 472 'fitToPageEnabled': fitToPageSettings.hasFitToPage(), |
434 'previewModifiable': previewModifiable}; | 473 'previewModifiable': previewModifiable}; |
435 | 474 |
436 if (marginSettings.isCustomMarginsSelected()) | 475 if (marginSettings.isCustomMarginsSelected()) |
437 settings['marginsCustom'] = marginSettings.customMargins; | 476 settings['marginsCustom'] = marginSettings.customMargins; |
438 | 477 |
439 var printerList = $('printer-list'); | 478 var printerList = $('printer-list'); |
440 var selectedPrinter = printerList.selectedIndex; | 479 var selectedPrinter = printerList.selectedIndex; |
441 if (cloudprint.isCloudPrint(printerList.options[selectedPrinter])) { | 480 if (cloudprint.isCloudPrint(printerList.options[selectedPrinter])) { |
442 settings['cloudPrintID'] = | 481 settings['cloudPrintID'] = |
443 printerList.options[selectedPrinter].value; | 482 printerList.options[selectedPrinter].value; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 var pageCount = pageSet.length; | 611 var pageCount = pageSet.length; |
573 if (pageCount == 0 || currentPreviewUid == '') | 612 if (pageCount == 0 || currentPreviewUid == '') |
574 return; | 613 return; |
575 | 614 |
576 cr.dispatchSimpleEvent(document, customEvents.UPDATE_SUMMARY); | 615 cr.dispatchSimpleEvent(document, customEvents.UPDATE_SUMMARY); |
577 for (var i = 0; i < pageCount; i++) | 616 for (var i = 0; i < pageCount; i++) |
578 onDidPreviewPage(pageSet[i] - 1, currentPreviewUid, lastPreviewRequestID); | 617 onDidPreviewPage(pageSet[i] - 1, currentPreviewUid, lastPreviewRequestID); |
579 } | 618 } |
580 | 619 |
581 /** | 620 /** |
582 * Asks the browser to generate a preview PDF based on current print settings. | 621 * Updates the variables states for preview. |
583 */ | 622 */ |
584 function requestPrintPreview() { | 623 function updateStateForPreview() { |
585 if (!isTabHidden) | 624 if (!isTabHidden) |
586 previewArea.showLoadingAnimation(); | 625 previewArea.showLoadingAnimation(); |
587 | 626 |
588 if (!hasPendingPreviewRequest && previewModifiable && | 627 if (!hasPendingPreviewRequest && previewModifiable && |
589 hasOnlyPageSettingsChanged()) { | 628 hasOnlyPageSettingsChanged()) { |
590 loadSelectedPages(); | 629 loadSelectedPages(); |
591 generateDraftData = false; | 630 generateDraftData = false; |
592 } else { | 631 } else { |
593 hasPendingPreviewRequest = true; | 632 hasPendingPreviewRequest = true; |
594 generateDraftData = true; | 633 generateDraftData = true; |
595 pageSettings.updatePageSelection(); | 634 pageSettings.updatePageSelection(); |
596 } | 635 } |
597 | 636 |
598 printSettings.save(); | 637 printSettings.save(); |
599 layoutSettings.updateState(); | 638 layoutSettings.updateState(); |
600 previewArea.resetState(); | 639 previewArea.resetState(); |
601 isPrintReadyMetafileReady = false; | 640 isPrintReadyMetafileReady = false; |
602 isFirstPageLoaded = false; | 641 isFirstPageLoaded = false; |
603 | 642 |
604 var totalPageCount = pageSettings.totalPageCount; | 643 var totalPageCount = pageSettings.totalPageCount; |
605 if (!previewModifiable && totalPageCount > 0) | 644 if (!previewModifiable && totalPageCount > 0) |
606 generateDraftData = false; | 645 generateDraftData = false; |
| 646 } |
607 | 647 |
608 var pageCount = totalPageCount != undefined ? totalPageCount : -1; | 648 /** |
| 649 * Asks the browser to generate a preview PDF based on current print settings. |
| 650 */ |
| 651 function requestPrintPreview() { |
| 652 updateStateForPreview(); |
| 653 var totalPageCount = pageSettings.totalPageCount; |
| 654 var pageCount = totalPageCount || -1; |
609 chrome.send('getPreview', [JSON.stringify(getSettingsWithRequestID()), | 655 chrome.send('getPreview', [JSON.stringify(getSettingsWithRequestID()), |
610 pageCount, | 656 pageCount, |
611 previewModifiable]); | 657 previewModifiable]); |
612 } | 658 } |
613 | 659 |
614 /** | 660 /** |
615 * Called from PrintPreviewUI::OnFileSelectionCancelled to notify the print | 661 * Called from PrintPreviewUI::OnFileSelectionCancelled to notify the print |
616 * preview tab regarding the file selection cancel event. | 662 * preview tab regarding the file selection cancel event. |
617 */ | 663 */ |
618 function fileSelectionCancelled() { | 664 function fileSelectionCancelled() { |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 previewArea.displayErrorMessageAndNotify( | 867 previewArea.displayErrorMessageAndNotify( |
822 localStrings.getString('invalidPrinterSettings')); | 868 localStrings.getString('invalidPrinterSettings')); |
823 } | 869 } |
824 | 870 |
825 /** | 871 /** |
826 * Called when the PDF plugin loads its document. | 872 * Called when the PDF plugin loads its document. |
827 */ | 873 */ |
828 function onPDFLoad() { | 874 function onPDFLoad() { |
829 if (previewModifiable) { | 875 if (previewModifiable) { |
830 setPluginPreviewPageCount(); | 876 setPluginPreviewPageCount(); |
| 877 } else { |
| 878 // If the source is pdf, print ready metafile is available only after |
| 879 // loading the pdf in the plugin. |
| 880 isPrintReadyMetafileReady = true; |
831 } | 881 } |
832 // Instruct the plugin which page numbers to display in the page number | 882 // Instruct the plugin which page numbers to display in the page number |
833 // indicator. | 883 // indicator. |
834 previewArea.pdfPlugin.setPageNumbers( | 884 previewArea.pdfPlugin.setPageNumbers( |
835 JSON.stringify(pageSettings.selectedPagesSet)); | 885 JSON.stringify(pageSettings.selectedPagesSet)); |
836 cr.dispatchSimpleEvent(document, customEvents.PDF_LOADED); | 886 cr.dispatchSimpleEvent(document, customEvents.PDF_LOADED); |
837 isFirstPageLoaded = true; | 887 isFirstPageLoaded = true; |
838 checkAndHideOverlayLayerIfValid(); | 888 checkAndHideOverlayLayerIfValid(); |
839 sendPrintDocumentRequestIfNeeded(); | 889 sendPrintDocumentRequestIfNeeded(); |
840 if (printAutomaticallyInKioskMode) | 890 if (printAutomaticallyInKioskMode) |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 /** | 954 /** |
905 * Called when no pipelining previewed pages. | 955 * Called when no pipelining previewed pages. |
906 * @param {string} previewUid Preview unique identifier. | 956 * @param {string} previewUid Preview unique identifier. |
907 * @param {number} previewResponseId The preview request id that resulted in | 957 * @param {number} previewResponseId The preview request id that resulted in |
908 * this response. | 958 * this response. |
909 */ | 959 */ |
910 function reloadPreviewPages(previewUid, previewResponseId) { | 960 function reloadPreviewPages(previewUid, previewResponseId) { |
911 if (!isExpectedPreviewResponse(previewResponseId)) | 961 if (!isExpectedPreviewResponse(previewResponseId)) |
912 return; | 962 return; |
913 | 963 |
| 964 if (!previewModifiable) |
| 965 previewArea.createOrReloadPDFPlugin(PRINT_READY_DATA_INDEX); |
914 cr.dispatchSimpleEvent(document, customEvents.UPDATE_PRINT_BUTTON); | 966 cr.dispatchSimpleEvent(document, customEvents.UPDATE_PRINT_BUTTON); |
915 checkAndHideOverlayLayerIfValid(); | 967 checkAndHideOverlayLayerIfValid(); |
916 var pageSet = pageSettings.previouslySelectedPages; | 968 var pageSet = pageSettings.previouslySelectedPages; |
917 for (var i = 0; i < pageSet.length; i++) { | 969 for (var i = 0; i < pageSet.length; i++) { |
918 previewArea.pdfPlugin.loadPreviewPage( | 970 previewArea.pdfPlugin.loadPreviewPage( |
919 getPageSrcURL(previewUid, pageSet[i] - 1), i); | 971 getPageSrcURL(previewUid, pageSet[i] - 1), i); |
920 } | 972 } |
921 | 973 |
922 hasPendingPreviewRequest = false; | 974 hasPendingPreviewRequest = false; |
923 isPrintReadyMetafileReady = true; | 975 isPrintReadyMetafileReady = true; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 * Update the print preview when new preview data is available. | 1019 * Update the print preview when new preview data is available. |
968 * Create the PDF plugin as needed. | 1020 * Create the PDF plugin as needed. |
969 * Called from PrintPreviewUI::PreviewDataIsAvailable(). | 1021 * Called from PrintPreviewUI::PreviewDataIsAvailable(). |
970 * @param {string} previewUid Preview unique identifier. | 1022 * @param {string} previewUid Preview unique identifier. |
971 * @param {number} previewResponseId The preview request id that resulted in | 1023 * @param {number} previewResponseId The preview request id that resulted in |
972 * this response. | 1024 * this response. |
973 */ | 1025 */ |
974 function updatePrintPreview(previewUid, previewResponseId) { | 1026 function updatePrintPreview(previewUid, previewResponseId) { |
975 if (!isExpectedPreviewResponse(previewResponseId)) | 1027 if (!isExpectedPreviewResponse(previewResponseId)) |
976 return; | 1028 return; |
977 isPrintReadyMetafileReady = true; | |
978 | 1029 |
979 if (!previewModifiable) { | 1030 if (!previewModifiable) { |
980 // If the preview is not modifiable the plugin has not been created yet. | 1031 // If the preview is not modifiable the plugin has not been created yet. |
981 currentPreviewUid = previewUid; | 1032 currentPreviewUid = previewUid; |
982 hasPendingPreviewRequest = false; | 1033 hasPendingPreviewRequest = false; |
983 previewArea.createOrReloadPDFPlugin(PRINT_READY_DATA_INDEX); | 1034 previewArea.createOrReloadPDFPlugin(PRINT_READY_DATA_INDEX); |
| 1035 } else { |
| 1036 isPrintReadyMetafileReady = true; |
984 } | 1037 } |
985 | 1038 |
986 cr.dispatchSimpleEvent(document, customEvents.UPDATE_PRINT_BUTTON); | 1039 cr.dispatchSimpleEvent(document, customEvents.UPDATE_PRINT_BUTTON); |
987 if (previewModifiable) | 1040 if (previewModifiable) |
988 sendPrintDocumentRequestIfNeeded(); | 1041 sendPrintDocumentRequestIfNeeded(); |
989 } | 1042 } |
990 | 1043 |
991 /** | 1044 /** |
992 * Checks to see if the requested print data is available for printing and | 1045 * Checks to see if the requested print data is available for printing and |
993 * sends a print document request if needed. | 1046 * sends a print document request if needed. |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1196 window.addEventListener('keydown', onKeyDown); | 1249 window.addEventListener('keydown', onKeyDown); |
1197 | 1250 |
1198 /// Pull in all other scripts in a single shot. | 1251 /// Pull in all other scripts in a single shot. |
1199 <include src="print_preview_animations.js"/> | 1252 <include src="print_preview_animations.js"/> |
1200 <include src="print_preview_cloud.js"/> | 1253 <include src="print_preview_cloud.js"/> |
1201 <include src="print_preview_utils.js"/> | 1254 <include src="print_preview_utils.js"/> |
1202 <include src="print_header.js"/> | 1255 <include src="print_header.js"/> |
1203 <include src="page_settings.js"/> | 1256 <include src="page_settings.js"/> |
1204 <include src="copies_settings.js"/> | 1257 <include src="copies_settings.js"/> |
1205 <include src="header_footer_settings.js"/> | 1258 <include src="header_footer_settings.js"/> |
| 1259 <include src="fit_to_page_settings.js"/> |
1206 <include src="layout_settings.js"/> | 1260 <include src="layout_settings.js"/> |
1207 <include src="color_settings.js"/> | 1261 <include src="color_settings.js"/> |
1208 <include src="margin_settings.js"/> | 1262 <include src="margin_settings.js"/> |
1209 <include src="margin_textbox.js"/> | 1263 <include src="margin_textbox.js"/> |
1210 <include src="margin_utils.js"/> | 1264 <include src="margin_utils.js"/> |
1211 <include src="margins_ui.js"/> | 1265 <include src="margins_ui.js"/> |
1212 <include src="margins_ui_pair.js"/> | 1266 <include src="margins_ui_pair.js"/> |
| 1267 <include src="more_options.js"/> |
1213 <include src="preview_area.js"/> | 1268 <include src="preview_area.js"/> |
OLD | NEW |