Chromium Code Reviews| 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 // TODO(rltoscano): Move data/* into print_preview.data namespace | 5 // TODO(rltoscano): Move data/* into print_preview.data namespace |
| 6 | 6 |
| 7 var localStrings = new LocalStrings(templateData); | |
| 8 | |
| 9 <include src="component.js"/> | 7 <include src="component.js"/> |
| 10 <include src="print_preview_focus_manager.js"/> | 8 <include src="print_preview_focus_manager.js"/> |
| 11 | 9 |
| 12 cr.define('print_preview', function() { | 10 cr.define('print_preview', function() { |
| 13 'use strict'; | 11 'use strict'; |
| 14 | 12 |
| 15 /** | 13 /** |
| 16 * Container class for Chromium's print preview. | 14 * Container class for Chromium's print preview. |
| 17 * @constructor | 15 * @constructor |
| 18 * @extends {print_preview.Component} | 16 * @extends {print_preview.Component} |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 288 PRINTED: 'printed', | 286 PRINTED: 'printed', |
| 289 READY_WAITING_FOR_PREVIEW: 'ready-waiting-for-preview' | 287 READY_WAITING_FOR_PREVIEW: 'ready-waiting-for-preview' |
| 290 }; | 288 }; |
| 291 | 289 |
| 292 PrintPreview.prototype = { | 290 PrintPreview.prototype = { |
| 293 __proto__: print_preview.Component.prototype, | 291 __proto__: print_preview.Component.prototype, |
| 294 | 292 |
| 295 /** Sets up the page and print preview by getting the printer list. */ | 293 /** Sets up the page and print preview by getting the printer list. */ |
| 296 initialize: function() { | 294 initialize: function() { |
| 297 this.decorate($('print-preview')); | 295 this.decorate($('print-preview')); |
| 298 i18nTemplate.process(document, templateData); | |
| 299 if (!this.previewArea_.hasCompatiblePlugin) { | 296 if (!this.previewArea_.hasCompatiblePlugin) { |
| 300 this.setIsEnabled_(false); | 297 this.setIsEnabled_(false); |
| 301 } | 298 } |
| 302 this.nativeLayer_.startGetInitialSettings(); | 299 this.nativeLayer_.startGetInitialSettings(); |
| 303 print_preview.PrintPreviewFocusManager.getInstance().initialize(); | 300 print_preview.PrintPreviewFocusManager.getInstance().initialize(); |
| 304 cr.ui.FocusOutlineManager.forDocument(document); | 301 cr.ui.FocusOutlineManager.forDocument(document); |
| 305 }, | 302 }, |
| 306 | 303 |
| 307 /** @override */ | 304 /** @override */ |
| 308 enterDocument: function() { | 305 enterDocument: function() { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 345 this.onManipulateSettingsForTest_.bind(this)); | 342 this.onManipulateSettingsForTest_.bind(this)); |
| 346 | 343 |
| 347 this.tracker.add( | 344 this.tracker.add( |
| 348 $('system-dialog-link'), | 345 $('system-dialog-link'), |
| 349 'click', | 346 'click', |
| 350 this.openSystemPrintDialog_.bind(this)); | 347 this.openSystemPrintDialog_.bind(this)); |
| 351 this.tracker.add( | 348 this.tracker.add( |
| 352 $('cloud-print-dialog-link'), | 349 $('cloud-print-dialog-link'), |
| 353 'click', | 350 'click', |
| 354 this.onCloudPrintDialogLinkClick_.bind(this)); | 351 this.onCloudPrintDialogLinkClick_.bind(this)); |
| 355 this.tracker.add( | 352 if ($('open-pdf-in-preview-link')) { |
| 356 $('open-pdf-in-preview-link'), | 353 this.tracker.add( |
| 357 'click', | 354 $('open-pdf-in-preview-link'), |
| 358 this.onOpenPdfInPreviewLinkClick_.bind(this)); | 355 'click', |
| 356 this.onOpenPdfInPreviewLinkClick_.bind(this)); | |
| 357 } | |
| 359 | 358 |
| 360 this.tracker.add( | 359 this.tracker.add( |
| 361 this.previewArea_, | 360 this.previewArea_, |
| 362 print_preview.PreviewArea.EventType.PREVIEW_GENERATION_IN_PROGRESS, | 361 print_preview.PreviewArea.EventType.PREVIEW_GENERATION_IN_PROGRESS, |
| 363 this.onPreviewGenerationInProgress_.bind(this)); | 362 this.onPreviewGenerationInProgress_.bind(this)); |
| 364 this.tracker.add( | 363 this.tracker.add( |
| 365 this.previewArea_, | 364 this.previewArea_, |
| 366 print_preview.PreviewArea.EventType.PREVIEW_GENERATION_DONE, | 365 print_preview.PreviewArea.EventType.PREVIEW_GENERATION_DONE, |
| 367 this.onPreviewGenerationDone_.bind(this)); | 366 this.onPreviewGenerationDone_.bind(this)); |
| 368 this.tracker.add( | 367 this.tracker.add( |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 455 this.copiesSettings_.decorate($('copies-settings')); | 454 this.copiesSettings_.decorate($('copies-settings')); |
| 456 this.mediaSizeSettings_.decorate($('media-size-settings')); | 455 this.mediaSizeSettings_.decorate($('media-size-settings')); |
| 457 this.layoutSettings_.decorate($('layout-settings')); | 456 this.layoutSettings_.decorate($('layout-settings')); |
| 458 this.colorSettings_.decorate($('color-settings')); | 457 this.colorSettings_.decorate($('color-settings')); |
| 459 this.marginSettings_.decorate($('margin-settings')); | 458 this.marginSettings_.decorate($('margin-settings')); |
| 460 this.otherOptionsSettings_.decorate($('other-options-settings')); | 459 this.otherOptionsSettings_.decorate($('other-options-settings')); |
| 461 this.advancedOptionsSettings_.decorate($('advanced-options-settings')); | 460 this.advancedOptionsSettings_.decorate($('advanced-options-settings')); |
| 462 this.advancedSettings_.decorate($('advanced-settings')); | 461 this.advancedSettings_.decorate($('advanced-settings')); |
| 463 this.moreSettings_.decorate($('more-settings')); | 462 this.moreSettings_.decorate($('more-settings')); |
| 464 this.previewArea_.decorate($('preview-area')); | 463 this.previewArea_.decorate($('preview-area')); |
| 465 | |
| 466 setIsVisible($('open-pdf-in-preview-link'), cr.isMac); | |
| 467 }, | 464 }, |
| 468 | 465 |
| 469 /** | 466 /** |
| 470 * Sets whether the controls in the print preview are enabled. | 467 * Sets whether the controls in the print preview are enabled. |
| 471 * @param {boolean} isEnabled Whether the controls in the print preview are | 468 * @param {boolean} isEnabled Whether the controls in the print preview are |
| 472 * enabled. | 469 * enabled. |
| 473 * @private | 470 * @private |
| 474 */ | 471 */ |
| 475 setIsEnabled_: function(isEnabled) { | 472 setIsEnabled_: function(isEnabled) { |
| 476 $('system-dialog-link').disabled = !isEnabled; | 473 $('system-dialog-link').disabled = !isEnabled; |
| 477 $('cloud-print-dialog-link').disabled = !isEnabled; | 474 $('cloud-print-dialog-link').disabled = !isEnabled; |
| 478 $('open-pdf-in-preview-link').disabled = !isEnabled; | 475 if ($('open-pdf-in-preview-link')) { |
| 476 $('open-pdf-in-preview-link').disabled = !isEnabled; | |
| 477 } | |
| 479 this.printHeader_.isEnabled = isEnabled; | 478 this.printHeader_.isEnabled = isEnabled; |
| 480 this.destinationSettings_.isEnabled = isEnabled; | 479 this.destinationSettings_.isEnabled = isEnabled; |
| 481 this.pageSettings_.isEnabled = isEnabled; | 480 this.pageSettings_.isEnabled = isEnabled; |
| 482 this.copiesSettings_.isEnabled = isEnabled; | 481 this.copiesSettings_.isEnabled = isEnabled; |
| 483 this.mediaSizeSettings_.isEnabled = isEnabled; | 482 this.mediaSizeSettings_.isEnabled = isEnabled; |
| 484 this.layoutSettings_.isEnabled = isEnabled; | 483 this.layoutSettings_.isEnabled = isEnabled; |
| 485 this.colorSettings_.isEnabled = isEnabled; | 484 this.colorSettings_.isEnabled = isEnabled; |
| 486 this.marginSettings_.isEnabled = isEnabled; | 485 this.marginSettings_.isEnabled = isEnabled; |
| 487 this.otherOptionsSettings_.isEnabled = isEnabled; | 486 this.otherOptionsSettings_.isEnabled = isEnabled; |
| 488 this.advancedOptionsSettings_.isEnabled = isEnabled; | 487 this.advancedOptionsSettings_.isEnabled = isEnabled; |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 703 | 702 |
| 704 /** | 703 /** |
| 705 * Called from the native layer when save-to-pdf file selection is complete. | 704 * Called from the native layer when save-to-pdf file selection is complete. |
| 706 * @private | 705 * @private |
| 707 */ | 706 */ |
| 708 onFileSelectionComplete_: function() { | 707 onFileSelectionComplete_: function() { |
| 709 assert(this.uiState_ == PrintPreview.UiState_.FILE_SELECTION, | 708 assert(this.uiState_ == PrintPreview.UiState_.FILE_SELECTION, |
| 710 'File selection completed when not in file-selection state: ' + | 709 'File selection completed when not in file-selection state: ' + |
| 711 this.uiState_); | 710 this.uiState_); |
| 712 this.previewArea_.showCustomMessage( | 711 this.previewArea_.showCustomMessage( |
| 713 localStrings.getString('printingToPDFInProgress')); | 712 loadTimeData.getString('printingToPDFInProgress')); |
| 714 this.uiState_ = PrintPreview.UiState_.PRINTING; | 713 this.uiState_ = PrintPreview.UiState_.PRINTING; |
| 715 }, | 714 }, |
| 716 | 715 |
| 717 /** | 716 /** |
| 718 * Called after successfully submitting a job to Google Cloud Print. | 717 * Called after successfully submitting a job to Google Cloud Print. |
| 719 * @param {!Event} event Contains the ID of the submitted print job. | 718 * @param {!Event} event Contains the ID of the submitted print job. |
| 720 * @private | 719 * @private |
| 721 */ | 720 */ |
| 722 onCloudPrintSubmitDone_: function(event) { | 721 onCloudPrintSubmitDone_: function(event) { |
| 723 assert(this.uiState_ == PrintPreview.UiState_.PRINTING, | 722 assert(this.uiState_ == PrintPreview.UiState_.PRINTING, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 794 * Called when the 'Open pdf in preview' link is clicked. Launches the pdf | 793 * Called when the 'Open pdf in preview' link is clicked. Launches the pdf |
| 795 * preview app. | 794 * preview app. |
| 796 * @private | 795 * @private |
| 797 */ | 796 */ |
| 798 onOpenPdfInPreviewLinkClick_: function() { | 797 onOpenPdfInPreviewLinkClick_: function() { |
| 799 assert(this.uiState_ == PrintPreview.UiState_.READY, | 798 assert(this.uiState_ == PrintPreview.UiState_.READY, |
| 800 'Trying to open pdf in preview when not in ready state: ' + | 799 'Trying to open pdf in preview when not in ready state: ' + |
| 801 this.uiState_); | 800 this.uiState_); |
| 802 setIsVisible($('open-preview-app-throbber'), true); | 801 setIsVisible($('open-preview-app-throbber'), true); |
| 803 this.previewArea_.showCustomMessage( | 802 this.previewArea_.showCustomMessage( |
| 804 localStrings.getString('openingPDFInPreview')); | 803 loadTimeData.getString('openingPDFInPreview')); |
| 805 this.printDocumentOrOpenPdfPreview_(true /*isPdfPreview*/); | 804 this.printDocumentOrOpenPdfPreview_(true /*isPdfPreview*/); |
| 806 }, | 805 }, |
| 807 | 806 |
| 808 /** | 807 /** |
| 809 * Called when the print header's print button is clicked. Prints the | 808 * Called when the print header's print button is clicked. Prints the |
| 810 * document. | 809 * document. |
| 811 * @private | 810 * @private |
| 812 */ | 811 */ |
| 813 onPrintButtonClick_: function() { | 812 onPrintButtonClick_: function() { |
| 814 assert(this.uiState_ == PrintPreview.UiState_.READY, | 813 assert(this.uiState_ == PrintPreview.UiState_.READY, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 894 }, | 893 }, |
| 895 | 894 |
| 896 /** | 895 /** |
| 897 * Called when native layer receives invalid settings for a print request. | 896 * Called when native layer receives invalid settings for a print request. |
| 898 * @private | 897 * @private |
| 899 */ | 898 */ |
| 900 onSettingsInvalid_: function() { | 899 onSettingsInvalid_: function() { |
| 901 this.uiState_ = PrintPreview.UiState_.ERROR; | 900 this.uiState_ = PrintPreview.UiState_.ERROR; |
| 902 console.error('Invalid settings error reported from native layer'); | 901 console.error('Invalid settings error reported from native layer'); |
| 903 this.previewArea_.showCustomMessage( | 902 this.previewArea_.showCustomMessage( |
| 904 localStrings.getString('invalidPrinterSettings')); | 903 loadTimeData.getString('invalidPrinterSettings')); |
| 905 }, | 904 }, |
| 906 | 905 |
| 907 /** | 906 /** |
| 908 * Called when the destination settings' change button is activated. | 907 * Called when the destination settings' change button is activated. |
| 909 * Displays the destination search component. | 908 * Displays the destination search component. |
| 910 * @private | 909 * @private |
| 911 */ | 910 */ |
| 912 onDestinationChangeButtonActivate_: function() { | 911 onDestinationChangeButtonActivate_: function() { |
| 913 this.destinationSearch_.setIsVisible(true); | 912 this.destinationSearch_.setIsVisible(true); |
| 914 this.destinationStore_.startLoadCloudDestinations(); | 913 this.destinationStore_.startLoadCloudDestinations(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 967 | 966 |
| 968 /** | 967 /** |
| 969 * Called when privet printing fails. | 968 * Called when privet printing fails. |
| 970 * @param {Event} event Event object representing the failure. | 969 * @param {Event} event Event object representing the failure. |
| 971 * @private | 970 * @private |
| 972 */ | 971 */ |
| 973 onPrivetPrintFailed_: function(event) { | 972 onPrivetPrintFailed_: function(event) { |
| 974 console.error('Privet printing failed with error code ' + | 973 console.error('Privet printing failed with error code ' + |
| 975 event.httpError); | 974 event.httpError); |
| 976 this.printHeader_.setErrorMessage( | 975 this.printHeader_.setErrorMessage( |
| 977 localStrings.getString('couldNotPrint')); | 976 loadTimeData.getString('couldNotPrint')); |
|
Vitaly Buka (NO REVIEWS)
2014/09/20 03:51:13
two more spaces
Evan Stade
2014/09/22 20:15:48
Done.
| |
| 978 }, | 977 }, |
| 979 | 978 |
| 980 /** | 979 /** |
| 981 * Called when the print preview settings need to be changed for testing. | 980 * Called when the print preview settings need to be changed for testing. |
| 982 * @param {Event} event Event object that contains the option that is to | 981 * @param {Event} event Event object that contains the option that is to |
| 983 * be changed and what to set that option. | 982 * be changed and what to set that option. |
| 984 * @private | 983 * @private |
| 985 */ | 984 */ |
| 986 onManipulateSettingsForTest_: function(event) { | 985 onManipulateSettingsForTest_: function(event) { |
| 987 if ('selectSaveAsPdfDestination' in event.settings) { | 986 if ('selectSaveAsPdfDestination' in event.settings) { |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1286 <include src="search/cloud_destination_list.js"/> | 1285 <include src="search/cloud_destination_list.js"/> |
| 1287 <include src="search/recent_destination_list.js"/> | 1286 <include src="search/recent_destination_list.js"/> |
| 1288 <include src="search/destination_list_item.js"/> | 1287 <include src="search/destination_list_item.js"/> |
| 1289 <include src="search/destination_search.js"/> | 1288 <include src="search/destination_search.js"/> |
| 1290 <include src="search/fedex_tos.js"/> | 1289 <include src="search/fedex_tos.js"/> |
| 1291 | 1290 |
| 1292 window.addEventListener('DOMContentLoaded', function() { | 1291 window.addEventListener('DOMContentLoaded', function() { |
| 1293 printPreview = new print_preview.PrintPreview(); | 1292 printPreview = new print_preview.PrintPreview(); |
| 1294 printPreview.initialize(); | 1293 printPreview.initialize(); |
| 1295 }); | 1294 }); |
| OLD | NEW |