[FIX] excessive horizontal and vertical offsetting of edition button on images in webkit browsers

Manually adding margins to offsets was necessary due to
http://bugs.jquery.com/ticket/5445#comment:6 and the original code
using $.fn.position().

When edition buttons were moved to being children of the body (rather
than siblings of the image), $.fn.position() was replaced by
$.fn.offset() (to get the position of the image/link relative to the
body/page toplevel), the adjustment (addition of marginLeft/marginTop)
was left in, even though #5445 does not apply to $.fn.offset().

bzr revid: xmo@openerp.com-20140120144610-nu8q2naemzzhekv2
This commit is contained in:
Xavier Morel
2014-01-20 15:46:10 +01:00
parent 3ad6be4466
commit 620652c420
@@ -638,16 +638,14 @@
var $selected = $(this);
var position = $selected.offset();
if ($selected.is('img')) {
var image_top = position.top + parseInt($selected.css('marginTop'), 10);
var image_left = position.left + parseInt($selected.css('marginLeft'), 10);
$link_button.hide();
// center button on image
$image_button.show().offset({
top: $selected.outerHeight() / 2
+ image_top
+ position.top
- $image_button.outerHeight() / 2,
left: $selected.outerWidth() / 2
+ image_left
+ position.left
- $image_button.outerWidth() / 2,
});
} else {