| 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 */ | 152 */ |
| 153 this.otherOptionsSettings_ = new print_preview.OtherOptionsSettings( | 153 this.otherOptionsSettings_ = new print_preview.OtherOptionsSettings( |
| 154 this.printTicketStore_.duplex, | 154 this.printTicketStore_.duplex, |
| 155 this.printTicketStore_.fitToPage, | 155 this.printTicketStore_.fitToPage, |
| 156 this.printTicketStore_.cssBackground, | 156 this.printTicketStore_.cssBackground, |
| 157 this.printTicketStore_.selectionOnly, | 157 this.printTicketStore_.selectionOnly, |
| 158 this.printTicketStore_.headerFooter); | 158 this.printTicketStore_.headerFooter); |
| 159 this.addChild(this.otherOptionsSettings_); | 159 this.addChild(this.otherOptionsSettings_); |
| 160 | 160 |
| 161 /** | 161 /** |
| 162 * Component that renders the advanced options button. |
| 163 * @type {!print_preview.AdvancedOptionsSettings} |
| 164 * @private |
| 165 */ |
| 166 this.advancedOptionsSettings_ = new print_preview.AdvancedOptionsSettings( |
| 167 this.destinationStore_); |
| 168 this.addChild(this.advancedOptionsSettings_); |
| 169 |
| 170 /** |
| 162 * Component used to search for print destinations. | 171 * Component used to search for print destinations. |
| 163 * @type {!print_preview.AdvancedSettings} | 172 * @type {!print_preview.AdvancedSettings} |
| 164 * @private | 173 * @private |
| 165 */ | 174 */ |
| 166 this.advancedSettings_ = new print_preview.AdvancedSettings( | 175 this.advancedSettings_ = new print_preview.AdvancedSettings( |
| 167 this.printTicketStore_); | 176 this.printTicketStore_); |
| 168 this.addChild(this.advancedSettings_); | 177 this.addChild(this.advancedSettings_); |
| 169 | 178 |
| 170 /** | 179 /** |
| 171 * Area of the UI that holds the print preview. | 180 * Area of the UI that holds the print preview. |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 this.onCloudPrintSignInActivated_.bind(this, true /*addAccount*/)); | 385 this.onCloudPrintSignInActivated_.bind(this, true /*addAccount*/)); |
| 377 this.tracker.add( | 386 this.tracker.add( |
| 378 this.destinationSearch_, | 387 this.destinationSearch_, |
| 379 print_preview.DestinationSearch.EventType.SIGN_IN, | 388 print_preview.DestinationSearch.EventType.SIGN_IN, |
| 380 this.onCloudPrintSignInActivated_.bind(this, false /*addAccount*/)); | 389 this.onCloudPrintSignInActivated_.bind(this, false /*addAccount*/)); |
| 381 this.tracker.add( | 390 this.tracker.add( |
| 382 this.destinationSearch_, | 391 this.destinationSearch_, |
| 383 print_preview.DestinationListItem.EventType.REGISTER_PROMO_CLICKED, | 392 print_preview.DestinationListItem.EventType.REGISTER_PROMO_CLICKED, |
| 384 this.onCloudPrintRegisterPromoClick_.bind(this)); | 393 this.onCloudPrintRegisterPromoClick_.bind(this)); |
| 385 | 394 |
| 395 this.tracker.add( |
| 396 this.advancedOptionsSettings_, |
| 397 print_preview.AdvancedOptionsSettings.EventType.BUTTON_ACTIVATED, |
| 398 this.onAdvancedOptionsButtonActivated_.bind(this)); |
| 399 |
| 386 // TODO(rltoscano): Move no-destinations-promo into its own component | 400 // TODO(rltoscano): Move no-destinations-promo into its own component |
| 387 // instead being part of PrintPreview. | 401 // instead being part of PrintPreview. |
| 388 this.tracker.add( | 402 this.tracker.add( |
| 389 this.getChildElement('#no-destinations-promo .close-button'), | 403 this.getChildElement('#no-destinations-promo .close-button'), |
| 390 'click', | 404 'click', |
| 391 this.onNoDestinationsPromoClose_.bind(this)); | 405 this.onNoDestinationsPromoClose_.bind(this)); |
| 392 this.tracker.add( | 406 this.tracker.add( |
| 393 this.getChildElement('#no-destinations-promo .not-now-button'), | 407 this.getChildElement('#no-destinations-promo .not-now-button'), |
| 394 'click', | 408 'click', |
| 395 this.onNoDestinationsPromoClose_.bind(this)); | 409 this.onNoDestinationsPromoClose_.bind(this)); |
| 396 this.tracker.add( | 410 this.tracker.add( |
| 397 this.getChildElement('#no-destinations-promo .add-printer-button'), | 411 this.getChildElement('#no-destinations-promo .add-printer-button'), |
| 398 'click', | 412 'click', |
| 399 this.onNoDestinationsPromoClick_.bind(this)); | 413 this.onNoDestinationsPromoClick_.bind(this)); |
| 400 }, | 414 }, |
| 401 | 415 |
| 402 /** @override */ | 416 /** @override */ |
| 403 decorateInternal: function() { | 417 decorateInternal: function() { |
| 404 this.printHeader_.decorate($('print-header')); | 418 this.printHeader_.decorate($('print-header')); |
| 405 this.destinationSearch_.decorate($('destination-search')); | 419 this.destinationSearch_.decorate($('destination-search')); |
| 406 this.destinationSettings_.decorate($('destination-settings')); | 420 this.destinationSettings_.decorate($('destination-settings')); |
| 407 this.pageSettings_.decorate($('page-settings')); | 421 this.pageSettings_.decorate($('page-settings')); |
| 408 this.copiesSettings_.decorate($('copies-settings')); | 422 this.copiesSettings_.decorate($('copies-settings')); |
| 409 this.mediaSizeSettings_.decorate($('media-size-settings')); | 423 this.mediaSizeSettings_.decorate($('media-size-settings')); |
| 410 this.layoutSettings_.decorate($('layout-settings')); | 424 this.layoutSettings_.decorate($('layout-settings')); |
| 411 this.colorSettings_.decorate($('color-settings')); | 425 this.colorSettings_.decorate($('color-settings')); |
| 412 this.marginSettings_.decorate($('margin-settings')); | 426 this.marginSettings_.decorate($('margin-settings')); |
| 413 this.otherOptionsSettings_.decorate($('other-options-settings')); | 427 this.otherOptionsSettings_.decorate($('other-options-settings')); |
| 428 this.advancedOptionsSettings_.decorate($('advanced-options-settings')); |
| 414 this.advancedSettings_.decorate($('advanced-settings')); | 429 this.advancedSettings_.decorate($('advanced-settings')); |
| 415 this.previewArea_.decorate($('preview-area')); | 430 this.previewArea_.decorate($('preview-area')); |
| 416 | 431 |
| 417 setIsVisible($('open-pdf-in-preview-link'), cr.isMac); | 432 setIsVisible($('open-pdf-in-preview-link'), cr.isMac); |
| 418 }, | 433 }, |
| 419 | 434 |
| 420 /** | 435 /** |
| 421 * Sets whether the controls in the print preview are enabled. | 436 * Sets whether the controls in the print preview are enabled. |
| 422 * @param {boolean} isEnabled Whether the controls in the print preview are | 437 * @param {boolean} isEnabled Whether the controls in the print preview are |
| 423 * enabled. | 438 * enabled. |
| 424 * @private | 439 * @private |
| 425 */ | 440 */ |
| 426 setIsEnabled_: function(isEnabled) { | 441 setIsEnabled_: function(isEnabled) { |
| 427 $('system-dialog-link').disabled = !isEnabled; | 442 $('system-dialog-link').disabled = !isEnabled; |
| 428 $('cloud-print-dialog-link').disabled = !isEnabled; | 443 $('cloud-print-dialog-link').disabled = !isEnabled; |
| 429 $('open-pdf-in-preview-link').disabled = !isEnabled; | 444 $('open-pdf-in-preview-link').disabled = !isEnabled; |
| 430 this.printHeader_.isEnabled = isEnabled; | 445 this.printHeader_.isEnabled = isEnabled; |
| 431 this.destinationSettings_.isEnabled = isEnabled; | 446 this.destinationSettings_.isEnabled = isEnabled; |
| 432 this.pageSettings_.isEnabled = isEnabled; | 447 this.pageSettings_.isEnabled = isEnabled; |
| 433 this.copiesSettings_.isEnabled = isEnabled; | 448 this.copiesSettings_.isEnabled = isEnabled; |
| 434 this.mediaSizeSettings_.isEnabled = isEnabled; | 449 this.mediaSizeSettings_.isEnabled = isEnabled; |
| 435 this.layoutSettings_.isEnabled = isEnabled; | 450 this.layoutSettings_.isEnabled = isEnabled; |
| 436 this.colorSettings_.isEnabled = isEnabled; | 451 this.colorSettings_.isEnabled = isEnabled; |
| 437 this.marginSettings_.isEnabled = isEnabled; | 452 this.marginSettings_.isEnabled = isEnabled; |
| 438 this.otherOptionsSettings_.isEnabled = isEnabled; | 453 this.otherOptionsSettings_.isEnabled = isEnabled; |
| 454 this.advancedOptionsSettings_.isEnabled = isEnabled; |
| 439 }, | 455 }, |
| 440 | 456 |
| 441 /** | 457 /** |
| 442 * Prints the document or launches a pdf preview on the local system. | 458 * Prints the document or launches a pdf preview on the local system. |
| 443 * @param {boolean} isPdfPreview Whether to launch the pdf preview. | 459 * @param {boolean} isPdfPreview Whether to launch the pdf preview. |
| 444 * @private | 460 * @private |
| 445 */ | 461 */ |
| 446 printDocumentOrOpenPdfPreview_: function(isPdfPreview) { | 462 printDocumentOrOpenPdfPreview_: function(isPdfPreview) { |
| 447 assert(this.uiState_ == PrintPreview.UiState_.READY, | 463 assert(this.uiState_ == PrintPreview.UiState_.READY, |
| 448 'Print document request received when not in ready state: ' + | 464 'Print document request received when not in ready state: ' + |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 * @private | 860 * @private |
| 845 */ | 861 */ |
| 846 onDestinationChangeButtonActivate_: function() { | 862 onDestinationChangeButtonActivate_: function() { |
| 847 this.destinationSearch_.setIsVisible(true); | 863 this.destinationSearch_.setIsVisible(true); |
| 848 this.destinationStore_.startLoadCloudDestinations(); | 864 this.destinationStore_.startLoadCloudDestinations(); |
| 849 this.destinationStore_.startLoadLocalDestinations(); | 865 this.destinationStore_.startLoadLocalDestinations(); |
| 850 this.destinationStore_.startLoadPrivetDestinations(); | 866 this.destinationStore_.startLoadPrivetDestinations(); |
| 851 }, | 867 }, |
| 852 | 868 |
| 853 /** | 869 /** |
| 870 * Called when the destination settings' change button is activated. |
| 871 * Displays the destination search component. |
| 872 * @private |
| 873 */ |
| 874 onAdvancedOptionsButtonActivated_: function() { |
| 875 this.advancedSettings_.showForDestination( |
| 876 this.destinationStore_.selectedDestination); |
| 877 }, |
| 878 |
| 879 /** |
| 854 * Called when the destination search dispatches manage cloud destinations | 880 * Called when the destination search dispatches manage cloud destinations |
| 855 * event. Calls corresponding native layer method. | 881 * event. Calls corresponding native layer method. |
| 856 * @private | 882 * @private |
| 857 */ | 883 */ |
| 858 onManageCloudDestinationsActivated_: function() { | 884 onManageCloudDestinationsActivated_: function() { |
| 859 this.nativeLayer_.startManageCloudDestinations(); | 885 this.nativeLayer_.startManageCloudDestinations(); |
| 860 }, | 886 }, |
| 861 | 887 |
| 862 /** | 888 /** |
| 863 * Called when the destination search dispatches manage local destinations | 889 * Called when the destination search dispatches manage local destinations |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1165 <include src="metrics.js"/> | 1191 <include src="metrics.js"/> |
| 1166 | 1192 |
| 1167 <include src="settings/page_settings.js"/> | 1193 <include src="settings/page_settings.js"/> |
| 1168 <include src="settings/copies_settings.js"/> | 1194 <include src="settings/copies_settings.js"/> |
| 1169 <include src="settings/media_size_settings.js"/> | 1195 <include src="settings/media_size_settings.js"/> |
| 1170 <include src="settings/layout_settings.js"/> | 1196 <include src="settings/layout_settings.js"/> |
| 1171 <include src="settings/color_settings.js"/> | 1197 <include src="settings/color_settings.js"/> |
| 1172 <include src="settings/margin_settings.js"/> | 1198 <include src="settings/margin_settings.js"/> |
| 1173 <include src="settings/destination_settings.js"/> | 1199 <include src="settings/destination_settings.js"/> |
| 1174 <include src="settings/other_options_settings.js"/> | 1200 <include src="settings/other_options_settings.js"/> |
| 1201 <include src="settings/advanced_options_settings.js"/> |
| 1175 <include src="settings/advanced_settings/advanced_settings.js"/> | 1202 <include src="settings/advanced_settings/advanced_settings.js"/> |
| 1176 <include src="settings/advanced_settings/advanced_settings_item.js"/> | 1203 <include src="settings/advanced_settings/advanced_settings_item.js"/> |
| 1177 | 1204 |
| 1178 <include src="previewarea/margin_control.js"/> | 1205 <include src="previewarea/margin_control.js"/> |
| 1179 <include src="previewarea/margin_control_container.js"/> | 1206 <include src="previewarea/margin_control_container.js"/> |
| 1180 <include src="../pdf/pdf_scripting_api.js" /> | 1207 <include src="../pdf/pdf_scripting_api.js" /> |
| 1181 <include src="previewarea/preview_area.js"/> | 1208 <include src="previewarea/preview_area.js"/> |
| 1182 <include src="preview_generator.js"/> | 1209 <include src="preview_generator.js"/> |
| 1183 | 1210 |
| 1184 <include src="search/destination_list.js"/> | 1211 <include src="search/destination_list.js"/> |
| 1185 <include src="search/cloud_destination_list.js"/> | 1212 <include src="search/cloud_destination_list.js"/> |
| 1186 <include src="search/recent_destination_list.js"/> | 1213 <include src="search/recent_destination_list.js"/> |
| 1187 <include src="search/destination_list_item.js"/> | 1214 <include src="search/destination_list_item.js"/> |
| 1188 <include src="search/destination_search.js"/> | 1215 <include src="search/destination_search.js"/> |
| 1189 <include src="search/fedex_tos.js"/> | 1216 <include src="search/fedex_tos.js"/> |
| 1190 | 1217 |
| 1191 window.addEventListener('DOMContentLoaded', function() { | 1218 window.addEventListener('DOMContentLoaded', function() { |
| 1192 printPreview = new print_preview.PrintPreview(); | 1219 printPreview = new print_preview.PrintPreview(); |
| 1193 printPreview.initialize(); | 1220 printPreview.initialize(); |
| 1194 }); | 1221 }); |
| OLD | NEW |