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

Side by Side Diff: chrome/browser/resources/print_preview/settings/settings_section.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
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 cr.define('print_preview', function() {
6 'use strict';
7
8 /**
9 * Base class for print option section components.
10 * @constructor
11 * @extends {print_preview.Component}
12 */
13 function SettingsSection() {
14 print_preview.Component.call(this);
15
16 /**
17 * Cached "hasCollapsibleContent" status for COLLAPSIBLE_CONTENT_CHANGED
18 * notification.
19 * @private {?boolean}
20 */
21 this.hasCollapsibleContentCached_ = null;
22
23 /**
24 * Whether content of this section should be collapsed or not.
25 * @private {boolean}
26 */
27 this.collapseContent_ = false;
28 };
29
30 /**
31 * Event types dispatched by this class.
32 * @enum {string}
33 */
34 SettingsSection.EventType = {
35 COLLAPSIBLE_CONTENT_CHANGED:
36 'print_preview.SettingsSection.COLLAPSIBLE_CONTENT_CHANGED'
37 };
38
39 SettingsSection.prototype = {
40 __proto__: print_preview.Component.prototype,
41
42 /** @return {boolean} Whether this section should be displayed or not. */
43 isAvailable: function() {
44 throw Error('Abstract method not overridden');
45 },
46
47 /**
48 * @return {boolean} Whether this section has a content which can be
49 * collapsed/expanded.
50 */
51 hasCollapsibleContent: function() {
52 throw Error('Abstract method not overridden');
53 },
54
55 /** @param {boolean} isEnabled Whether this component is enabled. */
56 set isEnabled(isEnabled) {
57 throw Error('Abstract method not overridden');
58 },
59
60 /**
61 * @return {boolean} Whether the content of this section should be
62 * collapsed.
63 */
64 get collapseContent() {
65 return this.collapseContent_;
66 },
67
68 /**
69 * @param {boolean} collapseContent Whether the content of this section
70 * should be collapsed, even if this section is available.
71 */
72 set collapseContent(collapseContent) {
73 this.collapseContent_ = collapseContent && this.hasCollapsibleContent();
74 this.updateUiStateInternal();
75 },
76
77 /** @override */
78 enterDocument: function() {
79 print_preview.Component.prototype.enterDocument.call(this);
80 this.isAvailable_ = this.isAvailable();
81 if (!this.isAvailable())
82 fadeOutOption(this.getElement(), true);
83 },
84
85 /**
86 * Updates the component appearance according to the current state.
87 * @protected
88 */
89 updateUiStateInternal: function() {
90 var hasCollapsibleContent = this.hasCollapsibleContent();
91 var changed = this.hasCollapsibleContentCached_ != hasCollapsibleContent;
92 this.hasCollapsibleContentCached_ = hasCollapsibleContent;
93
94 if (this.isSectionVisibleInternal())
95 fadeInOption(this.getElement());
96 else
97 fadeOutOption(this.getElement());
98
99 if (changed) {
100 cr.dispatchSimpleEvent(
101 this, SettingsSection.EventType.COLLAPSIBLE_CONTENT_CHANGED);
102 }
103 },
104
105 /**
106 * @return {boolean} Whether this section should be displayed or not.
107 * @protected
108 */
109 isSectionVisibleInternal: function() {
110 return this.isAvailable() && !this.collapseContent_;
111 }
112 };
113
114 // Export
115 return {
116 SettingsSection: SettingsSection
117 };
118 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698