OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 * Component used for searching for a print destination. | 9 * Component used for searching for a print destination. |
10 * This is a modal dialog that allows the user to search and select a | 10 * This is a modal dialog that allows the user to search and select a |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 116 |
117 // Dispatched when the user requests to manage their local destinations. | 117 // Dispatched when the user requests to manage their local destinations. |
118 MANAGE_LOCAL_DESTINATIONS: | 118 MANAGE_LOCAL_DESTINATIONS: |
119 'print_preview.DestinationSearch.MANAGE_LOCAL_DESTINATIONS', | 119 'print_preview.DestinationSearch.MANAGE_LOCAL_DESTINATIONS', |
120 | 120 |
121 // Dispatched when the user requests to sign-in to their Google account. | 121 // Dispatched when the user requests to sign-in to their Google account. |
122 SIGN_IN: 'print_preview.DestinationSearch.SIGN_IN' | 122 SIGN_IN: 'print_preview.DestinationSearch.SIGN_IN' |
123 }; | 123 }; |
124 | 124 |
125 /** | 125 /** |
126 * Padding at the bottom of a destination list in pixels. | |
127 * @type {number} | |
128 * @const | |
129 * @private | |
130 */ | |
131 DestinationSearch.LIST_BOTTOM_PADDING_ = 18; | |
132 | |
133 /** | |
134 * Number of unregistered destinations that may be promoted to the top. | 126 * Number of unregistered destinations that may be promoted to the top. |
135 * @type {number} | 127 * @type {number} |
136 * @const | 128 * @const |
137 * @private | 129 * @private |
138 */ | 130 */ |
139 DestinationSearch.MAX_PROMOTED_UNREGISTERED_PRINTERS_ = 2; | 131 DestinationSearch.MAX_PROMOTED_UNREGISTERED_PRINTERS_ = 2; |
140 | 132 |
141 DestinationSearch.prototype = { | 133 DestinationSearch.prototype = { |
142 __proto__: print_preview.Overlay.prototype, | 134 __proto__: print_preview.Overlay.prototype, |
143 | 135 |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 } | 375 } |
384 | 376 |
385 var hasCloudList = getIsVisible(this.getChildElement('.cloud-list')); | 377 var hasCloudList = getIsVisible(this.getChildElement('.cloud-list')); |
386 var lists = [this.recentList_, this.localList_]; | 378 var lists = [this.recentList_, this.localList_]; |
387 if (hasCloudList) { | 379 if (hasCloudList) { |
388 lists.push(this.cloudList_); | 380 lists.push(this.cloudList_); |
389 } | 381 } |
390 | 382 |
391 var getListsTotalHeight = function(lists, counts) { | 383 var getListsTotalHeight = function(lists, counts) { |
392 return lists.reduce(function(sum, list, index) { | 384 return lists.reduce(function(sum, list, index) { |
| 385 var container = list.getContainerElement(); |
393 return sum + list.getEstimatedHeightInPixels(counts[index]) + | 386 return sum + list.getEstimatedHeightInPixels(counts[index]) + |
394 DestinationSearch.LIST_BOTTOM_PADDING_; | 387 parseInt(window.getComputedStyle(container).paddingBottom, 10); |
395 }, 0); | 388 }, 0); |
396 }; | 389 }; |
397 var getCounts = function(lists, count) { | 390 var getCounts = function(lists, count) { |
398 return lists.map(function(list) { return count; }); | 391 return lists.map(function(list) { return count; }); |
399 }; | 392 }; |
400 | 393 |
401 var availableHeight = this.getAvailableListsHeight_(); | 394 var availableHeight = this.getAvailableListsHeight_(); |
402 var listsEl = this.getChildElement('.lists'); | 395 var listsEl = this.getChildElement('.lists'); |
403 listsEl.style.maxHeight = availableHeight + 'px'; | 396 listsEl.style.maxHeight = availableHeight + 'px'; |
404 | 397 |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 onWindowResize_: function() { | 688 onWindowResize_: function() { |
696 this.reflowLists_(); | 689 this.reflowLists_(); |
697 } | 690 } |
698 }; | 691 }; |
699 | 692 |
700 // Export | 693 // Export |
701 return { | 694 return { |
702 DestinationSearch: DestinationSearch | 695 DestinationSearch: DestinationSearch |
703 }; | 696 }; |
704 }); | 697 }); |
OLD | NEW |