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

Commit

Permalink
Use .has() instead of .closest() to fix 'unfocus' event in jQuery 1.4…
Browse files Browse the repository at this point in the history
….4 (Thanks m4olivei)
  • Loading branch information
Craga89 committed Feb 27, 2012
1 parent dda65be commit 384c70a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions dist/jquery.qtip.basic.js
Expand Up @@ -9,7 +9,7 @@
* http://en.wikipedia.org/wiki/MIT_License
* http://en.wikipedia.org/wiki/GNU_General_Public_License
*
* Date: Mon Feb 27 01:41:07 2012 +0000
* Date: Mon Feb 27 02:03:04 2012 +0000
*/

/*jslint browser: true, onevar: true, undef: true, nomen: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: true */
Expand Down Expand Up @@ -557,12 +557,12 @@ function QTip(target, options, id, attr)
// Hide tooltip on document mousedown if unfocus events are enabled
if(('' + options.hide.event).indexOf('unfocus') > -1) {
posOptions.container.closest('html').bind('mousedown'+namespace, function(event) {
var $target = $(event.target),
var elem = $(event.target),
enabled = !tooltip.hasClass(disabled) && tooltip.is(':visible'),
isAncestor = $target.parents(selector).filter(tooltip[0]).length > 0;
isAncestor = elem.parents(selector).filter(tooltip[0]).length > 0;

if($target[0] !== tooltip[0] && !isAncestor &&
!$target.closest(target).length && !$target.attr('disabled')
if(elem[0] !== target[0] && elem[0] !== tooltip[0] && !isAncestor &&
!target.has(elem[0]).length && !elem.attr('disabled')
) {
self.hide(event);
}
Expand Down
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: Mon Feb 27 01:41:07 2012 +0000
* Date: Mon Feb 27 02:03:04 2012 +0000
*/

/* Core qTip styles */
Expand Down
10 changes: 5 additions & 5 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: Mon Feb 27 01:41:07 2012 +0000
* Date: Mon Feb 27 02:03:04 2012 +0000
*/

/*jslint browser: true, onevar: true, undef: true, nomen: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: true */
Expand Down Expand Up @@ -557,12 +557,12 @@ function QTip(target, options, id, attr)
// Hide tooltip on document mousedown if unfocus events are enabled
if(('' + options.hide.event).indexOf('unfocus') > -1) {
posOptions.container.closest('html').bind('mousedown'+namespace, function(event) {
var $target = $(event.target),
var elem = $(event.target),
enabled = !tooltip.hasClass(disabled) && tooltip.is(':visible'),
isAncestor = $target.parents(selector).filter(tooltip[0]).length > 0;
isAncestor = elem.parents(selector).filter(tooltip[0]).length > 0;

if($target[0] !== tooltip[0] && !isAncestor &&
!$target.closest(target).length && !$target.attr('disabled')
if(elem[0] !== target[0] && elem[0] !== tooltip[0] && !isAncestor &&
!target.has(elem[0]).length && !elem.attr('disabled')
) {
self.hide(event);
}
Expand Down
4 changes: 2 additions & 2 deletions dist/jquery.qtip.min.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/core.js
Expand Up @@ -485,12 +485,12 @@ function QTip(target, options, id, attr)
// Hide tooltip on document mousedown if unfocus events are enabled
if(('' + options.hide.event).indexOf('unfocus') > -1) {
posOptions.container.closest('html').bind('mousedown'+namespace, function(event) {
var $target = $(event.target),
var elem = $(event.target),
enabled = !tooltip.hasClass(disabled) && tooltip.is(':visible'),
isAncestor = $target.parents(selector).filter(tooltip[0]).length > 0;
isAncestor = elem.parents(selector).filter(tooltip[0]).length > 0;

if($target[0] !== tooltip[0] && !isAncestor &&
!$target.closest(target).length && !$target.attr('disabled')
if(elem[0] !== target[0] && elem[0] !== tooltip[0] && !isAncestor &&
!target.has(elem[0]).length && !elem.attr('disabled')
) {
self.hide(event);
}
Expand Down

0 comments on commit 384c70a

Please sign in to comment.