summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2019-06-18 14:19:03 +0300
committerAndrew Dolgov <[email protected]>2019-06-18 14:19:03 +0300
commitc78af7d56c4d2dbc46ffa1ebebc6d0bbf802e35b (patch)
tree2a05a6248b0af7f93a3bacaf18cca071e5e945be /lib
parent506a5a877ead4e4e756b645d3e0a303509ea10ec (diff)
switch to jquery mobile events; use doubletap to toggle fullscreen
Diffstat (limited to 'lib')
-rw-r--r--lib/jquery.mobile-events.min.js28
-rw-r--r--lib/jquery.mobile.custom.js864
2 files changed, 28 insertions, 864 deletions
diff --git a/lib/jquery.mobile-events.min.js b/lib/jquery.mobile-events.min.js
new file mode 100644
index 0000000..36a20fb
--- /dev/null
+++ b/lib/jquery.mobile-events.min.js
@@ -0,0 +1,28 @@
+/*!
+ * jQuery Mobile Events
+ * by Ben Major
+ *
+ * Copyright 2011-2017, Ben Major
+ * Licensed under the MIT License:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+
+"use strict";!function(e){e.attrFn=e.attrFn||{};var t="ontouchstart"in window,a={tap_pixel_range:5,swipe_h_threshold:50,swipe_v_threshold:50,taphold_threshold:750,doubletap_int:500,shake_threshold:15,touch_capable:t,orientation_support:"orientation"in window&&"onorientationchange"in window,startevent:t?"touchstart":"mousedown",endevent:t?"touchend":"mouseup",moveevent:t?"touchmove":"mousemove",tapevent:t?"tap":"click",scrollevent:t?"touchmove":"scroll",hold_timer:null,tap_timer:null};e.touch={},e.isTouchCapable=function(){return a.touch_capable},e.getStartEvent=function(){return a.startevent},e.getEndEvent=function(){return a.endevent},e.getMoveEvent=function(){return a.moveevent},e.getTapEvent=function(){return a.tapevent},e.getScrollEvent=function(){return a.scrollevent},e.touch.setSwipeThresholdX=function(e){if("number"!=typeof e)throw new Error("Threshold parameter must be a type of number");a.swipe_h_threshold=e},e.touch.setSwipeThresholdY=function(e){if("number"!=typeof e)throw new Error("Threshold parameter must be a type of number");a.swipe_v_threshold=e},e.touch.setDoubleTapInt=function(e){if("number"!=typeof e)throw new Error("Interval parameter must be a type of number");a.doubletap_int=e},e.touch.setTapHoldThreshold=function(e){if("number"!=typeof e)throw new Error("Threshold parameter must be a type of number");a.taphold_threshold=e},e.touch.setTapRange=function(e){if("number"!=typeof e)throw new Error("Ranger parameter must be a type of number");a.tap_pixel_range=threshold},e.each(["tapstart","tapend","tapmove","tap","singletap","doubletap","taphold","swipe","swipeup","swiperight","swipedown","swipeleft","swipeend","scrollstart","scrollend","orientationchange","tap2","taphold2"],function(t,a){e.fn[a]=function(e){return e?this.on(a,e):this.trigger(a)},e.attrFn[a]=!0}),e.event.special.tapstart={setup:function(){var t=this,o=e(t);o.on(a.startevent,function e(n){if(o.data("callee",e),n.which&&1!==n.which)return!1;var i=n.originalEvent,r={position:{x:a.touch_capable?i.touches[0].pageX:n.pageX,y:a.touch_capable?i.touches[0].pageY:n.pageY},offset:{x:a.touch_capable?Math.round(i.changedTouches[0].pageX-(o.offset()?o.offset().left:0)):Math.round(n.pageX-(o.offset()?o.offset().left:0)),y:a.touch_capable?Math.round(i.changedTouches[0].pageY-(o.offset()?o.offset().top:0)):Math.round(n.pageY-(o.offset()?o.offset().top:0))},time:Date.now(),target:n.target};return w(t,"tapstart",n,r),!0})},remove:function(){e(this).off(a.startevent,e(this).data.callee)}},e.event.special.tapmove={setup:function(){var t=this,o=e(t);o.on(a.moveevent,function e(n){o.data("callee",e);var i=n.originalEvent,r={position:{x:a.touch_capable?i.touches[0].pageX:n.pageX,y:a.touch_capable?i.touches[0].pageY:n.pageY},offset:{x:a.touch_capable?Math.round(i.changedTouches[0].pageX-(o.offset()?o.offset().left:0)):Math.round(n.pageX-(o.offset()?o.offset().left:0)),y:a.touch_capable?Math.round(i.changedTouches[0].pageY-(o.offset()?o.offset().top:0)):Math.round(n.pageY-(o.offset()?o.offset().top:0))},time:Date.now(),target:n.target};return w(t,"tapmove",n,r),!0})},remove:function(){e(this).off(a.moveevent,e(this).data.callee)}},e.event.special.tapend={setup:function(){var t=this,o=e(t);o.on(a.endevent,function e(n){o.data("callee",e);var i=n.originalEvent,r={position:{x:a.touch_capable?i.changedTouches[0].pageX:n.pageX,y:a.touch_capable?i.changedTouches[0].pageY:n.pageY},offset:{x:a.touch_capable?Math.round(i.changedTouches[0].pageX-(o.offset()?o.offset().left:0)):Math.round(n.pageX-(o.offset()?o.offset().left:0)),y:a.touch_capable?Math.round(i.changedTouches[0].pageY-(o.offset()?o.offset().top:0)):Math.round(n.pageY-(o.offset()?o.offset().top:0))},time:Date.now(),target:n.target};return w(t,"tapend",n,r),!0})},remove:function(){e(this).off(a.endevent,e(this).data.callee)}},e.event.special.taphold={setup:function(){var t,o=this,n=e(o),i={x:0,y:0},r=0,s=0;n.on(a.startevent,function e(p){if(p.which&&1!==p.which)return!1;n.data("tapheld",!1),t=p.target;var h=p.originalEvent,c=Date.now();a.touch_capable?h.touches[0].pageX:p.pageX,a.touch_capable?h.touches[0].pageY:p.pageY,a.touch_capable?(h.touches[0].pageX,h.touches[0].target.offsetLeft):p.offsetX,a.touch_capable?(h.touches[0].pageY,h.touches[0].target.offsetTop):p.offsetY;i.x=p.originalEvent.targetTouches?p.originalEvent.targetTouches[0].pageX:p.pageX,i.y=p.originalEvent.targetTouches?p.originalEvent.targetTouches[0].pageY:p.pageY,r=i.x,s=i.y;var u=n.parent().data("threshold")?n.parent().data("threshold"):n.data("threshold"),f=void 0!==u&&!1!==u&&parseInt(u)?parseInt(u):a.taphold_threshold;return a.hold_timer=window.setTimeout(function(){var u=i.x-r,f=i.y-s;if(p.target==t&&(i.x==r&&i.y==s||u>=-a.tap_pixel_range&&u<=a.tap_pixel_range&&f>=-a.tap_pixel_range&&f<=a.tap_pixel_range)){n.data("tapheld",!0);for(var l=Date.now()-c,g=p.originalEvent.targetTouches?p.originalEvent.targetTouches:[p],d=[],v=0;v<g.length;v++){var _={position:{x:a.touch_capable?h.changedTouches[v].pageX:p.pageX,y:a.touch_capable?h.changedTouches[v].pageY:p.pageY},offset:{x:a.touch_capable?Math.round(h.changedTouches[v].pageX-(n.offset()?n.offset().left:0)):Math.round(p.pageX-(n.offset()?n.offset().left:0)),y:a.touch_capable?Math.round(h.changedTouches[v].pageY-(n.offset()?n.offset().top:0)):Math.round(p.pageY-(n.offset()?n.offset().top:0))},time:Date.now(),target:p.target,duration:l};d.push(_)}var T=2==g.length?"taphold2":"taphold";n.data("callee1",e),w(o,T,p,d)}},f),!0}).on(a.endevent,function e(){n.data("callee2",e),n.data("tapheld",!1),window.clearTimeout(a.hold_timer)}).on(a.moveevent,function e(t){n.data("callee3",e),r=t.originalEvent.targetTouches?t.originalEvent.targetTouches[0].pageX:t.pageX,s=t.originalEvent.targetTouches?t.originalEvent.targetTouches[0].pageY:t.pageY})},remove:function(){e(this).off(a.startevent,e(this).data.callee1).off(a.endevent,e(this).data.callee2).off(a.moveevent,e(this).data.callee3)}},e.event.special.doubletap={setup:function(){var t,o,n=this,i=e(n),r=null,s=!1;i.on(a.startevent,function t(n){return(!n.which||1===n.which)&&(i.data("doubletapped",!1),n.target,i.data("callee1",t),o=n.originalEvent,r||(r={position:{x:a.touch_capable?o.touches[0].pageX:n.pageX,y:a.touch_capable?o.touches[0].pageY:n.pageY},offset:{x:a.touch_capable?Math.round(o.changedTouches[0].pageX-(i.offset()?i.offset().left:0)):Math.round(n.pageX-(i.offset()?i.offset().left:0)),y:a.touch_capable?Math.round(o.changedTouches[0].pageY-(i.offset()?i.offset().top:0)):Math.round(n.pageY-(i.offset()?i.offset().top:0))},time:Date.now(),target:n.target,element:n.originalEvent.srcElement,index:e(n.target).index()}),!0)}).on(a.endevent,function p(h){var c=Date.now(),u=c-(i.data("lastTouch")||c+1);if(window.clearTimeout(t),i.data("callee2",p),u<a.doubletap_int&&e(h.target).index()==r.index&&u>100){i.data("doubletapped",!0),window.clearTimeout(a.tap_timer);var f={position:{x:a.touch_capable?h.originalEvent.changedTouches[0].pageX:h.pageX,y:a.touch_capable?h.originalEvent.changedTouches[0].pageY:h.pageY},offset:{x:a.touch_capable?Math.round(o.changedTouches[0].pageX-(i.offset()?i.offset().left:0)):Math.round(h.pageX-(i.offset()?i.offset().left:0)),y:a.touch_capable?Math.round(o.changedTouches[0].pageY-(i.offset()?i.offset().top:0)):Math.round(h.pageY-(i.offset()?i.offset().top:0))},time:Date.now(),target:h.target,element:h.originalEvent.srcElement,index:e(h.target).index()},l={firstTap:r,secondTap:f,interval:f.time-r.time};s||(w(n,"doubletap",h,l),r=null),s=!0,window.setTimeout(function(){s=!1},a.doubletap_int)}else i.data("lastTouch",c),t=window.setTimeout(function(){r=null,window.clearTimeout(t)},a.doubletap_int,[h]);i.data("lastTouch",c)})},remove:function(){e(this).off(a.startevent,e(this).data.callee1).off(a.endevent,e(this).data.callee2)}},e.event.special.singletap={setup:function(){var t=this,o=e(t),n=null,i=null,r={x:0,y:0};o.on(a.startevent,function e(t){return(!t.which||1===t.which)&&(i=Date.now(),n=t.target,o.data("callee1",e),r.x=t.originalEvent.targetTouches?t.originalEvent.targetTouches[0].pageX:t.pageX,r.y=t.originalEvent.targetTouches?t.originalEvent.targetTouches[0].pageY:t.pageY,!0)}).on(a.endevent,function e(s){if(o.data("callee2",e),s.target==n){var p=s.originalEvent.changedTouches?s.originalEvent.changedTouches[0].pageX:s.pageX,h=s.originalEvent.changedTouches?s.originalEvent.changedTouches[0].pageY:s.pageY;a.tap_timer=window.setTimeout(function(){var e=r.x-p,n=r.y-h;if(!o.data("doubletapped")&&!o.data("tapheld")&&(r.x==p&&r.y==h||e>=-a.tap_pixel_range&&e<=a.tap_pixel_range&&n>=-a.tap_pixel_range&&n<=a.tap_pixel_range)){var c=s.originalEvent,u={position:{x:a.touch_capable?c.changedTouches[0].pageX:s.pageX,y:a.touch_capable?c.changedTouches[0].pageY:s.pageY},offset:{x:a.touch_capable?Math.round(c.changedTouches[0].pageX-(o.offset()?o.offset().left:0)):Math.round(s.pageX-(o.offset()?o.offset().left:0)),y:a.touch_capable?Math.round(c.changedTouches[0].pageY-(o.offset()?o.offset().top:0)):Math.round(s.pageY-(o.offset()?o.offset().top:0))},time:Date.now(),target:s.target};u.time-i<a.taphold_threshold&&w(t,"singletap",s,u)}},a.doubletap_int)}})},remove:function(){e(this).off(a.startevent,e(this).data.callee1).off(a.endevent,e(this).data.callee2)}},e.event.special.tap={setup:function(){var t,o,n=this,i=e(n),r=!1,s=null,p={x:0,y:0};i.on(a.startevent,function e(a){return i.data("callee1",e),(!a.which||1===a.which)&&(r=!0,p.x=a.originalEvent.targetTouches?a.originalEvent.targetTouches[0].pageX:a.pageX,p.y=a.originalEvent.targetTouches?a.originalEvent.targetTouches[0].pageY:a.pageY,t=Date.now(),s=a.target,o=a.originalEvent.targetTouches?a.originalEvent.targetTouches:[a],!0)}).on(a.endevent,function e(h){i.data("callee2",e);var c=h.originalEvent.targetTouches?h.originalEvent.changedTouches[0].pageX:h.pageX,u=h.originalEvent.targetTouches?h.originalEvent.changedTouches[0].pageY:h.pageY,f=p.x-c,l=p.y-u;if(s==h.target&&r&&Date.now()-t<a.taphold_threshold&&(p.x==c&&p.y==u||f>=-a.tap_pixel_range&&f<=a.tap_pixel_range&&l>=-a.tap_pixel_range&&l<=a.tap_pixel_range)){for(var g=h.originalEvent,d=[],v=0;v<o.length;v++){var _={position:{x:a.touch_capable?g.changedTouches[v].pageX:h.pageX,y:a.touch_capable?g.changedTouches[v].pageY:h.pageY},offset:{x:a.touch_capable?Math.round(g.changedTouches[v].pageX-(i.offset()?i.offset().left:0)):Math.round(h.pageX-(i.offset()?i.offset().left:0)),y:a.touch_capable?Math.round(g.changedTouches[v].pageY-(i.offset()?i.offset().top:0)):Math.round(h.pageY-(i.offset()?i.offset().top:0))},time:Date.now(),target:h.target};d.push(_)}var T=2==o.length?"tap2":"tap";w(n,T,h,d)}})},remove:function(){e(this).off(a.startevent,e(this).data.callee1).off(a.endevent,e(this).data.callee2)}},e.event.special.swipe={setup:function(){var t,o=e(this),n=!1,i=!1,r={x:0,y:0},s={x:0,y:0};o.on(a.startevent,function i(p){(o=e(p.currentTarget)).data("callee1",i),r.x=p.originalEvent.targetTouches?p.originalEvent.targetTouches[0].pageX:p.pageX,r.y=p.originalEvent.targetTouches?p.originalEvent.targetTouches[0].pageY:p.pageY,s.x=r.x,s.y=r.y,n=!0;var h=p.originalEvent;t={position:{x:a.touch_capable?h.touches[0].pageX:p.pageX,y:a.touch_capable?h.touches[0].pageY:p.pageY},offset:{x:a.touch_capable?Math.round(h.changedTouches[0].pageX-(o.offset()?o.offset().left:0)):Math.round(p.pageX-(o.offset()?o.offset().left:0)),y:a.touch_capable?Math.round(h.changedTouches[0].pageY-(o.offset()?o.offset().top:0)):Math.round(p.pageY-(o.offset()?o.offset().top:0))},time:Date.now(),target:p.target}}),o.on(a.moveevent,function p(h){var c;(o=e(h.currentTarget)).data("callee2",p),s.x=h.originalEvent.targetTouches?h.originalEvent.targetTouches[0].pageX:h.pageX,s.y=h.originalEvent.targetTouches?h.originalEvent.targetTouches[0].pageY:h.pageY;var u=o.parent().data("xthreshold")?o.parent().data("xthreshold"):o.data("xthreshold"),f=o.parent().data("ythreshold")?o.parent().data("ythreshold"):o.data("ythreshold"),l=void 0!==u&&!1!==u&&parseInt(u)?parseInt(u):a.swipe_h_threshold,g=void 0!==f&&!1!==f&&parseInt(f)?parseInt(f):a.swipe_v_threshold;if(r.y>s.y&&r.y-s.y>g&&(c="swipeup"),r.x<s.x&&s.x-r.x>l&&(c="swiperight"),r.y<s.y&&s.y-r.y>g&&(c="swipedown"),r.x>s.x&&r.x-s.x>l&&(c="swipeleft"),void 0!=c&&n){r.x=0,r.y=0,s.x=0,s.y=0,n=!1;var d=h.originalEvent,v={position:{x:a.touch_capable?d.touches[0].pageX:h.pageX,y:a.touch_capable?d.touches[0].pageY:h.pageY},offset:{x:a.touch_capable?Math.round(d.changedTouches[0].pageX-(o.offset()?o.offset().left:0)):Math.round(h.pageX-(o.offset()?o.offset().left:0)),y:a.touch_capable?Math.round(d.changedTouches[0].pageY-(o.offset()?o.offset().top:0)):Math.round(h.pageY-(o.offset()?o.offset().top:0))},time:Date.now(),target:h.target},w=Math.abs(t.position.x-v.position.x),_=Math.abs(t.position.y-v.position.y),T={startEvnt:t,endEvnt:v,direction:c.replace("swipe",""),xAmount:w,yAmount:_,duration:v.time-t.time};i=!0,o.trigger("swipe",T).trigger(c,T)}}),o.on(a.endevent,function r(s){var p="";if((o=e(s.currentTarget)).data("callee3",r),i){var h=o.data("xthreshold"),c=o.data("ythreshold"),u=void 0!==h&&!1!==h&&parseInt(h)?parseInt(h):a.swipe_h_threshold,f=void 0!==c&&!1!==c&&parseInt(c)?parseInt(c):a.swipe_v_threshold,l=s.originalEvent,g={position:{x:a.touch_capable?l.changedTouches[0].pageX:s.pageX,y:a.touch_capable?l.changedTouches[0].pageY:s.pageY},offset:{x:a.touch_capable?Math.round(l.changedTouches[0].pageX-(o.offset()?o.offset().left:0)):Math.round(s.pageX-(o.offset()?o.offset().left:0)),y:a.touch_capable?Math.round(l.changedTouches[0].pageY-(o.offset()?o.offset().top:0)):Math.round(s.pageY-(o.offset()?o.offset().top:0))},time:Date.now(),target:s.target};t.position.y>g.position.y&&t.position.y-g.position.y>f&&(p="swipeup"),t.position.x<g.position.x&&g.position.x-t.position.x>u&&(p="swiperight"),t.position.y<g.position.y&&g.position.y-t.position.y>f&&(p="swipedown"),t.position.x>g.position.x&&t.position.x-g.position.x>u&&(p="swipeleft");var d=Math.abs(t.position.x-g.position.x),v=Math.abs(t.position.y-g.position.y),w={startEvnt:t,endEvnt:g,direction:p.replace("swipe",""),xAmount:d,yAmount:v,duration:g.time-t.time};o.trigger("swipeend",w)}n=!1,i=!1})},remove:function(){e(this).off(a.startevent,e(this).data.callee1).off(a.moveevent,e(this).data.callee2).off(a.endevent,e(this).data.callee3)}},e.event.special.scrollstart={setup:function(){var t,o,n=this,i=e(n);function r(e,a){w(n,(t=a)?"scrollstart":"scrollend",e)}i.on(a.scrollevent,function e(a){i.data("callee",e),t||r(a,!0),clearTimeout(o),o=setTimeout(function(){r(a,!1)},50)})},remove:function(){e(this).off(a.scrollevent,e(this).data.callee)}};var o,n,i,r,s=e(window),p={0:!0,180:!0};if(a.orientation_support){var h=window.innerWidth||s.width(),c=window.innerHeight||s.height();i=h>c&&h-c>50,r=p[window.orientation],(i&&r||!i&&!r)&&(p={"-90":!0,90:!0})}function u(){var e=o();e!==n&&(n=e,s.trigger("orientationchange"))}e.event.special.orientationchange={setup:function(){return!a.orientation_support&&(n=o(),s.on("throttledresize",u),!0)},teardown:function(){return!a.orientation_support&&(s.off("throttledresize",u),!0)},add:function(e){var t=e.handler;e.handler=function(e){return e.orientation=o(),t.apply(this,arguments)}}},e.event.special.orientationchange.orientation=o=function(){var e=document.documentElement;return(a.orientation_support?p[window.orientation]:e&&e.clientWidth/e.clientHeight<1.1)?"portrait":"landscape"},e.event.special.throttledresize={setup:function(){e(this).on("resize",d)},teardown:function(){e(this).off("resize",d)}};var f,l,g,d=function(){l=Date.now(),(g=l-v)>=250?(v=l,e(this).trigger("throttledresize")):(f&&window.clearTimeout(f),f=window.setTimeout(u,250-g))},v=0;function w(t,a,o,n){var i=o.type;o.type=a,e.event.dispatch.call(t,o,n),o.type=i}e.each({scrollend:"scrollstart",swipeup:"swipe",swiperight:"swipe",swipedown:"swipe",swipeleft:"swipe",swipeend:"swipe",tap2:"tap",taphold2:"taphold"},function(t,a){e.event.special[t]={setup:function(){e(this).on(a,e.noop)}}})}(jQuery);
diff --git a/lib/jquery.mobile.custom.js b/lib/jquery.mobile.custom.js
deleted file mode 100644
index 376d183..0000000
--- a/lib/jquery.mobile.custom.js
+++ /dev/null
@@ -1,864 +0,0 @@
-/*
-* jQuery Mobile v1.4.5
-* http://jquerymobile.com
-*
-* Copyright 2010, 2014 jQuery Foundation, Inc. and other contributors
-* Released under the MIT license.
-* http://jquery.org/license
-*
-*/
-
-(function ( root, doc, factory ) {
- if ( typeof define === "function" && define.amd ) {
- // AMD. Register as an anonymous module.
- define( [ "jquery" ], function ( $ ) {
- factory( $, root, doc );
- return $.mobile;
- });
- } else {
- // Browser globals
- factory( root.jQuery, root, doc );
- }
-}( this, document, function ( jQuery, window, document, undefined ) {// This plugin is an experiment for abstracting away the touch and mouse
-// events so that developers don't have to worry about which method of input
-// the device their document is loaded on supports.
-//
-// The idea here is to allow the developer to register listeners for the
-// basic mouse events, such as mousedown, mousemove, mouseup, and click,
-// and the plugin will take care of registering the correct listeners
-// behind the scenes to invoke the listener at the fastest possible time
-// for that device, while still retaining the order of event firing in
-// the traditional mouse environment, should multiple handlers be registered
-// on the same element for different events.
-//
-// The current version exposes the following virtual events to jQuery bind methods:
-// "vmouseover vmousedown vmousemove vmouseup vclick vmouseout vmousecancel"
-
-(function( $, window, document, undefined ) {
-
-var dataPropertyName = "virtualMouseBindings",
- touchTargetPropertyName = "virtualTouchID",
- virtualEventNames = "vmouseover vmousedown vmousemove vmouseup vclick vmouseout vmousecancel".split( " " ),
- touchEventProps = "clientX clientY pageX pageY screenX screenY".split( " " ),
- mouseHookProps = $.event.mouseHooks ? $.event.mouseHooks.props : [],
- mouseEventProps = $.event.props.concat( mouseHookProps ),
- activeDocHandlers = {},
- resetTimerID = 0,
- startX = 0,
- startY = 0,
- didScroll = false,
- clickBlockList = [],
- blockMouseTriggers = false,
- blockTouchTriggers = false,
- eventCaptureSupported = "addEventListener" in document,
- $document = $( document ),
- nextTouchID = 1,
- lastTouchID = 0, threshold,
- i;
-
-$.vmouse = {
- moveDistanceThreshold: 10,
- clickDistanceThreshold: 10,
- resetTimerDuration: 1500
-};
-
-function getNativeEvent( event ) {
-
- while ( event && typeof event.originalEvent !== "undefined" ) {
- event = event.originalEvent;
- }
- return event;
-}
-
-function createVirtualEvent( event, eventType ) {
-
- var t = event.type,
- oe, props, ne, prop, ct, touch, i, j, len;
-
- event = $.Event( event );
- event.type = eventType;
-
- oe = event.originalEvent;
- props = $.event.props;
-
- // addresses separation of $.event.props in to $.event.mouseHook.props and Issue 3280
- // https://github.com/jquery/jquery-mobile/issues/3280
- if ( t.search( /^(mouse|click)/ ) > -1 ) {
- props = mouseEventProps;
- }
-
- // copy original event properties over to the new event
- // this would happen if we could call $.event.fix instead of $.Event
- // but we don't have a way to force an event to be fixed multiple times
- if ( oe ) {
- for ( i = props.length, prop; i; ) {
- prop = props[ --i ];
- event[ prop ] = oe[ prop ];
- }
- }
-
- // make sure that if the mouse and click virtual events are generated
- // without a .which one is defined
- if ( t.search(/mouse(down|up)|click/) > -1 && !event.which ) {
- event.which = 1;
- }
-
- if ( t.search(/^touch/) !== -1 ) {
- ne = getNativeEvent( oe );
- t = ne.touches;
- ct = ne.changedTouches;
- touch = ( t && t.length ) ? t[0] : ( ( ct && ct.length ) ? ct[ 0 ] : undefined );
-
- if ( touch ) {
- for ( j = 0, len = touchEventProps.length; j < len; j++) {
- prop = touchEventProps[ j ];
- event[ prop ] = touch[ prop ];
- }
- }
- }
-
- return event;
-}
-
-function getVirtualBindingFlags( element ) {
-
- var flags = {},
- b, k;
-
- while ( element ) {
-
- b = $.data( element, dataPropertyName );
-
- for ( k in b ) {
- if ( b[ k ] ) {
- flags[ k ] = flags.hasVirtualBinding = true;
- }
- }
- element = element.parentNode;
- }
- return flags;
-}
-
-function getClosestElementWithVirtualBinding( element, eventType ) {
- var b;
- while ( element ) {
-
- b = $.data( element, dataPropertyName );
-
- if ( b && ( !eventType || b[ eventType ] ) ) {
- return element;
- }
- element = element.parentNode;
- }
- return null;
-}
-
-function enableTouchBindings() {
- blockTouchTriggers = false;
-}
-
-function disableTouchBindings() {
- blockTouchTriggers = true;
-}
-
-function enableMouseBindings() {
- lastTouchID = 0;
- clickBlockList.length = 0;
- blockMouseTriggers = false;
-
- // When mouse bindings are enabled, our
- // touch bindings are disabled.
- disableTouchBindings();
-}
-
-function disableMouseBindings() {
- // When mouse bindings are disabled, our
- // touch bindings are enabled.
- enableTouchBindings();
-}
-
-function startResetTimer() {
- clearResetTimer();
- resetTimerID = setTimeout( function() {
- resetTimerID = 0;
- enableMouseBindings();
- }, $.vmouse.resetTimerDuration );
-}
-
-function clearResetTimer() {
- if ( resetTimerID ) {
- clearTimeout( resetTimerID );
- resetTimerID = 0;
- }
-}
-
-function triggerVirtualEvent( eventType, event, flags ) {
- var ve;
-
- if ( ( flags && flags[ eventType ] ) ||
- ( !flags && getClosestElementWithVirtualBinding( event.target, eventType ) ) ) {
-
- ve = createVirtualEvent( event, eventType );
-
- $( event.target).trigger( ve );
- }
-
- return ve;
-}
-
-function mouseEventCallback( event ) {
- var touchID = $.data( event.target, touchTargetPropertyName ),
- ve;
-
- if ( !blockMouseTriggers && ( !lastTouchID || lastTouchID !== touchID ) ) {
- ve = triggerVirtualEvent( "v" + event.type, event );
- if ( ve ) {
- if ( ve.isDefaultPrevented() ) {
- event.preventDefault();
- }
- if ( ve.isPropagationStopped() ) {
- event.stopPropagation();
- }
- if ( ve.isImmediatePropagationStopped() ) {
- event.stopImmediatePropagation();
- }
- }
- }
-}
-
-function handleTouchStart( event ) {
-
- var touches = getNativeEvent( event ).touches,
- target, flags, t;
-
- if ( touches && touches.length === 1 ) {
-
- target = event.target;
- flags = getVirtualBindingFlags( target );
-
- if ( flags.hasVirtualBinding ) {
-
- lastTouchID = nextTouchID++;
- $.data( target, touchTargetPropertyName, lastTouchID );
-
- clearResetTimer();
-
- disableMouseBindings();
- didScroll = false;
-
- t = getNativeEvent( event ).touches[ 0 ];
- startX = t.pageX;
- startY = t.pageY;
-
- triggerVirtualEvent( "vmouseover", event, flags );
- triggerVirtualEvent( "vmousedown", event, flags );
- }
- }
-}
-
-function handleScroll( event ) {
- if ( blockTouchTriggers ) {
- return;
- }
-
- if ( !didScroll ) {
- triggerVirtualEvent( "vmousecancel", event, getVirtualBindingFlags( event.target ) );
- }
-
- didScroll = true;
- startResetTimer();
-}
-
-function handleTouchMove( event ) {
- if ( blockTouchTriggers ) {
- return;
- }
-
- var t = getNativeEvent( event ).touches[ 0 ],
- didCancel = didScroll,
- moveThreshold = $.vmouse.moveDistanceThreshold,
- flags = getVirtualBindingFlags( event.target );
-
- didScroll = didScroll ||
- ( Math.abs( t.pageX - startX ) > moveThreshold ||
- Math.abs( t.pageY - startY ) > moveThreshold );
-
- if ( didScroll && !didCancel ) {
- triggerVirtualEvent( "vmousecancel", event, flags );
- }
-
- triggerVirtualEvent( "vmousemove", event, flags );
- startResetTimer();
-}
-
-function handleTouchEnd( event ) {
- if ( blockTouchTriggers ) {
- return;
- }
-
- disableTouchBindings();
-
- var flags = getVirtualBindingFlags( event.target ),
- ve, t;
- triggerVirtualEvent( "vmouseup", event, flags );
-
- if ( !didScroll ) {
- ve = triggerVirtualEvent( "vclick", event, flags );
- if ( ve && ve.isDefaultPrevented() ) {
- // The target of the mouse events that follow the touchend
- // event don't necessarily match the target used during the
- // touch. This means we need to rely on coordinates for blocking
- // any click that is generated.
- t = getNativeEvent( event ).changedTouches[ 0 ];
- clickBlockList.push({
- touchID: lastTouchID,
- x: t.clientX,
- y: t.clientY
- });
-
- // Prevent any mouse events that follow from triggering
- // virtual event notifications.
- blockMouseTriggers = true;
- }
- }
- triggerVirtualEvent( "vmouseout", event, flags);
- didScroll = false;
-
- startResetTimer();
-}
-
-function hasVirtualBindings( ele ) {
- var bindings = $.data( ele, dataPropertyName ),
- k;
-
- if ( bindings ) {
- for ( k in bindings ) {
- if ( bindings[ k ] ) {
- return true;
- }
- }
- }
- return false;
-}
-
-function dummyMouseHandler() {}
-
-function getSpecialEventObject( eventType ) {
- var realType = eventType.substr( 1 );
-
- return {
- setup: function(/* data, namespace */) {
- // If this is the first virtual mouse binding for this element,
- // add a bindings object to its data.
-
- if ( !hasVirtualBindings( this ) ) {
- $.data( this, dataPropertyName, {} );
- }
-
- // If setup is called, we know it is the first binding for this
- // eventType, so initialize the count for the eventType to zero.
- var bindings = $.data( this, dataPropertyName );
- bindings[ eventType ] = true;
-
- // If this is the first virtual mouse event for this type,
- // register a global handler on the document.
-
- activeDocHandlers[ eventType ] = ( activeDocHandlers[ eventType ] || 0 ) + 1;
-
- if ( activeDocHandlers[ eventType ] === 1 ) {
- $document.bind( realType, mouseEventCallback );
- }
-
- // Some browsers, like Opera Mini, won't dispatch mouse/click events
- // for elements unless they actually have handlers registered on them.
- // To get around this, we register dummy handlers on the elements.
-
- $( this ).bind( realType, dummyMouseHandler );
-
- // For now, if event capture is not supported, we rely on mouse handlers.
- if ( eventCaptureSupported ) {
- // If this is the first virtual mouse binding for the document,
- // register our touchstart handler on the document.
-
- activeDocHandlers[ "touchstart" ] = ( activeDocHandlers[ "touchstart" ] || 0) + 1;
-
- if ( activeDocHandlers[ "touchstart" ] === 1 ) {
- $document.bind( "touchstart", handleTouchStart )
- .bind( "touchend", handleTouchEnd )
-
- // On touch platforms, touching the screen and then dragging your finger
- // causes the window content to scroll after some distance threshold is
- // exceeded. On these platforms, a scroll prevents a click event from being
- // dispatched, and on some platforms, even the touchend is suppressed. To
- // mimic the suppression of the click event, we need to watch for a scroll
- // event. Unfortunately, some platforms like iOS don't dispatch scroll
- // events until *AFTER* the user lifts their finger (touchend). This means
- // we need to watch both scroll and touchmove events to figure out whether
- // or not a scroll happenens before the touchend event is fired.
-
- .bind( "touchmove", handleTouchMove )
- .bind( "scroll", handleScroll );
- }
- }
- },
-
- teardown: function(/* data, namespace */) {
- // If this is the last virtual binding for this eventType,
- // remove its global handler from the document.
-
- --activeDocHandlers[ eventType ];
-
- if ( !activeDocHandlers[ eventType ] ) {
- $document.unbind( realType, mouseEventCallback );
- }
-
- if ( eventCaptureSupported ) {
- // If this is the last virtual mouse binding in existence,
- // remove our document touchstart listener.
-
- --activeDocHandlers[ "touchstart" ];
-
- if ( !activeDocHandlers[ "touchstart" ] ) {
- $document.unbind( "touchstart", handleTouchStart )
- .unbind( "touchmove", handleTouchMove )
- .unbind( "touchend", handleTouchEnd )
- .unbind( "scroll", handleScroll );
- }
- }
-
- var $this = $( this ),
- bindings = $.data( this, dataPropertyName );
-
- // teardown may be called when an element was
- // removed from the DOM. If this is the case,
- // jQuery core may have already stripped the element
- // of any data bindings so we need to check it before
- // using it.
- if ( bindings ) {
- bindings[ eventType ] = false;
- }
-
- // Unregister the dummy event handler.
-
- $this.unbind( realType, dummyMouseHandler );
-
- // If this is the last virtual mouse binding on the
- // element, remove the binding data from the element.
-
- if ( !hasVirtualBindings( this ) ) {
- $this.removeData( dataPropertyName );
- }
- }
- };
-}
-
-// Expose our custom events to the jQuery bind/unbind mechanism.
-
-for ( i = 0; i < virtualEventNames.length; i++ ) {
- $.event.special[ virtualEventNames[ i ] ] = getSpecialEventObject( virtualEventNames[ i ] );
-}
-
-// Add a capture click handler to block clicks.
-// Note that we require event capture support for this so if the device
-// doesn't support it, we punt for now and rely solely on mouse events.
-if ( eventCaptureSupported ) {
- document.addEventListener( "click", function( e ) {
- var cnt = clickBlockList.length,
- target = e.target,
- x, y, ele, i, o, touchID;
-
- if ( cnt ) {
- x = e.clientX;
- y = e.clientY;
- threshold = $.vmouse.clickDistanceThreshold;
-
- // The idea here is to run through the clickBlockList to see if
- // the current click event is in the proximity of one of our
- // vclick events that had preventDefault() called on it. If we find
- // one, then we block the click.
- //
- // Why do we have to rely on proximity?
- //
- // Because the target of the touch event that triggered the vclick
- // can be different from the target of the click event synthesized
- // by the browser. The target of a mouse/click event that is synthesized
- // from a touch event seems to be implementation specific. For example,
- // some browsers will fire mouse/click events for a link that is near
- // a touch event, even though the target of the touchstart/touchend event
- // says the user touched outside the link. Also, it seems that with most
- // browsers, the target of the mouse/click event is not calculated until the
- // time it is dispatched, so if you replace an element that you touched
- // with another element, the target of the mouse/click will be the new
- // element underneath that point.
- //
- // Aside from proximity, we also check to see if the target and any
- // of its ancestors were the ones that blocked a click. This is necessary
- // because of the strange mouse/click target calculation done in the
- // Android 2.1 browser, where if you click on an element, and there is a
- // mouse/click handler on one of its ancestors, the target will be the
- // innermost child of the touched element, even if that child is no where
- // near the point of touch.
-
- ele = target;
-
- while ( ele ) {
- for ( i = 0; i < cnt; i++ ) {
- o = clickBlockList[ i ];
- touchID = 0;
-
- if ( ( ele === target && Math.abs( o.x - x ) < threshold && Math.abs( o.y - y ) < threshold ) ||
- $.data( ele, touchTargetPropertyName ) === o.touchID ) {
- // XXX: We may want to consider removing matches from the block list
- // instead of waiting for the reset timer to fire.
- e.preventDefault();
- e.stopPropagation();
- return;
- }
- }
- ele = ele.parentNode;
- }
- }
- }, true);
-}
-})( jQuery, window, document );
-
-(function( $ ) {
- $.mobile = {};
-}( jQuery ));
-
- (function( $, undefined ) {
- var support = {
- touch: "ontouchend" in document
- };
-
- $.mobile.support = $.mobile.support || {};
- $.extend( $.support, support );
- $.extend( $.mobile.support, support );
- }( jQuery ));
-
-
-(function( $, window, undefined ) {
- var $document = $( document ),
- supportTouch = $.mobile.support.touch,
- scrollEvent = "touchmove scroll",
- touchStartEvent = supportTouch ? "touchstart" : "mousedown",
- touchStopEvent = supportTouch ? "touchend" : "mouseup",
- touchMoveEvent = supportTouch ? "touchmove" : "mousemove";
-
- // setup new event shortcuts
- $.each( ( "touchstart touchmove touchend " +
- "tap taphold " +
- "swipe swipeleft swiperight " +
- "scrollstart scrollstop" ).split( " " ), function( i, name ) {
-
- $.fn[ name ] = function( fn ) {
- return fn ? this.bind( name, fn ) : this.trigger( name );
- };
-
- // jQuery < 1.8
- if ( $.attrFn ) {
- $.attrFn[ name ] = true;
- }
- });
-
- function triggerCustomEvent( obj, eventType, event, bubble ) {
- var originalType = event.type;
- event.type = eventType;
- if ( bubble ) {
- $.event.trigger( event, undefined, obj );
- } else {
- $.event.dispatch.call( obj, event );
- }
- event.type = originalType;
- }
-
- // also handles scrollstop
- $.event.special.scrollstart = {
-
- enabled: true,
- setup: function() {
-
- var thisObject = this,
- $this = $( thisObject ),
- scrolling,
- timer;
-
- function trigger( event, state ) {
- scrolling = state;
- triggerCustomEvent( thisObject, scrolling ? "scrollstart" : "scrollstop", event );
- }
-
- // iPhone triggers scroll after a small delay; use touchmove instead
- $this.bind( scrollEvent, function( event ) {
-
- if ( !$.event.special.scrollstart.enabled ) {
- return;
- }
-
- if ( !scrolling ) {
- trigger( event, true );
- }
-
- clearTimeout( timer );
- timer = setTimeout( function() {
- trigger( event, false );
- }, 50 );
- });
- },
- teardown: function() {
- $( this ).unbind( scrollEvent );
- }
- };
-
- // also handles taphold
- $.event.special.tap = {
- tapholdThreshold: 750,
- emitTapOnTaphold: true,
- setup: function() {
- var thisObject = this,
- $this = $( thisObject ),
- isTaphold = false;
-
- $this.bind( "vmousedown", function( event ) {
- isTaphold = false;
- if ( event.which && event.which !== 1 ) {
- return false;
- }
-
- var origTarget = event.target,
- timer;
-
- function clearTapTimer() {
- clearTimeout( timer );
- }
-
- function clearTapHandlers() {
- clearTapTimer();
-
- $this.unbind( "vclick", clickHandler )
- .unbind( "vmouseup", clearTapTimer );
- $document.unbind( "vmousecancel", clearTapHandlers );
- }
-
- function clickHandler( event ) {
- clearTapHandlers();
-
- // ONLY trigger a 'tap' event if the start target is
- // the same as the stop target.
- if ( !isTaphold && origTarget === event.target ) {
- triggerCustomEvent( thisObject, "tap", event );
- } else if ( isTaphold ) {
- event.preventDefault();
- }
- }
-
- $this.bind( "vmouseup", clearTapTimer )
- .bind( "vclick", clickHandler );
- $document.bind( "vmousecancel", clearTapHandlers );
-
- timer = setTimeout( function() {
- if ( !$.event.special.tap.emitTapOnTaphold ) {
- isTaphold = true;
- }
- triggerCustomEvent( thisObject, "taphold", $.Event( "taphold", { target: origTarget } ) );
- }, $.event.special.tap.tapholdThreshold );
- });
- },
- teardown: function() {
- $( this ).unbind( "vmousedown" ).unbind( "vclick" ).unbind( "vmouseup" );
- $document.unbind( "vmousecancel" );
- }
- };
-
- // Also handles swipeleft, swiperight
- $.event.special.swipe = {
-
- // More than this horizontal displacement, and we will suppress scrolling.
- scrollSupressionThreshold: 30,
-
- // More time than this, and it isn't a swipe.
- durationThreshold: 1000,
-
- // Swipe horizontal displacement must be more than this.
- horizontalDistanceThreshold: 30,
-
- // Swipe vertical displacement must be less than this.
- verticalDistanceThreshold: 30,
-
- getLocation: function ( event ) {
- var winPageX = window.pageXOffset,
- winPageY = window.pageYOffset,
- x = event.clientX,
- y = event.clientY;
-
- if ( event.pageY === 0 && Math.floor( y ) > Math.floor( event.pageY ) ||
- event.pageX === 0 && Math.floor( x ) > Math.floor( event.pageX ) ) {
-
- // iOS4 clientX/clientY have the value that should have been
- // in pageX/pageY. While pageX/page/ have the value 0
- x = x - winPageX;
- y = y - winPageY;
- } else if ( y < ( event.pageY - winPageY) || x < ( event.pageX - winPageX ) ) {
-
- // Some Android browsers have totally bogus values for clientX/Y
- // when scrolling/zooming a page. Detectable since clientX/clientY
- // should never be smaller than pageX/pageY minus page scroll
- x = event.pageX - winPageX;
- y = event.pageY - winPageY;
- }
-
- return {
- x: x,
- y: y
- };
- },
-
- start: function( event ) {
- var data = event.originalEvent.touches ?
- event.originalEvent.touches[ 0 ] : event,
- location = $.event.special.swipe.getLocation( data );
- return {
- time: ( new Date() ).getTime(),
- coords: [ location.x, location.y ],
- origin: $( event.target )
- };
- },
-
- stop: function( event ) {
- var data = event.originalEvent.touches ?
- event.originalEvent.touches[ 0 ] : event,
- location = $.event.special.swipe.getLocation( data );
- return {
- time: ( new Date() ).getTime(),
- coords: [ location.x, location.y ]
- };
- },
-
- handleSwipe: function( start, stop, thisObject, origTarget ) {
- if ( stop.time - start.time < $.event.special.swipe.durationThreshold &&
- Math.abs( start.coords[ 0 ] - stop.coords[ 0 ] ) > $.event.special.swipe.horizontalDistanceThreshold &&
- Math.abs( start.coords[ 1 ] - stop.coords[ 1 ] ) < $.event.special.swipe.verticalDistanceThreshold ) {
- var direction = start.coords[0] > stop.coords[ 0 ] ? "swipeleft" : "swiperight";
-
- triggerCustomEvent( thisObject, "swipe", $.Event( "swipe", { target: origTarget, swipestart: start, swipestop: stop }), true );
- triggerCustomEvent( thisObject, direction,$.Event( direction, { target: origTarget, swipestart: start, swipestop: stop } ), true );
- return true;
- }
- return false;
-
- },
-
- // This serves as a flag to ensure that at most one swipe event event is
- // in work at any given time
- eventInProgress: false,
-
- setup: function() {
- var events,
- thisObject = this,
- $this = $( thisObject ),
- context = {};
-
- // Retrieve the events data for this element and add the swipe context
- events = $.data( this, "mobile-events" );
- if ( !events ) {
- events = { length: 0 };
- $.data( this, "mobile-events", events );
- }
- events.length++;
- events.swipe = context;
-
- context.start = function( event ) {
-
- // Bail if we're already working on a swipe event
- if ( $.event.special.swipe.eventInProgress ) {
- return;
- }
- $.event.special.swipe.eventInProgress = true;
-
- var stop,
- start = $.event.special.swipe.start( event ),
- origTarget = event.target,
- emitted = false;
-
- context.move = function( event ) {
- if ( !start || event.isDefaultPrevented() ) {
- return;
- }
-
- stop = $.event.special.swipe.stop( event );
- if ( !emitted ) {
- emitted = $.event.special.swipe.handleSwipe( start, stop, thisObject, origTarget );
- if ( emitted ) {
-
- // Reset the context to make way for the next swipe event
- $.event.special.swipe.eventInProgress = false;
- }
- }
- // prevent scrolling
- if ( Math.abs( start.coords[ 0 ] - stop.coords[ 0 ] ) > $.event.special.swipe.scrollSupressionThreshold ) {
- event.preventDefault();
- }
- };
-
- context.stop = function() {
- emitted = true;
-
- // Reset the context to make way for the next swipe event
- $.event.special.swipe.eventInProgress = false;
- $document.off( touchMoveEvent, context.move );
- context.move = null;
- };
-
- $document.on( touchMoveEvent, context.move )
- .one( touchStopEvent, context.stop );
- };
- $this.on( touchStartEvent, context.start );
- },
-
- teardown: function() {
- var events, context;
-
- events = $.data( this, "mobile-events" );
- if ( events ) {
- context = events.swipe;
- delete events.swipe;
- events.length--;
- if ( events.length === 0 ) {
- $.removeData( this, "mobile-events" );
- }
- }
-
- if ( context ) {
- if ( context.start ) {
- $( this ).off( touchStartEvent, context.start );
- }
- if ( context.move ) {
- $document.off( touchMoveEvent, context.move );
- }
- if ( context.stop ) {
- $document.off( touchStopEvent, context.stop );
- }
- }
- }
- };
- $.each({
- scrollstop: "scrollstart",
- taphold: "tap",
- swipeleft: "swipe.left",
- swiperight: "swipe.right"
- }, function( event, sourceEvent ) {
-
- $.event.special[ event ] = {
- setup: function() {
- $( this ).bind( sourceEvent, $.noop );
- },
- teardown: function() {
- $( this ).unbind( sourceEvent );
- }
- };
- });
-
-})( jQuery, this );
-
-
-}));