(function(a){"function"===typeof define&&define.amd?define(["jquery"],a):a(jQuery)})(function(a){a.fn.jqDrag=function(b){return u(this,b,"d")};a.fn.jqResize=function(b,c){return u(this,b,"r",c)};a.jqDnR={dnr:{},e:0,drag:function(b){"d"==e.k?f.css({left:e.X+b.pageX-e.pX,top:e.Y+b.pageY-e.pY}):(f.css({width:Math.max(b.pageX-e.pX+e.W,0),height:Math.max(b.pageY-e.pY+e.H,0)}),k&&l.css({width:Math.max(b.pageX-k.pX+k.W,0),height:Math.max(b.pageY-k.pY+k.H,0)}));return!1},stop:function(){a(document).off("mousemove",
n.drag).off("mouseup",n.stop)}};var n=a.jqDnR,e=n.dnr,f=n.e,l,k,u=function(b,c,p,m){return b.each(function(){c=c?a(c,b):b;c.on("mousedown",{e:b,k:p},function(d){var g=d.data,h={};f=g.e;l=m?a(m):!1;if("relative"!=f.css("position"))try{f.position(h)}catch(q){}e={X:h.left||r("left")||0,Y:h.top||r("top")||0,W:r("width")||f[0].scrollWidth||0,H:r("height")||f[0].scrollHeight||0,pX:d.pageX,pY:d.pageY,k:g.k};k=l&&"d"!=g.k?{X:h.left||t("left")||0,Y:h.top||t("top")||0,W:l[0].offsetWidth||t("width")||0,H:l[0].offsetHeight||
t("height")||0,pX:d.pageX,pY:d.pageY,k:g.k}:!1;if(a("input.hasDatepicker",f[0])[0])try{a("input.hasDatepicker",f[0]).datepicker("hide")}catch(q){}a(document).on("mousemove",a.jqDnR.drag).mouseup(a.jqDnR.stop);return!1})})},r=function(b){return parseInt(f.css(b),10)||!1},t=function(b){return parseInt(l.css(b),10)||!1};a.fn.tinyDraggable=function(b){var c=a.extend({handle:0,exclude:0},b);return this.each(function(){var p,m,d=a(this);(c.handle?a(c.handle,d):d).on({mousedown:function(g){if(!c.exclude||
!~a.inArray(g.target,a(c.exclude,d))){g.preventDefault();var h=d.offset();p=g.pageX-h.left;m=g.pageY-h.top;a(document).on("mousemove.drag",function(q){d.offset({top:q.pageY-m,left:q.pageX-p})})}},mouseup:function(g){a(document).off("mousemove.drag")}})})}});
