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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // will be valid even if no preview can be generated. | 44 // will be valid even if no preview can be generated. |
45 var initialPageSize = new print_preview.Size(612, 792); // 8.5"x11" | 45 var initialPageSize = new print_preview.Size(612, 792); // 8.5"x11" |
46 | 46 |
47 /** | 47 /** |
48 * Information about the document to print. | 48 * Information about the document to print. |
49 * @type {!print_preview.DocumentInfo} | 49 * @type {!print_preview.DocumentInfo} |
50 * @private | 50 * @private |
51 */ | 51 */ |
52 this.documentInfo_ = new print_preview.DocumentInfo(); | 52 this.documentInfo_ = new print_preview.DocumentInfo(); |
53 this.documentInfo_.isModifiable = true; | 53 this.documentInfo_.isModifiable = true; |
54 this.documentInfo_.pageCount = 1; | 54 this.documentInfo_.pageCount = 0; |
55 this.documentInfo_.pageSize = initialPageSize; | 55 this.documentInfo_.pageSize = initialPageSize; |
56 this.documentInfo_.printableArea = new print_preview.PrintableArea( | 56 this.documentInfo_.printableArea = new print_preview.PrintableArea( |
57 new print_preview.Coordinate2d(0, 0), initialPageSize); | 57 new print_preview.Coordinate2d(0, 0), initialPageSize); |
58 | 58 |
59 /** | 59 /** |
60 * Printing capabilities of Chromium and the currently selected destination. | 60 * Printing capabilities of Chromium and the currently selected destination. |
61 * @type {!print_preview.CapabilitiesHolder} | 61 * @type {!print_preview.CapabilitiesHolder} |
62 * @private | 62 * @private |
63 */ | 63 */ |
64 this.capabilitiesHolder_ = new print_preview.CapabilitiesHolder(); | 64 this.capabilitiesHolder_ = new print_preview.CapabilitiesHolder(); |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 isPageRangeValid: function() { | 586 isPageRangeValid: function() { |
587 return this.pageRange_.isValid(); | 587 return this.pageRange_.isValid(); |
588 }, | 588 }, |
589 | 589 |
590 /** @return {string} String representation of the page range. */ | 590 /** @return {string} String representation of the page range. */ |
591 getPageRangeStr: function() { | 591 getPageRangeStr: function() { |
592 return this.pageRange_.getValue(); | 592 return this.pageRange_.getValue(); |
593 }, | 593 }, |
594 | 594 |
595 /** | 595 /** |
| 596 * @return {!Array.<object.<{from: number, to: number}>>} Page ranges |
| 597 * represented by of the page range string. |
| 598 */ |
| 599 getPageRanges: function() { |
| 600 return this.pageRange_.getPageRanges(); |
| 601 }, |
| 602 |
| 603 /** |
| 604 * @return {!Array.<object.<{from: number, to: number}>>} Page ranges |
| 605 * represented by of the page range string and constraied by ducument |
| 606 * page count. |
| 607 */ |
| 608 getDocumentPageRanges: function() { |
| 609 return this.pageRange_.getDocumentPageRanges(); |
| 610 }, |
| 611 |
| 612 /** |
596 * @return {!print_preview.PageNumberSet} Page number set specified by the | 613 * @return {!print_preview.PageNumberSet} Page number set specified by the |
597 * string representation of the page range string. | 614 * string representation of the page range string. |
598 */ | 615 */ |
599 getPageNumberSet: function() { | 616 getPageNumberSet: function() { |
600 return this.pageRange_.getPageNumberSet(); | 617 return this.pageRange_.getPageNumberSet(); |
601 }, | 618 }, |
602 | 619 |
603 /** | 620 /** |
604 * Updates the page range string. Dispatches a TICKET_CHANGE if the string | 621 * Updates the page range string. Dispatches a TICKET_CHANGE if the string |
605 * changed. | 622 * changed. |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 this, PrintTicketStore.EventType.CAPABILITIES_CHANGE); | 761 this, PrintTicketStore.EventType.CAPABILITIES_CHANGE); |
745 } | 762 } |
746 } | 763 } |
747 }; | 764 }; |
748 | 765 |
749 // Export | 766 // Export |
750 return { | 767 return { |
751 PrintTicketStore: PrintTicketStore | 768 PrintTicketStore: PrintTicketStore |
752 }; | 769 }; |
753 }); | 770 }); |
OLD | NEW |