diff options
| author | Xavier Morel <xmo@openerp.com> | 2013-11-22 11:11:54 +0100 |
|---|---|---|
| committer | Xavier Morel <xmo@openerp.com> | 2013-11-22 11:11:54 +0100 |
| commit | 1f2a40e3f78277a90b357b1e26d195bd548bec28 (patch) | |
| tree | 304e53bac8d91e418927ebb49171e9a507199a3d /addons/website/static/src/js/website.editor.js | |
| parent | 73d16d6d9b2b140cef42605c02721a4cf4bccb99 (diff) | |
[FIX] horizontal centering of edition button on images centered with margin: 0 auto in webkit-based browsers
bzr revid: xmo@openerp.com-20131122101154-fsae9uz33smy2ja9
Diffstat (limited to 'addons/website/static/src/js/website.editor.js')
| -rw-r--r-- | addons/website/static/src/js/website.editor.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index d1cb5781eba..aedd5b011d9 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -90,10 +90,18 @@ }); var position = $el.position(); + // http://bugs.jquery.com/ticket/5445#comment:6 + // if the image has margin: x auto for centering, FF & IE + // will report top/left as the "correct" value and + // marginTop/marginLeft at "0px", webkit browsers will + // report top/left as 0-ish and set marginTop and + // marginLeft + var image_top = position.top + parseInt($el.css('marginTop'), 10); + var image_left = position.left + parseInt($el.css('marginLeft'), 10); $btn.css({ position: 'absolute', - top: $el.height() / 2 + position.top - $btn.outerHeight() / 2, - left: $el.width() / 2 + position.left - $btn.outerWidth() / 2, + top: $el.height() / 2 + image_top - $btn.outerHeight() / 2, + left: $el.width() / 2 + image_left - $btn.outerWidth() / 2, }); }).on('mouseleave', 'img', function (e) { var $button = $(previousSelection.$).next('button'); |
