/*! Dragpan - v1.1.3 - 2015-02-19 * https://github.com/lgoldstien/jquery-dragpan * Copyright (c) 2015 Lawrence Goldstien; Licensed MIT */ !function(){"use strict";var a;$.widget("oml.dragpan",{_defaults:{speedX:10,speedY:10,cursor:"all-scroll",on:!0,bodyselect:!1},_create:function(){a=this,this._defaults.$parent=$(this.element),this.options="undefined"==typeof this.options?this._defaults:$.extend(this._defaults,this.options),"object"==typeof this.options.parent&&(this.options.$parent=this.options.parent),this.vars={$parent:this.options.$parent,$child:this.options.$parent.children(),maxX:this.options.$parent.children().prop("scrollWidth"),maxY:this.options.$parent.children().prop("scrollHeight"),posX:this.options.$parent.scrollLeft(),posY:this.options.$parent.scrollTop(),lastPosX:0,lastPosY:0,state:"off"},this.vars.selection=!1,"none"!==this.vars.$parent.css("-webkit-touch-callout")&&(this.vars.selection=!0),"none"!==this.vars.$parent.css("-webkit-user-select")&&(this.vars.selection=!0),"none"!==this.vars.$parent.css("-khtml-user-select")&&(this.vars.selection=!0),"none"!==this.vars.$parent.css("-moz-user-select")&&(this.vars.selection=!0),"none"!==this.vars.$parent.css("-ms-user-select")&&(this.vars.selection=!0),"none"!==this.vars.$parent.css("user-select")&&(this.vars.selection=!0),this.vars.$parent.scroll(function(){a.vars.posX=a.vars.$parent.scrollLeft(),a.vars.posY=a.vars.$parent.scrollTop()}),a.options.on===!0&&this.on()},_dragging:function(b){"on"===b?this.vars.$parent.mousemove(function(b){var c=(a.vars.lastPosX-b.clientX)*(a.options.speedX/10),d=(a.vars.lastPosY-b.clientY)*(a.options.speedY/10);a._updateScrollPosition(c,d,!0),a.vars.lastPosX=b.clientX,a.vars.lastPosY=b.clientY}):this.vars.$parent.off("mousemove")},_updateScrollPosition:function(a,b,c){c===!0?(this.vars.$parent.scrollLeft(this.vars.posX+a),this.vars.$parent.scrollTop(this.vars.posY+b)):(this.vars.$parent.scrollLeft(a),this.vars.$parent.scrollTop(b))},_addMouseBinding:function(){this.vars.$parent.mousedown(function(b){a.vars.lastPosX=b.clientX,a.vars.lastPosY=b.clientY,a._dragging("on")}),this.vars.$parent.mouseup(function(){a._dragging("off")}),this.vars.$parent.mouseleave(function(){a._dragging("off")})},_removeMouseBinding:function(){this.vars.$parent.off("mousemove").off("mousedown").off("mouseup").off("mouseleave"),this._dragging("off")},_state:function(){return this.vars.state},_selectionOff:function(){this.vars.bodyselect===!1&&$("body").css("-webkit-touch-callout","none").css("-webkit-user-select","none").css("-khtml-user-select","none").css("-moz-user-select","-moz-none").css("-ms-user-select","none").css("user-select","none")},on:function(){"off"===this._state()&&(this.options.$parent.css("cursor",this.options.cursor),this.vars.$parent.css("-webkit-touch-callout","none").css("-webkit-user-select","none").css("-khtml-user-select","none").css("-moz-user-select","-moz-none").css("-ms-user-select","none").css("user-select","none"),this._addMouseBinding(),this._selectionOff(),this.vars.state="on")},off:function(){"on"===this._state()&&(this.vars.selection===!0&&this.vars.$parent.css("-webkit-touch-callout","all").css("-webkit-user-select","all").css("-khtml-user-select","all").css("-moz-user-select","all").css("-ms-user-select","all").css("user-select","all"),this.options.$parent.css("cursor","default"),this._removeMouseBinding(),this.vars.state="off")}})}();