1/*
2 * jQuery UI Touch Punch
3 * Depends:
4 *  jquery.ui.widget.js
5 *  jquery.ui.mouse.js
6 */
7(function (b) {
8	b.support.touch = "ontouchend" in document;
9	if (!b.support.touch) {
10		return;
11	}
12	var c = b.ui.mouse.prototype,
13		e = c._mouseInit,
14		a;
15
16	function d(g, h) {
17		if (g.originalEvent.touches.length > 1) {
18			return;
19		}
20		g.preventDefault();
21		var i = g.originalEvent.changedTouches[0],
22			f = document.createEvent("MouseEvents");
23		f.initMouseEvent(h, true, true, window, 1, i.screenX, i.screenY, i.clientX, i.clientY, false, false, false, false, 0, null);
24		g.target.dispatchEvent(f);
25	}
26
27	c._touchStart = function (g) {
28		var f = this;
29		if (a || !f._mouseCapture(g.originalEvent.changedTouches[0])) {
30			return;
31		}
32		a = true;
33		f._touchMoved = false;
34		d(g, "mouseover");
35		d(g, "mousemove");
36		d(g, "mousedown");
37	};
38	c._touchMove = function (f) {
39		if (!a) {
40			return;
41		}
42		this._touchMoved = true;
43		d(f, "mousemove");
44	};
45	c._touchEnd = function (f) {
46		if (!a) {
47			return;
48		}
49		d(f, "mouseup");
50		d(f, "mouseout");
51		if (!this._touchMoved) {
52			d(f, "click");
53		}
54		a = false;
55	};
56	c._mouseInit = function () {
57		var f = this;
58		f.element.bind("touchstart", b.proxy(f, "_touchStart")).bind("touchmove", b.proxy(f, "_touchMove")).bind("touchend", b.proxy(f, "_touchEnd"));
59		e.call(f);
60	};
61})(jQuery);