| 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 <include src="component.js"> | 7 <include src="component.js"> |
| 8 <include src="print_preview_focus_manager.js"> | 8 <include src="print_preview_focus_manager.js"> |
| 9 | 9 |
| 10 cr.define('print_preview', function() { | 10 cr.define('print_preview', function() { |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 | 174 |
| 175 /** | 175 /** |
| 176 * Component used to search for print destinations. | 176 * Component used to search for print destinations. |
| 177 * @type {!print_preview.AdvancedSettings} | 177 * @type {!print_preview.AdvancedSettings} |
| 178 * @private | 178 * @private |
| 179 */ | 179 */ |
| 180 this.advancedSettings_ = new print_preview.AdvancedSettings( | 180 this.advancedSettings_ = new print_preview.AdvancedSettings( |
| 181 this.printTicketStore_); | 181 this.printTicketStore_); |
| 182 this.addChild(this.advancedSettings_); | 182 this.addChild(this.advancedSettings_); |
| 183 | 183 |
| 184 /** | |
| 185 * Component representing more/less settings button. | |
| 186 * @type {!print_preview.MoreSettings} | |
| 187 * @private | |
| 188 */ | |
| 189 var settingsSections = [ | 184 var settingsSections = [ |
| 190 this.destinationSettings_, | 185 this.destinationSettings_, |
| 191 this.pageSettings_, | 186 this.pageSettings_, |
| 192 this.copiesSettings_, | 187 this.copiesSettings_, |
| 193 this.mediaSizeSettings_, | 188 this.mediaSizeSettings_, |
| 194 this.layoutSettings_, | 189 this.layoutSettings_, |
| 195 this.marginSettings_, | 190 this.marginSettings_, |
| 196 this.colorSettings_, | 191 this.colorSettings_, |
| 197 this.otherOptionsSettings_, | 192 this.otherOptionsSettings_, |
| 198 this.advancedOptionsSettings_]; | 193 this.advancedOptionsSettings_]; |
| 194 /** |
| 195 * Component representing more/less settings button. |
| 196 * @type {!print_preview.MoreSettings} |
| 197 * @private |
| 198 */ |
| 199 this.moreSettings_ = new print_preview.MoreSettings( | 199 this.moreSettings_ = new print_preview.MoreSettings( |
| 200 this.destinationStore_, settingsSections); | 200 this.destinationStore_, settingsSections); |
| 201 this.addChild(this.moreSettings_); | 201 this.addChild(this.moreSettings_); |
| 202 | 202 |
| 203 /** | 203 /** |
| 204 * Area of the UI that holds the print preview. | 204 * Area of the UI that holds the print preview. |
| 205 * @type {!print_preview.PreviewArea} | 205 * @type {!print_preview.PreviewArea} |
| 206 * @private | 206 * @private |
| 207 */ | 207 */ |
| 208 this.previewArea_ = new print_preview.PreviewArea(this.destinationStore_, | 208 this.previewArea_ = new print_preview.PreviewArea(this.destinationStore_, |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 this.tracker.add( | 342 this.tracker.add( |
| 343 this.nativeLayer_, | 343 this.nativeLayer_, |
| 344 print_preview.NativeLayer.EventType.PRIVET_PRINT_FAILED, | 344 print_preview.NativeLayer.EventType.PRIVET_PRINT_FAILED, |
| 345 this.onPrivetPrintFailed_.bind(this)); | 345 this.onPrivetPrintFailed_.bind(this)); |
| 346 this.tracker.add( | 346 this.tracker.add( |
| 347 this.nativeLayer_, | 347 this.nativeLayer_, |
| 348 print_preview.NativeLayer.EventType.MANIPULATE_SETTINGS_FOR_TEST, | 348 print_preview.NativeLayer.EventType.MANIPULATE_SETTINGS_FOR_TEST, |
| 349 this.onManipulateSettingsForTest_.bind(this)); | 349 this.onManipulateSettingsForTest_.bind(this)); |
| 350 | 350 |
| 351 this.tracker.add( | 351 this.tracker.add( |
| 352 $('system-dialog-link'), | 352 getRequiredElement('system-dialog-link'), |
| 353 'click', | 353 'click', |
| 354 this.openSystemPrintDialog_.bind(this)); | 354 this.openSystemPrintDialog_.bind(this)); |
| 355 this.tracker.add( | 355 this.tracker.add( |
| 356 $('cloud-print-dialog-link'), | 356 getRequiredElement('cloud-print-dialog-link'), |
| 357 'click', | 357 'click', |
| 358 this.onCloudPrintDialogLinkClick_.bind(this)); | 358 this.onCloudPrintDialogLinkClick_.bind(this)); |
| 359 if ($('open-pdf-in-preview-link')) { | 359 if ($('open-pdf-in-preview-link')) { |
| 360 this.tracker.add( | 360 this.tracker.add( |
| 361 $('open-pdf-in-preview-link'), | 361 $('open-pdf-in-preview-link'), |
| 362 'click', | 362 'click', |
| 363 this.onOpenPdfInPreviewLinkClick_.bind(this)); | 363 this.onOpenPdfInPreviewLinkClick_.bind(this)); |
| 364 } | 364 } |
| 365 | 365 |
| 366 this.tracker.add( | 366 this.tracker.add( |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 * @private | 582 * @private |
| 583 */ | 583 */ |
| 584 openSystemPrintDialog_: function() { | 584 openSystemPrintDialog_: function() { |
| 585 if (!this.shouldShowSystemDialogLink_()) | 585 if (!this.shouldShowSystemDialogLink_()) |
| 586 return; | 586 return; |
| 587 if (cr.isWindows) { | 587 if (cr.isWindows) { |
| 588 this.showSystemDialogBeforeNextPrint_ = true; | 588 this.showSystemDialogBeforeNextPrint_ = true; |
| 589 this.printDocumentOrOpenPdfPreview_(false /*isPdfPreview*/); | 589 this.printDocumentOrOpenPdfPreview_(false /*isPdfPreview*/); |
| 590 return; | 590 return; |
| 591 } | 591 } |
| 592 setIsVisible($('system-dialog-throbber'), true); | 592 setIsVisible(getRequiredElement('system-dialog-throbber'), true); |
| 593 this.setIsEnabled_(false); | 593 this.setIsEnabled_(false); |
| 594 this.uiState_ = PrintPreview.UiState_.OPENING_NATIVE_PRINT_DIALOG; | 594 this.uiState_ = PrintPreview.UiState_.OPENING_NATIVE_PRINT_DIALOG; |
| 595 this.nativeLayer_.startShowSystemDialog(); | 595 this.nativeLayer_.startShowSystemDialog(); |
| 596 }, | 596 }, |
| 597 | 597 |
| 598 /** | 598 /** |
| 599 * Called when the native layer has initial settings to set. Sets the | 599 * Called when the native layer has initial settings to set. Sets the |
| 600 * initial settings of the print preview and begins fetching print | 600 * initial settings of the print preview and begins fetching print |
| 601 * destinations. | 601 * destinations. |
| 602 * @param {Event} event Contains the initial print preview settings | 602 * @param {Event} event Contains the initial print preview settings |
| (...skipping 22 matching lines...) Expand all Loading... |
| 625 settings.thousandsDelimeter, | 625 settings.thousandsDelimeter, |
| 626 settings.decimalDelimeter, | 626 settings.decimalDelimeter, |
| 627 settings.unitType, | 627 settings.unitType, |
| 628 settings.selectionOnly); | 628 settings.selectionOnly); |
| 629 this.destinationStore_.init(settings.isInAppKioskMode); | 629 this.destinationStore_.init(settings.isInAppKioskMode); |
| 630 this.appState_.setInitialized(); | 630 this.appState_.setInitialized(); |
| 631 | 631 |
| 632 $('document-title').innerText = settings.documentTitle; | 632 $('document-title').innerText = settings.documentTitle; |
| 633 this.isSystemDialogAvailable_ = !settings.hidePrintWithSystemDialogLink && | 633 this.isSystemDialogAvailable_ = !settings.hidePrintWithSystemDialogLink && |
| 634 !settings.isInAppKioskMode; | 634 !settings.isInAppKioskMode; |
| 635 setIsVisible($('system-dialog-link'), this.shouldShowSystemDialogLink_()); | 635 setIsVisible(getRequiredElement('system-dialog-link'), |
| 636 this.shouldShowSystemDialogLink_()); |
| 636 }, | 637 }, |
| 637 | 638 |
| 638 /** | 639 /** |
| 639 * Calls when the native layer enables Google Cloud Print integration. | 640 * Calls when the native layer enables Google Cloud Print integration. |
| 640 * Fetches the user's cloud printers. | 641 * Fetches the user's cloud printers. |
| 641 * @param {Event} event Contains the base URL of the Google Cloud Print | 642 * @param {Event} event Contains the base URL of the Google Cloud Print |
| 642 * service. | 643 * service. |
| 643 * @private | 644 * @private |
| 644 */ | 645 */ |
| 645 onCloudPrintEnable_: function(event) { | 646 onCloudPrintEnable_: function(event) { |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 | 801 |
| 801 /** | 802 /** |
| 802 * Called when the 'Open pdf in preview' link is clicked. Launches the pdf | 803 * Called when the 'Open pdf in preview' link is clicked. Launches the pdf |
| 803 * preview app. | 804 * preview app. |
| 804 * @private | 805 * @private |
| 805 */ | 806 */ |
| 806 onOpenPdfInPreviewLinkClick_: function() { | 807 onOpenPdfInPreviewLinkClick_: function() { |
| 807 assert(this.uiState_ == PrintPreview.UiState_.READY, | 808 assert(this.uiState_ == PrintPreview.UiState_.READY, |
| 808 'Trying to open pdf in preview when not in ready state: ' + | 809 'Trying to open pdf in preview when not in ready state: ' + |
| 809 this.uiState_); | 810 this.uiState_); |
| 810 setIsVisible($('open-preview-app-throbber'), true); | 811 setIsVisible(getRequiredElement('open-preview-app-throbber'), true); |
| 811 this.previewArea_.showCustomMessage( | 812 this.previewArea_.showCustomMessage( |
| 812 loadTimeData.getString('openingPDFInPreview')); | 813 loadTimeData.getString('openingPDFInPreview')); |
| 813 this.printDocumentOrOpenPdfPreview_(true /*isPdfPreview*/); | 814 this.printDocumentOrOpenPdfPreview_(true /*isPdfPreview*/); |
| 814 }, | 815 }, |
| 815 | 816 |
| 816 /** | 817 /** |
| 817 * Called when the print header's print button is clicked. Prints the | 818 * Called when the print header's print button is clicked. Prints the |
| 818 * document. | 819 * document. |
| 819 * @private | 820 * @private |
| 820 */ | 821 */ |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1136 | 1137 |
| 1137 /** | 1138 /** |
| 1138 * Called when the open-cloud-print-dialog link is clicked. Opens the Google | 1139 * Called when the open-cloud-print-dialog link is clicked. Opens the Google |
| 1139 * Cloud Print web dialog. | 1140 * Cloud Print web dialog. |
| 1140 * @private | 1141 * @private |
| 1141 */ | 1142 */ |
| 1142 onCloudPrintDialogLinkClick_: function() { | 1143 onCloudPrintDialogLinkClick_: function() { |
| 1143 assert(this.uiState_ == PrintPreview.UiState_.READY, | 1144 assert(this.uiState_ == PrintPreview.UiState_.READY, |
| 1144 'Opening Google Cloud Print dialog when not in ready state: ' + | 1145 'Opening Google Cloud Print dialog when not in ready state: ' + |
| 1145 this.uiState_); | 1146 this.uiState_); |
| 1146 setIsVisible($('cloud-print-dialog-throbber'), true); | 1147 setIsVisible(getRequiredElement('cloud-print-dialog-throbber'), true); |
| 1147 this.setIsEnabled_(false); | 1148 this.setIsEnabled_(false); |
| 1148 this.uiState_ = PrintPreview.UiState_.OPENING_CLOUD_PRINT_DIALOG; | 1149 this.uiState_ = PrintPreview.UiState_.OPENING_CLOUD_PRINT_DIALOG; |
| 1149 this.printIfReady_(); | 1150 this.printIfReady_(); |
| 1150 }, | 1151 }, |
| 1151 | 1152 |
| 1152 /** | 1153 /** |
| 1153 * Called when a print destination is selected. Shows/hides the "Print with | 1154 * Called when a print destination is selected. Shows/hides the "Print with |
| 1154 * Cloud Print" link in the navbar. | 1155 * Cloud Print" link in the navbar. |
| 1155 * @private | 1156 * @private |
| 1156 */ | 1157 */ |
| 1157 onDestinationSelect_: function() { | 1158 onDestinationSelect_: function() { |
| 1158 var selectedDest = this.destinationStore_.selectedDestination; | 1159 var selectedDest = this.destinationStore_.selectedDestination; |
| 1159 setIsVisible( | 1160 setIsVisible( |
| 1160 $('cloud-print-dialog-link'), | 1161 getRequiredElement('cloud-print-dialog-link'), |
| 1161 selectedDest && !cr.isChromeOS && !selectedDest.isLocal); | 1162 selectedDest && !cr.isChromeOS && !selectedDest.isLocal); |
| 1162 setIsVisible( | 1163 setIsVisible( |
| 1163 $('system-dialog-link'), | 1164 getRequiredElement('system-dialog-link'), |
| 1164 this.shouldShowSystemDialogLink_()); | 1165 this.shouldShowSystemDialogLink_()); |
| 1165 if (selectedDest && this.isInKioskAutoPrintMode_) { | 1166 if (selectedDest && this.isInKioskAutoPrintMode_) { |
| 1166 this.onPrintButtonClick_(); | 1167 this.onPrintButtonClick_(); |
| 1167 } | 1168 } |
| 1168 }, | 1169 }, |
| 1169 | 1170 |
| 1170 /** | 1171 /** |
| 1171 * Called when the destination store loads a group of destinations. Shows | 1172 * Called when the destination store loads a group of destinations. Shows |
| 1172 * a promo on Chrome OS if the user has no print destinations promoting | 1173 * a promo on Chrome OS if the user has no print destinations promoting |
| 1173 * Google Cloud Print. | 1174 * Google Cloud Print. |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1293 <include src="search/cloud_destination_list.js"> | 1294 <include src="search/cloud_destination_list.js"> |
| 1294 <include src="search/recent_destination_list.js"> | 1295 <include src="search/recent_destination_list.js"> |
| 1295 <include src="search/destination_list_item.js"> | 1296 <include src="search/destination_list_item.js"> |
| 1296 <include src="search/destination_search.js"> | 1297 <include src="search/destination_search.js"> |
| 1297 <include src="search/fedex_tos.js"> | 1298 <include src="search/fedex_tos.js"> |
| 1298 | 1299 |
| 1299 window.addEventListener('DOMContentLoaded', function() { | 1300 window.addEventListener('DOMContentLoaded', function() { |
| 1300 printPreview = new print_preview.PrintPreview(); | 1301 printPreview = new print_preview.PrintPreview(); |
| 1301 printPreview.initialize(); | 1302 printPreview.initialize(); |
| 1302 }); | 1303 }); |
| OLD | NEW |