if(typeof(touchhandler_js)=="undefined"){touchhandler_js=true;var MAXIMUM_MOVE=40;var TOUCH_TAP_DELAY=500;var TOUCH_DOUBLE_TAP_DELAY=300;var LONG_PRESS_DELAY=600;function _isValidTapTouch(b,a,c,e){if(b==undefined){return false}var d=b.changedTouches[b.changedTouches.length-1];var g=a.changedTouches[a.changedTouches.length-1];var f=e[g.identifier];return f&&g.identifier===d.identifier&&Math.abs(g.screenX-f.screenX)<MAXIMUM_MOVE&&Math.abs(g.screenY-f.screenY)<MAXIMUM_MOVE&&(!c||a.timeStamp-b.timeStamp<c)}if(obips.view==undefined){obips.view=function(){}}obips.view.TouchTapAndLongPressHandler=function(c,b,a){this.tapHandler=c;this.doubleTapHandler=b;this.longPressHandler=a};obips.view.TouchTapAndLongPressHandler.prototype.addTouchTapAndLongPressSupport=function(b){var a=this;b.addEventListener("touchstart",function(c){return a.handleTouchStart.call(this,a,c)},false);b.addEventListener("touchmove",function(c){return a.handleTouchMove.call(this,a,c)},false);b.addEventListener("touchend",function(c){return a.handleTouchEnd.call(this,a,c)},false)},obips.view.TouchTapAndLongPressHandler.prototype.handleTouchStart=function(b,a){var d=a.changedTouches[a.changedTouches.length-1];var c={identifier:d.identifier,screenX:d.screenX,screenY:d.screenY,clientX:d.clientX,clientY:d.clientY,event:a};this._touchesTracker=this._touchesTracker||{};this._touchesTracker[d.identifier]=c;if(b.longPressHandler){c.timeStamp=event.timeStamp;c.longPressTimeoutID=setTimeout(longPressHandler(d,this,b),LONG_PRESS_DELAY)}this._touchStart=a},obips.view.TouchTapAndLongPressHandler.prototype.handleTouchMove=function(c,a){var b=this._touchStart;if(b!==undefined){if(!_isValidTapTouch(b,a,null,this._touchesTracker)){var d=a.changedTouches[a.changedTouches.length-1];trackedTouch=this._touchesTracker[d.identifier];if(trackedTouch.longPressTimeoutID){clearTimeout(trackedTouch.longPressTimeoutID);delete trackedTouch.longPressTimeoutID}this._touchStart=undefined}}this._lastTouchMove=a};function _isValidDoubleTapTouch(a,c,b){if(!c){return false}return a.timeStamp-c.timeStamp<TOUCH_DOUBLE_TAP_DELAY&&(!b||b.timeStamp<c.timeStamp)}obips.view.TouchTapAndLongPressHandler.prototype.handleTouchEnd=function(e,a){var c=this._touchStart;var d=a.changedTouches;for(var b=0;b<d.length;b++){var g=d[b];var f=this._touchesTracker[g.identifier];if(f){if(f.longPressTimeoutID){clearTimeout(f.longPressTimeoutID);delete f.longPressTimeoutID}}}if(_isValidTapTouch(c,a,TOUCH_TAP_DELAY,this._touchesTracker)){if(_isValidDoubleTapTouch(a,this._lastTouchTapEnd,this._lastTouchMove)){this._lastTouchTapEnd=undefined;if(e.doubleTapHandler){e.doubleTapHandler.call(this,c)}}else{this._lastTouchTapEnd=a;if(e.tapHandler){e.tapHandler.call(this,c)}}}for(var b=0;b<d.length;b++){var g=d[b];var f=this._touchesTracker[g.identifier];if(f){delete this._touchesTracker[g.identifier]}}};var longPressHandler=function(c,b,a){return function(){var e=b._touchesTracker[c.identifier];if(e!==undefined&&e.longPressTimeoutID!==undefined){delete e.longPressTimeoutID;b._touchStart=undefined;var d=e.event;if(a.longPressHandler){a.longPressHandler.call(b,e.event)}}}}};