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

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

Issue 568973002: Print Preview Advanced settings tweaks: (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
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 * Modal dialog for print destination's advanced settings. 9 * Modal dialog for print destination's advanced settings.
10 * @param {!print_preview.PrintTicketStore} printTicketStore Contains the 10 * @param {!print_preview.PrintTicketStore} printTicketStore Contains the
(...skipping 21 matching lines...) Expand all
32 localStrings.getString('advancedSettingsSearchBoxPlaceholder')); 32 localStrings.getString('advancedSettingsSearchBoxPlaceholder'));
33 this.addChild(this.searchBox_); 33 this.addChild(this.searchBox_);
34 34
35 /** @private {print_preview.Destination} */ 35 /** @private {print_preview.Destination} */
36 this.destination_ = null; 36 this.destination_ = null;
37 37
38 /** @private {!Array.<!print_preview.AdvancedSettingsItem>} */ 38 /** @private {!Array.<!print_preview.AdvancedSettingsItem>} */
39 this.items_ = []; 39 this.items_ = [];
40 }; 40 };
41 41
42 /**
43 * CSS classes used by the component.
44 * @enum {string}
45 * @private
46 */
47 AdvancedSettings.Classes_ = {
48 EXTRA_PADDING: 'advanced-settings-item-extra-padding'
49 };
50
42 AdvancedSettings.prototype = { 51 AdvancedSettings.prototype = {
43 __proto__: print_preview.Overlay.prototype, 52 __proto__: print_preview.Overlay.prototype,
44 53
45 /** 54 /**
46 * @param {!print_preview.Destination} destination Destination to show 55 * @param {!print_preview.Destination} destination Destination to show
47 * advanced settings for. 56 * advanced settings for.
48 */ 57 */
49 showForDestination: function(destination) { 58 showForDestination: function(destination) {
50 assert(!this.destination_); 59 assert(!this.destination_);
51 this.destination_ = destination; 60 this.destination_ = destination;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 this.getChildElement('.settings-area').offsetTop - 128 this.getChildElement('.settings-area').offsetTop -
120 this.getChildElement('.action-area').offsetHeight; 129 this.getChildElement('.action-area').offsetHeight;
121 }, 130 },
122 131
123 /** 132 /**
124 * Filters displayed settings with the given query. 133 * Filters displayed settings with the given query.
125 * @param {?string} query Query to filter settings by. 134 * @param {?string} query Query to filter settings by.
126 * @private 135 * @private
127 */ 136 */
128 filterLists_: function(query) { 137 filterLists_: function(query) {
138 var atLeastOneMatch = false;
129 var lastVisibleItemWithBubble = null; 139 var lastVisibleItemWithBubble = null;
130 this.items_.forEach(function(item) { 140 this.items_.forEach(function(item) {
131 item.updateSearchQuery(query); 141 item.updateSearchQuery(query);
142 if (getIsVisible(item.getElement()))
143 atLeastOneMatch = true;
132 if (item.searchBubbleShown) 144 if (item.searchBubbleShown)
133 lastVisibleItemWithBubble = item; 145 lastVisibleItemWithBubble = item;
134 }); 146 });
135 setIsVisible( 147 setIsVisible(
136 this.getChildElement('.advanced-settings-item-extra-padding'), 148 this.getChildElement('.no-settings-match-hint'), !atLeastOneMatch);
149 setIsVisible(
150 this.getChildElement('.' + AdvancedSettings.Classes_.EXTRA_PADDING),
137 !!lastVisibleItemWithBubble); 151 !!lastVisibleItemWithBubble);
138 }, 152 },
139 153
140 /** 154 /**
141 * Resets the filter query. 155 * Resets the filter query.
142 * @private 156 * @private
143 */ 157 */
144 resetSearch_: function() { 158 resetSearch_: function() {
145 this.searchBox_.setQuery(null); 159 this.searchBox_.setQuery(null);
146 this.filterLists_(null); 160 this.filterLists_(null);
147 }, 161 },
148 162
149 /** 163 /**
150 * Renders all of the available settings. 164 * Renders all of the available settings.
151 * @private 165 * @private
152 */ 166 */
153 renderSettings_: function() { 167 renderSettings_: function() {
154 // Remove all children settings elements. 168 // Remove all children settings elements.
155 this.items_.forEach(function(item) { 169 this.items_.forEach(function(item) {
156 this.removeChild(item); 170 this.removeChild(item);
157 }.bind(this)); 171 }.bind(this));
158 this.items_ = []; 172 this.items_ = [];
159 173
174 var extraPadding =
175 this.getChildElement('.' + AdvancedSettings.Classes_.EXTRA_PADDING);
176 if (extraPadding)
177 extraPadding.parentNode.removeChild(extraPadding);
178
160 var vendorCapabilities = this.printTicketStore_.vendorItems.capability; 179 var vendorCapabilities = this.printTicketStore_.vendorItems.capability;
161 if (!vendorCapabilities) 180 if (!vendorCapabilities)
162 return; 181 return;
163 182
164 var availableHeight = this.getAvailableContentHeight_(); 183 var availableHeight = this.getAvailableContentHeight_();
165 var containerEl = this.getChildElement('.settings-area'); 184 var containerEl = this.getChildElement('.settings-area');
166 containerEl.style.maxHeight = availableHeight + 'px'; 185 containerEl.style.maxHeight = availableHeight + 'px';
167 var settingsEl = this.getChildElement('.settings'); 186 var settingsEl = this.getChildElement('.settings');
168 187
169 vendorCapabilities.forEach(function(capability) { 188 vendorCapabilities.forEach(function(capability) {
170 var item = new print_preview.AdvancedSettingsItem( 189 var item = new print_preview.AdvancedSettingsItem(
171 this.eventTarget_, this.printTicketStore_, capability); 190 this.eventTarget_, this.printTicketStore_, capability);
172 this.addChild(item); 191 this.addChild(item);
173 item.render(settingsEl); 192 item.render(settingsEl);
174 this.items_.push(item); 193 this.items_.push(item);
175 }.bind(this)); 194 }.bind(this));
176 195
177 var extraPadding = document.createElement('div'); 196 extraPadding = document.createElement('div');
178 extraPadding.classList.add('advanced-settings-item-extra-padding'); 197 extraPadding.classList.add(AdvancedSettings.Classes_.EXTRA_PADDING);
179 extraPadding.hidden = true; 198 extraPadding.hidden = true;
180 settingsEl.appendChild(extraPadding); 199 settingsEl.appendChild(extraPadding);
181 }, 200 },
182 201
183 /** 202 /**
184 * Called when settings search query changes. Filters displayed settings 203 * Called when settings search query changes. Filters displayed settings
185 * with the given query. 204 * with the given query.
186 * @param {Event} evt Contains search query. 205 * @param {Event} evt Contains search query.
187 * @private 206 * @private
188 */ 207 */
(...skipping 16 matching lines...) Expand all
205 224
206 this.printTicketStore_.vendorItems.updateValue(values); 225 this.printTicketStore_.vendorItems.updateValue(values);
207 } 226 }
208 }; 227 };
209 228
210 // Export 229 // Export
211 return { 230 return {
212 AdvancedSettings: AdvancedSettings 231 AdvancedSettings: AdvancedSettings
213 }; 232 };
214 }); 233 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698