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 * Encapsulated handling of a search bubble. | 9 * Encapsulated handling of a search bubble. |
10 * @constructor | 10 * @constructor |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 */ | 84 */ |
85 updatePosition: function() { | 85 updatePosition: function() { |
86 // This bubble is 'owned' by the next sibling. | 86 // This bubble is 'owned' by the next sibling. |
87 var owner = (this.wrapper || this).nextSibling; | 87 var owner = (this.wrapper || this).nextSibling; |
88 | 88 |
89 // If there isn't an offset parent, we have nothing to do. | 89 // If there isn't an offset parent, we have nothing to do. |
90 if (!owner.offsetParent) | 90 if (!owner.offsetParent) |
91 return; | 91 return; |
92 | 92 |
93 // Position the bubble below the location of the owner. | 93 // Position the bubble below the location of the owner. |
94 var left = owner.offsetLeft + owner.offsetWidth / 2 - | 94 var left = |
95 this.offsetWidth / 2; | 95 owner.offsetLeft + owner.offsetWidth / 2 - this.offsetWidth / 2; |
96 var top = owner.offsetTop + owner.offsetHeight; | 96 var top = owner.offsetTop + owner.offsetHeight; |
97 | 97 |
98 // Update the position in the CSS. Cache the last values for | 98 // Update the position in the CSS. Cache the last values for |
99 // best performance. | 99 // best performance. |
100 if (left != this.lastLeft) { | 100 if (left != this.lastLeft) { |
101 this.style.left = left + 'px'; | 101 this.style.left = left + 'px'; |
102 this.lastLeft = left; | 102 this.lastLeft = left; |
103 } | 103 } |
104 if (top != this.lastTop) { | 104 if (top != this.lastTop) { |
105 this.style.top = top + 'px'; | 105 this.style.top = top + 'px'; |
106 this.lastTop = top; | 106 this.lastTop = top; |
107 } | 107 } |
108 }, | 108 }, |
109 }; | 109 }; |
110 | 110 |
111 // Export | 111 // Export |
112 return { | 112 return {SearchBubble: SearchBubble}; |
113 SearchBubble: SearchBubble | |
114 }; | |
115 }); | 113 }); |
OLD | NEW |