Skip to content
This repository has been archived by the owner on Jun 14, 2020. It is now read-only.

Commit

Permalink
Fixed imagemap plugin to take into account padding and border of images
Browse files Browse the repository at this point in the history
  • Loading branch information
Craga89 committed Nov 30, 2010
1 parent bcb52c6 commit a14fa60
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 66 deletions.
2 changes: 1 addition & 1 deletion dist/jquery.qtip.css
Expand Up @@ -9,7 +9,7 @@
* http://en.wikipedia.org/wiki/MIT_License
* http://en.wikipedia.org/wiki/GNU_General_Public_License
*
* Date: Tue Nov 30 02:30:24 2010 +0000
* Date: Tue Nov 30 02:48:10 2010 +0000
*/

.ui-tooltip-accessible{
Expand Down
9 changes: 7 additions & 2 deletions dist/jquery.qtip.js
Expand Up @@ -9,7 +9,7 @@
* http://en.wikipedia.org/wiki/MIT_License
* http://en.wikipedia.org/wiki/GNU_General_Public_License
*
* Date: Tue Nov 30 02:30:24 2010 +0000
* Date: Tue Nov 30 02:48:10 2010 +0000
*/

"use strict"; // Enable ECMAScript "strict" operation for this function. See more: http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/
Expand Down Expand Up @@ -2186,7 +2186,8 @@ $.extend(TRUE, $.fn.qtip.defaults, {
var shape = area.attr('shape').toLowerCase(),
baseCoords = area.attr('coords').split(','),
coords = [],
imageOffset = $('img[usemap="#'+area.parent('map').attr('name')+'"]').offset(),
image = $('img[usemap="#'+area.parent('map').attr('name')+'"]'),
imageOffset = image.offset(),
result = {
width: 0, height: 0,
offset: { top: 1e10, right: 0, bottom: 0, left: 1e10 }
Expand Down Expand Up @@ -2239,6 +2240,10 @@ $.extend(TRUE, $.fn.qtip.defaults, {
return { left: coords[0][0], top: coords[0][1] };
}

// Make sure we account for padding and borders on the image
imageOffset.left += Math.floor((image.outerWidth() - image.width()) / 2);
imageOffset.top += Math.floor((image.outerHeight() - image.height()) / 2);

// Parse coordinates into proper array
if(shape === 'poly') {
i = baseCoords.length; while(i--)
Expand Down

0 comments on commit a14fa60

Please sign in to comment.