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

Side by Side Diff: chrome/browser/resources/print_preview/settings/layout_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 * Creates a LayoutSettings object. This object encapsulates all settings and 9 * Creates a LayoutSettings object. This object encapsulates all settings and
10 * logic related to layout mode (portrait/landscape). 10 * logic related to layout mode (portrait/landscape).
11 * @param {!print_preview.ticket_items.Landscape} landscapeTicketItem Used to 11 * @param {!print_preview.ticket_items.Landscape} landscapeTicketItem Used to
12 * get the layout written to the print ticket. 12 * get the layout written to the print ticket.
13 * @constructor 13 * @constructor
14 * @extends {print_preview.Component} 14 * @extends {print_preview.SettingsSection}
15 */ 15 */
16 function LayoutSettings(landscapeTicketItem) { 16 function LayoutSettings(landscapeTicketItem) {
17 print_preview.Component.call(this); 17 print_preview.SettingsSection.call(this);
18 18
19 /** 19 /**
20 * Used to get the layout written to the print ticket. 20 * Used to get the layout written to the print ticket.
21 * @type {!print_preview.ticket_items.Landscape} 21 * @type {!print_preview.ticket_items.Landscape}
22 * @private 22 * @private
23 */ 23 */
24 this.landscapeTicketItem_ = landscapeTicketItem; 24 this.landscapeTicketItem_ = landscapeTicketItem;
25 }; 25 };
26 26
27 /** 27 /**
28 * CSS classes used by the layout settings. 28 * CSS classes used by the layout settings.
29 * @enum {string} 29 * @enum {string}
30 * @private 30 * @private
31 */ 31 */
32 LayoutSettings.Classes_ = { 32 LayoutSettings.Classes_ = {
33 LANDSCAPE_RADIO: 'layout-settings-landscape-radio', 33 LANDSCAPE_RADIO: 'layout-settings-landscape-radio',
34 PORTRAIT_RADIO: 'layout-settings-portrait-radio' 34 PORTRAIT_RADIO: 'layout-settings-portrait-radio'
35 }; 35 };
36 36
37 LayoutSettings.prototype = { 37 LayoutSettings.prototype = {
38 __proto__: print_preview.Component.prototype, 38 __proto__: print_preview.SettingsSection.prototype,
39 39
40 /** @param {boolean} isEnabled Whether this component is enabled. */ 40 /** @override */
41 isAvailable: function() {
42 return this.landscapeTicketItem_.isCapabilityAvailable();
43 },
44
45 /** @override */
46 hasCollapsibleContent: function() {
47 return false;
48 },
49
50 /** @override */
41 set isEnabled(isEnabled) { 51 set isEnabled(isEnabled) {
42 this.landscapeRadioButton_.disabled = !isEnabled; 52 this.landscapeRadioButton_.disabled = !isEnabled;
43 this.portraitRadioButton_.disabled = !isEnabled; 53 this.portraitRadioButton_.disabled = !isEnabled;
44 }, 54 },
45 55
46 /** @override */ 56 /** @override */
47 enterDocument: function() { 57 enterDocument: function() {
48 print_preview.Component.prototype.enterDocument.call(this); 58 print_preview.SettingsSection.prototype.enterDocument.call(this);
49 fadeOutOption(this.getElement(), true);
50 this.tracker.add( 59 this.tracker.add(
51 this.portraitRadioButton_, 60 this.portraitRadioButton_,
52 'click', 61 'click',
53 this.onLayoutButtonClick_.bind(this)); 62 this.onLayoutButtonClick_.bind(this));
54 this.tracker.add( 63 this.tracker.add(
55 this.landscapeRadioButton_, 64 this.landscapeRadioButton_,
56 'click', 65 'click',
57 this.onLayoutButtonClick_.bind(this)); 66 this.onLayoutButtonClick_.bind(this));
58 this.tracker.add( 67 this.tracker.add(
59 this.landscapeTicketItem_, 68 this.landscapeTicketItem_,
(...skipping 27 matching lines...) Expand all
87 onLayoutButtonClick_: function() { 96 onLayoutButtonClick_: function() {
88 this.landscapeTicketItem_.updateValue(this.landscapeRadioButton_.checked); 97 this.landscapeTicketItem_.updateValue(this.landscapeRadioButton_.checked);
89 }, 98 },
90 99
91 /** 100 /**
92 * Called when the print ticket store changes state. Updates the state of 101 * Called when the print ticket store changes state. Updates the state of
93 * the radio buttons and hides the setting if necessary. 102 * the radio buttons and hides the setting if necessary.
94 * @private 103 * @private
95 */ 104 */
96 onLandscapeTicketItemChange_: function() { 105 onLandscapeTicketItemChange_: function() {
97 if (this.landscapeTicketItem_.isCapabilityAvailable()) { 106 if (this.isAvailable()) {
98 var isLandscapeEnabled = this.landscapeTicketItem_.getValue(); 107 var isLandscapeEnabled = this.landscapeTicketItem_.getValue();
99 this.portraitRadioButton_.checked = !isLandscapeEnabled; 108 this.portraitRadioButton_.checked = !isLandscapeEnabled;
100 this.landscapeRadioButton_.checked = isLandscapeEnabled; 109 this.landscapeRadioButton_.checked = isLandscapeEnabled;
101 fadeInOption(this.getElement());
102 } else {
103 fadeOutOption(this.getElement());
104 } 110 }
111 this.updateUiStateInternal();
105 } 112 }
106 }; 113 };
107 114
108 // Export 115 // Export
109 return { 116 return {
110 LayoutSettings: LayoutSettings 117 LayoutSettings: LayoutSettings
111 }; 118 };
112 }); 119 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698