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 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 */ | 416 */ |
417 onSelectedDestinationCapabilitiesReady_: function() { | 417 onSelectedDestinationCapabilitiesReady_: function() { |
418 var caps = this.destinationStore_.selectedDestination.capabilities; | 418 var caps = this.destinationStore_.selectedDestination.capabilities; |
419 var isFirstUpdate = this.capabilitiesHolder_.get() == null; | 419 var isFirstUpdate = this.capabilitiesHolder_.get() == null; |
420 this.capabilitiesHolder_.set(caps); | 420 this.capabilitiesHolder_.set(caps); |
421 if (isFirstUpdate) { | 421 if (isFirstUpdate) { |
422 this.isInitialized_ = true; | 422 this.isInitialized_ = true; |
423 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.INITIALIZE); | 423 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.INITIALIZE); |
424 } else { | 424 } else { |
425 // Reset user selection for certain ticket items. | 425 // Reset user selection for certain ticket items. |
426 this.customMargins_.updateValue(null); | |
427 | |
428 if (this.marginsType_.getValue() == | 426 if (this.marginsType_.getValue() == |
429 print_preview.ticket_items.MarginsType.Value.CUSTOM) { | 427 print_preview.ticket_items.MarginsType.Value.CUSTOM && |
| 428 !this.customMargins_.wouldValueBeValid( |
| 429 this.customMargins_.getValue())) { |
| 430 this.customMargins_.updateValue(null); |
430 this.marginsType_.updateValue( | 431 this.marginsType_.updateValue( |
431 print_preview.ticket_items.MarginsType.Value.DEFAULT); | 432 print_preview.ticket_items.MarginsType.Value.DEFAULT); |
432 } | 433 } |
433 cr.dispatchSimpleEvent( | 434 cr.dispatchSimpleEvent( |
434 this, PrintTicketStore.EventType.CAPABILITIES_CHANGE); | 435 this, PrintTicketStore.EventType.CAPABILITIES_CHANGE); |
435 } | 436 } |
436 }, | 437 }, |
437 | 438 |
438 /** | 439 /** |
439 * Called when document data model has changed. Dispatches a print ticket | 440 * Called when document data model has changed. Dispatches a print ticket |
440 * store event. | 441 * store event. |
441 * @private | 442 * @private |
442 */ | 443 */ |
443 onDocumentInfoChange_: function() { | 444 onDocumentInfoChange_: function() { |
444 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.DOCUMENT_CHANGE); | 445 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.DOCUMENT_CHANGE); |
445 }, | 446 }, |
446 }; | 447 }; |
447 | 448 |
448 // Export | 449 // Export |
449 return { | 450 return { |
450 PrintTicketStore: PrintTicketStore | 451 PrintTicketStore: PrintTicketStore |
451 }; | 452 }; |
452 }); | 453 }); |
OLD | NEW |