jquery.ui.touch-punch.min.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*!
  2. *
  3. * This library has been modified! This function has been changed: mouseProto._mouseInit
  4. *
  5. * Original Version:
  6. *
  7. * mouseProto._mouseInit = function () {
  8. *
  9. * var self = this;
  10. *
  11. * // Delegate the touch handlers to the widget's element
  12. * self.element.bind({
  13. * touchstart: $.proxy(self, '_touchStart'),
  14. * touchmove: $.proxy(self, '_touchMove'),
  15. * touchend: $.proxy(self, '_touchEnd')
  16. * });
  17. *
  18. * // Call the original $.ui.mouse init method
  19. * _mouseInit.call(self);
  20. * };
  21. *
  22. *
  23. * New Version:
  24. *
  25. * mouseProto._mouseInit = function () {
  26. *
  27. * var self = this;
  28. *
  29. * // Delegate the touch handlers to the widget's element
  30. * self.element
  31. * .bind('taphold', $.proxy(self, '_touchStart')) // IMPORTANT!MOD FOR TAPHOLD TO START SORTABLE
  32. * .bind('touchmove', $.proxy(self, '_touchMove'))
  33. * .bind('touchend', $.proxy(self, '_touchEnd'));
  34. *
  35. * // Call the original $.ui.mouse init method
  36. * _mouseInit.call(self);
  37. * };
  38. *
  39. * Why?
  40. *
  41. * The original version mapped any tap start to a click. This means that you weren't able to scroll through
  42. * the sortable on a mobile device, as every attempt to scroll was intercepted as a click.
  43. *
  44. * jQuery UI Touch Punch 0.2.3
  45. *
  46. * Copyright 2011–2014, Dave Furfero
  47. * Dual licensed under the MIT or GPL Version 2 licenses.
  48. *
  49. * Depends:
  50. * jquery.ui.widget.js
  51. * jquery.ui.mouse.js
  52. */
  53. !function(o){function t(o,t){if(!(o.originalEvent.touches.length>1)){o.preventDefault();var e=o.originalEvent.changedTouches[0],u=document.createEvent("MouseEvents");u.initMouseEvent(t,!0,!0,window,1,e.screenX,e.screenY,e.clientX,e.clientY,!1,!1,!1,!1,0,null),o.target.dispatchEvent(u)}}if(o.support.touch="ontouchend"in document,o.support.touch){var e,u=o.ui.mouse.prototype,n=u._mouseInit,c=u._mouseDestroy;u._touchStart=function(o){var u=this;!e&&u._mouseCapture(o.originalEvent.changedTouches[0])&&(e=!0,u._touchMoved=!1,t(o,"mouseover"),t(o,"mousemove"),t(o,"mousedown"))},u._touchMove=function(o){e&&(this._touchMoved=!0,t(o,"mousemove"))},u._touchEnd=function(o){e&&(t(o,"mouseup"),t(o,"mouseout"),this._touchMoved||t(o,"click"),e=!1)},u._mouseInit=function(){var t=this;t.element.bind("taphold",o.proxy(t,"_touchStart")).bind("touchmove",o.proxy(t,"_touchMove")).bind("touchend",o.proxy(t,"_touchEnd")),n.call(t)},u._mouseDestroy=function(){var t=this;t.element.unbind({touchstart:o.proxy(t,"_touchStart"),touchmove:o.proxy(t,"_touchMove"),touchend:o.proxy(t,"_touchEnd")}),c.call(t)}}}(jQuery);