Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: chrome/browser/resources/print_preview/data/ticket_items/header_footer.js

Issue 10108001: Refactor print preview web ui (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address reviewer comments Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 /**
46 * Minimum value of a top or bottom margin that can fit a header and footer.
47 * @type {number}
48 * @const
49 * @private
50 */
51 HeaderFooter.MIN_MARGIN_SIZE_ = 72.0 / 2.0; // Half inch.
52
53 HeaderFooter.prototype = {
54 __proto__: print_preview.ticket_items.TicketItem.prototype,
55
56 /** @override */
57 wouldValueBeValid: function(value) {
58 return true;
59 },
60
61 /** @override */
62 isCapabilityAvailable: function() {
63 if (!this.documentInfo_.isModifiable ||
64 this.marginsType_.getValue() ==
65 print_preview.ticket_items.MarginsType.Value.NO_MARGINS) {
66 return false;
67 }
68 if (this.marginsType_.getValue() ==
69 print_preview.ticket_items.MarginsType.Value.CUSTOM) {
70 if (!this.customMargins_.isValid()) {
71 return false;
72 }
73 var marginsInPts = this.customMargins_.getValueInPts();
74 var orientEnum = print_preview.ticket_items.CustomMargins.Orientation;
75 if (marginsInPts.get(orientEnum.TOP) < HeaderFooter.MIN_MARGIN_SIZE_ &&
76 marginsInPts.get(orientEnum.BOTTOM) <
77 HeaderFooter.MIN_MARGIN_SIZE_) {
78 return false;
79 }
80 }
81 return true;
82 },
83
84 /** @override */
85 getDefaultValueInternal: function() {
86 return true;
87 },
88
89 /** @override */
90 getCapabilityNotAvailableValueInternal: function() {
91 return false;
92 }
93 };
94
95 // Export
96 return {
97 HeaderFooter: HeaderFooter
98 };
99 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698