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