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

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

Issue 596633002: Do not change state of More/less settings button until printer capabilities are retrieved to avoid … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 * Toggles visibility of the specified printing options sections. 9 * Toggles visibility of the specified printing options sections.
10 * @param {!print_preview.DestinationStore} destinationStore To listen for 10 * @param {!print_preview.DestinationStore} destinationStore To listen for
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 * Updates the component appearance according to the current state. 105 * Updates the component appearance according to the current state.
106 * @param {boolean} noAnimation Whether section visibility transitions 106 * @param {boolean} noAnimation Whether section visibility transitions
107 * should not be animated. 107 * should not be animated.
108 * @private 108 * @private
109 */ 109 */
110 updateState_: function(noAnimation) { 110 updateState_: function(noAnimation) {
111 if (!this.firstDestinationReady_) { 111 if (!this.firstDestinationReady_) {
112 fadeOutElement(this.getElement(), noAnimation); 112 fadeOutElement(this.getElement(), noAnimation);
113 return; 113 return;
114 } 114 }
115 // When capabilities are not known yet, don't change the state to avoid
116 // unnecessary fade in/out cycles.
117 if (!this.capabilitiesReady_)
118 return;
115 119
116 var all = this.settingsToShow_ == MoreSettings.SettingsToShow.ALL; 120 var all = this.settingsToShow_ == MoreSettings.SettingsToShow.ALL;
117 this.getChildElement('.more-settings-label').textContent = 121 this.getChildElement('.more-settings-label').textContent =
118 loadTimeData.getString(all ? 'lessOptionsLabel' : 'moreOptionsLabel'); 122 loadTimeData.getString(all ? 'lessOptionsLabel' : 'moreOptionsLabel');
119 var iconEl = this.getChildElement('.more-settings-icon'); 123 var iconEl = this.getChildElement('.more-settings-icon');
120 iconEl.classList.toggle('more-settings-icon-plus', !all); 124 iconEl.classList.toggle('more-settings-icon-plus', !all);
121 iconEl.classList.toggle('more-settings-icon-minus', all); 125 iconEl.classList.toggle('more-settings-icon-minus', all);
122 126
123 var availableSections = this.settingsSections_.reduce( 127 var availableSections = this.settingsSections_.reduce(
124 function(count, section) { 128 function(count, section) {
125 return count + (section.isAvailable() ? 1 : 0); 129 return count + (section.isAvailable() ? 1 : 0);
126 }, 0); 130 }, 0);
127 131
128 // Magic 6 is chosen as the number of sections when it still feels like 132 // Magic 6 is chosen as the number of sections when it still feels like
129 // manageable and not too crowded. Also, when capabilities are not know 133 // manageable and not too crowded.
130 // yet, ignore this limit to avoid unnecessary fade in/out cycles.
131 var hasSectionsToToggle = 134 var hasSectionsToToggle =
132 (availableSections > 6 || !this.capabilitiesReady_) && 135 availableSections > 6 &&
133 this.settingsSections_.some(function(section) { 136 this.settingsSections_.some(function(section) {
134 return section.hasCollapsibleContent(); 137 return section.hasCollapsibleContent();
135 }); 138 });
136 139
137 if (hasSectionsToToggle) 140 if (hasSectionsToToggle)
138 fadeInElement(this.getElement(), noAnimation); 141 fadeInElement(this.getElement(), noAnimation);
139 else 142 else
140 fadeOutElement(this.getElement(), noAnimation); 143 fadeOutElement(this.getElement(), noAnimation);
141 144
142 var collapseContent = 145 var collapseContent =
143 this.settingsToShow_ == MoreSettings.SettingsToShow.MOST_POPULAR && 146 this.settingsToShow_ == MoreSettings.SettingsToShow.MOST_POPULAR &&
144 hasSectionsToToggle; 147 hasSectionsToToggle;
145 this.settingsSections_.forEach(function(section) { 148 this.settingsSections_.forEach(function(section) {
146 section.setCollapseContent(collapseContent, noAnimation); 149 section.setCollapseContent(collapseContent, noAnimation);
147 }); 150 });
148 } 151 }
149 }; 152 };
150 153
151 // Export 154 // Export
152 return { 155 return {
153 MoreSettings: MoreSettings 156 MoreSettings: MoreSettings
154 }; 157 };
155 }); 158 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698