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

Side by Side Diff: chrome/browser/resources/print_preview/settings/other_options_settings.js

Issue 11818062: Adds option to enable CSS backgrounds for printing. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Merge with trunk. Created 7 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', function() { 5 cr.define('print_preview', function() {
6 'use strict'; 6 'use strict';
7 7
8 /** 8 /**
9 * UI component that renders checkboxes for various print options. 9 * UI component that renders checkboxes for various print options.
10 * @param {!print_preview.PrintTicketStore} printTicketStore Used to monitor 10 * @param {!print_preview.PrintTicketStore} printTicketStore Used to monitor
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 * @private 56 * @private
57 */ 57 */
58 this.duplexContainer_ = null; 58 this.duplexContainer_ = null;
59 59
60 /** 60 /**
61 * Duplex checkbox. 61 * Duplex checkbox.
62 * @type {HTMLInputElement} 62 * @type {HTMLInputElement}
63 * @private 63 * @private
64 */ 64 */
65 this.duplexCheckbox_ = null; 65 this.duplexCheckbox_ = null;
66
67 /**
68 * Print CSS backgrounds container element.
69 * @type {HTMLElement}
70 * @private
71 */
72 this.cssBackgroundContainer_ = null;
73
74 /**
75 * Print CSS backgrounds checkbox.
76 * @type {HTMLInputElement}
77 * @private
78 */
79 this.cssBackgroundCheckbox_ = null;
66 }; 80 };
67 81
68 OtherOptionsSettings.prototype = { 82 OtherOptionsSettings.prototype = {
69 __proto__: print_preview.Component.prototype, 83 __proto__: print_preview.Component.prototype,
70 84
71 /** @param {boolean} isEnabled Whether the settings is enabled. */ 85 /** @param {boolean} isEnabled Whether the settings is enabled. */
72 set isEnabled(isEnabled) { 86 set isEnabled(isEnabled) {
73 this.headerFooterCheckbox_.disabled = !isEnabled; 87 this.headerFooterCheckbox_.disabled = !isEnabled;
74 this.fitToPageCheckbox_.disabled = !isEnabled; 88 this.fitToPageCheckbox_.disabled = !isEnabled;
75 this.duplexCheckbox_.disabled = !isEnabled; 89 this.duplexCheckbox_.disabled = !isEnabled;
90 this.cssBackgroundCheckbox_.disabled = !isEnabled;
76 }, 91 },
77 92
78 /** @override */ 93 /** @override */
79 enterDocument: function() { 94 enterDocument: function() {
80 print_preview.Component.prototype.enterDocument.call(this); 95 print_preview.Component.prototype.enterDocument.call(this);
81 this.tracker.add( 96 this.tracker.add(
82 this.headerFooterCheckbox_, 97 this.headerFooterCheckbox_,
83 'click', 98 'click',
84 this.onHeaderFooterCheckboxClick_.bind(this)); 99 this.onHeaderFooterCheckboxClick_.bind(this));
85 this.tracker.add( 100 this.tracker.add(
86 this.fitToPageCheckbox_, 101 this.fitToPageCheckbox_,
87 'click', 102 'click',
88 this.onFitToPageCheckboxClick_.bind(this)); 103 this.onFitToPageCheckboxClick_.bind(this));
89 this.tracker.add( 104 this.tracker.add(
90 this.duplexCheckbox_, 105 this.duplexCheckbox_,
91 'click', 106 'click',
92 this.onDuplexCheckboxClick_.bind(this)); 107 this.onDuplexCheckboxClick_.bind(this));
93 this.tracker.add( 108 this.tracker.add(
109 this.cssBackgroundCheckbox_,
110 'click',
111 this.onCssBackgroundCheckboxClick_.bind(this));
112 this.tracker.add(
94 this.printTicketStore_, 113 this.printTicketStore_,
95 print_preview.PrintTicketStore.EventType.INITIALIZE, 114 print_preview.PrintTicketStore.EventType.INITIALIZE,
96 this.onPrintTicketStoreChange_.bind(this)); 115 this.onPrintTicketStoreChange_.bind(this));
97 this.tracker.add( 116 this.tracker.add(
98 this.printTicketStore_, 117 this.printTicketStore_,
99 print_preview.PrintTicketStore.EventType.DOCUMENT_CHANGE, 118 print_preview.PrintTicketStore.EventType.DOCUMENT_CHANGE,
100 this.onPrintTicketStoreChange_.bind(this)); 119 this.onPrintTicketStoreChange_.bind(this));
101 this.tracker.add( 120 this.tracker.add(
102 this.printTicketStore_, 121 this.printTicketStore_,
103 print_preview.PrintTicketStore.EventType.CAPABILITIES_CHANGE, 122 print_preview.PrintTicketStore.EventType.CAPABILITIES_CHANGE,
104 this.onPrintTicketStoreChange_.bind(this)); 123 this.onPrintTicketStoreChange_.bind(this));
105 this.tracker.add( 124 this.tracker.add(
106 this.printTicketStore_, 125 this.printTicketStore_,
107 print_preview.PrintTicketStore.EventType.TICKET_CHANGE, 126 print_preview.PrintTicketStore.EventType.TICKET_CHANGE,
108 this.onPrintTicketStoreChange_.bind(this)); 127 this.onPrintTicketStoreChange_.bind(this));
109 }, 128 },
110 129
111 /** @override */ 130 /** @override */
112 exitDocument: function() { 131 exitDocument: function() {
113 print_preview.Component.prototype.exitDocument.call(this); 132 print_preview.Component.prototype.exitDocument.call(this);
114 this.headerFooterContainer_ = null; 133 this.headerFooterContainer_ = null;
115 this.headerFooterCheckbox_ = null; 134 this.headerFooterCheckbox_ = null;
116 this.fitToPageContainer_ = null; 135 this.fitToPageContainer_ = null;
117 this.fitToPageCheckbox_ = null; 136 this.fitToPageCheckbox_ = null;
118 this.duplexContainer_ = null; 137 this.duplexContainer_ = null;
119 this.duplexCheckbox_ = null; 138 this.duplexCheckbox_ = null;
139 this.cssBackgroundContainer_ = null;
140 this.cssBackgroundCheckbox_ = null;
120 }, 141 },
121 142
122 /** @override */ 143 /** @override */
123 decorateInternal: function() { 144 decorateInternal: function() {
124 this.headerFooterContainer_ = this.getElement().querySelector( 145 this.headerFooterContainer_ = this.getElement().querySelector(
125 '.header-footer-container'); 146 '.header-footer-container');
126 this.headerFooterCheckbox_ = this.headerFooterContainer_.querySelector( 147 this.headerFooterCheckbox_ = this.headerFooterContainer_.querySelector(
127 '.header-footer-checkbox'); 148 '.header-footer-checkbox');
128 this.fitToPageContainer_ = this.getElement().querySelector( 149 this.fitToPageContainer_ = this.getElement().querySelector(
129 '.fit-to-page-container'); 150 '.fit-to-page-container');
130 this.fitToPageCheckbox_ = this.fitToPageContainer_.querySelector( 151 this.fitToPageCheckbox_ = this.fitToPageContainer_.querySelector(
131 '.fit-to-page-checkbox'); 152 '.fit-to-page-checkbox');
132 this.duplexContainer_ = this.getElement().querySelector( 153 this.duplexContainer_ = this.getElement().querySelector(
133 '.duplex-container'); 154 '.duplex-container');
134 this.duplexCheckbox_ = this.duplexContainer_.querySelector( 155 this.duplexCheckbox_ = this.duplexContainer_.querySelector(
135 '.duplex-checkbox'); 156 '.duplex-checkbox');
157 this.cssBackgroundContainer_ = this.getElement().querySelector(
158 '.css-background-container');
159 this.cssBackgroundCheckbox_ = this.cssBackgroundContainer_.querySelector(
160 '.css-background-checkbox');
136 }, 161 },
137 162
138 /** 163 /**
139 * Called when the header-footer checkbox is clicked. Updates the print 164 * Called when the header-footer checkbox is clicked. Updates the print
140 * ticket. 165 * ticket.
141 * @private 166 * @private
142 */ 167 */
143 onHeaderFooterCheckboxClick_: function() { 168 onHeaderFooterCheckboxClick_: function() {
144 this.printTicketStore_.updateHeaderFooter( 169 this.printTicketStore_.updateHeaderFooter(
145 this.headerFooterCheckbox_.checked); 170 this.headerFooterCheckbox_.checked);
(...skipping 10 matching lines...) Expand all
156 181
157 /** 182 /**
158 * Called when the duplex checkbox is clicked. Updates the print ticket. 183 * Called when the duplex checkbox is clicked. Updates the print ticket.
159 * @private 184 * @private
160 */ 185 */
161 onDuplexCheckboxClick_: function() { 186 onDuplexCheckboxClick_: function() {
162 this.printTicketStore_.updateDuplex(this.duplexCheckbox_.checked); 187 this.printTicketStore_.updateDuplex(this.duplexCheckbox_.checked);
163 }, 188 },
164 189
165 /** 190 /**
191 * Called when the print CSS backgrounds checkbox is clicked. Updates the
192 * print ticket store.
193 * @private
194 */
195 onCssBackgroundCheckboxClick_: function() {
196 this.printTicketStore_.updateCssBackground(
197 this.cssBackgroundCheckbox_.checked);
198 },
199
200 /**
166 * Called when the print ticket store has changed. Hides or shows the 201 * Called when the print ticket store has changed. Hides or shows the
167 * setting. 202 * settings.
168 * @private 203 * @private
169 */ 204 */
170 onPrintTicketStoreChange_: function() { 205 onPrintTicketStoreChange_: function() {
171 setIsVisible(this.headerFooterContainer_, 206 setIsVisible(this.headerFooterContainer_,
172 this.printTicketStore_.hasHeaderFooterCapability()); 207 this.printTicketStore_.hasHeaderFooterCapability());
173 this.headerFooterCheckbox_.checked = 208 this.headerFooterCheckbox_.checked =
174 this.printTicketStore_.isHeaderFooterEnabled(); 209 this.printTicketStore_.isHeaderFooterEnabled();
175 210
176 setIsVisible(this.fitToPageContainer_, 211 setIsVisible(this.fitToPageContainer_,
177 this.printTicketStore_.hasFitToPageCapability()); 212 this.printTicketStore_.hasFitToPageCapability());
178 this.fitToPageCheckbox_.checked = 213 this.fitToPageCheckbox_.checked =
179 this.printTicketStore_.isFitToPageEnabled(); 214 this.printTicketStore_.isFitToPageEnabled();
180 215
181 setIsVisible(this.duplexContainer_, 216 setIsVisible(this.duplexContainer_,
182 this.printTicketStore_.hasDuplexCapability()); 217 this.printTicketStore_.hasDuplexCapability());
183 this.duplexCheckbox_.checked = this.printTicketStore_.isDuplexEnabled(); 218 this.duplexCheckbox_.checked = this.printTicketStore_.isDuplexEnabled();
184 219
220 setIsVisible(this.cssBackgroundContainer_,
221 this.printTicketStore_.hasCssBackgroundCapability());
222 this.cssBackgroundCheckbox_.checked =
223 this.printTicketStore_.isCssBackgroundEnabled();
224
185 if (this.printTicketStore_.hasHeaderFooterCapability() || 225 if (this.printTicketStore_.hasHeaderFooterCapability() ||
186 this.printTicketStore_.hasFitToPageCapability() || 226 this.printTicketStore_.hasFitToPageCapability() ||
187 this.printTicketStore_.hasDuplexCapability()) { 227 this.printTicketStore_.hasDuplexCapability() ||
228 this.printTicketStore_.hasCssBackgroundCapability()) {
188 fadeInOption(this.getElement()); 229 fadeInOption(this.getElement());
189 } else { 230 } else {
190 fadeOutOption(this.getElement()); 231 fadeOutOption(this.getElement());
191 } 232 }
192 } 233 }
193 }; 234 };
194 235
195 // Export 236 // Export
196 return { 237 return {
197 OtherOptionsSettings: OtherOptionsSettings 238 OtherOptionsSettings: OtherOptionsSettings
198 }; 239 };
199 }); 240 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698