summaryrefslogtreecommitdiff
path: root/misc/farbtastic
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2008-06-12 19:49:10 +0000
committerDries Buytaert <dries@buytaert.net>2008-06-12 19:49:10 +0000
commitaa8c6466ccd4aae7ce5e84033bc4d9b9fb4f8af4 (patch)
tree291b94a87f4606e3ca40f46a272137246b7162df /misc/farbtastic
parenta251ff70fc5b49abc1a4556945c5f63afcdb01fa (diff)
downloadbrdo-aa8c6466ccd4aae7ce5e84033bc4d9b9fb4f8af4.tar.gz
brdo-aa8c6466ccd4aae7ce5e84033bc4d9b9fb4f8af4.tar.bz2
- Patch #256285 by mfer: upgraded to jQuery 1.2.6. This patch was tested
extensively by mfer but might be slightly experimental still. Hard to test.
Diffstat (limited to 'misc/farbtastic')
-rw-r--r--misc/farbtastic/farbtastic.js88
1 files changed, 37 insertions, 51 deletions
diff --git a/misc/farbtastic/farbtastic.js b/misc/farbtastic/farbtastic.js
index c89e94029..da87a0df8 100644
--- a/misc/farbtastic/farbtastic.js
+++ b/misc/farbtastic/farbtastic.js
@@ -105,48 +105,48 @@ jQuery._farbtastic = function (container, callback) {
var el = event.target || event.srcElement;
var reference = fb.wheel;
- if (typeof event.offsetX != 'undefined') {
- // 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;
- }
+ // 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;
+ }
- // 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;
- }
+ // 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;
+ }
- // Reset stored coordinates
- e = el;
- while (e) {
- e.mouseX = undefined;
- e.mouseY = undefined;
- 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;
}
- else {
- // Use absolute coordinates
- var pos = fb.absolutePosition(reference);
- x = (event.pageX || 0*(event.clientX + $('html').get(0).scrollLeft)) - pos.x;
- y = (event.pageY || 0*(event.clientY + $('html').get(0).scrollTop)) - pos.y;
+
+ // 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 };
};
@@ -240,20 +240,6 @@ jQuery._farbtastic = function (container, callback) {
}
};
- /**
- * Get absolute position of element
- */
- fb.absolutePosition = function (el) {
- var r = { x: el.offsetLeft, y: el.offsetTop };
- // Resolve relative to offsetParent
- if (el.offsetParent) {
- var tmp = fb.absolutePosition(el.offsetParent);
- r.x += tmp.x;
- r.y += tmp.y;
- }
- return r;
- };
-
/* Various color utility functions */
fb.pack = function (rgb) {
var r = Math.round(rgb[0] * 255);