mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-30 02:32:42 +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 x = 0;
|
||||||
var y = 0;
|
var y = 0;
|
||||||
do {
|
do {
|
||||||
x += node.offsetLeft;
|
var offsetParent = node.offsetParent;
|
||||||
y += node.offsetTop;
|
var scrollLeft = 0;
|
||||||
node = node.offsetParent;
|
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);
|
} while (node && node != document.body);
|
||||||
|
|
||||||
return new JX.Vector(x, y);
|
return new JX.Vector(x, y);
|
||||||
|
|
|
@ -27,18 +27,21 @@ JX.install('Hovercard', {
|
||||||
},
|
},
|
||||||
|
|
||||||
getCard : function() {
|
getCard : function() {
|
||||||
return this._node;
|
var self = JX.Hovercard;
|
||||||
|
return self._node;
|
||||||
},
|
},
|
||||||
|
|
||||||
show : function(root, phid) {
|
show : function(root, phid) {
|
||||||
var self = JX.Hovercard;
|
var self = JX.Hovercard;
|
||||||
|
// Already displaying
|
||||||
|
if (self.getCard() && phid == self._visiblePHID) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
self.hide();
|
self.hide();
|
||||||
|
|
||||||
self._visiblePHID = phid;
|
self._visiblePHID = phid;
|
||||||
self._activeRoot = root;
|
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)) {
|
if (!(phid in self._cards)) {
|
||||||
self._load([phid]);
|
self._load([phid]);
|
||||||
} else {
|
} else {
|
||||||
|
@ -48,8 +51,8 @@ JX.install('Hovercard', {
|
||||||
|
|
||||||
_drawCard : function(phid) {
|
_drawCard : function(phid) {
|
||||||
var self = JX.Hovercard;
|
var self = JX.Hovercard;
|
||||||
// Already displaying
|
// card is loading...
|
||||||
if (self.getCard() && phid == self._visiblePHID) {
|
if (self._cards[phid] === true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Not the current requested card
|
// Not the current requested card
|
||||||
|
@ -74,7 +77,6 @@ JX.install('Hovercard', {
|
||||||
|
|
||||||
// Retrieve size from child (wrapper), since node gives wrong dimensions?
|
// Retrieve size from child (wrapper), since node gives wrong dimensions?
|
||||||
var child = node.firstChild;
|
var child = node.firstChild;
|
||||||
|
|
||||||
var p = JX.$V(root);
|
var p = JX.$V(root);
|
||||||
var d = JX.Vector.getDim(root);
|
var d = JX.Vector.getDim(root);
|
||||||
var n = JX.Vector.getDim(child);
|
var n = JX.Vector.getDim(child);
|
||||||
|
@ -122,8 +124,20 @@ JX.install('Hovercard', {
|
||||||
var self = JX.Hovercard;
|
var self = JX.Hovercard;
|
||||||
var uri = JX.$U(self.fetchUrl);
|
var uri = JX.$U(self.fetchUrl);
|
||||||
|
|
||||||
|
var send = false;
|
||||||
for (var ii = 0; ii < phids.length; ii++) {
|
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]);
|
uri.setQueryParam("phids["+ii+"]", phids[ii]);
|
||||||
|
send = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!send) {
|
||||||
|
// already loaded / loading everything!
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
new JX.Request(uri, function(r) {
|
new JX.Request(uri, function(r) {
|
||||||
|
|
Loading…
Reference in a new issue