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

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

Issue 2861713004: Print Preview: Fix compile errors in settings/ directory (Closed)
Patch Set: Remove extra semis 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 19 matching lines...) Expand all
30 /** @private {!print_preview.SearchBox} */ 30 /** @private {!print_preview.SearchBox} */
31 this.searchBox_ = new print_preview.SearchBox( 31 this.searchBox_ = new print_preview.SearchBox(
32 loadTimeData.getString('advancedSettingsSearchBoxPlaceholder')); 32 loadTimeData.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 /** 42 /**
43 * CSS classes used by the component. 43 * CSS classes used by the component.
44 * @enum {string} 44 * @enum {string}
45 * @private 45 * @private
46 */ 46 */
47 AdvancedSettings.Classes_ = { 47 AdvancedSettings.Classes_ = {
48 EXTRA_PADDING: 'advanced-settings-item-extra-padding' 48 EXTRA_PADDING: 'advanced-settings-item-extra-padding'
49 }; 49 };
50 50
(...skipping 12 matching lines...) Expand all
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 this.getChildElement('.button-strip .cancel-button'), 73 assert(this.getChildElement('.button-strip .cancel-button')),
dpapad 2017/05/04 01:20:04 Follow up from previous comment: if we make getChi
rbpotter 2017/05/04 01:43:07 Acknowledged - will investigate getChildElement an
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 this.getChildElement('.button-strip .done-button'), 78 assert(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 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(this.getChildElement('.search-box-area')); 90 this.searchBox_.render(assert(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 23 matching lines...) Expand all
124 var elStyle = window.getComputedStyle(this.getElement()); 124 var elStyle = window.getComputedStyle(this.getElement());
125 return this.getElement().offsetHeight - 125 return this.getElement().offsetHeight -
126 parseInt(elStyle.getPropertyValue('padding-top'), 10) - 126 parseInt(elStyle.getPropertyValue('padding-top'), 10) -
127 parseInt(elStyle.getPropertyValue('padding-bottom'), 10) - 127 parseInt(elStyle.getPropertyValue('padding-bottom'), 10) -
128 this.getChildElement('.settings-area').offsetTop - 128 this.getChildElement('.settings-area').offsetTop -
129 this.getChildElement('.action-area').offsetHeight; 129 this.getChildElement('.action-area').offsetHeight;
130 }, 130 },
131 131
132 /** 132 /**
133 * Filters displayed settings with the given query. 133 * Filters displayed settings with the given query.
134 * @param {?string} query Query to filter settings by. 134 * @param {?RegExp} query Query to filter settings by.
135 * @private 135 * @private
136 */ 136 */
137 filterLists_: function(query) { 137 filterLists_: function(query) {
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 this.getChildElement('.no-settings-match-hint'), !atLeastOneMatch); 148 assert(this.getChildElement('.no-settings-match-hint')),
149 !atLeastOneMatch);
149 setIsVisible( 150 setIsVisible(
150 this.getChildElement('.' + AdvancedSettings.Classes_.EXTRA_PADDING), 151 assert(this.getChildElement(
152 '.' + AdvancedSettings.Classes_.EXTRA_PADDING)),
151 !!lastVisibleItemWithBubble); 153 !!lastVisibleItemWithBubble);
152 }, 154 },
153 155
154 /** 156 /**
155 * Resets the filter query. 157 * Resets the filter query.
156 * @private 158 * @private
157 */ 159 */
158 resetSearch_: function() { 160 resetSearch_: function() {
159 this.searchBox_.setQuery(null); 161 this.searchBox_.setQuery(null);
160 this.filterLists_(null); 162 this.filterLists_(null);
(...skipping 19 matching lines...) Expand all
180 if (!vendorCapabilities) 182 if (!vendorCapabilities)
181 return; 183 return;
182 184
183 var availableHeight = this.getAvailableContentHeight_(); 185 var availableHeight = this.getAvailableContentHeight_();
184 var containerEl = this.getChildElement('.settings-area'); 186 var containerEl = this.getChildElement('.settings-area');
185 containerEl.style.maxHeight = availableHeight + 'px'; 187 containerEl.style.maxHeight = availableHeight + 'px';
186 var settingsEl = this.getChildElement('.settings'); 188 var settingsEl = this.getChildElement('.settings');
187 189
188 vendorCapabilities.forEach(function(capability) { 190 vendorCapabilities.forEach(function(capability) {
189 var item = new print_preview.AdvancedSettingsItem( 191 var item = new print_preview.AdvancedSettingsItem(
190 this.eventTarget_, this.printTicketStore_, capability); 192 this.printTicketStore_, capability);
191 this.addChild(item); 193 this.addChild(item);
192 item.render(settingsEl); 194 item.render(assert(settingsEl));
193 this.items_.push(item); 195 this.items_.push(item);
194 }.bind(this)); 196 }.bind(this));
195 197
196 if (this.items_.length <= 1) { 198 if (this.items_.length <= 1) {
197 setIsVisible(this.getChildElement('.search-box-area'), false); 199 setIsVisible(assert(this.getChildElement('.search-box-area')), false);
dpapad 2017/05/04 01:20:04 Nit: Assertions are not free. Perhaps use a local
rbpotter 2017/05/04 01:43:06 Done.
198 } else { 200 } else {
199 setIsVisible(this.getChildElement('.search-box-area'), true); 201 setIsVisible(assert(this.getChildElement('.search-box-area')), true);
200 this.searchBox_.focus(); 202 this.searchBox_.focus();
201 } 203 }
202 204
203 extraPadding = document.createElement('div'); 205 extraPadding = document.createElement('div');
204 extraPadding.classList.add(AdvancedSettings.Classes_.EXTRA_PADDING); 206 extraPadding.classList.add(AdvancedSettings.Classes_.EXTRA_PADDING);
205 extraPadding.hidden = true; 207 extraPadding.hidden = true;
206 settingsEl.appendChild(extraPadding); 208 settingsEl.appendChild(extraPadding);
207 }, 209 },
208 210
209 /** 211 /**
(...skipping 21 matching lines...) Expand all
231 233
232 this.printTicketStore_.vendorItems.updateValue(values); 234 this.printTicketStore_.vendorItems.updateValue(values);
233 } 235 }
234 }; 236 };
235 237
236 // Export 238 // Export
237 return { 239 return {
238 AdvancedSettings: AdvancedSettings 240 AdvancedSettings: AdvancedSettings
239 }; 241 };
240 }); 242 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698