diff --git a/src/definitions/modules/popup.js b/src/definitions/modules/popup.js index 14ed8ad89..4a343c80b 100644 --- a/src/definitions/modules/popup.js +++ b/src/definitions/modules/popup.js @@ -148,6 +148,8 @@ $.fn.popup = function(parameters) { if($popup && !settings.preserve) { module.removePopup(); } + clearTimeout(module.hideTimer); + clearTimeout(module.showTimer); $module .off(eventNamespace) .removeData(moduleNamespace) @@ -163,7 +165,7 @@ $.fn.popup = function(parameters) { ; clearTimeout(module.hideTimer); module.showTimer = setTimeout(function() { - if( module.is.hidden() && !( module.is.active() && module.is.dropdown()) ) { + if(module.is.hidden() && !( module.is.active() && module.is.dropdown()) ) { module.show(); } }, delay); @@ -174,9 +176,10 @@ $.fn.popup = function(parameters) { ? settings.delay.hide : settings.delay ; + console.log($popup); clearTimeout(module.showTimer); module.hideTimer = setTimeout(function() { - if( module.is.visible() ) { + if(module.is.visible() ) { module.hide(); } }, delay); @@ -308,19 +311,22 @@ $.fn.popup = function(parameters) { return false; } if(settings.inline || settings.popup) { - return ( $popup.size() !== 0 ); + return ( module.has.popup() ); } else { - return ( $popup.closest($context).size() ); + return ( $popup.closest($context).size() > 1 ) + ? true + : false + ; } }, removePopup: function() { - module.debug('Removing popup'); - $.proxy(settings.onRemove, $popup)(element); - if($popup.size() > 0) { + module.debug('Removing popup', $popup); + if( module.has.popup() ) { $popup.remove(); } + $.proxy(settings.onRemove, $popup)(element); }, save: { @@ -731,7 +737,7 @@ $.fn.popup = function(parameters) { bind: { popup: function() { module.verbose('Allowing hover events on popup to prevent closing'); - if($popup && $popup.size() > 0) { + if( $popup && module.has.popup() ) { $popup .on('mouseenter' + eventNamespace, module.event.start) .on('mouseleave' + eventNamespace, module.event.end) @@ -780,6 +786,12 @@ $.fn.popup = function(parameters) { } }, + has: { + popup: function() { + return ($popup.size() > 0); + } + }, + is: { active: function() { return $module.hasClass(className.active);