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 /** | 8 /** |
9 * Interface to the Chromium print preview generator. | 9 * Interface to the Chromium print preview generator. |
10 * @param {!print_preview.DestinationStore} destinationStore Used to get the | 10 * @param {!print_preview.DestinationStore} destinationStore Used to get the |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 this.mediaSize_ = null; | 65 this.mediaSize_ = null; |
66 | 66 |
67 /** | 67 /** |
68 * Whether the previews are being generated in landscape mode. | 68 * Whether the previews are being generated in landscape mode. |
69 * @type {boolean} | 69 * @type {boolean} |
70 * @private | 70 * @private |
71 */ | 71 */ |
72 this.isLandscapeEnabled_ = false; | 72 this.isLandscapeEnabled_ = false; |
73 | 73 |
74 /** | 74 /** |
| 75 * Whether the previews are being generated from a simplified page. |
| 76 * @type {boolean} |
| 77 * @private |
| 78 */ |
| 79 this.isPrintFriendlyEnabled_ = false; |
| 80 |
| 81 /** |
75 * Whether the previews are being generated with a header and footer. | 82 * Whether the previews are being generated with a header and footer. |
76 * @type {boolean} | 83 * @type {boolean} |
77 * @private | 84 * @private |
78 */ | 85 */ |
79 this.isHeaderFooterEnabled_ = false; | 86 this.isHeaderFooterEnabled_ = false; |
80 | 87 |
81 /** | 88 /** |
82 * Whether the previews are being generated in color. | 89 * Whether the previews are being generated in color. |
83 * @type {boolean} | 90 * @type {boolean} |
84 * @private | 91 * @private |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 if (!this.hasPreviewChanged_()) { | 175 if (!this.hasPreviewChanged_()) { |
169 // Changes to these ticket items might not trigger a new preview, but | 176 // Changes to these ticket items might not trigger a new preview, but |
170 // they still need to be recorded. | 177 // they still need to be recorded. |
171 this.marginsType_ = this.printTicketStore_.marginsType.getValue(); | 178 this.marginsType_ = this.printTicketStore_.marginsType.getValue(); |
172 return false; | 179 return false; |
173 } | 180 } |
174 this.mediaSize_ = this.printTicketStore_.mediaSize.getValue(); | 181 this.mediaSize_ = this.printTicketStore_.mediaSize.getValue(); |
175 this.isLandscapeEnabled_ = this.printTicketStore_.landscape.getValue(); | 182 this.isLandscapeEnabled_ = this.printTicketStore_.landscape.getValue(); |
176 this.isHeaderFooterEnabled_ = | 183 this.isHeaderFooterEnabled_ = |
177 this.printTicketStore_.headerFooter.getValue(); | 184 this.printTicketStore_.headerFooter.getValue(); |
| 185 this.isPrintFriendlyEnabled_ = |
| 186 this.printTicketStore_.printFriendly.getValue(); |
178 this.colorValue_ = this.printTicketStore_.color.getValue(); | 187 this.colorValue_ = this.printTicketStore_.color.getValue(); |
179 this.isFitToPageEnabled_ = this.printTicketStore_.fitToPage.getValue(); | 188 this.isFitToPageEnabled_ = this.printTicketStore_.fitToPage.getValue(); |
180 this.pageRanges_ = this.printTicketStore_.pageRange.getPageRanges(); | 189 this.pageRanges_ = this.printTicketStore_.pageRange.getPageRanges(); |
181 this.marginsType_ = this.printTicketStore_.marginsType.getValue(); | 190 this.marginsType_ = this.printTicketStore_.marginsType.getValue(); |
182 this.isCssBackgroundEnabled_ = | 191 this.isCssBackgroundEnabled_ = |
183 this.printTicketStore_.cssBackground.getValue(); | 192 this.printTicketStore_.cssBackground.getValue(); |
184 this.isSelectionOnlyEnabled_ = | 193 this.isSelectionOnlyEnabled_ = |
185 this.printTicketStore_.selectionOnly.getValue(); | 194 this.printTicketStore_.selectionOnly.getValue(); |
186 this.selectedDestination_ = this.destinationStore_.selectedDestination; | 195 this.selectedDestination_ = this.destinationStore_.selectedDestination; |
187 | 196 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 * @return {boolean} Whether the print ticket has changed sufficiently to | 276 * @return {boolean} Whether the print ticket has changed sufficiently to |
268 * determine whether a new preview request should be issued. | 277 * determine whether a new preview request should be issued. |
269 * @private | 278 * @private |
270 */ | 279 */ |
271 hasPreviewChanged_: function() { | 280 hasPreviewChanged_: function() { |
272 var ticketStore = this.printTicketStore_; | 281 var ticketStore = this.printTicketStore_; |
273 return this.inFlightRequestId_ == -1 || | 282 return this.inFlightRequestId_ == -1 || |
274 !ticketStore.mediaSize.isValueEqual(this.mediaSize_) || | 283 !ticketStore.mediaSize.isValueEqual(this.mediaSize_) || |
275 !ticketStore.landscape.isValueEqual(this.isLandscapeEnabled_) || | 284 !ticketStore.landscape.isValueEqual(this.isLandscapeEnabled_) || |
276 !ticketStore.headerFooter.isValueEqual(this.isHeaderFooterEnabled_) || | 285 !ticketStore.headerFooter.isValueEqual(this.isHeaderFooterEnabled_) || |
| 286 !ticketStore.printFriendly.isValueEqual( |
| 287 this.isPrintFriendlyEnabled_) || |
277 !ticketStore.color.isValueEqual(this.colorValue_) || | 288 !ticketStore.color.isValueEqual(this.colorValue_) || |
278 !ticketStore.fitToPage.isValueEqual(this.isFitToPageEnabled_) || | 289 !ticketStore.fitToPage.isValueEqual(this.isFitToPageEnabled_) || |
279 this.pageRanges_ == null || | 290 this.pageRanges_ == null || |
280 !areRangesEqual(ticketStore.pageRange.getPageRanges(), | 291 !areRangesEqual(ticketStore.pageRange.getPageRanges(), |
281 this.pageRanges_) || | 292 this.pageRanges_) || |
282 (!ticketStore.marginsType.isValueEqual(this.marginsType_) && | 293 (!ticketStore.marginsType.isValueEqual(this.marginsType_) && |
283 !ticketStore.marginsType.isValueEqual( | 294 !ticketStore.marginsType.isValueEqual( |
284 print_preview.ticket_items.MarginsType.Value.CUSTOM)) || | 295 print_preview.ticket_items.MarginsType.Value.CUSTOM)) || |
285 (ticketStore.marginsType.isValueEqual( | 296 (ticketStore.marginsType.isValueEqual( |
286 print_preview.ticket_items.MarginsType.Value.CUSTOM) && | 297 print_preview.ticket_items.MarginsType.Value.CUSTOM) && |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 // current one. | 405 // current one. |
395 cr.dispatchSimpleEvent(this, PreviewGenerator.EventType.FAIL); | 406 cr.dispatchSimpleEvent(this, PreviewGenerator.EventType.FAIL); |
396 } | 407 } |
397 }; | 408 }; |
398 | 409 |
399 // Export | 410 // Export |
400 return { | 411 return { |
401 PreviewGenerator: PreviewGenerator | 412 PreviewGenerator: PreviewGenerator |
402 }; | 413 }; |
403 }); | 414 }); |
OLD | NEW |