(function(c){var a=c.Touchable;c.fn.Hoverable=function(d){return this.each(function(){var e=c(this).data.Hoverable=new b(this,d);return e;});};c.fn.newHover=function(f,e,d){return this.each(function(){c(this).bind("newHoverIn",f).bind("newHoverOut",e);});};c.fn.newHover2=function(e,d){return this.each(function(){c(this).bind("newHoverIn2",e).bind("newHoverOut2",d);});};function b(i,f){var e=this;this.logging=false;var g=function(j){if(e.logging&&(typeof console!=="undefined")){console.log(Array.prototype.slice.call(arguments));}};this.elem=i;if(!c(i).Touchable){throw new Error("Hoverable depends on Touchable! Please be sure to include Touchable in your project.");}this.$elem=c(i).Touchable(f);this.inHover=false;this.target=null;if(typeof f!=="undefined"){if(typeof f.disableHover!=="undefined"){this.disableHover=f.disableHover;}else{this.disableHover=false;}if(typeof f.logging!=="undefined"){this.logging=f.logging;}}if(!this.disableHover){this.$elem.mouseenter(d);this.$elem.bind("mouseleave",d);}this.$elem.bind("longTap",d);this.$elem.bind("touchableend",d);function d(j,k){if(j.type==="touchableend"||j.type==="mouseleave"){g("Touchable newHoverOut");return e.$elem.trigger("newHoverOut",e);}g("Touchable newHoverIn");e.$elem.trigger("newHoverIn",e);}if(!this.disableHover){this.$elem.bind("mouseenter",h);this.$elem.bind("mouseleave",h);}e.$elem.bind("touchablestart",function(j,k){e.$elem.bind("touchablemove",h);},false);e.$elem.bind("touchableend",function(j,k){e.$elem.unbind("touchablemove",h);h(j,k);},false);function h(l,m){if(l.type==="touchableend"||l.type==="touchend"){g("Touchable newHoverOut2");e.inHover=false;return e.$elem.trigger("newHoverOut2",e);}else{if(l.type==="mouseenter"){g("Touchable newHoverIn2");return e.$elem.trigger("newHoverIn2",e);}else{if(l.type==="mouseleave"){g("Touchable newHoverOut2");return e.$elem.trigger("newHoverOut2",e);}}}if(l.type=="touchablemove"){if(m instanceof a){var j=e.hitTarget;g("Touchable target ID/node hitTarget "+j+"e.target"+l.target+" e.currentTarget"+l.currentTarget+" self in hover"+e.inHover);var k=false;if(typeof l.currentTarget!=="undefined"&&l.currentTarget===e.$elem.get(0)){k=true;}if(k&&!e.inHover){e.inHover=true;g("Touchable newHoverIn2");e.$elem.trigger("newHoverIn2",e);}else{if(k===false&&e.inHover){e.inHover=false;g("Touchable newHoverOut2");e.$elem.trigger("newHoverOut2",e);}}}}}}})(jQuery);
