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); | 7 var localStrings = new LocalStrings(templateData); |
8 | 8 |
9 <include src="component.js"/> | 9 <include src="component.js"/> |
10 <include src="print_preview_focus_manager.js"/> | 10 <include src="print_preview_focus_manager.js"/> |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 169 |
170 /** | 170 /** |
171 * Component used to search for print destinations. | 171 * Component used to search for print destinations. |
172 * @type {!print_preview.AdvancedSettings} | 172 * @type {!print_preview.AdvancedSettings} |
173 * @private | 173 * @private |
174 */ | 174 */ |
175 this.advancedSettings_ = new print_preview.AdvancedSettings( | 175 this.advancedSettings_ = new print_preview.AdvancedSettings( |
176 this.printTicketStore_); | 176 this.printTicketStore_); |
177 this.addChild(this.advancedSettings_); | 177 this.addChild(this.advancedSettings_); |
178 | 178 |
179 /** | |
180 * Component representing more/less settings button. | |
181 * @type {!print_preview.MoreSettings} | |
182 * @private | |
183 */ | |
184 var settingsSections = [ | 179 var settingsSections = [ |
185 this.destinationSettings_, | 180 this.destinationSettings_, |
186 this.pageSettings_, | 181 this.pageSettings_, |
187 this.copiesSettings_, | 182 this.copiesSettings_, |
188 this.mediaSizeSettings_, | 183 this.mediaSizeSettings_, |
189 this.layoutSettings_, | 184 this.layoutSettings_, |
190 this.marginSettings_, | 185 this.marginSettings_, |
191 this.colorSettings_, | 186 this.colorSettings_, |
192 this.otherOptionsSettings_, | 187 this.otherOptionsSettings_, |
193 this.advancedOptionsSettings_]; | 188 this.advancedOptionsSettings_]; |
| 189 /** |
| 190 * Component representing more/less settings button. |
| 191 * @type {!print_preview.MoreSettings} |
| 192 * @private |
| 193 */ |
194 this.moreSettings_ = new print_preview.MoreSettings( | 194 this.moreSettings_ = new print_preview.MoreSettings( |
195 this.destinationStore_, settingsSections); | 195 this.destinationStore_, settingsSections); |
196 this.addChild(this.moreSettings_); | 196 this.addChild(this.moreSettings_); |
197 | 197 |
198 /** | 198 /** |
199 * Area of the UI that holds the print preview. | 199 * Area of the UI that holds the print preview. |
200 * @type {!print_preview.PreviewArea} | 200 * @type {!print_preview.PreviewArea} |
201 * @private | 201 * @private |
202 */ | 202 */ |
203 this.previewArea_ = new print_preview.PreviewArea(this.destinationStore_, | 203 this.previewArea_ = new print_preview.PreviewArea(this.destinationStore_, |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 this.tracker.add( | 338 this.tracker.add( |
339 this.nativeLayer_, | 339 this.nativeLayer_, |
340 print_preview.NativeLayer.EventType.PRIVET_PRINT_FAILED, | 340 print_preview.NativeLayer.EventType.PRIVET_PRINT_FAILED, |
341 this.onPrivetPrintFailed_.bind(this)); | 341 this.onPrivetPrintFailed_.bind(this)); |
342 this.tracker.add( | 342 this.tracker.add( |
343 this.nativeLayer_, | 343 this.nativeLayer_, |
344 print_preview.NativeLayer.EventType.MANIPULATE_SETTINGS_FOR_TEST, | 344 print_preview.NativeLayer.EventType.MANIPULATE_SETTINGS_FOR_TEST, |
345 this.onManipulateSettingsForTest_.bind(this)); | 345 this.onManipulateSettingsForTest_.bind(this)); |
346 | 346 |
347 this.tracker.add( | 347 this.tracker.add( |
348 $('system-dialog-link'), | 348 getRequiredElement('system-dialog-link'), |
349 'click', | 349 'click', |
350 this.openSystemPrintDialog_.bind(this)); | 350 this.openSystemPrintDialog_.bind(this)); |
351 this.tracker.add( | 351 this.tracker.add( |
352 $('cloud-print-dialog-link'), | 352 getRequiredElement('cloud-print-dialog-link'), |
353 'click', | 353 'click', |
354 this.onCloudPrintDialogLinkClick_.bind(this)); | 354 this.onCloudPrintDialogLinkClick_.bind(this)); |
355 this.tracker.add( | 355 this.tracker.add( |
356 $('open-pdf-in-preview-link'), | 356 getRequiredElement('open-pdf-in-preview-link'), |
357 'click', | 357 'click', |
358 this.onOpenPdfInPreviewLinkClick_.bind(this)); | 358 this.onOpenPdfInPreviewLinkClick_.bind(this)); |
359 | 359 |
360 this.tracker.add( | 360 this.tracker.add( |
361 this.previewArea_, | 361 this.previewArea_, |
362 print_preview.PreviewArea.EventType.PREVIEW_GENERATION_IN_PROGRESS, | 362 print_preview.PreviewArea.EventType.PREVIEW_GENERATION_IN_PROGRESS, |
363 this.onPreviewGenerationInProgress_.bind(this)); | 363 this.onPreviewGenerationInProgress_.bind(this)); |
364 this.tracker.add( | 364 this.tracker.add( |
365 this.previewArea_, | 365 this.previewArea_, |
366 print_preview.PreviewArea.EventType.PREVIEW_GENERATION_DONE, | 366 print_preview.PreviewArea.EventType.PREVIEW_GENERATION_DONE, |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 this.mediaSizeSettings_.decorate($('media-size-settings')); | 456 this.mediaSizeSettings_.decorate($('media-size-settings')); |
457 this.layoutSettings_.decorate($('layout-settings')); | 457 this.layoutSettings_.decorate($('layout-settings')); |
458 this.colorSettings_.decorate($('color-settings')); | 458 this.colorSettings_.decorate($('color-settings')); |
459 this.marginSettings_.decorate($('margin-settings')); | 459 this.marginSettings_.decorate($('margin-settings')); |
460 this.otherOptionsSettings_.decorate($('other-options-settings')); | 460 this.otherOptionsSettings_.decorate($('other-options-settings')); |
461 this.advancedOptionsSettings_.decorate($('advanced-options-settings')); | 461 this.advancedOptionsSettings_.decorate($('advanced-options-settings')); |
462 this.advancedSettings_.decorate($('advanced-settings')); | 462 this.advancedSettings_.decorate($('advanced-settings')); |
463 this.moreSettings_.decorate($('more-settings')); | 463 this.moreSettings_.decorate($('more-settings')); |
464 this.previewArea_.decorate($('preview-area')); | 464 this.previewArea_.decorate($('preview-area')); |
465 | 465 |
466 setIsVisible($('open-pdf-in-preview-link'), cr.isMac); | 466 setIsVisible(getRequiredElement('open-pdf-in-preview-link'), cr.isMac); |
467 }, | 467 }, |
468 | 468 |
469 /** | 469 /** |
470 * Sets whether the controls in the print preview are enabled. | 470 * Sets whether the controls in the print preview are enabled. |
471 * @param {boolean} isEnabled Whether the controls in the print preview are | 471 * @param {boolean} isEnabled Whether the controls in the print preview are |
472 * enabled. | 472 * enabled. |
473 * @private | 473 * @private |
474 */ | 474 */ |
475 setIsEnabled_: function(isEnabled) { | 475 setIsEnabled_: function(isEnabled) { |
476 $('system-dialog-link').disabled = !isEnabled; | 476 $('system-dialog-link').disabled = !isEnabled; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 * @private | 576 * @private |
577 */ | 577 */ |
578 openSystemPrintDialog_: function() { | 578 openSystemPrintDialog_: function() { |
579 if (!this.shouldShowSystemDialogLink_()) | 579 if (!this.shouldShowSystemDialogLink_()) |
580 return; | 580 return; |
581 if (cr.isWindows) { | 581 if (cr.isWindows) { |
582 this.showSystemDialogBeforeNextPrint_ = true; | 582 this.showSystemDialogBeforeNextPrint_ = true; |
583 this.printDocumentOrOpenPdfPreview_(false /*isPdfPreview*/); | 583 this.printDocumentOrOpenPdfPreview_(false /*isPdfPreview*/); |
584 return; | 584 return; |
585 } | 585 } |
586 setIsVisible($('system-dialog-throbber'), true); | 586 setIsVisible(getRequiredElement('system-dialog-throbber'), true); |
587 this.setIsEnabled_(false); | 587 this.setIsEnabled_(false); |
588 this.uiState_ = PrintPreview.UiState_.OPENING_NATIVE_PRINT_DIALOG; | 588 this.uiState_ = PrintPreview.UiState_.OPENING_NATIVE_PRINT_DIALOG; |
589 this.nativeLayer_.startShowSystemDialog(); | 589 this.nativeLayer_.startShowSystemDialog(); |
590 }, | 590 }, |
591 | 591 |
592 /** | 592 /** |
593 * Called when the native layer has initial settings to set. Sets the | 593 * Called when the native layer has initial settings to set. Sets the |
594 * initial settings of the print preview and begins fetching print | 594 * initial settings of the print preview and begins fetching print |
595 * destinations. | 595 * destinations. |
596 * @param {Event} event Contains the initial print preview settings | 596 * @param {Event} event Contains the initial print preview settings |
(...skipping 22 matching lines...) Expand all Loading... |
619 settings.thousandsDelimeter, | 619 settings.thousandsDelimeter, |
620 settings.decimalDelimeter, | 620 settings.decimalDelimeter, |
621 settings.unitType, | 621 settings.unitType, |
622 settings.selectionOnly); | 622 settings.selectionOnly); |
623 this.destinationStore_.init(settings.isInAppKioskMode); | 623 this.destinationStore_.init(settings.isInAppKioskMode); |
624 this.appState_.setInitialized(); | 624 this.appState_.setInitialized(); |
625 | 625 |
626 $('document-title').innerText = settings.documentTitle; | 626 $('document-title').innerText = settings.documentTitle; |
627 this.isSystemDialogAvailable_ = !settings.hidePrintWithSystemDialogLink && | 627 this.isSystemDialogAvailable_ = !settings.hidePrintWithSystemDialogLink && |
628 !settings.isInAppKioskMode; | 628 !settings.isInAppKioskMode; |
629 setIsVisible($('system-dialog-link'), this.shouldShowSystemDialogLink_()); | 629 setIsVisible(getRequiredElement('system-dialog-link'), |
| 630 this.shouldShowSystemDialogLink_()); |
630 }, | 631 }, |
631 | 632 |
632 /** | 633 /** |
633 * Calls when the native layer enables Google Cloud Print integration. | 634 * Calls when the native layer enables Google Cloud Print integration. |
634 * Fetches the user's cloud printers. | 635 * Fetches the user's cloud printers. |
635 * @param {Event} event Contains the base URL of the Google Cloud Print | 636 * @param {Event} event Contains the base URL of the Google Cloud Print |
636 * service. | 637 * service. |
637 * @private | 638 * @private |
638 */ | 639 */ |
639 onCloudPrintEnable_: function(event) { | 640 onCloudPrintEnable_: function(event) { |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
792 | 793 |
793 /** | 794 /** |
794 * Called when the 'Open pdf in preview' link is clicked. Launches the pdf | 795 * Called when the 'Open pdf in preview' link is clicked. Launches the pdf |
795 * preview app. | 796 * preview app. |
796 * @private | 797 * @private |
797 */ | 798 */ |
798 onOpenPdfInPreviewLinkClick_: function() { | 799 onOpenPdfInPreviewLinkClick_: function() { |
799 assert(this.uiState_ == PrintPreview.UiState_.READY, | 800 assert(this.uiState_ == PrintPreview.UiState_.READY, |
800 'Trying to open pdf in preview when not in ready state: ' + | 801 'Trying to open pdf in preview when not in ready state: ' + |
801 this.uiState_); | 802 this.uiState_); |
802 setIsVisible($('open-preview-app-throbber'), true); | 803 setIsVisible(getRequiredElement('open-preview-app-throbber'), true); |
803 this.previewArea_.showCustomMessage( | 804 this.previewArea_.showCustomMessage( |
804 localStrings.getString('openingPDFInPreview')); | 805 localStrings.getString('openingPDFInPreview')); |
805 this.printDocumentOrOpenPdfPreview_(true /*isPdfPreview*/); | 806 this.printDocumentOrOpenPdfPreview_(true /*isPdfPreview*/); |
806 }, | 807 }, |
807 | 808 |
808 /** | 809 /** |
809 * Called when the print header's print button is clicked. Prints the | 810 * Called when the print header's print button is clicked. Prints the |
810 * document. | 811 * document. |
811 * @private | 812 * @private |
812 */ | 813 */ |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1131 | 1132 |
1132 /** | 1133 /** |
1133 * Called when the open-cloud-print-dialog link is clicked. Opens the Google | 1134 * Called when the open-cloud-print-dialog link is clicked. Opens the Google |
1134 * Cloud Print web dialog. | 1135 * Cloud Print web dialog. |
1135 * @private | 1136 * @private |
1136 */ | 1137 */ |
1137 onCloudPrintDialogLinkClick_: function() { | 1138 onCloudPrintDialogLinkClick_: function() { |
1138 assert(this.uiState_ == PrintPreview.UiState_.READY, | 1139 assert(this.uiState_ == PrintPreview.UiState_.READY, |
1139 'Opening Google Cloud Print dialog when not in ready state: ' + | 1140 'Opening Google Cloud Print dialog when not in ready state: ' + |
1140 this.uiState_); | 1141 this.uiState_); |
1141 setIsVisible($('cloud-print-dialog-throbber'), true); | 1142 setIsVisible(getRequiredElement('cloud-print-dialog-throbber'), true); |
1142 this.setIsEnabled_(false); | 1143 this.setIsEnabled_(false); |
1143 this.uiState_ = PrintPreview.UiState_.OPENING_CLOUD_PRINT_DIALOG; | 1144 this.uiState_ = PrintPreview.UiState_.OPENING_CLOUD_PRINT_DIALOG; |
1144 this.printIfReady_(); | 1145 this.printIfReady_(); |
1145 }, | 1146 }, |
1146 | 1147 |
1147 /** | 1148 /** |
1148 * Called when a print destination is selected. Shows/hides the "Print with | 1149 * Called when a print destination is selected. Shows/hides the "Print with |
1149 * Cloud Print" link in the navbar. | 1150 * Cloud Print" link in the navbar. |
1150 * @private | 1151 * @private |
1151 */ | 1152 */ |
1152 onDestinationSelect_: function() { | 1153 onDestinationSelect_: function() { |
1153 var selectedDest = this.destinationStore_.selectedDestination; | 1154 var selectedDest = this.destinationStore_.selectedDestination; |
1154 setIsVisible( | 1155 setIsVisible( |
1155 $('cloud-print-dialog-link'), | 1156 getRequiredElement('cloud-print-dialog-link'), |
1156 selectedDest && !cr.isChromeOS && !selectedDest.isLocal); | 1157 selectedDest && !cr.isChromeOS && !selectedDest.isLocal); |
1157 setIsVisible( | 1158 setIsVisible( |
1158 $('system-dialog-link'), | 1159 getRequiredElement('system-dialog-link'), |
1159 this.shouldShowSystemDialogLink_()); | 1160 this.shouldShowSystemDialogLink_()); |
1160 if (selectedDest && this.isInKioskAutoPrintMode_) { | 1161 if (selectedDest && this.isInKioskAutoPrintMode_) { |
1161 this.onPrintButtonClick_(); | 1162 this.onPrintButtonClick_(); |
1162 } | 1163 } |
1163 }, | 1164 }, |
1164 | 1165 |
1165 /** | 1166 /** |
1166 * Called when the destination store loads a group of destinations. Shows | 1167 * Called when the destination store loads a group of destinations. Shows |
1167 * a promo on Chrome OS if the user has no print destinations promoting | 1168 * a promo on Chrome OS if the user has no print destinations promoting |
1168 * Google Cloud Print. | 1169 * Google Cloud Print. |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1286 <include src="search/cloud_destination_list.js"/> | 1287 <include src="search/cloud_destination_list.js"/> |
1287 <include src="search/recent_destination_list.js"/> | 1288 <include src="search/recent_destination_list.js"/> |
1288 <include src="search/destination_list_item.js"/> | 1289 <include src="search/destination_list_item.js"/> |
1289 <include src="search/destination_search.js"/> | 1290 <include src="search/destination_search.js"/> |
1290 <include src="search/fedex_tos.js"/> | 1291 <include src="search/fedex_tos.js"/> |
1291 | 1292 |
1292 window.addEventListener('DOMContentLoaded', function() { | 1293 window.addEventListener('DOMContentLoaded', function() { |
1293 printPreview = new print_preview.PrintPreview(); | 1294 printPreview = new print_preview.PrintPreview(); |
1294 printPreview.initialize(); | 1295 printPreview.initialize(); |
1295 }); | 1296 }); |
OLD | NEW |