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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 return this.isTicketValidForPreview() && | 427 return this.isTicketValidForPreview() && |
428 (!this.copies_.isCapabilityAvailable() || this.copies_.isValid()) && | 428 (!this.copies_.isCapabilityAvailable() || this.copies_.isValid()) && |
429 (!this.pageRange_.isCapabilityAvailable() || | 429 (!this.pageRange_.isCapabilityAvailable() || |
430 this.pageRange_.isValid()); | 430 this.pageRange_.isValid()); |
431 }, | 431 }, |
432 | 432 |
433 /** @return {boolean} Whether the ticket is valid for preview generation. */ | 433 /** @return {boolean} Whether the ticket is valid for preview generation. */ |
434 isTicketValidForPreview: function() { | 434 isTicketValidForPreview: function() { |
435 return (!this.marginsType_.isCapabilityAvailable() || | 435 return (!this.marginsType_.isCapabilityAvailable() || |
436 !this.marginsType_.isValueEqual( | 436 !this.marginsType_.isValueEqual( |
437 print_preview.ticket_items.MarginsType.Value.CUSTOM) || | 437 print_preview.ticket_items.MarginsTypeValue.CUSTOM) || |
438 this.customMargins_.isValid()); | 438 this.customMargins_.isValid()); |
439 }, | 439 }, |
440 | 440 |
441 /** | 441 /** |
442 * Creates an object that represents a Google Cloud Print print ticket. | 442 * Creates an object that represents a Google Cloud Print print ticket. |
443 * @param {!print_preview.Destination} destination Destination to print to. | 443 * @param {!print_preview.Destination} destination Destination to print to. |
444 * @return {!Object} Google Cloud Print print ticket. | 444 * @return {!Object} Google Cloud Print print ticket. |
445 */ | 445 */ |
446 createPrintTicket: function(destination) { | 446 createPrintTicket: function(destination) { |
447 assert(!destination.isLocal || | 447 assert(!destination.isLocal || |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 | 552 |
553 /** | 553 /** |
554 * Called when the destination selected. | 554 * Called when the destination selected. |
555 * @private | 555 * @private |
556 */ | 556 */ |
557 onDestinationSelect_: function() { | 557 onDestinationSelect_: function() { |
558 // Reset user selection for certain ticket items. | 558 // Reset user selection for certain ticket items. |
559 if (this.capabilitiesHolder_.get() != null) { | 559 if (this.capabilitiesHolder_.get() != null) { |
560 this.customMargins_.updateValue(null); | 560 this.customMargins_.updateValue(null); |
561 if (this.marginsType_.getValue() == | 561 if (this.marginsType_.getValue() == |
562 print_preview.ticket_items.MarginsType.Value.CUSTOM) { | 562 print_preview.ticket_items.MarginsTypeValue.CUSTOM) { |
563 this.marginsType_.updateValue( | 563 this.marginsType_.updateValue( |
564 print_preview.ticket_items.MarginsType.Value.DEFAULT); | 564 print_preview.ticket_items.MarginsTypeValue.DEFAULT); |
565 } | 565 } |
566 this.vendorItems_.updateValue({}); | 566 this.vendorItems_.updateValue({}); |
567 } | 567 } |
568 }, | 568 }, |
569 | 569 |
570 /** | 570 /** |
571 * Called when the capabilities of the selected destination are ready. | 571 * Called when the capabilities of the selected destination are ready. |
572 * @private | 572 * @private |
573 */ | 573 */ |
574 onSelectedDestinationCapabilitiesReady_: function() { | 574 onSelectedDestinationCapabilitiesReady_: function() { |
(...skipping 18 matching lines...) Expand all Loading... |
593 onDocumentInfoChange_: function() { | 593 onDocumentInfoChange_: function() { |
594 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.DOCUMENT_CHANGE); | 594 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.DOCUMENT_CHANGE); |
595 }, | 595 }, |
596 }; | 596 }; |
597 | 597 |
598 // Export | 598 // Export |
599 return { | 599 return { |
600 PrintTicketStore: PrintTicketStore | 600 PrintTicketStore: PrintTicketStore |
601 }; | 601 }; |
602 }); | 602 }); |
OLD | NEW |