mirror of https://github.com/Radarr/Radarr
1 line
2.8 KiB
JavaScript
1 line
2.8 KiB
JavaScript
(function(c){var a=c.telerik;var b=10;a.draganddrop=function(e,f){if(!(this instanceof arguments.callee)){return new arguments.callee(e,f)}this.hitTestOffset=5;c.extend(this,f);e="."+(e||"draganddrop");var d=f.draggables;c.each(c.isArray(d)?d:[d],c.proxy(function(g,h){c(h).live("mousedown",c.proxy(this.waitForDrag,this)).live("dragstart",a.preventDefault)},this));this.evt={ss:"selectstart"+e,mm:"mousemove"+e,ku:"keyup"+e,mu:"mouseup"+e}};a.draganddrop.applyContext=function(f,d){var e={};c.each(f,function(g){e[g]=c.isFunction(this)?c.proxy(this,d):this});return e};a.draganddrop.prototype={moveClue:function(d){if(!this.useDragClue){this.onDragMove(d,this.$draggedElement);return}this.$dragClue.css({left:d.pageX+b,top:d.pageY+b});var f=this.onDragMove(d,this.$draggedElement,this.$dragClue)||"t-denied";this.$dragClueStatus.className="t-icon t-drag-status "+f},startDrag:function(h){var d=this.hittestCoordinates.left-h.pageX;var g=this.hittestCoordinates.top-h.pageY;var f=Math.sqrt((g*g)+(d*d));if(f>=this.hitTestOffset){c(document).bind(this.evt.ss,function(){return false}).unbind(this.evt.mm);if(this.onDragStart(h,this.$draggedElement)){}if(this.useDragClue){this.$dragClueStatus=c('<span class="t-icon t-drag-status t-denied" />')[0];this.$dragClue=c('<div class="t-header t-drag-clue" />').html(this.createDragClue(this.$draggedElement)).prepend(this.$dragClueStatus).css({left:h.pageX+b,top:h.pageY+b}).appendTo(document.body)}c(document).bind(this.evt.mm,a.stop(this.moveClue,this)).bind(this.evt.ku,a.stop(this.keyboardListener,this));this.dragStarted=true}},removeDragClue:function(){if(this.$dragClue){this.$dragClue.remove();this.$dragClue=null;this.$dragClueStatus=null}},stopDrag:function(d){if(this.dragStarted){var f=this.onDrop(d,this.$draggedElement,this.useDragClue?this.$dragClue:undefined);if(this.useDragClue&&this.$dragClue){if(!f){this.$dragClue.animate(this.$draggedElement.offset(),"fast",c.proxy(this.removeDragClue,this))}else{if(typeof f=="function"){f(c.proxy(this.removeDragClue,this))}else{this.removeDragClue()}}}this.dragStarted=false}c(document).unbind([this.evt.ss,this.evt.mm,this.evt.mu,this.evt.ku].join(" "))},waitForDrag:function(f){var d=c(f.target);if(f.which!==1||!this.shouldDrag(d)){return}this.$draggedElement=d;this.hittestCoordinates={left:f.pageX,top:f.pageY};c(document).bind(this.evt.mm,a.stop(this.startDrag,this)).bind(this.evt.mu,a.stop(this.stopDrag,this));if(this.hitTestOffset==0){this.startDrag(f)}c(document).trigger("mousedown",f);return false},keyboardListener:function(d){if(d.keyCode==27){c(document).unbind([this.evt.ss,this.evt.mm,this.evt.mu,this.evt.ku].join(" "));this.onDragCancelled(d,this.$draggedElement);if(this.useDragClue&&this.$dragClue){this.$dragClue.animate(this.$draggedElement.offset(),"fast",c.proxy(this.removeDragClue,this))}this.dragStarted=false}}}})(jQuery); |