{"id":158577,"date":"2012-11-14T08:19:04","date_gmt":"2012-11-14T04:19:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=158577"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=158577","title":{"rendered":"<span class=\"post_title\">jQuery-\u0441\u043d\u0438\u043f\u043f\u0435\u0442\u044b \u0438 \u043f\u043b\u0430\u0433\u0438\u043d\u044b \u0434\u043b\u044f iPad<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u041f\u043e\u0434\u0431\u043e\u0440\u043a\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 jQuery-\u0441\u043d\u0438\u043f\u043f\u0435\u0442\u043e\u0432 \u0438 \u043f\u043b\u0430\u0433\u0438\u043d\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0430\u0439\u0442 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043d\u0430 iPad. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u043e\u0439\u0434\u0443\u0442 \u0438 \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u0442\u0430\u0447-\u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/dbf\/0d4\/0e7\/dbf0d40e73fc71b93261df46d6dea115.png\"\/><a name=\"habracut\"><\/a><\/p>\n<h4>1. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u044d\u043a\u0440\u0430\u043d\u0430 (<a href=\"http:\/\/favo.asia\/2010\/07\/detecting-ipad-orientation-using-javascript\/\">\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a<\/a>)<\/h4>\n<p>  <\/p>\n<pre><code class=\"html\">&lt;button onclick=&quot;detectIPadOrientation();&quot;&gt;What's my Orientation?&lt;\/button&gt; &lt;script type=&quot;text\/javascript&quot;&gt; \u00a0window.onorientationchange = detectIPadOrientation; \u00a0function detectIPadOrientation () {  \u00a0 \u00a0 if ( orientation == 0 ) { \u00a0 \u00a0 \u00a0alert ('Portrait Mode, Home Button bottom'); \u00a0 \u00a0 } \u00a0 \u00a0 else if ( orientation == 90 ) { \u00a0 \u00a0 \u00a0alert ('Landscape Mode, Home Button right'); \u00a0 \u00a0 } \u00a0 \u00a0 else if ( orientation == -90 ) { \u00a0 \u00a0 \u00a0alert ('Landscape Mode, Home Button left'); \u00a0 \u00a0 } \u00a0 \u00a0 else if ( orientation == 180 ) { \u00a0 \u00a0 \u00a0alert ('Portrait Mode, Home Button top'); \u00a0 \u00a0 } \u00a0} &lt;\/script&gt; <\/code><\/pre>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 CSS:<\/p>\n<pre><code class=\"html\">&lt;link rel=&quot;stylesheet&quot; media=&quot;all and (orientation:portrait)&quot; href=&quot;portrait.css&quot;&gt;   &lt;link rel=&quot;stylesheet&quot; media=&quot;all and (orientation:landscape)&quot; href=&quot;landscape.css&quot;&gt;   <\/code><\/pre>\n<h4>2. \u041f\u0435\u0440\u0435\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u043d\u0438\u0435 (Drag) \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 (<a href=\"http:\/\/www.jquery4u.com\/mobile\/jquery-add-dragtouch-support-ipad\/#.UEAbXsHiY0U\">\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a<\/a>)<\/h4>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/iPAD Support $.fn.addTouch = function(){ \u00a0 this.each(function(i,el){ \u00a0 \u00a0 $(el).bind('touchstart touchmove touchend touchcancel',function(){ \u00a0 \u00a0 \u00a0 \/\/we pass the original event object because the jQuery event \u00a0 \u00a0 \u00a0 \/\/object is normalized to w3c specs and does not provide the TouchList \u00a0 \u00a0 \u00a0 handleTouch(event); \u00a0 \u00a0 }); \u00a0 }); \u00a0 \u00a0 var handleTouch = function(event) \u00a0 { \u00a0 \u00a0 var touches = event.changedTouches, \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 first = touches[0], \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 type = ''; \u00a0 \u00a0 \u00a0 switch(event.type) \u00a0 \u00a0 { \u00a0 \u00a0 \u00a0 case 'touchstart': \u00a0 \u00a0 \u00a0 \u00a0 type = 'mousedown'; \u00a0 \u00a0 \u00a0 \u00a0 break; \u00a0 \u00a0 \u00a0 \u00a0 case 'touchmove': \u00a0 \u00a0 \u00a0 \u00a0 type = 'mousemove'; \u00a0 \u00a0 \u00a0 \u00a0 event.preventDefault(); \u00a0 \u00a0 \u00a0 \u00a0 break; \u00a0 \u00a0 \u00a0 \u00a0 case 'touchend': \u00a0 \u00a0 \u00a0 \u00a0 type = 'mouseup'; \u00a0 \u00a0 \u00a0 \u00a0 break; \u00a0 \u00a0 \u00a0 \u00a0 default: \u00a0 \u00a0 \u00a0 \u00a0 return; \u00a0 \u00a0 } \u00a0 \u00a0 \u00a0 var simulatedEvent = document.createEvent('MouseEvent'); \u00a0 \u00a0 simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY, false, false, false, false, 0\/*left*\/, null); \u00a0 \u00a0 first.target.dispatchEvent(simulatedEvent); \u00a0 }; }; <\/code><\/pre>\n<h4>3. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0430\u0447\u0430 (<a href=\"http:\/\/labs.skinkers.com\/touchSwipe\/\">\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a<\/a>, <a href=\"http:\/\/labs.skinkers.com\/touchSwipe\/demo\/1_Basic_swipe.php\">\u0434\u0435\u043c\u043e<\/a>)<\/h4>\n<h4>4. \u0421\u043a\u0440\u043e\u043b\u043b\u0438\u043d\u0433 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0441 overflow:auto, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043e\u0434\u0438\u043d \u043f\u0430\u043b\u0435\u0446 \u0432\u043c\u0435\u0441\u0442\u043e \u0434\u0432\u0443\u0445 (<a href=\"http:\/\/forrst.com\/posts\/jQuery_iPad_one_finger_scroll-B30\">\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a<\/a>, <a href=\"http:\/\/jsfiddle.net\/mfXMn\/\">\u0434\u0435\u043c\u043e<\/a>)<\/h4>\n<h4>5. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 iPhone, iPod \u0438 iPad (<a href=\"http:\/\/www.jquery4u.com\/mobile\/jquery-detect-mobile-devices-iphone-ipod-ipad\/#.UEKkycHiY0V\">\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a<\/a>)<\/h4>\n<p>  <\/p>\n<pre><code class=\"javascript\">jQuery(document).ready(function($){ \u00a0 \u00a0 var deviceAgent = navigator.userAgent.toLowerCase(); \u00a0 \u00a0 var agentID = deviceAgent.match(\/(iphone|ipod|ipad)\/); \u00a0 \u00a0 if (agentID) {  \u00a0 \u00a0 \u00a0 \u00a0 \/\/ mobile code here \u00a0 \u00a0 \u00a0 } }); <\/code><\/pre>\n<h4>6. \u041c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0431\u043e\u0440 \u0432 \u0444\u043e\u0440\u043c\u0435 (<a href=\"http:\/\/www.tgerm.com\/2012\/01\/ipad-multiselect-picklist-jquery-plugin.html\">\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a<\/a>)<\/h4>\n<p>  <\/p>\n<pre><code class=\"html\">&lt;apex:selectList id=&quot;contactPickList&quot; value=&quot;{!selectedContactIds}&quot;  multiselect=&quot;true&quot; size=&quot;4&quot;&gt;    &lt;apex:selectOptions value=&quot;{!contactOptions}&quot;\/&gt;  &lt;\/apex:selectList&gt; <\/code><\/pre>\n<h4>7. \u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043d\u0430 \u043a\u043b\u0438\u043a \u043d\u0430 iPad (<a href=\"http:\/\/www.brightec.co.uk\/blog\/jquery-click-events-ipad\">\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a<\/a>)<\/h4>\n<p>  <\/p>\n<pre><code class=\"javascript\">var ua = navigator.userAgent,      event = (ua.match(\/iPad\/i)) ? &quot;touchstart&quot; : &quot;click&quot;;  $(&quot;#theElement&quot;).bind(event, function() {      \/\/ jquery code } <\/code><\/pre>\n<h4>8. \u041f\u0440\u043e\u0441\u0442\u044b\u0435 \u0436\u0435\u0441\u0442\u044b \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 iPad (\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a)<\/h4>\n<p>  \u041f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 <a href=\"http:\/\/www.netcu.de\/jquery-touchwipe-iphone-ipad-library\">touchwipe<\/a>:<\/p>\n<pre><code class=\"html\">&lt;script type=&quot;text\/javascript&quot; src=&quot;jquery.touchwipe.1.1.1.js&quot;&gt;&lt;\/script&gt; <\/code><\/pre>\n<p>  \u041d\u0430\u0437\u043d\u0430\u0447\u0430\u0435\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0436\u0435\u0441\u0442\u0430\u043c:<\/p>\n<pre><code class=\"javascript\">$(document).ready(function(){ \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 $('body').touchwipe({ \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 wipeLeft: function(){ alert('You swiped left!') }, \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 wipeRight: function(){ alert('You swiped right!') }, \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 wipeUp: function(){ alert('You swiped up!') }, \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 wipeDown: function(){ alert('You swiped down!') } \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 }) \u00a0 \u00a0 \u00a0 \u00a0 }) <\/code><\/pre>\n<h4>9. \u0414\u0432\u043e\u0439\u043d\u043e\u0439 \u0442\u0430\u043f (<a href=\"http:\/\/appcropolis.com\/implementing-doubletap-on-iphones-and-ipads\/\">\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a<\/a>, <a href=\"http:\/\/sanraul.com\/lab\/jquery.doubletap\/\">\u0434\u0435\u043c\u043e<\/a>)<\/h4>\n<p>  \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u0430\u043a\u0436\u0435 \u0438 \u0432 \u0434\u0435\u0441\u043a\u0442\u043e\u043f-\u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430\u0445.<\/p>\n<h4>10. jQuery.UI.iPad \u043f\u043b\u0430\u0433\u0438\u043d (<a href=\"http:\/\/cgiphpguy.com\/ajax\/javascript-for-ipad\/jqueryuiipad-plugin\">\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a<\/a>)<\/h4>\n<p>  \u041e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 jQuery UI \u0434\u043b\u044f \u0442\u0430\u0447-\u0434\u0435\u0432\u0430\u0439\u0441\u043e\u0432.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">$(function() { \u00a0 \/\/ \u00a0 \/\/ Extend jQuery feature detection \u00a0 \/\/ \u00a0 $.extend($.support, { \u00a0 \u00a0 touch: typeof Touch == &quot;object&quot; \u00a0 }); \u00a0  \u00a0 \/\/ \u00a0 \/\/ Hook up touch events \u00a0 \/\/ \u00a0 if ($.support.touch) { \u00a0 \u00a0 document.addEventListener(&quot;touchstart&quot;, iPadTouchHandler, false); \u00a0 \u00a0 document.addEventListener(&quot;touchmove&quot;, iPadTouchHandler, false); \u00a0 \u00a0 document.addEventListener(&quot;touchend&quot;, iPadTouchHandler, false); \u00a0 \u00a0 document.addEventListener(&quot;touchcancel&quot;, iPadTouchHandler, false); \u00a0 } });   var lastTap = null; \u00a0 \u00a0 \u00a0\/\/ Holds last tapped element (so we can compare for double tap) var tapValid = false; \u00a0 \u00a0 \u00a0\/\/ Are we still in the .6 second window where a double tap can occur var tapTimeout = null; \u00a0 \u00a0 \u00a0\/\/ The timeout reference  function cancelTap() { \u00a0 tapValid = false; }   var rightClickPending = false; \u00a0\/\/ Is a right click still feasible var rightClickEvent = null; \u00a0 \u00a0\/\/ the original event var holdTimeout = null; \u00a0 \u00a0 \u00a0\/\/ timeout reference var cancelMouseUp = false; \u00a0 \u00a0\/\/ prevents a click from occuring as we want the context menu   function cancelHold() { \u00a0 if (rightClickPending) { \u00a0 \u00a0 window.clearTimeout(holdTimeout); \u00a0 \u00a0 rightClickPending = false; \u00a0 \u00a0 rightClickEvent = null; \u00a0 } }  function startHold(event) { \u00a0 if (rightClickPending) \u00a0 \u00a0 return;  \u00a0 rightClickPending = true; \/\/ We could be performing a right click \u00a0 rightClickEvent = (event.changedTouches)[0]; \u00a0 holdTimeout = window.setTimeout(&quot;doRightClick();&quot;, 800); }   function doRightClick() { \u00a0 rightClickPending = false;  \u00a0 \/\/ \u00a0 \/\/ We need to mouse up (as we were down) \u00a0 \/\/ \u00a0 var first = rightClickEvent, \u00a0 \u00a0 simulatedEvent = document.createEvent(&quot;MouseEvent&quot;); \u00a0 simulatedEvent.initMouseEvent(&quot;mouseup&quot;, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY, \u00a0 \u00a0 \u00a0 false, false, false, false, 0, null); \u00a0 first.target.dispatchEvent(simulatedEvent);  \u00a0 \/\/ \u00a0 \/\/ emulate a right click \u00a0 \/\/ \u00a0 simulatedEvent = document.createEvent(&quot;MouseEvent&quot;); \u00a0 simulatedEvent.initMouseEvent(&quot;mousedown&quot;, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY, \u00a0 \u00a0 \u00a0 false, false, false, false, 2, null); \u00a0 first.target.dispatchEvent(simulatedEvent);  \u00a0 \/\/ \u00a0 \/\/ Show a context menu \u00a0 \/\/ \u00a0 simulatedEvent = document.createEvent(&quot;MouseEvent&quot;); \u00a0 simulatedEvent.initMouseEvent(&quot;contextmenu&quot;, true, true, window, 1, first.screenX + 50, first.screenY + 5, first.clientX + 50, first.clientY + 5, \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 false, false, false, false, 2, null); \u00a0 first.target.dispatchEvent(simulatedEvent);   \u00a0 \/\/ \u00a0 \/\/ Note:: I don't mouse up the right click here however feel free to add if required \u00a0 \/\/   \u00a0 cancelMouseUp = true; \u00a0 rightClickEvent = null; \/\/ Release memory }   \/\/ \/\/ mouse over event then mouse down \/\/ function iPadTouchStart(event) { \u00a0 var touches = event.changedTouches, \u00a0 \u00a0 first = touches[0], \u00a0 \u00a0 type = &quot;mouseover&quot;, \u00a0 \u00a0 simulatedEvent = document.createEvent(&quot;MouseEvent&quot;); \u00a0 \/\/ \u00a0 \/\/ Mouse over first - I have live events attached on mouse over \u00a0 \/\/ \u00a0 simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY, \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 false, false, false, false, 0, null); \u00a0 first.target.dispatchEvent(simulatedEvent);  \u00a0 type = &quot;mousedown&quot;; \u00a0 simulatedEvent = document.createEvent(&quot;MouseEvent&quot;);  \u00a0 simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY, \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 false, false, false, false, 0, null); \u00a0 first.target.dispatchEvent(simulatedEvent);   \u00a0 if (!tapValid) { \u00a0 \u00a0 lastTap = first.target; \u00a0 \u00a0 tapValid = true; \u00a0 \u00a0 tapTimeout = window.setTimeout(&quot;cancelTap();&quot;, 600); \u00a0 \u00a0 startHold(event); \u00a0 } \u00a0 else { \u00a0 \u00a0 window.clearTimeout(tapTimeout);  \u00a0 \u00a0 \/\/ \u00a0 \u00a0 \/\/ If a double tap is still a possibility and the elements are the same \u00a0 \u00a0 \/\/ \u00a0Then perform a double click \u00a0 \u00a0 \/\/ \u00a0 \u00a0 if (first.target == lastTap) { \u00a0 \u00a0 \u00a0 lastTap = null; \u00a0 \u00a0 \u00a0 tapValid = false;  \u00a0 \u00a0 \u00a0 type = &quot;click&quot;; \u00a0 \u00a0 \u00a0 simulatedEvent = document.createEvent(&quot;MouseEvent&quot;);  \u00a0 \u00a0 \u00a0 simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY, \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0false, false, false, false, 0\/*left*\/, null); \u00a0 \u00a0 \u00a0 first.target.dispatchEvent(simulatedEvent);  \u00a0 \u00a0 \u00a0 type = &quot;dblclick&quot;; \u00a0 \u00a0 \u00a0 simulatedEvent = document.createEvent(&quot;MouseEvent&quot;);  \u00a0 \u00a0 \u00a0 simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY, \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0false, false, false, false, 0\/*left*\/, null); \u00a0 \u00a0 \u00a0 first.target.dispatchEvent(simulatedEvent); \u00a0 \u00a0 } \u00a0 \u00a0 else { \u00a0 \u00a0 \u00a0 lastTap = first.target; \u00a0 \u00a0 \u00a0 tapValid = true; \u00a0 \u00a0 \u00a0 tapTimeout = window.setTimeout(&quot;cancelTap();&quot;, 600); \u00a0 \u00a0 \u00a0 startHold(event); \u00a0 \u00a0 } \u00a0 } }  function iPadTouchHandler(event) { \u00a0 var type = &quot;&quot;, \u00a0 \u00a0 button = 0; \/*left*\/  \u00a0 if (event.touches.length &gt; 1) \u00a0 \u00a0 return;  \u00a0 switch (event.type) { \u00a0 \u00a0 case &quot;touchstart&quot;: \u00a0 \u00a0 \u00a0 if ($(event.changedTouches[0].target).is(&quot;select&quot;)) { \u00a0 \u00a0 \u00a0 \u00a0 return; \u00a0 \u00a0 \u00a0 } \u00a0 \u00a0 \u00a0 iPadTouchStart(event); \/*We need to trigger two events here to support one touch drag and drop*\/ \u00a0 \u00a0 \u00a0 event.preventDefault(); \u00a0 \u00a0 \u00a0 return false; \u00a0 \u00a0 \u00a0 break;  \u00a0 \u00a0 case &quot;touchmove&quot;: \u00a0 \u00a0 \u00a0 cancelHold(); \u00a0 \u00a0 \u00a0 type = &quot;mousemove&quot;; \u00a0 \u00a0 \u00a0 event.preventDefault(); \u00a0 \u00a0 \u00a0 break;  \u00a0 \u00a0 case &quot;touchend&quot;: \u00a0 \u00a0 \u00a0 if (cancelMouseUp) { \u00a0 \u00a0 \u00a0 \u00a0 cancelMouseUp = false; \u00a0 \u00a0 \u00a0 \u00a0 event.preventDefault(); \u00a0 \u00a0 \u00a0 \u00a0 return false; \u00a0 \u00a0 \u00a0 } \u00a0 \u00a0 \u00a0 cancelHold(); \u00a0 \u00a0 \u00a0 type = &quot;mouseup&quot;; \u00a0 \u00a0 \u00a0 break;  \u00a0 \u00a0 default: \u00a0 \u00a0 \u00a0 return; \u00a0 }  \u00a0 var touches = event.changedTouches, \u00a0 \u00a0 first = touches[0], \u00a0 \u00a0 simulatedEvent = document.createEvent(&quot;MouseEvent&quot;);  \u00a0 simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY, \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 false, false, false, false, button, null);  \u00a0 first.target.dispatchEvent(simulatedEvent);  \u00a0 if (type == &quot;mouseup&quot; &amp;&amp; tapValid &amp;&amp; first.target == lastTap) { \u00a0\/\/ This actually emulates the ipads default behaviour (which we prevented) \u00a0 \u00a0 simulatedEvent = document.createEvent(&quot;MouseEvent&quot;); \u00a0 \u00a0\/\/ This check avoids click being emulated on a double tap  \u00a0 \u00a0 simulatedEvent.initMouseEvent(&quot;click&quot;, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY, \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 false, false, false, false, button, null);  \u00a0 \u00a0 first.target.dispatchEvent(simulatedEvent); \u00a0 } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/158577\/\"> http:\/\/habrahabr.ru\/post\/158577\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u041f\u043e\u0434\u0431\u043e\u0440\u043a\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 jQuery-\u0441\u043d\u0438\u043f\u043f\u0435\u0442\u043e\u0432 \u0438 \u043f\u043b\u0430\u0433\u0438\u043d\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0430\u0439\u0442 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043d\u0430 iPad. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u043e\u0439\u0434\u0443\u0442 \u0438 \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u0442\u0430\u0447-\u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/dbf\/0d4\/0e7\/dbf0d40e73fc71b93261df46d6dea115.png\"\/><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-158577","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/158577","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=158577"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/158577\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=158577"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=158577"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=158577"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}