mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 08:42:41 +01:00
Hovercards - make 'em work a bit better
Summary: this diff makes hovercards load and draw but a single time as appropos; pre-diff we could hammer the server by moving the mouse a bunch before the initial load and the re-draw event was continuously firing. also makes hovercards work inside whacked out divs like the Conpherence message panel. Fixes T2949. Test Plan: played with conpherence and phriction, observing hovercards showing up like they should Reviewers: epriestley, chad Reviewed By: epriestley CC: AnhNhan, aran, Korvin Maniphest Tasks: T2949 Differential Revision: https://secure.phabricator.com/D5719
This commit is contained in:
parent
9d5fc041f6
commit
58e35518b6
2 changed files with 30 additions and 9 deletions
13
webroot/rsrc/externals/javelin/lib/Vector.js
vendored
13
webroot/rsrc/externals/javelin/lib/Vector.js
vendored
|
@ -238,9 +238,16 @@ JX.install('Vector', {
|
|||
var x = 0;
|
||||
var y = 0;
|
||||
do {
|
||||
x += node.offsetLeft;
|
||||
y += node.offsetTop;
|
||||
node = node.offsetParent;
|
||||
var offsetParent = node.offsetParent;
|
||||
var scrollLeft = 0;
|
||||
var scrollTop = 0;
|
||||
if (offsetParent && offsetParent != document.body) {
|
||||
scrollLeft = offsetParent.scrollLeft;
|
||||
scrollTop = offsetParent.scrollTop;
|
||||
}
|
||||
x += (node.offsetLeft - scrollLeft);
|
||||
y += (node.offsetTop - scrollTop);
|
||||
node = offsetParent;
|
||||
} while (node && node != document.body);
|
||||
|
||||
return new JX.Vector(x, y);
|
||||
|
|
|
@ -27,18 +27,21 @@ JX.install('Hovercard', {
|
|||
},
|
||||
|
||||
getCard : function() {
|
||||
return this._node;
|
||||
var self = JX.Hovercard;
|
||||
return self._node;
|
||||
},
|
||||
|
||||
show : function(root, phid) {
|
||||
var self = JX.Hovercard;
|
||||
// Already displaying
|
||||
if (self.getCard() && phid == self._visiblePHID) {
|
||||
return;
|
||||
}
|
||||
self.hide();
|
||||
|
||||
self._visiblePHID = phid;
|
||||
self._activeRoot = root;
|
||||
|
||||
// Hovercards are all loaded by now, but when somebody previews a comment
|
||||
// for example it may not be loaded yet.
|
||||
if (!(phid in self._cards)) {
|
||||
self._load([phid]);
|
||||
} else {
|
||||
|
@ -48,8 +51,8 @@ JX.install('Hovercard', {
|
|||
|
||||
_drawCard : function(phid) {
|
||||
var self = JX.Hovercard;
|
||||
// Already displaying
|
||||
if (self.getCard() && phid == self._visiblePHID) {
|
||||
// card is loading...
|
||||
if (self._cards[phid] === true) {
|
||||
return;
|
||||
}
|
||||
// Not the current requested card
|
||||
|
@ -74,7 +77,6 @@ JX.install('Hovercard', {
|
|||
|
||||
// Retrieve size from child (wrapper), since node gives wrong dimensions?
|
||||
var child = node.firstChild;
|
||||
|
||||
var p = JX.$V(root);
|
||||
var d = JX.Vector.getDim(root);
|
||||
var n = JX.Vector.getDim(child);
|
||||
|
@ -122,8 +124,20 @@ JX.install('Hovercard', {
|
|||
var self = JX.Hovercard;
|
||||
var uri = JX.$U(self.fetchUrl);
|
||||
|
||||
var send = false;
|
||||
for (var ii = 0; ii < phids.length; ii++) {
|
||||
var phid = phids[ii];
|
||||
if (phid in self._cards) {
|
||||
continue;
|
||||
}
|
||||
self._cards[phid] = true; // means "loading"
|
||||
uri.setQueryParam("phids["+ii+"]", phids[ii]);
|
||||
send = true;
|
||||
}
|
||||
|
||||
if (!send) {
|
||||
// already loaded / loading everything!
|
||||
return;
|
||||
}
|
||||
|
||||
new JX.Request(uri, function(r) {
|
||||
|
|
Loading…
Reference in a new issue