OLD | NEW |
---|---|
1 // Copyright (C) 2013 Google Inc. All rights reserved. | 1 // Copyright (C) 2013 Google Inc. All rights reserved. |
2 // | 2 // |
3 // Redistribution and use in source and binary forms, with or without | 3 // Redistribution and use in source and binary forms, with or without |
4 // modification, are permitted provided that the following conditions are | 4 // modification, are permitted provided that the following conditions are |
5 // met: | 5 // met: |
6 // | 6 // |
7 // * Redistributions of source code must retain the above copyright | 7 // * Redistributions of source code must retain the above copyright |
8 // notice, this list of conditions and the following disclaimer. | 8 // notice, this list of conditions and the following disclaimer. |
9 // * Redistributions in binary form must reproduce the above | 9 // * Redistributions in binary form must reproduce the above |
10 // copyright notice, this list of conditions and the following disclaimer | 10 // copyright notice, this list of conditions and the following disclaimer |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 document.addEventListener('mousedown', ui.popup._handleMouseDown, false) ; | 51 document.addEventListener('mousedown', ui.popup._handleMouseDown, false) ; |
52 } | 52 } |
53 | 53 |
54 // Set html first so that we can get accurate size metrics on the popup. | 54 // Set html first so that we can get accurate size metrics on the popup. |
55 popup.innerHTML = html; | 55 popup.innerHTML = html; |
56 | 56 |
57 var targetRect = target.getBoundingClientRect(); | 57 var targetRect = target.getBoundingClientRect(); |
58 | 58 |
59 var x = Math.min(targetRect.left - 10, document.documentElement.clientWidth - popup.offsetWidth); | 59 var x = Math.min(targetRect.left - 10, document.documentElement.clientWidth - popup.offsetWidth); |
60 x = Math.max(0, x); | 60 x = Math.max(0, x); |
61 popup.style.left = x + document.body.scrollLeft + 'px'; | 61 popup.style.left = x + window.pageXOffset + 'px'; |
ojan
2014/06/29 03:46:37
This part of the web platform is so crufty. :(
| |
62 | 62 |
63 var y = targetRect.top + targetRect.height; | 63 var y = targetRect.top + targetRect.height; |
64 if (y + popup.offsetHeight > document.documentElement.clientHeight) | 64 if (y + popup.offsetHeight > document.documentElement.clientHeight) |
65 y = targetRect.top - popup.offsetHeight; | 65 y = targetRect.top - popup.offsetHeight; |
66 y = Math.max(0, y); | 66 y = Math.max(0, y); |
67 popup.style.top = y + document.body.scrollTop + 'px'; | 67 popup.style.top = y + window.pageYOffset + 'px'; |
68 } | 68 } |
69 | 69 |
70 ui.popup._handleMouseDown = function(e) { | 70 ui.popup._handleMouseDown = function(e) { |
71 // Clear the open popup, unless the click was inside the popup. | 71 // Clear the open popup, unless the click was inside the popup. |
72 var popup = $('popup'); | 72 var popup = $('popup'); |
73 if (popup && e.target != popup && !(popup.compareDocumentPosition(e.target) & 16)) | 73 if (popup && e.target != popup && !(popup.compareDocumentPosition(e.target) & 16)) |
74 ui.popup.hide(); | 74 ui.popup.hide(); |
75 } | 75 } |
76 | 76 |
77 ui.html = {}; | 77 ui.html = {}; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
221 { | 221 { |
222 this._messages += message + '<br>'; | 222 this._messages += message + '<br>'; |
223 }, | 223 }, |
224 hasErrors: function() | 224 hasErrors: function() |
225 { | 225 { |
226 return !!this._messages; | 226 return !!this._messages; |
227 } | 227 } |
228 } | 228 } |
229 | 229 |
230 })(); | 230 })(); |
OLD | NEW |