hammerjs-rails 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,9 @@
1
+ /*! Hammer.JS - v2.0.1 - 2014-07-15
2
+ * http://hammerjs.github.io/
3
+ *
4
+ * Copyright (c) 2014 Jorik Tangelder <j.tangelder@gmail.com>;
5
+ * Licensed under the MIT license */
6
+
7
+
8
+ !function(a,b){"use strict";function c(a,b,c){return setTimeout(i(a,c),b)}function d(a,b,c){return Array.isArray(a)?(e(a,c[b],c),!0):!1}function e(a,c,d){var e,f;if(a)if(a.forEach)a.forEach(c,d);else if(a.length!==b)for(e=0,f=a.length;f>e;e++)c.call(d,a[e],e,a);else for(e in a)a.hasOwnProperty(e)&&c.call(d,a[e],e,a)}function f(a,c,d){for(var e=Object.keys(c),f=0,g=e.length;g>f;f++)(!d||d&&a[e[f]]===b)&&(a[e[f]]=c[e[f]]);return a}function g(a,b){return f(a,b,!0)}function h(a,b,c){var d,e=b.prototype;d=a.prototype=Object.create(e),d.constructor=a,d._super=e,c&&f(d,c)}function i(a,b){return function(){return a.apply(b,arguments)}}function j(a,c){return typeof a==eb?a.apply(c?c[0]||b:b,c):a}function k(a,c){return a===b?c:a}function l(a,b,c){e(p(b),function(b){a.addEventListener(b,c,!1)})}function m(a,b,c){e(p(b),function(b){a.removeEventListener(b,c,!1)})}function n(a,b){for(;a;){if(a==b)return!0;a=a.parentNode}return!1}function o(a,b){return a.indexOf(b)>-1}function p(a){return a.trim().split(/\s+/g)}function q(a,b,c){if(a.indexOf&&!c)return a.indexOf(b);for(var d=0,e=a.length;e>d;d++)if(c&&a[d][c]==b||!c&&a[d]===b)return d;return-1}function r(a){return Array.prototype.slice.call(a,0)}function s(a,b){for(var c=[],d=[],e=0,f=a.length;f>e;e++){var g=b?a[e][b]:a[e];q(d,g)<0&&c.push(a[e]),d[e]=g}return c}function t(a,c){for(var d,e,f=c[0].toUpperCase()+c.slice(1),g=0,h=cb.length;h>g;g++)if(d=cb[g],e=d?d+f:c,e in a)return e;return b}function u(){return jb++}function v(b,c){var d=this;this.manager=b,this.callback=c,this.domHandler=function(a){j(d.manager.options.enable,[d.manager])&&d.handler(a)},this.evEl&&l(this.manager.element,this.evEl,this.domHandler),this.evWin&&l(a,this.evWin,this.domHandler)}function w(a){var b;return new(b=mb?J:nb?K:lb?M:I)(a,x)}function x(a,b,c){var d=c.pointers.length,e=c.changedPointers.length,f=b&tb&&d-e===0,g=b&(vb|wb)&&d-e===0;c.isFirst=f,c.isFinal=g,f&&(a.session={}),c.eventType=b,y(a,c),a.emit("hammer.input",c),a.recognize(c)}function y(a,b){var c=a.session,d=b.pointers,e=d.length;c.firstInput||(c.firstInput=A(b)),e>1&&!c.firstMultiple?c.firstMultiple=A(b):1===e&&(c.firstMultiple=!1);var f=c.firstInput,g=c.firstMultiple,h=g?g.center:f.center,i=B(d);b.timeStamp=ib(),b.deltaTime=b.timeStamp-f.timeStamp,b.deltaX=i.x-h.x,b.deltaY=i.y-h.y,b.center=i,b.angle=F(h,i),b.distance=E(h,i),b.offsetDirection=D(b.deltaX,b.deltaY),b.scale=g?H(g.pointers,d):1,b.rotation=g?G(g.pointers,d):0;var j=a.element;n(b.srcEvent.target,j)&&(j=b.srcEvent.target),b.target=j,z(c,b)}function z(a,c){var d=a.lastInterval;d||(d=a.lastInterval=A(c));var e,f,g,h,i=c.timeStamp-d.timeStamp;if(i>sb||d.velocity===b){var j=d.deltaX-c.deltaX,k=d.deltaY-c.deltaY,l=C(i,j,k);f=l.x,g=l.y,e=hb(l.x)>hb(l.y)?l.x:l.y,h=D(j,k)}else e=d.velocity,f=d.velocityX,g=d.velocityY,h=d.direction;c.velocity=e,c.velocityX=f,c.velocityY=g,c.direction=h}function A(a){for(var b=[],c=0;c<a.pointers.length;c++)b[c]={clientX:gb(a.pointers[c].clientX),clientY:gb(a.pointers[c].clientY)};return{timeStamp:ib(),pointers:b,center:B(b),deltaX:a.deltaX,deltaY:a.deltaY}}function B(a){var b=a.length;if(1===b)return{x:gb(a[0].clientX),y:gb(a[0].clientY)};for(var c=0,d=0,e=0;b>e;e++)c+=a[e].clientX,d+=a[e].clientY;return{x:gb(c/b),y:gb(d/b)}}function C(a,b,c){return{x:b/a||0,y:c/a||0}}function D(a,b){return a===b?xb:hb(a)>=hb(b)?a>0?yb:zb:b>0?Ab:Bb}function E(a,b,c){c||(c=Fb);var d=b[c[0]]-a[c[0]],e=b[c[1]]-a[c[1]];return Math.sqrt(d*d+e*e)}function F(a,b,c){c||(c=Fb);var d=b[c[0]]-a[c[0]],e=b[c[1]]-a[c[1]];return 180*Math.atan2(e,d)/Math.PI}function G(a,b){return F(b[1],b[0],Gb)-F(a[1],a[0],Gb)}function H(a,b){return E(b[0],b[1],Gb)/E(a[0],a[1],Gb)}function I(){this.evEl=Ib,this.evWin=Jb,this.allow=!0,this.pressed=!1,v.apply(this,arguments)}function J(){this.evEl=Mb,this.evWin=Nb,v.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}function K(){this.evEl=Pb,this.targetIds={},v.apply(this,arguments)}function L(a,b){var c,d,e=b.targetIds,f=r(a.targetTouches),g=r(a.changedTouches),h=[];if("touchstart"==a.type)for(c=0,d=f.length;d>c;c++)e[f[c].identifier]=!0;for(c=0,d=g.length;d>c;c++)e[g[c].identifier]&&h.push(g[c]),("touchend"==a.type||"touchcancel"==a.type)&&delete e[g[c].identifier];return[s(f.concat(h),"identifier"),h]}function M(){v.apply(this,arguments);var a=i(this.handler,this);this.touch=new K(this.manager,a),this.mouse=new I(this.manager,a)}function N(a,b){this.manager=a,this.set(b)}function O(a){if(o(a,Vb))return Vb;var b=o(a,Wb),c=o(a,Xb);return b&&c?Wb+" "+Xb:b||c?b?Wb:Xb:o(a,Ub)?Ub:Tb}function P(a){this.id=u(),this.manager=null,this.options=g(a||{},this.defaults),this.options.enable=k(this.options.enable,!0),this.state=Yb,this.simultaneous={},this.requireFail=[]}function Q(a){return a&bc?"cancel":a&_b?"end":a&$b?"move":a&Zb?"start":""}function R(a){return a==Bb?"down":a==Ab?"up":a==yb?"left":a==zb?"right":""}function S(a,b){var c=b.manager;return c?c.get(a):a}function T(){P.apply(this,arguments)}function U(){T.apply(this,arguments),this.pX=null,this.pY=null}function V(){T.apply(this,arguments)}function W(){P.apply(this,arguments),this._timer=null,this._input=null}function X(){T.apply(this,arguments)}function Y(){T.apply(this,arguments)}function Z(){P.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}function $(a,b){return b=b||{},b.recognizers=k(b.recognizers,$.defaults.preset),new _(a,b)}function _(a,b){b=b||{},this.options=g(b,$.defaults),this.handlers={},this.session={},this.recognizers=[],this.element=a,this.input=w(this),this.touchAction=new N(this,this.options.touchAction),ab(this,!0),e(b.recognizers,function(a){var b=this.add(new a[0](a[1]));a[2]&&b.recognizeWith(a[2]),a[3]&&b.requireFailure(a[2])},this)}function ab(a,b){var c=a.element,d=a.options.cssProps;e(d,function(a,d){c.style[t(c.style,d)]=b?a:""});var f=b&&function(){return!1};"none"==d.userSelect&&(c.onselectstart=f),"none"==d.userDrag&&(c.ondragstart=f)}function bb(a,b){var c=document.createEvent("Event");c.initEvent(a,!0,!0),c.gesture=b,b.target.dispatchEvent(c)}var cb=["","webkit","moz","MS","ms","o"],db=document.createElement("div"),eb="function",fb="undefined",gb=Math.round,hb=Math.abs,ib=Date.now,jb=1,kb=/mobile|tablet|ip(ad|hone|od)|android/i,lb="ontouchstart"in a,mb=t(a,"PointerEvent")!==b,nb=lb&&kb.test(navigator.userAgent),ob="touch",pb="pen",qb="mouse",rb="kinect",sb=25,tb=1,ub=2,vb=4,wb=8,xb=1,yb=2,zb=4,Ab=8,Bb=16,Cb=yb|zb,Db=Ab|Bb,Eb=Cb|Db,Fb=["x","y"],Gb=["clientX","clientY"];v.prototype={handler:function(){},destroy:function(){this.elEvents&&m(this.manager.element,this.elEvents,this.domHandler),this.winEvents&&m(a,this.winEvents,this.domHandler)}};var Hb={mousedown:tb,mousemove:ub,mouseup:vb,mouseout:wb},Ib="mousedown",Jb="mousemove mouseout mouseup";h(I,v,{handler:function(a){var b=Hb[a.type];if(b&tb&&0===a.button&&(this.pressed=!0),b&ub&&1!==a.which&&(b=vb),this.pressed&&this.allow){var c=a.relatedTarget||a.toElement||a.target;"mouseout"==a.type&&"HTML"!=c.nodeName&&(b=ub),b&(vb|wb)&&(this.pressed=!1),this.callback(this.manager,b,{pointers:[a],changedPointers:[a],pointerType:qb,srcEvent:a})}}});var Kb={pointerdown:tb,pointermove:ub,pointerup:vb,pointercancel:wb,pointerout:wb},Lb={2:ob,3:pb,4:qb,5:rb},Mb="pointerdown",Nb="pointermove pointerout pointerup pointercancel";a.MSPointerEvent&&(Mb="MSPointerDown",Nb="MSPointerMove MSPointerOut MSPointerUp MSPointerCancel"),h(J,v,{handler:function(a){var b=this.store,c=!1,d=a.type.toLowerCase().replace("ms",""),e=Kb[d],f=Lb[a.pointerType]||a.pointerType,g=a.relatedTarget||a.toElement||a.target;"pointerout"==d&&"HTML"!=g.nodeName&&(e=ub),e&tb&&(0===a.button||f==ob)?b.push(a):e&(vb|wb)&&(c=!0);var h=q(b,a.pointerId,"pointerId");0>h||(b[h]=a,this.callback(this.manager,e,{pointers:b,changedPointers:[a],pointerType:f,srcEvent:a}),c&&b.splice(h,1))}});var Ob={touchstart:tb,touchmove:ub,touchend:vb,touchcancel:wb},Pb="touchstart touchmove touchend touchcancel";h(K,v,{handler:function(a){var b=L(a,this);this.callback(this.manager,Ob[a.type],{pointers:b[0],changedPointers:b[1],pointerType:ob,srcEvent:a})}}),h(M,v,{handler:function(a,b,c){var d=c.pointerType==ob,e=c.pointerType==qb;if(d)this.mouse.allow=!1;else if(e&&!this.mouse.allow)return;b&(vb|wb)&&(this.mouse.allow=!0),this.callback(a,b,c)},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});var Qb=t(db.style,"touchAction"),Rb=Qb!==b,Sb="compute",Tb="auto",Ub="manipulation",Vb="none",Wb="pan-x",Xb="pan-y";N.prototype={set:function(a){a==Sb&&(a=this.compute()),Rb&&(this.manager.element.style[Qb]=a),this.actions=a.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var a=[];return e(this.manager.recognizers,function(b){j(b.options.enable,[b])&&(a=a.concat(b.getTouchAction()))}),O(a.join(" "))},preventDefaults:function(a){if(!Rb){var b=a.srcEvent,c=a.offsetDirection;if(this.manager.session.prevented)return void b.preventDefault();var d=this.actions,e=o(d,Vb),f=o(d,Xb),g=o(d,Wb);return e||f&&g||f&&c&Cb||g&&c&Db?this.preventSrc(b):void 0}},preventSrc:function(a){this.manager.session.prevented=!0,a.preventDefault()}};var Yb=1,Zb=2,$b=4,_b=8,ac=_b,bc=16,cc=32;P.prototype={defaults:{},set:function(a){return f(this.options,a),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(a){if(d(a,"recognizeWith",this))return this;var b=this.simultaneous;return a=S(a,this),b[a.id]||(b[a.id]=a,a.recognizeWith(this)),this},dropRecognizeWith:function(a){return d(a,"dropRecognizeWith",this)?this:(a=S(a,this),delete this.simultaneous[a.id],this)},requireFailure:function(a){if(d(a,"requireFailure",this))return this;var b=this.requireFail;return a=S(a,this),-1===q(b,a)&&(b.push(a),a.requireFailure(this)),this},dropRequireFailure:function(a){if(d(a,"dropRequireFailure",this))return this;a=S(a,this);var b=q(this.requireFail,a);return b>-1&&this.requireFail.splice(b,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(a){return!!this.simultaneous[a.id]},emit:function(a){this.manager.emit(this.options.event,a),this.manager.emit(this.options.event+Q(this.state),a)},tryEmit:function(a){return this.canEmit()?this.emit(a):void(this.state=cc)},canEmit:function(){for(var a=0;a<this.requireFail.length;a++)if(!(this.requireFail[a].state&(cc|Yb)))return!1;return!0},recognize:function(a){var b=f({},a);return j(this.options.enable,[this,b])?(this.state&(ac|bc|cc)&&(this.state=Yb),this.state=this.process(b),void(this.state&(Zb|$b|_b|bc)&&this.tryEmit(b))):(this.reset(),void(this.state=cc))},process:function(){},getTouchAction:function(){},reset:function(){}},h(T,P,{defaults:{pointers:1},attrTest:function(a){var b=this.options.pointers;return 0===b||a.pointers.length===b},process:function(a){var b=this.state,c=a.eventType,d=b&(Zb|$b),e=this.attrTest(a);return d&&(c&wb||!e)?b|bc:d||e?c&vb?b|_b:b&Zb?b|$b:Zb:cc}}),h(U,T,{defaults:{event:"pan",threshold:10,pointers:1,direction:Eb},getTouchAction:function(){var a=this.options.direction;if(a===Eb)return[Vb];var b=[];return a&Cb&&b.push(Xb),a&Db&&b.push(Wb),b},directionTest:function(a){var b=this.options,c=!0,d=a.distance,e=a.direction,f=a.deltaX,g=a.deltaY;return e&b.direction||(b.direction&Cb?(e=0===f?xb:0>f?yb:zb,c=f!=this.pX,d=Math.abs(a.deltaX)):(e=0===g?xb:0>g?Ab:Bb,c=g!=this.pY,d=Math.abs(a.deltaY))),a.direction=e,c&&d>b.threshold&&e&b.direction},attrTest:function(a){return T.prototype.attrTest.call(this,a)&&(this.state&Zb||!(this.state&Zb)&&this.directionTest(a))},emit:function(a){this.pX=a.deltaX,this.pY=a.deltaY,this._super.emit.call(this,a);var b=R(a.direction);b&&this.manager.emit(this.options.event+b,a)}}),h(V,T,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[Vb]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.scale-1)>this.options.threshold||this.state&Zb)},emit:function(a){if(this._super.emit.call(this,a),1!==a.scale){var b=a.scale<1?"in":"out";this.manager.emit(this.options.event+b,a)}}}),h(W,P,{defaults:{event:"press",pointers:1,time:500,threshold:5},getTouchAction:function(){return[Tb]},process:function(a){var b=this.options,d=a.pointers.length===b.pointers,e=a.distance<b.threshold,f=a.deltaTime>b.time;if(this._input=a,!e||!d||a.eventType&(vb|wb)&&!f)this.reset();else if(a.eventType&tb)this.reset(),this._timer=c(function(){this.state=ac,this.tryEmit()},b.time,this);else if(a.eventType&vb)return ac;return cc},reset:function(){clearTimeout(this._timer)},emit:function(a){this.state===ac&&(a&&a.eventType&vb?this.manager.emit(this.options.event+"up",a):(this._input.timeStamp=ib(),this.manager.emit(this.options.event,this._input)))}}),h(X,T,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[Vb]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.rotation)>this.options.threshold||this.state&Zb)}}),h(Y,T,{defaults:{event:"swipe",threshold:10,velocity:.65,direction:Cb|Db,pointers:1},getTouchAction:function(){return U.prototype.getTouchAction.call(this)},attrTest:function(a){var b,c=this.options.direction;return c&(Cb|Db)?b=a.velocity:c&Cb?b=a.velocityX:c&Db&&(b=a.velocityY),this._super.attrTest.call(this,a)&&c&a.direction&&hb(b)>this.options.velocity&&a.eventType&vb},emit:function(a){this.manager.emit(this.options.event,a);var b=R(a.direction);b&&this.manager.emit(this.options.event+b,a)}}),h(Z,P,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:2,posThreshold:10},getTouchAction:function(){return[Ub]},process:function(a){var b=this.options,d=a.pointers.length===b.pointers,e=a.distance<b.threshold,f=a.deltaTime<b.time;if(this.reset(),a.eventType&tb&&0===this.count)return this._failTimeout();if(e&&f&&d){if(a.eventType!=vb)return this._failTimeout();var g=this.pTime?a.timeStamp-this.pTime<b.interval:!0,h=!this.pCenter||E(this.pCenter,a.center)<b.posThreshold;this.pTime=a.timeStamp,this.pCenter=a.center,h&&g?this.count+=1:this.count=1,this._input=a;var i=this.count%b.taps;if(0===i)return this.hasRequireFailures()?(this._timer=c(function(){this.state=ac,this.tryEmit()},b.interval,this),Zb):ac}return cc},_failTimeout:function(){return this._timer=c(function(){this.state=cc},this.options.interval,this),cc},reset:function(){clearTimeout(this._timer)},emit:function(){this.state==ac&&(this._input.tapCount=this.count,this.manager.emit(this.options.event,this._input))}}),$.VERSION="2.0.1",$.defaults={domEvents:!1,touchAction:Sb,enable:!0,preset:[[X,{enable:!1}],[V,{enable:!1},["rotate"]],[Y,{direction:Cb}],[U,{direction:Cb},["swipe"]],[Z],[Z,{event:"doubletap",taps:2},["tap"]],[W]],cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};var dc=1,ec=2;_.prototype={set:function(a){return f(this.options,a),this},stop:function(a){this.session.stopped=a?ec:dc},recognize:function(a){if(!this.session.stopped){this.touchAction.preventDefaults(a);var b,c=this.session,d=c.curRecognizer;(!d||d&&d.state&ac)&&(d=c.curRecognizer=null);for(var e=0,f=this.recognizers.length;f>e;e++)b=this.recognizers[e],this.session.stopped===ec||d&&b!=d&&!b.canRecognizeWith(d)?b.reset():b.recognize(a),!d&&b.state&(Zb|$b|_b)&&(d=c.curRecognizer=b)}},get:function(a){if(a instanceof P)return a;for(var b=this.recognizers,c=0;c<b.length;c++)if(b[c].options.event==a)return b[c];return null},add:function(a){if(d(a,"add",this))return this;var b=this.get(a.options.event);return b&&this.remove(b),this.recognizers.push(a),a.manager=this,this.touchAction.update(),a},remove:function(a){if(d(a,"remove",this))return this;var b=this.recognizers;return a=this.get(a),b.splice(q(b,a),1),this.touchAction.update(),this},on:function(a,b){var c=this.handlers;return e(p(a),function(a){c[a]=c[a]||[],c[a].push(b)}),this},off:function(a,b){var c=this.handlers;return e(p(a),function(a){b?c[a].splice(q(c[a],b),1):delete c[a]}),this},emit:function(a,b){this.options.domEvents&&bb(a,b);var c=this.handlers[a];if(c&&c.length){b.type=a,b.preventDefault=function(){b.srcEvent.preventDefault()};for(var d=0,e=c.length;e>d;d++)c[d](b)}},destroy:function(){this.element&&ab(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}},f($,{INPUT_START:tb,INPUT_MOVE:ub,INPUT_END:vb,INPUT_CANCEL:wb,STATE_POSSIBLE:Yb,STATE_BEGAN:Zb,STATE_CHANGED:$b,STATE_ENDED:_b,STATE_RECOGNIZED:ac,STATE_CANCELLED:bc,STATE_FAILED:cc,DIRECTION_NONE:xb,DIRECTION_LEFT:yb,DIRECTION_RIGHT:zb,DIRECTION_UP:Ab,DIRECTION_DOWN:Bb,DIRECTION_HORIZONTAL:Cb,DIRECTION_VERTICAL:Db,DIRECTION_ALL:Eb,Manager:_,Input:v,TouchAction:N,Recognizer:P,AttrRecognizer:T,Tap:Z,Pan:U,Swipe:Y,Pinch:V,Rotate:X,Press:W,on:l,off:m,each:e,merge:g,extend:f,inherit:h,bindFn:i,prefixed:t}),typeof define==eb&&define.amd?define(function(){return $}):typeof module!=fb&&module.exports?module.exports=$:a.Hammer=$}(window);
9
+ //# sourceMappingURL=hammer.min.map
@@ -1,115 +1,25 @@
1
- /*! jQuery plugin for Hammer.JS - v1.0.0 - 2013-11-03
2
- * http://eightmedia.github.com/hammer.js
3
- *
4
- * Copyright (c) 2013 Jorik Tangelder <j.tangelder@gmail.com>;
5
- * Licensed under the MIT license */
6
-
7
- (function(window, undefined) {
8
- 'use strict';
9
-
10
- function setup(Hammer, $) {
11
- /**
12
- * bind dom events
13
- * this overwrites addEventListener
14
- * @param {HTMLElement} element
15
- * @param {String} eventTypes
16
- * @param {Function} handler
17
- */
18
- Hammer.event.bindDom = function(element, eventTypes, handler) {
19
- $(element).on(eventTypes, function(ev) {
20
- var data = ev.originalEvent || ev;
21
-
22
- if(data.pageX === undefined) {
23
- data.pageX = ev.pageX;
24
- data.pageY = ev.pageY;
25
- }
26
-
27
- if(!data.target) {
28
- data.target = ev.target;
29
- }
30
-
31
- if(data.which === undefined) {
32
- data.which = data.button;
33
- }
34
-
35
- if(!data.preventDefault) {
36
- data.preventDefault = ev.preventDefault;
37
- }
38
-
39
- if(!data.stopPropagation) {
40
- data.stopPropagation = ev.stopPropagation;
41
- }
42
-
43
- handler.call(this, data);
44
- });
45
- };
46
-
47
- /**
48
- * the methods are called by the instance, but with the jquery plugin
49
- * we use the jquery event methods instead.
50
- * @this {Hammer.Instance}
51
- * @return {jQuery}
52
- */
53
- Hammer.Instance.prototype.on = function(types, handler) {
54
- return $(this.element).on(types, handler);
55
- };
56
- Hammer.Instance.prototype.off = function(types, handler) {
57
- return $(this.element).off(types, handler);
58
- };
59
-
60
-
61
- /**
62
- * trigger events
63
- * this is called by the gestures to trigger an event like 'tap'
64
- * @this {Hammer.Instance}
65
- * @param {String} gesture
66
- * @param {Object} eventData
67
- * @return {jQuery}
68
- */
69
- Hammer.Instance.prototype.trigger = function(gesture, eventData) {
70
- var el = $(this.element);
71
- if(el.has(eventData.target).length) {
72
- el = $(eventData.target);
1
+ (function($, Hammer, dataAttr) {
2
+ function hammerify(el, options) {
3
+ var $el = $(el);
4
+ if(!$el.data(dataAttr)) {
5
+ $el.data(dataAttr, new Hammer($el[0], options));
6
+ }
73
7
  }
74
8
 
75
- return el.trigger({
76
- type : gesture,
77
- gesture: eventData
78
- });
79
- };
80
-
81
-
82
- /**
83
- * jQuery plugin
84
- * create instance of Hammer and watch for gestures,
85
- * and when called again you can change the options
86
- * @param {Object} [options={}]
87
- * @return {jQuery}
88
- */
89
- $.fn.hammer = function(options) {
90
- return this.each(function() {
91
- var el = $(this);
92
- var inst = el.data('hammer');
93
- // start new hammer instance
94
- if(!inst) {
95
- el.data('hammer', new Hammer(this, options || {}));
96
- }
97
- // change the options
98
- else if(inst && options) {
99
- Hammer.utils.extend(inst.options, options);
100
- }
101
- });
102
- };
103
- }
104
-
105
- // Based off Lo-Dash's excellent UMD wrapper (slightly modified) - https://github.com/bestiejs/lodash/blob/master/lodash.js#L5515-L5543
106
- // some AMD build optimizers, like r.js, check for specific condition patterns like the following:
107
- if(typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
108
- // define as an anonymous module
109
- define(['hammer', 'jquery'], setup);
110
-
111
- }
112
- else {
113
- setup(window.Hammer, window.jQuery || window.Zepto);
114
- }
115
- })(this);
9
+ $.fn.hammer = function(options) {
10
+ return this.each(function() {
11
+ hammerify(this, options);
12
+ });
13
+ };
14
+
15
+ // extend the emit method to also trigger jQuery events
16
+ Hammer.Manager.prototype.emit = (function(originalEmit) {
17
+ return function(type, data) {
18
+ originalEmit.call(this, type, data);
19
+ jQuery(this.element).triggerHandler({
20
+ type: type,
21
+ gesture: data
22
+ });
23
+ };
24
+ })(Hammer.Manager.prototype.emit);
25
+ })(jQuery, Hammer, "hammer");
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hammerjs-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Pochet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-18 00:00:00.000000000 Z
11
+ date: 2014-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description: hammerjs packaged for Rails assets pipeline
@@ -45,7 +45,7 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - .gitignore
48
+ - ".gitignore"
49
49
  - Gemfile
50
50
  - README.md
51
51
  - Rakefile
@@ -54,6 +54,7 @@ files:
54
54
  - lib/hammerjs/rails/version.rb
55
55
  - vendor/assets/javascripts/hammer.fakemultitouch.js
56
56
  - vendor/assets/javascripts/hammer.js
57
+ - vendor/assets/javascripts/hammer.min.js
57
58
  - vendor/assets/javascripts/hammer.showtouches.js
58
59
  - vendor/assets/javascripts/jquery.hammer.js
59
60
  homepage: https://github.com/vincent-pochet/hammerjs-rails
@@ -66,18 +67,19 @@ require_paths:
66
67
  - lib
67
68
  required_ruby_version: !ruby/object:Gem::Requirement
68
69
  requirements:
69
- - - '>='
70
+ - - ">="
70
71
  - !ruby/object:Gem::Version
71
72
  version: '0'
72
73
  required_rubygems_version: !ruby/object:Gem::Requirement
73
74
  requirements:
74
- - - '>='
75
+ - - ">="
75
76
  - !ruby/object:Gem::Version
76
77
  version: '0'
77
78
  requirements: []
78
79
  rubyforge_project:
79
- rubygems_version: 2.1.11
80
+ rubygems_version: 2.2.2
80
81
  signing_key:
81
82
  specification_version: 4
82
83
  summary: hammerjs packaged for Rails assets pipeline
83
84
  test_files: []
85
+ has_rdoc: