[sql] Remove _HAS_EXCEPTIONS=0 from build info.
[chromium-blink-merge.git] / chrome / browser / resources / print_preview / settings / settings_section.js
blobdffa7db563c6d49d7cd36a3b4dd056ada846e1a5
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.
5 cr.define('print_preview', function() {
6 'use strict';
8 /**
9 * Base class for print option section components.
10 * @constructor
11 * @extends {print_preview.Component}
13 function SettingsSection() {
14 print_preview.Component.call(this);
16 /**
17 * Cached "hasCollapsibleContent" status for COLLAPSIBLE_CONTENT_CHANGED
18 * notification.
19 * @private {?boolean}
21 this.hasCollapsibleContentCached_ = null;
23 /**
24 * Whether content of this section should be collapsed or not.
25 * @private {boolean}
27 this.collapseContent_ = true;
30 /**
31 * Event types dispatched by this class.
32 * @enum {string}
34 SettingsSection.EventType = {
35 COLLAPSIBLE_CONTENT_CHANGED:
36 'print_preview.SettingsSection.COLLAPSIBLE_CONTENT_CHANGED'
39 SettingsSection.prototype = {
40 __proto__: print_preview.Component.prototype,
42 /** @return {boolean} Whether this section should be displayed or not. */
43 isAvailable: function() {
44 throw Error('Abstract method not overridden');
47 /**
48 * @return {boolean} Whether this section has a content which can be
49 * collapsed/expanded.
51 hasCollapsibleContent: function() {
52 throw Error('Abstract method not overridden');
55 /** @param {boolean} isEnabled Whether this component is enabled. */
56 set isEnabled(isEnabled) {
57 throw Error('Abstract method not overridden');
60 /**
61 * @return {boolean} Whether the content of this section should be
62 * collapsed.
64 get collapseContent() {
65 return this.collapseContent_;
68 /**
69 * @param {boolean} collapseContent Whether the content of this section
70 * should be collapsed, even if this section is available.
71 * @param {boolean} noAnimation Whether section visibility transition
72 * should not be animated.
74 setCollapseContent: function(collapseContent, noAnimation) {
75 this.collapseContent_ = collapseContent && this.hasCollapsibleContent();
76 this.updateUiStateInternal(noAnimation);
79 /** @override */
80 enterDocument: function() {
81 print_preview.Component.prototype.enterDocument.call(this);
82 this.isAvailable_ = this.isAvailable();
83 if (!this.isAvailable())
84 fadeOutOption(this.getElement(), true);
87 /**
88 * Updates the component appearance according to the current state.
89 * @param {boolean=} opt_noAnimation Whether section visibility transition
90 * should not be animated.
91 * @protected
93 updateUiStateInternal: function(opt_noAnimation) {
94 var hasCollapsibleContent = this.hasCollapsibleContent();
95 var changed = this.hasCollapsibleContentCached_ != hasCollapsibleContent;
96 this.hasCollapsibleContentCached_ = hasCollapsibleContent;
98 if (this.isSectionVisibleInternal())
99 fadeInOption(this.getElement(), opt_noAnimation);
100 else
101 fadeOutOption(this.getElement(), opt_noAnimation);
103 if (changed) {
104 cr.dispatchSimpleEvent(
105 this, SettingsSection.EventType.COLLAPSIBLE_CONTENT_CHANGED);
110 * @return {boolean} Whether this section should be displayed or not.
111 * @protected
113 isSectionVisibleInternal: function() {
114 return this.isAvailable() && !this.collapseContent_;
118 // Export
119 return {
120 SettingsSection: SettingsSection