summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2008-10-22 18:27:51 +0000
committerDries Buytaert <dries@buytaert.net>2008-10-22 18:27:51 +0000
commitf381336d9fae43fca1bf49fd3323d0e90cee4e6e (patch)
treef81217289bfbbcb1caa84f1b1f14b0257fc6d2dd /misc
parent0adaec35bdcb227700164e1425cce4ab83cfcf61 (diff)
downloadbrdo-f381336d9fae43fca1bf49fd3323d0e90cee4e6e.tar.gz
brdo-f381336d9fae43fca1bf49fd3323d0e90cee4e6e.tar.bz2
- Patch #323965 by mfer: update farbtastic widgetCoords to use jQuery.
Diffstat (limited to 'misc')
-rw-r--r--misc/farbtastic/farbtastic.js50
1 files changed, 2 insertions, 48 deletions
diff --git a/misc/farbtastic/farbtastic.js b/misc/farbtastic/farbtastic.js
index da87a0df8..028b00b36 100644
--- a/misc/farbtastic/farbtastic.js
+++ b/misc/farbtastic/farbtastic.js
@@ -101,54 +101,8 @@ jQuery._farbtastic = function (container, callback) {
* of the widget.
*/
fb.widgetCoords = function (event) {
- var x, y;
- var el = event.target || event.srcElement;
- var reference = fb.wheel;
-
- // If the offset from the relative element is undefined calculate it.
- if ( typeof event.offsetX == 'undefined' && typeof event.offsetY == 'undefined' ) {
- var offset = $(event.target).offset(false);
- event.offsetX = event.pageX - offset.left;
- event.offsetY = event.pageY - offset.top;
- }
-
- // Use offset coordinates and find common offsetParent
- var pos = { x: event.offsetX, y: event.offsetY };
-
- // Send the coordinates upwards through the offsetParent chain.
- var e = el;
- while (e) {
- e.mouseX = pos.x;
- e.mouseY = pos.y;
- pos.x += e.offsetLeft;
- pos.y += e.offsetTop;
- e = e.offsetParent;
- }
-
- // Look for the coordinates starting from the wheel widget.
- var e = reference;
- var offset = { x: 0, y: 0 };
- while (e) {
- if (typeof e.mouseX != 'undefined') {
- x = e.mouseX - offset.x;
- y = e.mouseY - offset.y;
- break;
- }
- offset.x += e.offsetLeft;
- offset.y += e.offsetTop;
- e = e.offsetParent;
- }
-
- // Reset stored coordinates
- e = el;
- while (e) {
- e.mouseX = undefined;
- e.mouseY = undefined;
- e = e.offsetParent;
- }
-
- // Subtract distance to middle
- return { x: x - fb.width / 2, y: y - fb.width / 2 };
+ var offset = $(fb.wheel).offset();
+ return { x: (event.pageX - offset.left) - fb.width / 2, y: (event.pageY - offset.top) - fb.width / 2 };
};
/**