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

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

Issue 2617663002: WIP: run clang-format-js on lots of things (Closed)
Patch Set: merge Created 3 years, 11 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
OLDNEW
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.
11 * @param {!print_preview.AppState} appState App state used to persist whether 11 * @param {!print_preview.AppState} appState App state used to persist whether
12 * header-footer is enabled. 12 * header-footer is enabled.
13 * @param {!print_preview.DocumentInfo} documentInfo Information about the 13 * @param {!print_preview.DocumentInfo} documentInfo Information about the
14 * document to print. 14 * document to print.
15 * @param {!print_preview.ticket_items.MarginsType} marginsType Ticket item 15 * @param {!print_preview.ticket_items.MarginsType} marginsType Ticket item
16 * that stores which predefined margins to print with. 16 * that stores which predefined margins to print with.
17 * @param {!print_preview.ticket_items.CustomMargins} customMargins Ticket 17 * @param {!print_preview.ticket_items.CustomMargins} customMargins Ticket
18 * item that stores custom margin values. 18 * item that stores custom margin values.
19 * @constructor 19 * @constructor
20 * @extends {print_preview.ticket_items.TicketItem} 20 * @extends {print_preview.ticket_items.TicketItem}
21 */ 21 */
22 function HeaderFooter(appState, documentInfo, marginsType, customMargins) { 22 function HeaderFooter(appState, documentInfo, marginsType, customMargins) {
23 print_preview.ticket_items.TicketItem.call( 23 print_preview.ticket_items.TicketItem.call(
24 this, 24 this, appState, print_preview.AppState.Field.IS_HEADER_FOOTER_ENABLED,
25 appState, 25 null /*destinationStore*/, documentInfo);
26 print_preview.AppState.Field.IS_HEADER_FOOTER_ENABLED,
27 null /*destinationStore*/,
28 documentInfo);
29 26
30 /** 27 /**
31 * Ticket item that stores which predefined margins to print with. 28 * Ticket item that stores which predefined margins to print with.
32 * @type {!print_preview.ticket_items.MarginsType} 29 * @type {!print_preview.ticket_items.MarginsType}
33 * @private 30 * @private
34 */ 31 */
35 this.marginsType_ = marginsType; 32 this.marginsType_ = marginsType;
36 33
37 /** 34 /**
38 * Ticket item that stores custom margin values. 35 * Ticket item that stores custom margin values.
(...skipping 10 matching lines...) Expand all
49 46
50 /** @override */ 47 /** @override */
51 wouldValueBeValid: function(value) { 48 wouldValueBeValid: function(value) {
52 return true; 49 return true;
53 }, 50 },
54 51
55 /** @override */ 52 /** @override */
56 isCapabilityAvailable: function() { 53 isCapabilityAvailable: function() {
57 if (!this.getDocumentInfoInternal().isModifiable) { 54 if (!this.getDocumentInfoInternal().isModifiable) {
58 return false; 55 return false;
59 } else if (this.marginsType_.getValue() == 56 } else if (
57 this.marginsType_.getValue() ==
60 print_preview.ticket_items.MarginsType.Value.NO_MARGINS) { 58 print_preview.ticket_items.MarginsType.Value.NO_MARGINS) {
61 return false; 59 return false;
62 } else if (this.marginsType_.getValue() == 60 } else if (
61 this.marginsType_.getValue() ==
63 print_preview.ticket_items.MarginsType.Value.MINIMUM) { 62 print_preview.ticket_items.MarginsType.Value.MINIMUM) {
64 return true; 63 return true;
65 } 64 }
66 var margins; 65 var margins;
67 if (this.marginsType_.getValue() == 66 if (this.marginsType_.getValue() ==
68 print_preview.ticket_items.MarginsType.Value.CUSTOM) { 67 print_preview.ticket_items.MarginsType.Value.CUSTOM) {
69 if (!this.customMargins_.isValid()) { 68 if (!this.customMargins_.isValid()) {
70 return false; 69 return false;
71 } 70 }
72 margins = this.customMargins_.getValue(); 71 margins = this.customMargins_.getValue();
73 } else { 72 } else {
74 margins = this.getDocumentInfoInternal().margins; 73 margins = this.getDocumentInfoInternal().margins;
75 } 74 }
76 var orientEnum = print_preview.ticket_items.CustomMargins.Orientation; 75 var orientEnum = print_preview.ticket_items.CustomMargins.Orientation;
77 return margins == null || 76 return margins == null || margins.get(orientEnum.TOP) > 0 ||
78 margins.get(orientEnum.TOP) > 0 || 77 margins.get(orientEnum.BOTTOM) > 0;
79 margins.get(orientEnum.BOTTOM) > 0;
80 }, 78 },
81 79
82 /** @override */ 80 /** @override */
83 getDefaultValueInternal: function() { 81 getDefaultValueInternal: function() {
84 return true; 82 return true;
85 }, 83 },
86 84
87 /** @override */ 85 /** @override */
88 getCapabilityNotAvailableValueInternal: function() { 86 getCapabilityNotAvailableValueInternal: function() {
89 return false; 87 return false;
90 }, 88 },
91 89
92 /** 90 /**
93 * Adds CHANGE listeners to dependent ticket items. 91 * Adds CHANGE listeners to dependent ticket items.
94 * @private 92 * @private
95 */ 93 */
96 addEventListeners_: function() { 94 addEventListeners_: function() {
97 this.getTrackerInternal().add( 95 this.getTrackerInternal().add(
98 this.marginsType_, 96 this.marginsType_,
99 print_preview.ticket_items.TicketItem.EventType.CHANGE, 97 print_preview.ticket_items.TicketItem.EventType.CHANGE,
100 this.dispatchChangeEventInternal.bind(this)); 98 this.dispatchChangeEventInternal.bind(this));
101 this.getTrackerInternal().add( 99 this.getTrackerInternal().add(
102 this.customMargins_, 100 this.customMargins_,
103 print_preview.ticket_items.TicketItem.EventType.CHANGE, 101 print_preview.ticket_items.TicketItem.EventType.CHANGE,
104 this.dispatchChangeEventInternal.bind(this)); 102 this.dispatchChangeEventInternal.bind(this));
105 } 103 }
106 }; 104 };
107 105
108 // Export 106 // Export
109 return { 107 return {HeaderFooter: HeaderFooter};
110 HeaderFooter: HeaderFooter
111 };
112 }); 108 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698