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

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

Issue 2857983007: Print Preview: Make getChildElement return required HTMLElement (Closed)
Patch Set: Created 3 years, 7 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 this.destination_.displayName); 63 this.destination_.displayName);
64 this.setIsVisible(true); 64 this.setIsVisible(true);
65 this.renderSettings_(); 65 this.renderSettings_();
66 }, 66 },
67 67
68 /** @override */ 68 /** @override */
69 enterDocument: function() { 69 enterDocument: function() {
70 print_preview.Overlay.prototype.enterDocument.call(this); 70 print_preview.Overlay.prototype.enterDocument.call(this);
71 71
72 this.tracker.add( 72 this.tracker.add(
73 assert(this.getChildElement('.button-strip .cancel-button')), 73 this.getChildElement('.button-strip .cancel-button'),
74 'click', 74 'click',
75 this.cancel.bind(this)); 75 this.cancel.bind(this));
76 76
77 this.tracker.add( 77 this.tracker.add(
78 assert(this.getChildElement('.button-strip .done-button')), 78 this.getChildElement('.button-strip .done-button'),
79 'click', 79 'click',
80 this.onApplySettings_.bind(this)); 80 this.onApplySettings_.bind(this));
81 81
82 this.tracker.add( 82 this.tracker.add(
83 assert(this.searchBox_), 83 assert(this.searchBox_),
84 print_preview.SearchBox.EventType.SEARCH, 84 print_preview.SearchBox.EventType.SEARCH,
85 this.onSearch_.bind(this)); 85 this.onSearch_.bind(this));
86 }, 86 },
87 87
88 /** @override */ 88 /** @override */
89 decorateInternal: function() { 89 decorateInternal: function() {
90 this.searchBox_.render(assert(this.getChildElement('.search-box-area'))); 90 this.searchBox_.render(this.getChildElement('.search-box-area'));
91 }, 91 },
92 92
93 /** @override */ 93 /** @override */
94 onSetVisibleInternal: function(isVisible) { 94 onSetVisibleInternal: function(isVisible) {
95 if (isVisible) { 95 if (isVisible) {
96 this.searchBox_.focus(); 96 this.searchBox_.focus();
97 this.metrics_.record(print_preview.Metrics.PrintSettingsUiBucket. 97 this.metrics_.record(print_preview.Metrics.PrintSettingsUiBucket.
98 ADVANCED_SETTINGS_DIALOG_SHOWN); 98 ADVANCED_SETTINGS_DIALOG_SHOWN);
99 } else { 99 } else {
100 this.resetSearch_(); 100 this.resetSearch_();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 var atLeastOneMatch = false; 138 var atLeastOneMatch = false;
139 var lastVisibleItemWithBubble = null; 139 var lastVisibleItemWithBubble = null;
140 this.items_.forEach(function(item) { 140 this.items_.forEach(function(item) {
141 item.updateSearchQuery(query); 141 item.updateSearchQuery(query);
142 if (getIsVisible(item.getElement())) 142 if (getIsVisible(item.getElement()))
143 atLeastOneMatch = true; 143 atLeastOneMatch = true;
144 if (item.searchBubbleShown) 144 if (item.searchBubbleShown)
145 lastVisibleItemWithBubble = item; 145 lastVisibleItemWithBubble = item;
146 }); 146 });
147 setIsVisible( 147 setIsVisible(
148 assert(this.getChildElement('.no-settings-match-hint')), 148 this.getChildElement('.no-settings-match-hint'),
149 !atLeastOneMatch); 149 !atLeastOneMatch);
150 setIsVisible( 150 setIsVisible(
151 assert(this.getChildElement( 151 this.getChildElement('.' + AdvancedSettings.Classes_.EXTRA_PADDING),
152 '.' + AdvancedSettings.Classes_.EXTRA_PADDING)),
153 !!lastVisibleItemWithBubble); 152 !!lastVisibleItemWithBubble);
154 }, 153 },
155 154
156 /** 155 /**
157 * Resets the filter query. 156 * Resets the filter query.
158 * @private 157 * @private
159 */ 158 */
160 resetSearch_: function() { 159 resetSearch_: function() {
161 this.searchBox_.setQuery(null); 160 this.searchBox_.setQuery(null);
162 this.filterLists_(null); 161 this.filterLists_(null);
163 }, 162 },
164 163
165 /** 164 /**
166 * Renders all of the available settings. 165 * Renders all of the available settings.
167 * @private 166 * @private
168 */ 167 */
169 renderSettings_: function() { 168 renderSettings_: function() {
170 // Remove all children settings elements. 169 // Remove all children settings elements.
171 this.items_.forEach(function(item) { 170 this.items_.forEach(function(item) {
172 this.removeChild(item); 171 this.removeChild(item);
173 }.bind(this)); 172 }.bind(this));
174 this.items_ = []; 173 this.items_ = [];
175 174
176 var extraPadding = 175 var extraPadding = this.element_.querySelector(
177 this.getChildElement('.' + AdvancedSettings.Classes_.EXTRA_PADDING); 176 '.' + AdvancedSettings.Classes_.EXTRA_PADDING);
178 if (extraPadding) 177 if (extraPadding)
179 extraPadding.parentNode.removeChild(extraPadding); 178 extraPadding.parentNode.removeChild(extraPadding);
180 179
181 var vendorCapabilities = this.printTicketStore_.vendorItems.capability; 180 var vendorCapabilities = this.printTicketStore_.vendorItems.capability;
182 if (!vendorCapabilities) 181 if (!vendorCapabilities)
183 return; 182 return;
184 183
185 var availableHeight = this.getAvailableContentHeight_(); 184 var availableHeight = this.getAvailableContentHeight_();
186 var containerEl = this.getChildElement('.settings-area'); 185 var containerEl = this.getChildElement('.settings-area');
187 containerEl.style.maxHeight = availableHeight + 'px'; 186 containerEl.style.maxHeight = availableHeight + 'px';
188 var settingsEl = this.getChildElement('.settings'); 187 var settingsEl = this.getChildElement('.settings');
189 188
190 vendorCapabilities.forEach(function(capability) { 189 vendorCapabilities.forEach(function(capability) {
191 var item = new print_preview.AdvancedSettingsItem( 190 var item = new print_preview.AdvancedSettingsItem(
192 this.printTicketStore_, capability); 191 this.printTicketStore_, capability);
193 this.addChild(item); 192 this.addChild(item);
194 item.render(assert(settingsEl)); 193 item.render(settingsEl);
195 this.items_.push(item); 194 this.items_.push(item);
196 }.bind(this)); 195 }.bind(this));
197 196
198 var searchBoxArea = assert(this.getChildElement('.search-box-area')); 197 var searchBoxArea = this.getChildElement('.search-box-area');
199 if (this.items_.length <= 1) { 198 if (this.items_.length <= 1) {
200 setIsVisible(searchBoxArea, false); 199 setIsVisible(searchBoxArea, false);
201 } else { 200 } else {
202 setIsVisible(searchBoxArea, true); 201 setIsVisible(searchBoxArea, true);
203 this.searchBox_.focus(); 202 this.searchBox_.focus();
204 } 203 }
205 204
206 extraPadding = document.createElement('div'); 205 extraPadding = document.createElement('div');
207 extraPadding.classList.add(AdvancedSettings.Classes_.EXTRA_PADDING); 206 extraPadding.classList.add(AdvancedSettings.Classes_.EXTRA_PADDING);
208 extraPadding.hidden = true; 207 extraPadding.hidden = true;
(...skipping 25 matching lines...) Expand all
234 233
235 this.printTicketStore_.vendorItems.updateValue(values); 234 this.printTicketStore_.vendorItems.updateValue(values);
236 } 235 }
237 }; 236 };
238 237
239 // Export 238 // Export
240 return { 239 return {
241 AdvancedSettings: AdvancedSettings 240 AdvancedSettings: AdvancedSettings
242 }; 241 };
243 }); 242 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698