| 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.ticket_items', function() { | 5 cr.define('print_preview.ticket_items', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Header-footer ticket item whose value is a {@code boolean} that indicates | 9 * Header-footer ticket item whose value is a {@code boolean} that indicates |
| 10 * whether the document should be printed with headers and footers. | 10 * whether the document should be printed with headers and footers. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * @param {!print_preview.ticket_items.Landscape} landscape Ticket item that | 21 * @param {!print_preview.ticket_items.Landscape} landscape Ticket item that |
| 22 * stores landscape values. | 22 * stores landscape values. |
| 23 * @constructor | 23 * @constructor |
| 24 * @extends {print_preview.ticket_items.TicketItem} | 24 * @extends {print_preview.ticket_items.TicketItem} |
| 25 */ | 25 */ |
| 26 function HeaderFooter(appState, documentInfo, marginsType, customMargins, | 26 function HeaderFooter(appState, documentInfo, marginsType, customMargins, |
| 27 mediaSize, landscape) { | 27 mediaSize, landscape) { |
| 28 print_preview.ticket_items.TicketItem.call( | 28 print_preview.ticket_items.TicketItem.call( |
| 29 this, | 29 this, |
| 30 appState, | 30 appState, |
| 31 print_preview.AppState.Field.IS_HEADER_FOOTER_ENABLED, | 31 print_preview.AppStateField.IS_HEADER_FOOTER_ENABLED, |
| 32 null /*destinationStore*/, | 32 null /*destinationStore*/, |
| 33 documentInfo); | 33 documentInfo); |
| 34 | 34 |
| 35 /** | 35 /** |
| 36 * Ticket item that stores which predefined margins to print with. | 36 * Ticket item that stores which predefined margins to print with. |
| 37 * @private {!print_preview.ticket_items.MarginsType} | 37 * @private {!print_preview.ticket_items.MarginsType} |
| 38 */ | 38 */ |
| 39 this.marginsType_ = marginsType; | 39 this.marginsType_ = marginsType; |
| 40 | 40 |
| 41 /** | 41 /** |
| 42 * Ticket item that stores custom margin values. | 42 * Ticket item that stores custom margin values. |
| 43 * @private {!print_preview.ticket_items.CustomMargins} | 43 * @private {!print_preview.ticket_items.CustomMargins} |
| 44 */ | 44 */ |
| 45 this.customMargins_ = customMargins; | 45 this.customMargins_ = customMargins; |
| 46 | 46 |
| 47 /** | 47 /** |
| 48 * Ticket item that stores media size values. | 48 * Ticket item that stores media size values. |
| 49 * @private {!print_preview.ticket_items.MediaSize} | 49 * @private {!print_preview.ticket_items.MediaSize} |
| 50 */ | 50 */ |
| 51 this.mediaSize_ = mediaSize; | 51 this.mediaSize_ = mediaSize; |
| 52 | 52 |
| 53 /** | 53 /** |
| 54 * Ticket item that stores landscape values. | 54 * Ticket item that stores landscape values. |
| 55 * @private {!print_preview.ticket_items.Landscape} | 55 * @private {!print_preview.ticket_items.Landscape} |
| 56 */ | 56 */ |
| 57 this.landscape_ = landscape; | 57 this.landscape_ = landscape; |
| 58 | 58 |
| 59 this.addEventListeners_(); | 59 this.addEventListeners_(); |
| 60 }; | 60 } |
| 61 | 61 |
| 62 /** | 62 /** |
| 63 * Minimum height of page in microns to allow headers and footers. Should | 63 * Minimum height of page in microns to allow headers and footers. Should |
| 64 * match the value for min_size_printer_units in printing/print_settings.cc | 64 * match the value for min_size_printer_units in printing/print_settings.cc |
| 65 * so that we do not request header/footer for margins that will be zero. | 65 * so that we do not request header/footer for margins that will be zero. |
| 66 * @private {number} | 66 * @private {number} |
| 67 * @const | 67 * @const |
| 68 */ | 68 */ |
| 69 HeaderFooter.MINIMUM_HEIGHT_MICRONS_ = 25400; | 69 HeaderFooter.MINIMUM_HEIGHT_MICRONS_ = 25400; |
| 70 | 70 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 100 var margins; | 100 var margins; |
| 101 if (this.marginsType_.getValue() == | 101 if (this.marginsType_.getValue() == |
| 102 print_preview.ticket_items.MarginsTypeValue.CUSTOM) { | 102 print_preview.ticket_items.MarginsTypeValue.CUSTOM) { |
| 103 if (!this.customMargins_.isValid()) { | 103 if (!this.customMargins_.isValid()) { |
| 104 return false; | 104 return false; |
| 105 } | 105 } |
| 106 margins = this.customMargins_.getValue(); | 106 margins = this.customMargins_.getValue(); |
| 107 } else { | 107 } else { |
| 108 margins = this.getDocumentInfoInternal().margins; | 108 margins = this.getDocumentInfoInternal().margins; |
| 109 } | 109 } |
| 110 var orientEnum = print_preview.ticket_items.CustomMargins.Orientation; | 110 var orientEnum = print_preview.ticket_items.CustomMarginsOrientation; |
| 111 return margins == null || | 111 return margins == null || |
| 112 margins.get(orientEnum.TOP) > 0 || | 112 margins.get(orientEnum.TOP) > 0 || |
| 113 margins.get(orientEnum.BOTTOM) > 0; | 113 margins.get(orientEnum.BOTTOM) > 0; |
| 114 }, | 114 }, |
| 115 | 115 |
| 116 /** @override */ | 116 /** @override */ |
| 117 getDefaultValueInternal: function() { | 117 getDefaultValueInternal: function() { |
| 118 return true; | 118 return true; |
| 119 }, | 119 }, |
| 120 | 120 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 145 print_preview.ticket_items.TicketItem.EventType.CHANGE, | 145 print_preview.ticket_items.TicketItem.EventType.CHANGE, |
| 146 this.dispatchChangeEventInternal.bind(this)); | 146 this.dispatchChangeEventInternal.bind(this)); |
| 147 } | 147 } |
| 148 }; | 148 }; |
| 149 | 149 |
| 150 // Export | 150 // Export |
| 151 return { | 151 return { |
| 152 HeaderFooter: HeaderFooter | 152 HeaderFooter: HeaderFooter |
| 153 }; | 153 }; |
| 154 }); | 154 }); |
| OLD | NEW |