OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 cr.define('print_preview.ticket_items', function() { |
| 6 'use strict'; |
| 7 |
| 8 /** |
| 9 * Header-footer ticket item whose value is a {@code boolean} that indicates |
| 10 * whether the document should be printed with headers and footers. |
| 11 * @param {!print_preview.DocumentInfo} documentInfo Information about the |
| 12 * document to print. |
| 13 * @param {!print_preview.ticket_items.MarginsType} marginsType Ticket item |
| 14 * that stores which predefined margins to print with. |
| 15 * @param {!print_preview.ticket_items.CustomMargins} customMargins Ticket |
| 16 * item that stores custom margin values. |
| 17 * @constructor |
| 18 * @extends {print_preview.ticket_items.TicketItem} |
| 19 */ |
| 20 function HeaderFooter(documentInfo, marginsType, customMargins) { |
| 21 print_preview.ticket_items.TicketItem.call(this); |
| 22 |
| 23 /** |
| 24 * Information about the document to print. |
| 25 * @type {!print_preview.DocumentInfo} |
| 26 * @private |
| 27 */ |
| 28 this.documentInfo_ = documentInfo; |
| 29 |
| 30 /** |
| 31 * Ticket item that stores which predefined margins to print with. |
| 32 * @type {!print_preview.ticket_items.MarginsType} |
| 33 * @private |
| 34 */ |
| 35 this.marginsType_ = marginsType; |
| 36 |
| 37 /** |
| 38 * Ticket item that stores custom margin values. |
| 39 * @type {!print_preview.ticket_items.CustomMargins} |
| 40 * @private |
| 41 */ |
| 42 this.customMargins_ = customMargins; |
| 43 }; |
| 44 |
| 45 HeaderFooter.prototype = { |
| 46 __proto__: print_preview.ticket_items.TicketItem.prototype, |
| 47 |
| 48 /** @override */ |
| 49 wouldValueBeValid: function(value) { |
| 50 return true; |
| 51 }, |
| 52 |
| 53 /** @override */ |
| 54 isCapabilityAvailable: function() { |
| 55 if (!this.documentInfo_.isModifiable) { |
| 56 return false; |
| 57 } else if (this.marginsType_.getValue() == |
| 58 print_preview.ticket_items.MarginsType.Value.NO_MARGINS) { |
| 59 return false; |
| 60 } else if (this.marginsType_.getValue() == |
| 61 print_preview.ticket_items.MarginsType.Value.MINIMUM) { |
| 62 return true; |
| 63 } |
| 64 var margins; |
| 65 if (this.marginsType_.getValue() == |
| 66 print_preview.ticket_items.MarginsType.Value.CUSTOM) { |
| 67 if (!this.customMargins_.isValid()) { |
| 68 return false; |
| 69 } |
| 70 margins = this.customMargins_.getValue(); |
| 71 } else { |
| 72 margins = this.documentInfo_.margins; |
| 73 } |
| 74 var orientEnum = print_preview.ticket_items.CustomMargins.Orientation; |
| 75 return margins == null || |
| 76 margins.get(orientEnum.TOP) > 0 || |
| 77 margins.get(orientEnum.BOTTOM) > 0; |
| 78 }, |
| 79 |
| 80 /** @override */ |
| 81 getDefaultValueInternal: function() { |
| 82 return true; |
| 83 }, |
| 84 |
| 85 /** @override */ |
| 86 getCapabilityNotAvailableValueInternal: function() { |
| 87 return false; |
| 88 } |
| 89 }; |
| 90 |
| 91 // Export |
| 92 return { |
| 93 HeaderFooter: HeaderFooter |
| 94 }; |
| 95 }); |
OLD | NEW |