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 cr.define('print_preview', function() { | 5 cr.define('print_preview', function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 // TODO(rltoscano): Maybe clear print ticket when destination changes. Or | 8 // TODO(rltoscano): Maybe clear print ticket when destination changes. Or |
9 // better yet, carry over any print ticket state that is possible. I.e. if | 9 // better yet, carry over any print ticket state that is possible. I.e. if |
10 // destination changes, the new destination might not support duplex anymore, | 10 // destination changes, the new destination might not support duplex anymore, |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 if (this.appState_.hasField( | 265 if (this.appState_.hasField( |
266 print_preview.AppState.Field.IS_COLLATE_ENABLED)) { | 266 print_preview.AppState.Field.IS_COLLATE_ENABLED)) { |
267 this.collate_.updateValue(this.appState_.getField( | 267 this.collate_.updateValue(this.appState_.getField( |
268 print_preview.AppState.Field.IS_COLLATE_ENABLED)); | 268 print_preview.AppState.Field.IS_COLLATE_ENABLED)); |
269 } | 269 } |
270 if (this.appState_.hasField( | 270 if (this.appState_.hasField( |
271 print_preview.AppState.Field.IS_CSS_BACKGROUND_ENABLED)) { | 271 print_preview.AppState.Field.IS_CSS_BACKGROUND_ENABLED)) { |
272 this.cssBackground_.updateValue(this.appState_.getField( | 272 this.cssBackground_.updateValue(this.appState_.getField( |
273 print_preview.AppState.Field.IS_CSS_BACKGROUND_ENABLED)); | 273 print_preview.AppState.Field.IS_CSS_BACKGROUND_ENABLED)); |
274 } | 274 } |
| 275 this.isInitialized_ = true; |
| 276 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.INITIALIZE); |
275 }, | 277 }, |
276 | 278 |
277 /** @return {boolean} Whether the header-footer capability is available. */ | 279 /** @return {boolean} Whether the header-footer capability is available. */ |
278 hasHeaderFooterCapability: function() { | 280 hasHeaderFooterCapability: function() { |
279 return this.headerFooter_.isCapabilityAvailable(); | 281 return this.headerFooter_.isCapabilityAvailable(); |
280 }, | 282 }, |
281 | 283 |
282 /** @return {boolean} Whether the header-footer setting is enabled. */ | 284 /** @return {boolean} Whether the header-footer setting is enabled. */ |
283 isHeaderFooterEnabled: function() { | 285 isHeaderFooterEnabled: function() { |
284 return this.headerFooter_.getValue(); | 286 return this.headerFooter_.getValue(); |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 }, | 514 }, |
513 | 515 |
514 /** | 516 /** |
515 * Called when the capabilities of the selected destination are ready. | 517 * Called when the capabilities of the selected destination are ready. |
516 * @private | 518 * @private |
517 */ | 519 */ |
518 onSelectedDestinationCapabilitiesReady_: function() { | 520 onSelectedDestinationCapabilitiesReady_: function() { |
519 var caps = this.destinationStore_.selectedDestination.capabilities; | 521 var caps = this.destinationStore_.selectedDestination.capabilities; |
520 var isFirstUpdate = this.capabilitiesHolder_.get() == null; | 522 var isFirstUpdate = this.capabilitiesHolder_.get() == null; |
521 this.capabilitiesHolder_.set(caps); | 523 this.capabilitiesHolder_.set(caps); |
522 if (isFirstUpdate) { | 524 if (!isFirstUpdate) { |
523 this.isInitialized_ = true; | |
524 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.INITIALIZE); | |
525 } else { | |
526 // Reset user selection for certain ticket items. | 525 // Reset user selection for certain ticket items. |
527 this.customMargins_.updateValue(null); | 526 this.customMargins_.updateValue(null); |
528 this.appState_.persistCustomMargins(null); | 527 this.appState_.persistCustomMargins(null); |
529 | 528 |
530 if (this.marginsType_.getValue() == | 529 if (this.marginsType_.getValue() == |
531 print_preview.ticket_items.MarginsType.Value.CUSTOM) { | 530 print_preview.ticket_items.MarginsType.Value.CUSTOM) { |
532 this.marginsType_.updateValue( | 531 this.marginsType_.updateValue( |
533 print_preview.ticket_items.MarginsType.Value.DEFAULT); | 532 print_preview.ticket_items.MarginsType.Value.DEFAULT); |
534 this.appState_.persistMarginsType( | 533 this.appState_.persistMarginsType( |
535 print_preview.ticket_items.MarginsType.Value.DEFAULT); | 534 print_preview.ticket_items.MarginsType.Value.DEFAULT); |
(...skipping 11 matching lines...) Expand all Loading... |
547 onDocumentInfoChange_: function() { | 546 onDocumentInfoChange_: function() { |
548 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.DOCUMENT_CHANGE); | 547 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.DOCUMENT_CHANGE); |
549 } | 548 } |
550 }; | 549 }; |
551 | 550 |
552 // Export | 551 // Export |
553 return { | 552 return { |
554 PrintTicketStore: PrintTicketStore | 553 PrintTicketStore: PrintTicketStore |
555 }; | 554 }; |
556 }); | 555 }); |
OLD | NEW |