mirror of https://github.com/Radarr/Radarr
1 line
2.9 KiB
JavaScript
1 line
2.9 KiB
JavaScript
(function(d){var g=d.telerik,b=function(){},c={},a={},f={scope:"default",drop:b,over:b,out:b,owner:document.body},e={distance:5,cursorAt:{left:10,top:10},scope:"default",start:b,drag:b,stop:b,destroy:b,owner:document.body,cue:function(){return d("<span />")}};g.droppable=function(h){d.extend(this,f,h);d(this.owner).delegate(this.selector,"mouseenter",d.proxy(this._over,this)).delegate(this.selector,"mouseup",d.proxy(this._drop,this)).delegate(this.selector,"mouseleave",d.proxy(this._out,this))};g.droppable.prototype={_over:function(h){this._raise(h,this.over)},_out:function(h){this._raise(h,this.out)},_drop:function(h){this._raise(h,d.proxy(function(i){this.drop(i);i.destroy(i)},this))},_raise:function(j,i){var h=c[this.scope];if(h){i(d.extend(j,h,{$droppable:d(j.currentTarget)}))}}};g.dragCue=function(h){return d('<div class="t-header t-drag-clue" />').html(h).prepend('<span class="t-icon t-drag-status t-denied" />').appendTo(document.body)};g.dragCueStatus=function(h,i){h.find(".t-drag-status").attr("className","t-icon t-drag-status").addClass(i)};g.draggable=function(h){d.extend(this,e,h);d(this.owner).delegate(this.selector,"mousedown",d.proxy(this._wait,this)).delegate(this.selector,"dragstart",g.preventDefault);this._startProxy=d.proxy(this._start,this);this._destroyProxy=d.proxy(this._destroy,this);this._stopProxy=d.proxy(this._stop,this);this._dragProxy=d.proxy(this._drag,this)};g.draggable.get=function(h){return c[h]};g.draggable.prototype={_raise:function(j,i){var h=c[this.scope];if(h){return i(d.extend(j,h))}},_wait:function(h){this.$target=d(h.currentTarget);this._startPosition={x:h.pageX,y:h.pageY};d(document).bind({mousemove:this._startProxy,mouseup:this._destroyProxy});d(document.documentElement).trigger("mousedown",h);return false},_start:function(l){var k=this._startPosition.x-l.pageX,j=this._startPosition.y-l.pageY;var i=Math.sqrt((k*k)+(j*j));if(i>=this.distance){var h=a[this.selector];if(!h){h=a[this.selector]=this.cue({$draggable:this.$target});d(document).unbind("mousemove",this._startProxy).unbind("mouseup",this._destroyProxy).bind({"mouseup keydown":this._stopProxy,mousemove:this._dragProxy,selectstart:false})}c[this.scope]={$cue:h.css({position:"absolute",left:l.pageX+this.cursorAt.left,top:l.pageY+this.cursorAt.top}),$draggable:this.$target,destroy:this._destroyProxy};if(this._raise(l,this.start)===false){this._destroy(l)}}},_drag:function(h){this._raise(h,this.drag);c[this.scope].$cue.css({left:h.pageX+this.cursorAt.left,top:h.pageY+this.cursorAt.top})},_stop:function(h){if(h.type=="mouseup"||h.keyCode==27){if(this._raise(h,this.stop)===false){this._destroy(h)}else{var i=c[this.scope];i.$cue.animate(i.$draggable.offset(),"fast",this._destroyProxy)}}},_destroy:function(h){d(document).unbind("mouseup keydown",this._stopProxy).unbind("mousemove",this._dragProxy).unbind("mousemove",this._startProxy).unbind("selectstart",false);this._raise(h,this.destroy);c[this.scope]=null;a[this.selector]=null}}})(jQuery); |