| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 145 |
| 146 /** | 146 /** |
| 147 * Fit-to-page ticket item. | 147 * Fit-to-page ticket item. |
| 148 * @type {!print_preview.ticket_items.FitToPage} | 148 * @type {!print_preview.ticket_items.FitToPage} |
| 149 * @private | 149 * @private |
| 150 */ | 150 */ |
| 151 this.fitToPage_ = new print_preview.ticket_items.FitToPage( | 151 this.fitToPage_ = new print_preview.ticket_items.FitToPage( |
| 152 this.documentInfo_, this.destinationStore_); | 152 this.documentInfo_, this.destinationStore_); |
| 153 | 153 |
| 154 /** | 154 /** |
| 155 * Print CSS backgrounds ticket item. |
| 156 * @type {!print_preview.ticket_items.CssBackground} |
| 157 * @private |
| 158 */ |
| 159 this.cssBackground_ = |
| 160 new print_preview.ticket_items.CssBackground(this.documentInfo_); |
| 161 |
| 162 /** |
| 155 * Keeps track of event listeners for the print ticket store. | 163 * Keeps track of event listeners for the print ticket store. |
| 156 * @type {!EventTracker} | 164 * @type {!EventTracker} |
| 157 * @private | 165 * @private |
| 158 */ | 166 */ |
| 159 this.tracker_ = new EventTracker(); | 167 this.tracker_ = new EventTracker(); |
| 160 | 168 |
| 161 this.addEventListeners_(); | 169 this.addEventListeners_(); |
| 162 }; | 170 }; |
| 163 | 171 |
| 164 /** | 172 /** |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 thousandsDelimeter, decimalDelimeter, unitType); | 290 thousandsDelimeter, decimalDelimeter, unitType); |
| 283 | 291 |
| 284 // Initialize ticket with user's previous values. | 292 // Initialize ticket with user's previous values. |
| 285 this.marginsType_.updateValue(this.appState_.marginsType); | 293 this.marginsType_.updateValue(this.appState_.marginsType); |
| 286 this.customMargins_.updateValue(this.appState_.customMargins); | 294 this.customMargins_.updateValue(this.appState_.customMargins); |
| 287 this.color_.updateValue(this.appState_.isColorEnabled); | 295 this.color_.updateValue(this.appState_.isColorEnabled); |
| 288 this.duplex_.updateValue(this.appState_.isDuplexEnabled); | 296 this.duplex_.updateValue(this.appState_.isDuplexEnabled); |
| 289 this.headerFooter_.updateValue(this.appState_.isHeaderFooterEnabled); | 297 this.headerFooter_.updateValue(this.appState_.isHeaderFooterEnabled); |
| 290 this.landscape_.updateValue(this.appState_.isLandscapeEnabled); | 298 this.landscape_.updateValue(this.appState_.isLandscapeEnabled); |
| 291 this.collate_.updateValue(this.appState_.isCollateEnabled); | 299 this.collate_.updateValue(this.appState_.isCollateEnabled); |
| 300 this.cssBackground_.updateValue( |
| 301 this.appState_.isCssBackgroundEnabled); |
| 292 }, | 302 }, |
| 293 | 303 |
| 294 /** @return {boolean} Whether the ticket store has the copies capability. */ | 304 /** @return {boolean} Whether the ticket store has the copies capability. */ |
| 295 hasCopiesCapability: function() { | 305 hasCopiesCapability: function() { |
| 296 return this.copies_.isCapabilityAvailable(); | 306 return this.copies_.isCapabilityAvailable(); |
| 297 }, | 307 }, |
| 298 | 308 |
| 299 /** | 309 /** |
| 300 * @return {boolean} Whether the string representation of the copies value | 310 * @return {boolean} Whether the string representation of the copies value |
| 301 * currently in the ticket store is valid. | 311 * currently in the ticket store is valid. |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 * capability. | 612 * capability. |
| 603 */ | 613 */ |
| 604 updateFitToPage: function(isFitToPageEnabled) { | 614 updateFitToPage: function(isFitToPageEnabled) { |
| 605 if (this.fitToPage_.getValue() != isFitToPageEnabled) { | 615 if (this.fitToPage_.getValue() != isFitToPageEnabled) { |
| 606 this.fitToPage_.updateValue(isFitToPageEnabled); | 616 this.fitToPage_.updateValue(isFitToPageEnabled); |
| 607 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.TICKET_CHANGE); | 617 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.TICKET_CHANGE); |
| 608 } | 618 } |
| 609 }, | 619 }, |
| 610 | 620 |
| 611 /** | 621 /** |
| 622 * @return {boolean} Whether the print CSS backgrounds capability is |
| 623 * available. |
| 624 */ |
| 625 hasCssBackgroundCapability: function() { |
| 626 return this.cssBackground_.isCapabilityAvailable(); |
| 627 }, |
| 628 |
| 629 /** |
| 630 * @return {boolean} Whether the print CSS backgrounds capability is |
| 631 * enabled. |
| 632 */ |
| 633 isCssBackgroundEnabled: function() { |
| 634 return this.cssBackground_.getValue(); |
| 635 }, |
| 636 |
| 637 /** |
| 638 * @param {boolean} isCssBackgroundEnabled Whether to enable the |
| 639 * print CSS backgrounds capability. |
| 640 */ |
| 641 updateCssBackground: function(isCssBackgroundEnabled) { |
| 642 if (this.cssBackground_.getValue() != isCssBackgroundEnabled) { |
| 643 this.cssBackground_.updateValue(isCssBackgroundEnabled); |
| 644 this.appState_.persistIsCssBackgroundEnabled(isCssBackgroundEnabled); |
| 645 cr.dispatchSimpleEvent(this, PrintTicketStore.EventType.TICKET_CHANGE); |
| 646 } |
| 647 }, |
| 648 |
| 649 /** |
| 612 * @return {boolean} {@code true} if the stored print ticket is valid, | 650 * @return {boolean} {@code true} if the stored print ticket is valid, |
| 613 * {@code false} otherwise. | 651 * {@code false} otherwise. |
| 614 */ | 652 */ |
| 615 isTicketValid: function() { | 653 isTicketValid: function() { |
| 616 return this.isTicketValidForPreview() && | 654 return this.isTicketValidForPreview() && |
| 617 (!this.hasPageRangeCapability() || this.isPageRangeValid()); | 655 (!this.hasPageRangeCapability() || this.isPageRangeValid()); |
| 618 }, | 656 }, |
| 619 | 657 |
| 620 /** @return {boolean} Whether the ticket is valid for preview generation. */ | 658 /** @return {boolean} Whether the ticket is valid for preview generation. */ |
| 621 isTicketValidForPreview: function() { | 659 isTicketValidForPreview: function() { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 this, PrintTicketStore.EventType.CAPABILITIES_CHANGE); | 702 this, PrintTicketStore.EventType.CAPABILITIES_CHANGE); |
| 665 } | 703 } |
| 666 } | 704 } |
| 667 }; | 705 }; |
| 668 | 706 |
| 669 // Export | 707 // Export |
| 670 return { | 708 return { |
| 671 PrintTicketStore: PrintTicketStore | 709 PrintTicketStore: PrintTicketStore |
| 672 }; | 710 }; |
| 673 }); | 711 }); |
| OLD | NEW |