| OLD | NEW |
| 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 this.getChildElement('.settings-area').offsetTop - | 119 this.getChildElement('.settings-area').offsetTop - |
| 120 this.getChildElement('.action-area').offsetHeight; | 120 this.getChildElement('.action-area').offsetHeight; |
| 121 }, | 121 }, |
| 122 | 122 |
| 123 /** | 123 /** |
| 124 * Filters displayed settings with the given query. | 124 * Filters displayed settings with the given query. |
| 125 * @param {?string} query Query to filter settings by. | 125 * @param {?string} query Query to filter settings by. |
| 126 * @private | 126 * @private |
| 127 */ | 127 */ |
| 128 filterLists_: function(query) { | 128 filterLists_: function(query) { |
| 129 var lastVisibleItemWithBubble = null; |
| 129 this.items_.forEach(function(item) { | 130 this.items_.forEach(function(item) { |
| 130 item.updateSearchQuery(query); | 131 item.updateSearchQuery(query); |
| 132 if (item.searchBubbleShown) |
| 133 lastVisibleItemWithBubble = item; |
| 131 }); | 134 }); |
| 135 setIsVisible( |
| 136 this.getChildElement('.advanced-settings-item-extra-padding'), |
| 137 !!lastVisibleItemWithBubble); |
| 132 }, | 138 }, |
| 133 | 139 |
| 134 /** | 140 /** |
| 135 * Resets the filter query. | 141 * Resets the filter query. |
| 136 * @private | 142 * @private |
| 137 */ | 143 */ |
| 138 resetSearch_: function() { | 144 resetSearch_: function() { |
| 139 this.searchBox_.setQuery(null); | 145 this.searchBox_.setQuery(null); |
| 140 this.filterLists_(null); | 146 this.filterLists_(null); |
| 141 }, | 147 }, |
| 142 | 148 |
| 143 /** | 149 /** |
| 144 * Renders all of the available settings. | 150 * Renders all of the available settings. |
| 145 * @private | 151 * @private |
| 146 */ | 152 */ |
| 147 renderSettings_: function() { | 153 renderSettings_: function() { |
| 148 // Remove all children settings elements. | 154 // Remove all children settings elements. |
| 149 this.items_.forEach(function(item) { | 155 this.items_.forEach(function(item) { |
| 150 this.removeChild(item); | 156 this.removeChild(item); |
| 151 }.bind(this)); | 157 }.bind(this)); |
| 152 this.items_ = []; | 158 this.items_ = []; |
| 153 | 159 |
| 154 var vendorCapabilities = this.printTicketStore_.vendorItems.capability; | 160 var vendorCapabilities = this.printTicketStore_.vendorItems.capability; |
| 155 if (!vendorCapabilities) | 161 if (!vendorCapabilities) |
| 156 return; | 162 return; |
| 157 | 163 |
| 158 var availableHeight = this.getAvailableContentHeight_(); | 164 var availableHeight = this.getAvailableContentHeight_(); |
| 159 var containerEl = this.getChildElement('.settings-area'); | 165 var containerEl = this.getChildElement('.settings-area'); |
| 160 containerEl.style.maxHeight = availableHeight + 'px'; | 166 containerEl.style.maxHeight = availableHeight + 'px'; |
| 167 var settingsEl = this.getChildElement('.settings'); |
| 161 | 168 |
| 162 vendorCapabilities.forEach(function(capability) { | 169 vendorCapabilities.forEach(function(capability) { |
| 163 var item = new print_preview.AdvancedSettingsItem( | 170 var item = new print_preview.AdvancedSettingsItem( |
| 164 this.eventTarget_, this.printTicketStore_, capability); | 171 this.eventTarget_, this.printTicketStore_, capability); |
| 165 this.addChild(item); | 172 this.addChild(item); |
| 166 item.render(this.getChildElement('.settings')); | 173 item.render(settingsEl); |
| 167 this.items_.push(item); | 174 this.items_.push(item); |
| 168 }.bind(this)); | 175 }.bind(this)); |
| 176 |
| 177 var extraPadding = document.createElement('div'); |
| 178 extraPadding.classList.add('advanced-settings-item-extra-padding'); |
| 179 extraPadding.hidden = true; |
| 180 settingsEl.appendChild(extraPadding); |
| 169 }, | 181 }, |
| 170 | 182 |
| 171 /** | 183 /** |
| 172 * Called when settings search query changes. Filters displayed settings | 184 * Called when settings search query changes. Filters displayed settings |
| 173 * with the given query. | 185 * with the given query. |
| 174 * @param {Event} evt Contains search query. | 186 * @param {Event} evt Contains search query. |
| 175 * @private | 187 * @private |
| 176 */ | 188 */ |
| 177 onSearch_: function(evt) { | 189 onSearch_: function(evt) { |
| 178 this.filterLists_(evt.queryRegExp); | 190 this.filterLists_(evt.queryRegExp); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 193 | 205 |
| 194 this.printTicketStore_.vendorItems.updateValue(values); | 206 this.printTicketStore_.vendorItems.updateValue(values); |
| 195 } | 207 } |
| 196 }; | 208 }; |
| 197 | 209 |
| 198 // Export | 210 // Export |
| 199 return { | 211 return { |
| 200 AdvancedSettings: AdvancedSettings | 212 AdvancedSettings: AdvancedSettings |
| 201 }; | 213 }; |
| 202 }); | 214 }); |
| OLD | NEW |