Commit f381336d authored by Dries's avatar Dries

- Patch #323965 by mfer: update farbtastic widgetCoords to use jQuery.

parent 0adaec35
......@@ -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 };
};
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment