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

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

Issue 477133004: Printe Preview: add 'More/less options' button and make non-essential sections collapsible (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Print Preview UI tests adjusted. Created 6 years, 4 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
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 * @constructor 19 * @constructor
20 * @extends {print_preview.Component} 20 * @extends {print_preview.SettingsSection}
21 */ 21 */
22 function OtherOptionsSettings( 22 function OtherOptionsSettings(
23 duplex, fitToPage, cssBackground, selectionOnly, headerFooter) { 23 duplex, fitToPage, cssBackground, selectionOnly, headerFooter) {
24 print_preview.Component.call(this); 24 print_preview.SettingsSection.call(this);
25 25
26 /** 26 /**
27 * Duplex ticket item, used to read/write the duplex selection. 27 * Duplex ticket item, used to read/write the duplex selection.
28 * @type {!print_preview.ticket_items.Duplex} 28 * @type {!print_preview.ticket_items.Duplex}
29 * @private 29 * @private
30 */ 30 */
31 this.duplexTicketItem_ = duplex; 31 this.duplexTicketItem_ = duplex;
32 32
33 /** 33 /**
34 * Fit-to-page ticket item, used to read/write the fit-to-page selection. 34 * Fit-to-page ticket item, used to read/write the fit-to-page selection.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 123
124 /** 124 /**
125 * Print selection only checkbox. 125 * Print selection only checkbox.
126 * @type {HTMLInputElement} 126 * @type {HTMLInputElement}
127 * @private 127 * @private
128 */ 128 */
129 this.selectionOnlyCheckbox_ = null; 129 this.selectionOnlyCheckbox_ = null;
130 }; 130 };
131 131
132 OtherOptionsSettings.prototype = { 132 OtherOptionsSettings.prototype = {
133 __proto__: print_preview.Component.prototype, 133 __proto__: print_preview.SettingsSection.prototype,
134 134
135 /** @param {boolean} isEnabled Whether the settings is enabled. */ 135 /** @override */
136 isAvailable: function() {
137 return this.headerFooterTicketItem_.isCapabilityAvailable() ||
138 this.fitToPageTicketItem_.isCapabilityAvailable() ||
139 this.duplexTicketItem_.isCapabilityAvailable() ||
140 this.cssBackgroundTicketItem_.isCapabilityAvailable() ||
141 this.selectionOnlyTicketItem_.isCapabilityAvailable();
142 },
143
144 /** @override */
145 hasCollapsibleContent: function() {
146 return this.headerFooterTicketItem_.isCapabilityAvailable() ||
147 this.fitToPageTicketItem_.isCapabilityAvailable() ||
148 this.cssBackgroundTicketItem_.isCapabilityAvailable() ||
149 this.selectionOnlyTicketItem_.isCapabilityAvailable();
150 },
151
152 /** @override */
136 set isEnabled(isEnabled) { 153 set isEnabled(isEnabled) {
137 this.headerFooterCheckbox_.disabled = !isEnabled; 154 this.headerFooterCheckbox_.disabled = !isEnabled;
138 this.fitToPageCheckbox_.disabled = !isEnabled; 155 this.fitToPageCheckbox_.disabled = !isEnabled;
139 this.duplexCheckbox_.disabled = !isEnabled; 156 this.duplexCheckbox_.disabled = !isEnabled;
140 this.cssBackgroundCheckbox_.disabled = !isEnabled; 157 this.cssBackgroundCheckbox_.disabled = !isEnabled;
141 }, 158 },
142 159
143 /** @override */ 160 /** @override */
144 enterDocument: function() { 161 enterDocument: function() {
145 print_preview.Component.prototype.enterDocument.call(this); 162 print_preview.SettingsSection.prototype.enterDocument.call(this);
146 fadeOutOption(this.getElement(), true);
147 this.tracker.add( 163 this.tracker.add(
148 this.headerFooterCheckbox_, 164 this.headerFooterCheckbox_,
149 'click', 165 'click',
150 this.onHeaderFooterCheckboxClick_.bind(this)); 166 this.onHeaderFooterCheckboxClick_.bind(this));
151 this.tracker.add( 167 this.tracker.add(
152 this.fitToPageCheckbox_, 168 this.fitToPageCheckbox_,
153 'click', 169 'click',
154 this.onFitToPageCheckboxClick_.bind(this)); 170 this.onFitToPageCheckboxClick_.bind(this));
155 this.tracker.add( 171 this.tracker.add(
156 this.duplexCheckbox_, 172 this.duplexCheckbox_,
(...skipping 24 matching lines...) Expand all
181 print_preview.ticket_items.TicketItem.EventType.CHANGE, 197 print_preview.ticket_items.TicketItem.EventType.CHANGE,
182 this.onSelectionOnlyChange_.bind(this)); 198 this.onSelectionOnlyChange_.bind(this));
183 this.tracker.add( 199 this.tracker.add(
184 this.headerFooterTicketItem_, 200 this.headerFooterTicketItem_,
185 print_preview.ticket_items.TicketItem.EventType.CHANGE, 201 print_preview.ticket_items.TicketItem.EventType.CHANGE,
186 this.onHeaderFooterChange_.bind(this)); 202 this.onHeaderFooterChange_.bind(this));
187 }, 203 },
188 204
189 /** @override */ 205 /** @override */
190 exitDocument: function() { 206 exitDocument: function() {
191 print_preview.Component.prototype.exitDocument.call(this); 207 print_preview.SettingsSection.prototype.exitDocument.call(this);
192 this.headerFooterContainer_ = null; 208 this.headerFooterContainer_ = null;
193 this.headerFooterCheckbox_ = null; 209 this.headerFooterCheckbox_ = null;
194 this.fitToPageContainer_ = null; 210 this.fitToPageContainer_ = null;
195 this.fitToPageCheckbox_ = null; 211 this.fitToPageCheckbox_ = null;
196 this.duplexContainer_ = null; 212 this.duplexContainer_ = null;
197 this.duplexCheckbox_ = null; 213 this.duplexCheckbox_ = null;
198 this.cssBackgroundContainer_ = null; 214 this.cssBackgroundContainer_ = null;
199 this.cssBackgroundCheckbox_ = null; 215 this.cssBackgroundCheckbox_ = null;
200 this.selectionOnlyContainer_ = null; 216 this.selectionOnlyContainer_ = null;
201 this.selectionOnlyCheckbox_ = null; 217 this.selectionOnlyCheckbox_ = null;
(...skipping 16 matching lines...) Expand all
218 this.cssBackgroundContainer_ = this.getElement().querySelector( 234 this.cssBackgroundContainer_ = this.getElement().querySelector(
219 '.css-background-container'); 235 '.css-background-container');
220 this.cssBackgroundCheckbox_ = this.cssBackgroundContainer_.querySelector( 236 this.cssBackgroundCheckbox_ = this.cssBackgroundContainer_.querySelector(
221 '.css-background-checkbox'); 237 '.css-background-checkbox');
222 this.selectionOnlyContainer_ = this.getElement().querySelector( 238 this.selectionOnlyContainer_ = this.getElement().querySelector(
223 '.selection-only-container'); 239 '.selection-only-container');
224 this.selectionOnlyCheckbox_ = this.selectionOnlyContainer_.querySelector( 240 this.selectionOnlyCheckbox_ = this.selectionOnlyContainer_.querySelector(
225 '.selection-only-checkbox'); 241 '.selection-only-checkbox');
226 }, 242 },
227 243
228 /** 244 /** @override */
229 * Updates the state of the entire other options settings area. 245 updateUiStateInternal: function() {
230 * @private 246 if (this.isAvailable()) {
231 */
232 updateContainerState_: function() {
233 if (this.headerFooterTicketItem_.isCapabilityAvailable() ||
234 this.fitToPageTicketItem_.isCapabilityAvailable() ||
235 this.duplexTicketItem_.isCapabilityAvailable() ||
236 this.cssBackgroundTicketItem_.isCapabilityAvailable() ||
237 this.selectionOnlyTicketItem_.isCapabilityAvailable()) {
238 setIsVisible(this.headerFooterContainer_, 247 setIsVisible(this.headerFooterContainer_,
239 this.headerFooterTicketItem_.isCapabilityAvailable()); 248 this.headerFooterTicketItem_.isCapabilityAvailable() &&
249 !this.collapseContent);
240 setIsVisible(this.fitToPageContainer_, 250 setIsVisible(this.fitToPageContainer_,
241 this.fitToPageTicketItem_.isCapabilityAvailable()); 251 this.fitToPageTicketItem_.isCapabilityAvailable() &&
252 !this.collapseContent);
242 setIsVisible(this.duplexContainer_, 253 setIsVisible(this.duplexContainer_,
243 this.duplexTicketItem_.isCapabilityAvailable()); 254 this.duplexTicketItem_.isCapabilityAvailable());
244 setIsVisible(this.cssBackgroundContainer_, 255 setIsVisible(this.cssBackgroundContainer_,
245 this.cssBackgroundTicketItem_.isCapabilityAvailable()); 256 this.cssBackgroundTicketItem_.isCapabilityAvailable() &&
257 !this.collapseContent);
246 setIsVisible(this.selectionOnlyContainer_, 258 setIsVisible(this.selectionOnlyContainer_,
247 this.selectionOnlyTicketItem_.isCapabilityAvailable()); 259 this.selectionOnlyTicketItem_.isCapabilityAvailable() &&
248 fadeInOption(this.getElement()); 260 !this.collapseContent);
249 } else {
250 fadeOutOption(this.getElement());
251 } 261 }
262 print_preview.SettingsSection.prototype.updateUiStateInternal.call(this);
263 },
264
265 /** @override */
266 isSectionVisibleInternal: function() {
267 return this.collapseContent ?
268 this.duplexTicketItem_.isCapabilityAvailable() : this.isAvailable();
252 }, 269 },
253 270
254 /** 271 /**
255 * Called when the header-footer checkbox is clicked. Updates the print 272 * Called when the header-footer checkbox is clicked. Updates the print
256 * ticket. 273 * ticket.
257 * @private 274 * @private
258 */ 275 */
259 onHeaderFooterCheckboxClick_: function() { 276 onHeaderFooterCheckboxClick_: function() {
260 this.headerFooterTicketItem_.updateValue( 277 this.headerFooterTicketItem_.updateValue(
261 this.headerFooterCheckbox_.checked); 278 this.headerFooterCheckbox_.checked);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 this.selectionOnlyCheckbox_.checked); 315 this.selectionOnlyCheckbox_.checked);
299 }, 316 },
300 317
301 /** 318 /**
302 * Called when the duplex ticket item has changed. Updates the duplex 319 * Called when the duplex ticket item has changed. Updates the duplex
303 * checkbox. 320 * checkbox.
304 * @private 321 * @private
305 */ 322 */
306 onDuplexChange_: function() { 323 onDuplexChange_: function() {
307 this.duplexCheckbox_.checked = this.duplexTicketItem_.getValue(); 324 this.duplexCheckbox_.checked = this.duplexTicketItem_.getValue();
308 this.updateContainerState_(); 325 this.updateUiStateInternal();
309 }, 326 },
310 327
311 /** 328 /**
312 * Called when the fit-to-page ticket item has changed. Updates the 329 * Called when the fit-to-page ticket item has changed. Updates the
313 * fit-to-page checkbox. 330 * fit-to-page checkbox.
314 * @private 331 * @private
315 */ 332 */
316 onFitToPageChange_: function() { 333 onFitToPageChange_: function() {
317 this.fitToPageCheckbox_.checked = this.fitToPageTicketItem_.getValue(); 334 this.fitToPageCheckbox_.checked = this.fitToPageTicketItem_.getValue();
318 this.updateContainerState_(); 335 this.updateUiStateInternal();
319 }, 336 },
320 337
321 /** 338 /**
322 * Called when the CSS background ticket item has changed. Updates the 339 * Called when the CSS background ticket item has changed. Updates the
323 * CSS background checkbox. 340 * CSS background checkbox.
324 * @private 341 * @private
325 */ 342 */
326 onCssBackgroundChange_: function() { 343 onCssBackgroundChange_: function() {
327 this.cssBackgroundCheckbox_.checked = 344 this.cssBackgroundCheckbox_.checked =
328 this.cssBackgroundTicketItem_.getValue(); 345 this.cssBackgroundTicketItem_.getValue();
329 this.updateContainerState_(); 346 this.updateUiStateInternal();
330 }, 347 },
331 348
332 /** 349 /**
333 * Called when the print selection only ticket item has changed. Updates the 350 * Called when the print selection only ticket item has changed. Updates the
334 * CSS background checkbox. 351 * CSS background checkbox.
335 * @private 352 * @private
336 */ 353 */
337 onSelectionOnlyChange_: function() { 354 onSelectionOnlyChange_: function() {
338 this.selectionOnlyCheckbox_.checked = 355 this.selectionOnlyCheckbox_.checked =
339 this.selectionOnlyTicketItem_.getValue(); 356 this.selectionOnlyTicketItem_.getValue();
340 this.updateContainerState_(); 357 this.updateUiStateInternal();
341 }, 358 },
342 359
343 /** 360 /**
344 * Called when the header-footer ticket item has changed. Updates the 361 * Called when the header-footer ticket item has changed. Updates the
345 * header-footer checkbox. 362 * header-footer checkbox.
346 * @private 363 * @private
347 */ 364 */
348 onHeaderFooterChange_: function() { 365 onHeaderFooterChange_: function() {
349 this.headerFooterCheckbox_.checked = 366 this.headerFooterCheckbox_.checked =
350 this.headerFooterTicketItem_.getValue(); 367 this.headerFooterTicketItem_.getValue();
351 this.updateContainerState_(); 368 this.updateUiStateInternal();
352 } 369 }
353 }; 370 };
354 371
355 // Export 372 // Export
356 return { 373 return {
357 OtherOptionsSettings: OtherOptionsSettings 374 OtherOptionsSettings: OtherOptionsSettings
358 }; 375 };
359 }); 376 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698