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

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

Issue 1125343004: Add a "Simplify Page" option to the print preview dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More refactors and remove tab_helpers dependency Created 5 years, 5 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.ticket_items.Duplex} duplex Duplex ticket item. 10 * @param {!print_preview.ticket_items.Duplex} duplex Duplex ticket item.
11 * @param {!print_preview.ticket_items.FitToPage} fitToPage Fit-to-page ticket 11 * @param {!print_preview.ticket_items.FitToPage} fitToPage Fit-to-page ticket
12 * item. 12 * item.
13 * @param {!print_preview.ticket_items.CssBackground} cssBackground CSS 13 * @param {!print_preview.ticket_items.CssBackground} cssBackground CSS
14 * background ticket item. 14 * background ticket item.
15 * @param {!print_preview.ticket_items.SelectionOnly} selectionOnly Selection 15 * @param {!print_preview.ticket_items.SelectionOnly} selectionOnly Selection
16 * only ticket item. 16 * only ticket item.
17 * @param {!print_preview.ticket_items.HeaderFooter} headerFooter Header 17 * @param {!print_preview.ticket_items.HeaderFooter} headerFooter Header
18 * footer ticket item. 18 * footer ticket item.
19 * @param {!print_preview.ticket_items.DistillPage} distillPage Print
20 * distill page ticket item.
19 * @constructor 21 * @constructor
20 * @extends {print_preview.SettingsSection} 22 * @extends {print_preview.SettingsSection}
21 */ 23 */
22 function OtherOptionsSettings( 24 function OtherOptionsSettings(
23 duplex, fitToPage, cssBackground, selectionOnly, headerFooter) { 25 duplex, fitToPage, cssBackground, selectionOnly,
26 headerFooter, distillPage) {
24 print_preview.SettingsSection.call(this); 27 print_preview.SettingsSection.call(this);
25 28
26 /** 29 /**
27 * Duplex ticket item, used to read/write the duplex selection. 30 * Duplex ticket item, used to read/write the duplex selection.
28 * @type {!print_preview.ticket_items.Duplex} 31 * @type {!print_preview.ticket_items.Duplex}
29 * @private 32 * @private
30 */ 33 */
31 this.duplexTicketItem_ = duplex; 34 this.duplexTicketItem_ = duplex;
32 35
33 /** 36 /**
(...skipping 18 matching lines...) Expand all
52 this.selectionOnlyTicketItem_ = selectionOnly; 55 this.selectionOnlyTicketItem_ = selectionOnly;
53 56
54 /** 57 /**
55 * Header-footer ticket item, used to read/write. 58 * Header-footer ticket item, used to read/write.
56 * @type {!print_preview.ticket_items.HeaderFooter} 59 * @type {!print_preview.ticket_items.HeaderFooter}
57 * @private 60 * @private
58 */ 61 */
59 this.headerFooterTicketItem_ = headerFooter; 62 this.headerFooterTicketItem_ = headerFooter;
60 63
61 /** 64 /**
65 * Distill page ticket item, used to read/write.
66 * @type {!print_preview.ticket_items.DistillPage}
67 * @private
68 */
69 this.distillPageTicketItem_ = distillPage;
70
71 /**
72 * Distill page container element.
73 * @type {HTMLElement}
74 * @private
75 */
76 this.distillPageContainer_ = null;
77
78 /**
79 * Distill page checkbox.
80 * @type {HTMLInputElement}
81 * @private
82 */
83 this.distillPageCheckbox_ = null;
84
85 /**
62 * Header footer container element. 86 * Header footer container element.
63 * @type {HTMLElement} 87 * @type {HTMLElement}
64 * @private 88 * @private
65 */ 89 */
66 this.headerFooterContainer_ = null; 90 this.headerFooterContainer_ = null;
67 91
68 /** 92 /**
69 * Header footer checkbox. 93 * Header footer checkbox.
70 * @type {HTMLInputElement} 94 * @type {HTMLInputElement}
71 * @private 95 * @private
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 * @private 151 * @private
128 */ 152 */
129 this.selectionOnlyCheckbox_ = null; 153 this.selectionOnlyCheckbox_ = null;
130 }; 154 };
131 155
132 OtherOptionsSettings.prototype = { 156 OtherOptionsSettings.prototype = {
133 __proto__: print_preview.SettingsSection.prototype, 157 __proto__: print_preview.SettingsSection.prototype,
134 158
135 /** @override */ 159 /** @override */
136 isAvailable: function() { 160 isAvailable: function() {
137 return this.headerFooterTicketItem_.isCapabilityAvailable() || 161 return this.distillPageTicketItem_.isCapabilityAvailable() ||
162 this.headerFooterTicketItem_.isCapabilityAvailable() ||
138 this.fitToPageTicketItem_.isCapabilityAvailable() || 163 this.fitToPageTicketItem_.isCapabilityAvailable() ||
139 this.duplexTicketItem_.isCapabilityAvailable() || 164 this.duplexTicketItem_.isCapabilityAvailable() ||
140 this.cssBackgroundTicketItem_.isCapabilityAvailable() || 165 this.cssBackgroundTicketItem_.isCapabilityAvailable() ||
141 this.selectionOnlyTicketItem_.isCapabilityAvailable(); 166 this.selectionOnlyTicketItem_.isCapabilityAvailable();
142 }, 167 },
143 168
144 /** @override */ 169 /** @override */
145 hasCollapsibleContent: function() { 170 hasCollapsibleContent: function() {
146 return this.headerFooterTicketItem_.isCapabilityAvailable() || 171 return this.headerFooterTicketItem_.isCapabilityAvailable() ||
147 this.fitToPageTicketItem_.isCapabilityAvailable() || 172 this.fitToPageTicketItem_.isCapabilityAvailable() ||
148 this.cssBackgroundTicketItem_.isCapabilityAvailable() || 173 this.cssBackgroundTicketItem_.isCapabilityAvailable() ||
149 this.selectionOnlyTicketItem_.isCapabilityAvailable(); 174 this.selectionOnlyTicketItem_.isCapabilityAvailable();
150 }, 175 },
151 176
152 /** @override */ 177 /** @override */
153 set isEnabled(isEnabled) { 178 set isEnabled(isEnabled) {
154 this.headerFooterCheckbox_.disabled = !isEnabled; 179 this.headerFooterCheckbox_.disabled = !isEnabled;
155 this.fitToPageCheckbox_.disabled = !isEnabled; 180 this.fitToPageCheckbox_.disabled = !isEnabled;
156 this.duplexCheckbox_.disabled = !isEnabled; 181 this.duplexCheckbox_.disabled = !isEnabled;
182 this.distillPageCheckbox_.disabled = !isEnabled;
157 this.cssBackgroundCheckbox_.disabled = !isEnabled; 183 this.cssBackgroundCheckbox_.disabled = !isEnabled;
158 }, 184 },
159 185
160 /** @override */ 186 /** @override */
161 enterDocument: function() { 187 enterDocument: function() {
162 print_preview.SettingsSection.prototype.enterDocument.call(this); 188 print_preview.SettingsSection.prototype.enterDocument.call(this);
163 this.tracker.add( 189 this.tracker.add(
190 this.distillPageCheckbox_,
191 'click',
192 this.onDistillPageCheckboxClick_.bind(this));
193 this.tracker.add(
164 this.headerFooterCheckbox_, 194 this.headerFooterCheckbox_,
165 'click', 195 'click',
166 this.onHeaderFooterCheckboxClick_.bind(this)); 196 this.onHeaderFooterCheckboxClick_.bind(this));
167 this.tracker.add( 197 this.tracker.add(
168 this.fitToPageCheckbox_, 198 this.fitToPageCheckbox_,
169 'click', 199 'click',
170 this.onFitToPageCheckboxClick_.bind(this)); 200 this.onFitToPageCheckboxClick_.bind(this));
171 this.tracker.add( 201 this.tracker.add(
172 this.duplexCheckbox_, 202 this.duplexCheckbox_,
173 'click', 203 'click',
(...skipping 19 matching lines...) Expand all
193 print_preview.ticket_items.TicketItem.EventType.CHANGE, 223 print_preview.ticket_items.TicketItem.EventType.CHANGE,
194 this.onCssBackgroundChange_.bind(this)); 224 this.onCssBackgroundChange_.bind(this));
195 this.tracker.add( 225 this.tracker.add(
196 this.selectionOnlyTicketItem_, 226 this.selectionOnlyTicketItem_,
197 print_preview.ticket_items.TicketItem.EventType.CHANGE, 227 print_preview.ticket_items.TicketItem.EventType.CHANGE,
198 this.onSelectionOnlyChange_.bind(this)); 228 this.onSelectionOnlyChange_.bind(this));
199 this.tracker.add( 229 this.tracker.add(
200 this.headerFooterTicketItem_, 230 this.headerFooterTicketItem_,
201 print_preview.ticket_items.TicketItem.EventType.CHANGE, 231 print_preview.ticket_items.TicketItem.EventType.CHANGE,
202 this.onHeaderFooterChange_.bind(this)); 232 this.onHeaderFooterChange_.bind(this));
233 this.tracker.add(
234 this.distillPageTicketItem_,
235 print_preview.ticket_items.TicketItem.EventType.CHANGE,
236 this.onDistillPageChange_.bind(this));
203 }, 237 },
204 238
205 /** @override */ 239 /** @override */
206 exitDocument: function() { 240 exitDocument: function() {
207 print_preview.SettingsSection.prototype.exitDocument.call(this); 241 print_preview.SettingsSection.prototype.exitDocument.call(this);
242 this.distillPageContainer_ = null;
243 this.distillPageCheckbox_ = null;
208 this.headerFooterContainer_ = null; 244 this.headerFooterContainer_ = null;
209 this.headerFooterCheckbox_ = null; 245 this.headerFooterCheckbox_ = null;
210 this.fitToPageContainer_ = null; 246 this.fitToPageContainer_ = null;
211 this.fitToPageCheckbox_ = null; 247 this.fitToPageCheckbox_ = null;
212 this.duplexContainer_ = null; 248 this.duplexContainer_ = null;
213 this.duplexCheckbox_ = null; 249 this.duplexCheckbox_ = null;
214 this.cssBackgroundContainer_ = null; 250 this.cssBackgroundContainer_ = null;
215 this.cssBackgroundCheckbox_ = null; 251 this.cssBackgroundCheckbox_ = null;
216 this.selectionOnlyContainer_ = null; 252 this.selectionOnlyContainer_ = null;
217 this.selectionOnlyCheckbox_ = null; 253 this.selectionOnlyCheckbox_ = null;
218 }, 254 },
219 255
220 /** @override */ 256 /** @override */
221 decorateInternal: function() { 257 decorateInternal: function() {
258 this.distillPageContainer_ = this.getElement().querySelector(
259 '.distill-page-container');
260 this.distillPageCheckbox_ = this.distillPageContainer_.querySelector(
261 '.distill-page-checkbox');
222 this.headerFooterContainer_ = this.getElement().querySelector( 262 this.headerFooterContainer_ = this.getElement().querySelector(
223 '.header-footer-container'); 263 '.header-footer-container');
224 this.headerFooterCheckbox_ = this.headerFooterContainer_.querySelector( 264 this.headerFooterCheckbox_ = this.headerFooterContainer_.querySelector(
225 '.header-footer-checkbox'); 265 '.header-footer-checkbox');
226 this.fitToPageContainer_ = this.getElement().querySelector( 266 this.fitToPageContainer_ = this.getElement().querySelector(
227 '.fit-to-page-container'); 267 '.fit-to-page-container');
228 this.fitToPageCheckbox_ = this.fitToPageContainer_.querySelector( 268 this.fitToPageCheckbox_ = this.fitToPageContainer_.querySelector(
229 '.fit-to-page-checkbox'); 269 '.fit-to-page-checkbox');
230 this.duplexContainer_ = this.getElement().querySelector( 270 this.duplexContainer_ = this.getElement().querySelector(
231 '.duplex-container'); 271 '.duplex-container');
232 this.duplexCheckbox_ = this.duplexContainer_.querySelector( 272 this.duplexCheckbox_ = this.duplexContainer_.querySelector(
233 '.duplex-checkbox'); 273 '.duplex-checkbox');
234 this.cssBackgroundContainer_ = this.getElement().querySelector( 274 this.cssBackgroundContainer_ = this.getElement().querySelector(
235 '.css-background-container'); 275 '.css-background-container');
236 this.cssBackgroundCheckbox_ = this.cssBackgroundContainer_.querySelector( 276 this.cssBackgroundCheckbox_ = this.cssBackgroundContainer_.querySelector(
237 '.css-background-checkbox'); 277 '.css-background-checkbox');
238 this.selectionOnlyContainer_ = this.getElement().querySelector( 278 this.selectionOnlyContainer_ = this.getElement().querySelector(
239 '.selection-only-container'); 279 '.selection-only-container');
240 this.selectionOnlyCheckbox_ = this.selectionOnlyContainer_.querySelector( 280 this.selectionOnlyCheckbox_ = this.selectionOnlyContainer_.querySelector(
241 '.selection-only-checkbox'); 281 '.selection-only-checkbox');
242 }, 282 },
243 283
244 /** @override */ 284 /** @override */
245 updateUiStateInternal: function() { 285 updateUiStateInternal: function() {
246 if (this.isAvailable()) { 286 if (this.isAvailable()) {
287 setIsVisible(this.distillPageContainer_,
288 this.distillPageTicketItem_.isCapabilityAvailable());
247 setIsVisible(this.headerFooterContainer_, 289 setIsVisible(this.headerFooterContainer_,
248 this.headerFooterTicketItem_.isCapabilityAvailable() && 290 this.headerFooterTicketItem_.isCapabilityAvailable() &&
249 !this.collapseContent); 291 !this.collapseContent);
250 setIsVisible(this.fitToPageContainer_, 292 setIsVisible(this.fitToPageContainer_,
251 this.fitToPageTicketItem_.isCapabilityAvailable() && 293 this.fitToPageTicketItem_.isCapabilityAvailable() &&
252 !this.collapseContent); 294 !this.collapseContent);
253 setIsVisible(this.duplexContainer_, 295 setIsVisible(this.duplexContainer_,
254 this.duplexTicketItem_.isCapabilityAvailable()); 296 this.duplexTicketItem_.isCapabilityAvailable());
255 setIsVisible(this.cssBackgroundContainer_, 297 setIsVisible(this.cssBackgroundContainer_,
256 this.cssBackgroundTicketItem_.isCapabilityAvailable() && 298 this.cssBackgroundTicketItem_.isCapabilityAvailable() &&
257 !this.collapseContent); 299 !this.collapseContent);
258 setIsVisible(this.selectionOnlyContainer_, 300 setIsVisible(this.selectionOnlyContainer_,
259 this.selectionOnlyTicketItem_.isCapabilityAvailable() && 301 this.selectionOnlyTicketItem_.isCapabilityAvailable() &&
260 !this.collapseContent); 302 !this.collapseContent);
261 } 303 }
262 print_preview.SettingsSection.prototype.updateUiStateInternal.call(this); 304 print_preview.SettingsSection.prototype.updateUiStateInternal.call(this);
263 }, 305 },
264 306
265 /** @override */ 307 /** @override */
266 isSectionVisibleInternal: function() { 308 isSectionVisibleInternal: function() {
267 return this.collapseContent ? 309 if (this.collapseContent) {
268 this.duplexTicketItem_.isCapabilityAvailable() : this.isAvailable(); 310 return this.distillPageTicketItem_.isCapabilityAvailable() ||
311 this.duplexTicketItem_.isCapabilityAvailable();
312 }
313
314 return this.isAvailable();
269 }, 315 },
270 316
271 /** 317 /**
318 * Called when the distill-page checkbox is clicked. Updates the print
319 * ticket.
320 * @private
321 */
322 onDistillPageCheckboxClick_: function() {
323 this.distillPageTicketItem_.updateValue(
324 this.distillPageCheckbox_.checked);
325 },
326
327 /**
272 * Called when the header-footer checkbox is clicked. Updates the print 328 * Called when the header-footer checkbox is clicked. Updates the print
273 * ticket. 329 * ticket.
274 * @private 330 * @private
275 */ 331 */
276 onHeaderFooterCheckboxClick_: function() { 332 onHeaderFooterCheckboxClick_: function() {
277 this.headerFooterTicketItem_.updateValue( 333 this.headerFooterTicketItem_.updateValue(
278 this.headerFooterCheckbox_.checked); 334 this.headerFooterCheckbox_.checked);
279 }, 335 },
280 336
281 /** 337 /**
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 415
360 /** 416 /**
361 * Called when the header-footer ticket item has changed. Updates the 417 * Called when the header-footer ticket item has changed. Updates the
362 * header-footer checkbox. 418 * header-footer checkbox.
363 * @private 419 * @private
364 */ 420 */
365 onHeaderFooterChange_: function() { 421 onHeaderFooterChange_: function() {
366 this.headerFooterCheckbox_.checked = 422 this.headerFooterCheckbox_.checked =
367 this.headerFooterTicketItem_.getValue(); 423 this.headerFooterTicketItem_.getValue();
368 this.updateUiStateInternal(); 424 this.updateUiStateInternal();
425 },
426
427 /**
428 * Called when the distill-page ticket item has changed. Updates the
429 * distill-page checkbox.
430 * @private
431 */
432 onDistillPageChange_: function() {
433 this.distillPageCheckbox_.checked =
434 this.distillPageTicketItem_.getValue();
435 this.updateUiStateInternal();
369 } 436 }
370 }; 437 };
371 438
372 // Export 439 // Export
373 return { 440 return {
374 OtherOptionsSettings: OtherOptionsSettings 441 OtherOptionsSettings: OtherOptionsSettings
375 }; 442 };
376 }); 443 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698