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

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

Issue 556363003: Print Preview UI tweaks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adjust browser_tests accordingly. 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
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 {!Array.<print_preview.SettingsSection>} settingsSections Sections 10 * @param {!Array.<print_preview.SettingsSection>} settingsSections Sections
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 * @private 67 * @private
68 */ 68 */
69 updateState_: function() { 69 updateState_: function() {
70 var all = this.settingsToShow_ == MoreSettings.SettingsToShow.ALL; 70 var all = this.settingsToShow_ == MoreSettings.SettingsToShow.ALL;
71 this.getChildElement('.more-settings-label').textContent = 71 this.getChildElement('.more-settings-label').textContent =
72 localStrings.getString(all ? 'lessOptionsLabel' : 'moreOptionsLabel'); 72 localStrings.getString(all ? 'lessOptionsLabel' : 'moreOptionsLabel');
73 var iconEl = this.getChildElement('.more-settings-icon'); 73 var iconEl = this.getChildElement('.more-settings-icon');
74 iconEl.classList.toggle('more-settings-icon-plus', !all); 74 iconEl.classList.toggle('more-settings-icon-plus', !all);
75 iconEl.classList.toggle('more-settings-icon-minus', all); 75 iconEl.classList.toggle('more-settings-icon-minus', all);
76 76
77 var hasSectionsToToggle = this.settingsSections_.some(function(section) { 77 var availableSections = this.settingsSections_.reduce(
78 return section.hasCollapsibleContent(); 78 function(count, section) {
79 }); 79 return count + (section.isAvailable() ? 1 : 0);
80 }, 0);
81
82 // Magic 6 is chosen as the number of sections when it still feels like
83 // manageable and not too crowded.
84 var hasSectionsToToggle =
85 availableSections > 6 &&
86 this.settingsSections_.some(function(section) {
87 return section.hasCollapsibleContent();
88 });
80 89
81 if (hasSectionsToToggle) 90 if (hasSectionsToToggle)
82 fadeInElement(this.getElement()); 91 fadeInElement(this.getElement());
83 else 92 else
84 fadeOutElement(this.getElement()); 93 fadeOutElement(this.getElement());
85 94
86 var collapseContent = 95 var collapseContent =
87 this.settingsToShow_ == MoreSettings.SettingsToShow.MOST_POPULAR && 96 this.settingsToShow_ == MoreSettings.SettingsToShow.MOST_POPULAR &&
88 hasSectionsToToggle; 97 hasSectionsToToggle;
89 this.settingsSections_.forEach(function(section) { 98 this.settingsSections_.forEach(function(section) {
90 section.collapseContent = collapseContent; 99 section.collapseContent = collapseContent;
91 }); 100 });
92 } 101 }
93 }; 102 };
94 103
95 // Export 104 // Export
96 return { 105 return {
97 MoreSettings: MoreSettings 106 MoreSettings: MoreSettings
98 }; 107 };
99 }); 108 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/print_preview/settings/more_settings.html ('k') | chrome/test/data/webui/print_preview.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698