{"version":3,"file":"../jquery.ui.touch-punch.min.js","sources":["src/js/jquery.ui.touch-punch.min.js"],"sourcesContent":["/*!\r\n * jQuery UI Touch Punch 0.2.3\r\n *\r\n * Copyright 2011–2014, Dave Furfero\r\n * Dual licensed under the MIT or GPL Version 2 licenses.\r\n *\r\n * Depends:\r\n * jquery.ui.widget.js\r\n * jquery.ui.mouse.js\r\n */\r\n(function ($) {\r\n\r\n // Detect touch support\r\n $.support.touch = 'ontouchend' in document;\r\n\r\n // Ignore browsers without touch support\r\n if (!$.support.touch) {\r\n return;\r\n }\r\n\r\n var mouseProto = $.ui.mouse.prototype,\r\n _mouseInit = mouseProto._mouseInit,\r\n _mouseDestroy = mouseProto._mouseDestroy,\r\n touchHandled;\r\n\r\n /**\r\n * Simulate a mouse event based on a corresponding touch event\r\n * @param {Object} event A touch event\r\n * @param {String} simulatedType The corresponding mouse event\r\n */\r\n function simulateMouseEvent (event, simulatedType) {\r\n\r\n // Ignore multi-touch events\r\n if (event.originalEvent.touches.length > 1) {\r\n return;\r\n }\r\n\r\n if(event.cancelable) {\r\n event.preventDefault();\r\n }\r\n\r\n var touch = event.originalEvent.changedTouches[0],\r\n simulatedEvent = document.createEvent('MouseEvents');\r\n \r\n // Initialize the simulated mouse event using the touch event's coordinates\r\n simulatedEvent.initMouseEvent(\r\n simulatedType, // type\r\n true, // bubbles \r\n true, // cancelable \r\n window, // view \r\n 1, // detail \r\n touch.screenX, // screenX \r\n touch.screenY, // screenY \r\n touch.clientX, // clientX \r\n touch.clientY, // clientY \r\n false, // ctrlKey \r\n false, // altKey \r\n false, // shiftKey \r\n false, // metaKey \r\n 0, // button \r\n null // relatedTarget \r\n );\r\n\r\n // Dispatch the simulated event to the target element\r\n event.target.dispatchEvent(simulatedEvent);\r\n }\r\n\r\n /**\r\n * Handle the jQuery UI widget's touchstart events\r\n * @param {Object} event The widget element's touchstart event\r\n */\r\n mouseProto._touchStart = function (event) {\r\n\r\n var self = this;\r\n\r\n // Ignore the event if another widget is already being handled\r\n if (touchHandled || !self._mouseCapture(event.originalEvent.changedTouches[0])) {\r\n return;\r\n }\r\n\r\n // Set the flag to prevent other widgets from inheriting the touch event\r\n touchHandled = true;\r\n\r\n // Track movement to determine if interaction was a click\r\n self._touchMoved = false;\r\n\r\n // Simulate the mouseover event\r\n simulateMouseEvent(event, 'mouseover');\r\n\r\n // Simulate the mousemove event\r\n simulateMouseEvent(event, 'mousemove');\r\n\r\n // Simulate the mousedown event\r\n simulateMouseEvent(event, 'mousedown');\r\n };\r\n\r\n /**\r\n * Handle the jQuery UI widget's touchmove events\r\n * @param {Object} event The document's touchmove event\r\n */\r\n mouseProto._touchMove = function (event) {\r\n\r\n // Ignore event if not handled\r\n if (!touchHandled) {\r\n return;\r\n }\r\n\r\n // Interaction was not a click\r\n this._touchMoved = true;\r\n\r\n // Simulate the mousemove event\r\n simulateMouseEvent(event, 'mousemove');\r\n };\r\n\r\n /**\r\n * Handle the jQuery UI widget's touchend events\r\n * @param {Object} event The document's touchend event\r\n */\r\n mouseProto._touchEnd = function (event) {\r\n\r\n // Ignore event if not handled\r\n if (!touchHandled) {\r\n return;\r\n }\r\n\r\n // Simulate the mouseup event\r\n simulateMouseEvent(event, 'mouseup');\r\n\r\n // Simulate the mouseout event\r\n simulateMouseEvent(event, 'mouseout');\r\n\r\n // If the touch interaction did not move, it should trigger a click\r\n if (!this._touchMoved) {\r\n\r\n // Simulate the click event\r\n simulateMouseEvent(event, 'click');\r\n }\r\n\r\n // Unset the flag to allow other widgets to inherit the touch event\r\n touchHandled = false;\r\n };\r\n\r\n /**\r\n * A duck punch of the $.ui.mouse _mouseInit method to support touch events.\r\n * This method extends the widget with bound touch event handlers that\r\n * translate touch events to mouse events and pass them to the widget's\r\n * original mouse event handling methods.\r\n */\r\n mouseProto._mouseInit = function () {\r\n \r\n var self = this;\r\n\r\n // Delegate the touch handlers to the widget's element\r\n self.element.bind({\r\n touchstart: $.proxy(self, '_touchStart'),\r\n touchmove: $.proxy(self, '_touchMove'),\r\n touchend: $.proxy(self, '_touchEnd')\r\n });\r\n\r\n // Call the original $.ui.mouse init method\r\n _mouseInit.call(self);\r\n };\r\n\r\n /**\r\n * Remove the touch event handlers\r\n */\r\n mouseProto._mouseDestroy = function () {\r\n \r\n var self = this;\r\n\r\n // Delegate the touch handlers to the widget's element\r\n self.element.unbind({\r\n touchstart: $.proxy(self, '_touchStart'),\r\n touchmove: $.proxy(self, '_touchMove'),\r\n touchend: $.proxy(self, '_touchEnd')\r\n });\r\n\r\n // Call the original $.ui.mouse destroy method\r\n _mouseDestroy.call(self);\r\n };\r\n\r\n})(jQuery);"],"names":["$","support","touch","document","mouseProto","ui","mouse","prototype","_mouseInit","_mouseDestroy","touchHandled","simulateMouseEvent","event","simulatedType","originalEvent","touches","length","cancelable","preventDefault","changedTouches","simulatedEvent","createEvent","initMouseEvent","window","screenX","screenY","clientX","clientY","target","dispatchEvent","_touchStart","self","_mouseCapture","_touchMoved","_touchMove","_touchEnd","element","bind","touchstart","proxy","touchmove","touchend","call","unbind","jQuery"],"mappings":";;;EAAA;;;;;;;;;KAUA,CAAC,SAAUA,CAAV,CAAa;EAGZA,CAAC,CAACC,OAAF,CAAUC,KAAV,CAAkB,eAAgBC,QAAlC,CAEA;EACA,GAAI,CAACH,CAAC,CAACC,OAAF,CAAUC,KAAf,CAAsB,CACpB,MACD,CAED,IAAIE,UAAU,CAAGJ,CAAC,CAACK,EAAF,CAAKC,KAAL,CAAWC,SAA5B,CACIC,UAAU,CAAGJ,UAAU,CAACI,UAD5B,CAEIC,aAAa,CAAGL,UAAU,CAACK,aAF/B,CAGIC,YAHJ,CAKA;;;;OAKA,SAASC,kBAAT,CAA6BC,KAA7B,CAAoCC,aAApC,CAAmD;EAGjD,GAAID,KAAK,CAACE,aAAN,CAAoBC,OAApB,CAA4BC,MAA5B,CAAqC,CAAzC,CAA4C,CAC1C,MACD,CAED,GAAGJ,KAAK,CAACK,UAAT,CAAqB,CACjBL,KAAK,CAACM,cAAN,GACH,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