diff --git a/bower.json b/bower.json index ffc6b89..2885cca 100644 --- a/bower.json +++ b/bower.json @@ -1,5 +1,5 @@ { - "name": "jqueryui-touch-punch", + "name": "jquery-ui-touch-punch", "version": "0.2.3", "main": "jquery.ui.touch-punch.min.js", "ignore": [], @@ -7,4 +7,4 @@ "jquery": ">=1.6", "jquery-ui": ">=1.8" } -} +} \ No newline at end of file diff --git a/jquery.ui.touch-punch.js b/jquery.ui.touch-punch.js index 16ce41d..a391aad 100755 --- a/jquery.ui.touch-punch.js +++ b/jquery.ui.touch-punch.js @@ -8,8 +8,18 @@ * jquery.ui.widget.js * jquery.ui.mouse.js */ -(function ($) { - +(function (factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['jquery'], factory); + } else if (typeof exports === 'object') { + // Node/CommonJS + module.exports = factory(require('jquery')); + } else { + // Browser globals + factory(jQuery); + } +}(function ($) { // Detect touch support $.support.touch = 'ontouchend' in document; @@ -176,5 +186,4 @@ // Call the original $.ui.mouse destroy method _mouseDestroy.call(self); }; - -})(jQuery); \ No newline at end of file +})); \ No newline at end of file diff --git a/jquery.ui.touch-punch.min.js b/jquery.ui.touch-punch.min.js index 31272ce..82d38af 100644 --- a/jquery.ui.touch-punch.min.js +++ b/jquery.ui.touch-punch.min.js @@ -8,4 +8,4 @@ * jquery.ui.widget.js * jquery.ui.mouse.js */ -!function(a){function f(a,b){if(!(a.originalEvent.touches.length>1)){a.preventDefault();var c=a.originalEvent.changedTouches[0],d=document.createEvent("MouseEvents");d.initMouseEvent(b,!0,!0,window,1,c.screenX,c.screenY,c.clientX,c.clientY,!1,!1,!1,!1,0,null),a.target.dispatchEvent(d)}}if(a.support.touch="ontouchend"in document,a.support.touch){var e,b=a.ui.mouse.prototype,c=b._mouseInit,d=b._mouseDestroy;b._touchStart=function(a){var b=this;!e&&b._mouseCapture(a.originalEvent.changedTouches[0])&&(e=!0,b._touchMoved=!1,f(a,"mouseover"),f(a,"mousemove"),f(a,"mousedown"))},b._touchMove=function(a){e&&(this._touchMoved=!0,f(a,"mousemove"))},b._touchEnd=function(a){e&&(f(a,"mouseup"),f(a,"mouseout"),this._touchMoved||f(a,"click"),e=!1)},b._mouseInit=function(){var b=this;b.element.bind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),c.call(b)},b._mouseDestroy=function(){var b=this;b.element.unbind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),d.call(b)}}}(jQuery); \ No newline at end of file +!function(o){"function"==typeof define&&define.amd?define(["jquery"],o):"object"==typeof exports?module.exports=o(require("jquery")):o(jQuery)}(function(o){function e(o,e){if(!(o.originalEvent.touches.length>1)){o.preventDefault();var t=o.originalEvent.changedTouches[0],u=document.createEvent("MouseEvents");u.initMouseEvent(e,!0,!0,window,1,t.screenX,t.screenY,t.clientX,t.clientY,!1,!1,!1,!1,0,null),o.target.dispatchEvent(u)}}if(o.support.touch="ontouchend"in document,o.support.touch){var t,u=o.ui.mouse.prototype,n=u._mouseInit,c=u._mouseDestroy;u._touchStart=function(o){var u=this;!t&&u._mouseCapture(o.originalEvent.changedTouches[0])&&(t=!0,u._touchMoved=!1,e(o,"mouseover"),e(o,"mousemove"),e(o,"mousedown"))},u._touchMove=function(o){t&&(this._touchMoved=!0,e(o,"mousemove"))},u._touchEnd=function(o){t&&(e(o,"mouseup"),e(o,"mouseout"),this._touchMoved||e(o,"click"),t=!1)},u._mouseInit=function(){var e=this;e.element.bind({touchstart:o.proxy(e,"_touchStart"),touchmove:o.proxy(e,"_touchMove"),touchend:o.proxy(e,"_touchEnd")}),n.call(e)},u._mouseDestroy=function(){var e=this;e.element.unbind({touchstart:o.proxy(e,"_touchStart"),touchmove:o.proxy(e,"_touchMove"),touchend:o.proxy(e,"_touchEnd")}),c.call(e)}}}); \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..2885cca --- /dev/null +++ b/package.json @@ -0,0 +1,10 @@ +{ + "name": "jquery-ui-touch-punch", + "version": "0.2.3", + "main": "jquery.ui.touch-punch.min.js", + "ignore": [], + "dependencies": { + "jquery": ">=1.6", + "jquery-ui": ">=1.8" + } +} \ No newline at end of file