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

Commit

Permalink
Event targetting now caches event target for reposition method
Browse files Browse the repository at this point in the history
PRior to this commit when using 'event' for the position target, calling the reposition
method with no event object would cause an error, since the method had no target reference
to use for positioning calculations. Previous target is now used if no event object is provided
to prevent this issue.
  • Loading branch information
Craga89 committed Jul 28, 2010
1 parent a7afb92 commit d947638
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/core.js
Expand Up @@ -100,7 +100,7 @@ function QTip(target, options, id)
self.id = id;
self.rendered = FALSE;
self.elements = { target: target };
self.cache = { event: {}, disabled: FALSE, posClass: FALSE };
self.cache = { event: {}, target: NULL, disabled: FALSE, posClass: FALSE };
self.timers = {};
self.options = options;
self.plugins = {};
Expand Down Expand Up @@ -813,7 +813,7 @@ function QTip(target, options, id)
{
if(self.rendered === FALSE) { return FALSE; }

var target = options.position.target === 'event' && event ? $(event.target) : options.position.target,
var target = options.position.target,
tooltip = self.elements.tooltip,
posOptions = options.position,
my = posOptions.my,
Expand Down Expand Up @@ -869,6 +869,17 @@ function QTip(target, options, id)
position = { top: event.pageY, left: event.pageX };
}
else {
// Check if event targetting is being used
if(target === 'event') {
if(event && event.target) {
target = self.cache.target = $(event.target)
}
else {
target = self.cache.target;
}
}

// Check if window or document is the target
if(target[0] === document || target[0] === window) {
targetWidth = target.width();
targetHeight = target.height();
Expand All @@ -877,12 +888,15 @@ function QTip(target, options, id)
left: target.scrollLeft()
};
}

// Use Imagemap plugin if target is an AREA element
else if(target.is('area') && $.fn.qtip.plugins.imagemap) {
position = $.fn.qtip.plugins.imagemap(target, at);
targetWidth = position.width;
targetHeight = position.height;
position = position.offset;
}

else {
targetWidth = target.outerWidth();
targetHeight = target.outerHeight();
Expand Down

0 comments on commit d947638

Please sign in to comment.