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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/print_preview/settings/settings_section.js
diff --git a/chrome/browser/resources/print_preview/settings/settings_section.js b/chrome/browser/resources/print_preview/settings/settings_section.js
new file mode 100644
index 0000000000000000000000000000000000000000..d36178eec9d689357fa47c90935ad22cbf5a9943
--- /dev/null
+++ b/chrome/browser/resources/print_preview/settings/settings_section.js
@@ -0,0 +1,118 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+cr.define('print_preview', function() {
+ 'use strict';
+
+ /**
+ * Base class for print option section components.
+ * @constructor
+ * @extends {print_preview.Component}
+ */
+ function SettingsSection() {
+ print_preview.Component.call(this);
+
+ /**
+ * Cached "hasCollapsibleContent" status for COLLAPSIBLE_CONTENT_CHANGED
+ * notification.
+ * @private {?boolean}
+ */
+ this.hasCollapsibleContentCached_ = null;
+
+ /**
+ * Whether content of this section should be collapsed or not.
+ * @private {boolean}
+ */
+ this.collapseContent_ = false;
+ };
+
+ /**
+ * Event types dispatched by this class.
+ * @enum {string}
+ */
+ SettingsSection.EventType = {
+ COLLAPSIBLE_CONTENT_CHANGED:
+ 'print_preview.SettingsSection.COLLAPSIBLE_CONTENT_CHANGED'
+ };
+
+ SettingsSection.prototype = {
+ __proto__: print_preview.Component.prototype,
+
+ /** @return {boolean} Whether this section should be displayed or not. */
+ isAvailable: function() {
+ throw Error('Abstract method not overridden');
+ },
+
+ /**
+ * @return {boolean} Whether this section has a content which can be
+ * collapsed/expanded.
+ */
+ hasCollapsibleContent: function() {
+ throw Error('Abstract method not overridden');
+ },
+
+ /** @param {boolean} isEnabled Whether this component is enabled. */
+ set isEnabled(isEnabled) {
+ throw Error('Abstract method not overridden');
+ },
+
+ /**
+ * @return {boolean} Whether the content of this section should be
+ * collapsed.
+ */
+ get collapseContent() {
+ return this.collapseContent_;
+ },
+
+ /**
+ * @param {boolean} collapseContent Whether the content of this section
+ * should be collapsed, even if this section is available.
+ */
+ set collapseContent(collapseContent) {
+ this.collapseContent_ = collapseContent && this.hasCollapsibleContent();
+ this.updateUiStateInternal();
+ },
+
+ /** @override */
+ enterDocument: function() {
+ print_preview.Component.prototype.enterDocument.call(this);
+ this.isAvailable_ = this.isAvailable();
+ if (!this.isAvailable())
+ fadeOutOption(this.getElement(), true);
+ },
+
+ /**
+ * Updates the component appearance according to the current state.
+ * @protected
+ */
+ updateUiStateInternal: function() {
+ var hasCollapsibleContent = this.hasCollapsibleContent();
+ var changed = this.hasCollapsibleContentCached_ != hasCollapsibleContent;
+ this.hasCollapsibleContentCached_ = hasCollapsibleContent;
+
+ if (this.isSectionVisibleInternal())
+ fadeInOption(this.getElement());
+ else
+ fadeOutOption(this.getElement());
+
+ if (changed) {
+ cr.dispatchSimpleEvent(
+ this, SettingsSection.EventType.COLLAPSIBLE_CONTENT_CHANGED);
+ }
+ },
+
+ /**
+ * @return {boolean} Whether this section should be displayed or not.
+ * @protected
+ */
+ isSectionVisibleInternal: function() {
+ return this.isAvailable() && !this.collapseContent_;
+ }
+ };
+
+ // Export
+ return {
+ SettingsSection: SettingsSection
+ };
+});

Powered by Google App Engine
This is Rietveld 408576698