﻿// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Permissive License.
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
// All other rights reserved.

Type.registerNamespace("Telerik.Web");
Telerik.Web.IDragSource=function(){
};
Telerik.Web.IDragSource.prototype={get_dragDataType:function(){
throw Error.notImplemented();
},getDragData:function(){
throw Error.notImplemented();
},get_dragMode:function(){
throw Error.notImplemented();
},onDragStart:function(){
throw Error.notImplemented();
},onDrag:function(){
throw Error.notImplemented();
},onDragEnd:function(){
throw Error.notImplemented();
}};
Telerik.Web.IDragSource.registerInterface("Telerik.Web.IDragSource");
Telerik.Web.IDropTarget=function(){
};
Telerik.Web.IDropTarget.prototype={get_dropTargetElement:function(){
throw Error.notImplemented();
},canDrop:function(){
throw Error.notImplemented();
},drop:function(){
throw Error.notImplemented();
},onDragEnterTarget:function(){
throw Error.notImplemented();
},onDragLeaveTarget:function(){
throw Error.notImplemented();
},onDragInTarget:function(){
throw Error.notImplemented();
}};
Telerik.Web.IDropTarget.registerInterface("Telerik.Web.IDropTarget");
Telerik.Web.DragMode=function(){
throw Error.invalidOperation();
};
Telerik.Web.DragMode.prototype={Copy:0,Move:1};
Telerik.Web.DragMode.registerEnum("Telerik.Web.DragMode");
Telerik.Web.DragDropEventArgs=function(_1,_2,_3){
this._dragMode=_1;
this._dataType=_2;
this._data=_3;
};
Telerik.Web.DragDropEventArgs.prototype={get_dragMode:function(){
return this._dragMode||null;
},get_dragDataType:function(){
return this._dataType||null;
},get_dragData:function(){
return this._data||null;
}};
Telerik.Web.DragDropEventArgs.registerClass("Telerik.Web.DragDropEventArgs");
Telerik.Web._DragDropManager=function(){
this._instance=null;
this._events=null;
};
Telerik.Web._DragDropManager.prototype={add_dragStart:function(_4){
this.get_events().addHandler("dragStart",_4);
},remove_dragStart:function(_5){
this.get_events().removeHandler("dragStart",_5);
},get_events:function(){
if(!this._events){
this._events=new Sys.EventHandlerList();
}
return this._events;
},add_dragStop:function(_6){
this.get_events().addHandler("dragStop",_6);
},remove_dragStop:function(_7){
this.get_events().removeHandler("dragStop",_7);
},_getInstance:function(){
if(!this._instance){
if(Sys.Browser.agent===Sys.Browser.InternetExplorer){
this._instance=new Telerik.Web.IEDragDropManager();
}else{
this._instance=new Telerik.Web.GenericDragDropManager();
}
this._instance.initialize();
this._instance.add_dragStart(Function.createDelegate(this,this._raiseDragStart));
this._instance.add_dragStop(Function.createDelegate(this,this._raiseDragStop));
}
return this._instance;
},startDragDrop:function(_8,_9,_a){
this._getInstance().startDragDrop(_8,_9,_a);
},registerDropTarget:function(_b,_c){
this._getInstance().registerDropTarget(_b,_c);
},unregisterDropTarget:function(_d){
this._getInstance().unregisterDropTarget(_d);
},dispose:function(){
delete this._events;
Sys.Application.unregisterDisposableObject(this);
Sys.Application.removeComponent(this);
},_raiseDragStart:function(_e,_f){
var _10=this.get_events().getHandler("dragStart");
if(_10){
_10(this,_f);
}
},_raiseDragStop:function(_11,_12){
var _13=this.get_events().getHandler("dragStop");
if(_13){
_13(this,_12);
}
}};
Telerik.Web._DragDropManager.registerClass("Telerik.Web._DragDropManager");
Telerik.Web.DragDropManager=new Telerik.Web._DragDropManager();
Telerik.Web.IEDragDropManager=function(){
Telerik.Web.IEDragDropManager.initializeBase(this);
this._dropTargets=null;
this._radius=10;
this._activeDragVisual=null;
this._activeContext=null;
this._activeDragSource=null;
this._underlyingTarget=null;
this._oldOffset=null;
this._potentialTarget=null;
this._isDragging=false;
this._mouseUpHandler=null;
this._documentMouseMoveHandler=null;
this._documentDragOverHandler=null;
this._dragStartHandler=null;
this._mouseMoveHandler=null;
this._dragEnterHandler=null;
this._dragLeaveHandler=null;
this._dragOverHandler=null;
this._dropHandler=null;
};
Telerik.Web.IEDragDropManager.prototype={add_dragStart:function(_14){
this.get_events().addHandler("dragStart",_14);
},remove_dragStart:function(_15){
this.get_events().removeHandler("dragStart",_15);
},add_dragStop:function(_16){
this.get_events().addHandler("dragStop",_16);
},remove_dragStop:function(_17){
this.get_events().removeHandler("dragStop",_17);
},initialize:function(){
Telerik.Web.IEDragDropManager.callBaseMethod(this,"initialize");
this._mouseUpHandler=Function.createDelegate(this,this._onMouseUp);
this._documentMouseMoveHandler=Function.createDelegate(this,this._onDocumentMouseMove);
this._documentDragOverHandler=Function.createDelegate(this,this._onDocumentDragOver);
this._dragStartHandler=Function.createDelegate(this,this._onDragStart);
this._mouseMoveHandler=Function.createDelegate(this,this._onMouseMove);
this._dragEnterHandler=Function.createDelegate(this,this._onDragEnter);
this._dragLeaveHandler=Function.createDelegate(this,this._onDragLeave);
this._dragOverHandler=Function.createDelegate(this,this._onDragOver);
this._dropHandler=Function.createDelegate(this,this._onDrop);
},dispose:function(){
if(this._dropTargets){
for(var i=0;i<this._dropTargets;i++){
this.unregisterDropTarget(this._dropTargets[i]);
}
this._dropTargets=null;
}
Telerik.Web.IEDragDropManager.callBaseMethod(this,"dispose");
},startDragDrop:function(_19,_1a,_1b){
var ev=window._event;
if(this._isDragging){
return;
}
this._underlyingTarget=null;
this._activeDragSource=_19;
this._activeDragVisual=_1a;
this._activeContext=_1b;
var _1d={x:ev.clientX,y:ev.clientY};
_1a.originalPosition=_1a.style.position;
var _1e=Telerik.Web.DomElement.getLocation(_1a);
_1a.style.position="absolute";
document._lastPosition=_1d;
_1a.startingPoint=_1d;
var _1f=this.getScrollOffset(_1a,true);
_1a.startingPoint=this.addPoints(_1a.startingPoint,_1f);
if(_1a.style.position=="absolute"){
_1a.startingPoint=this.subtractPoints(_1a.startingPoint,_1e);
}else{
var _20=parseInt(_1a.style.left);
var top=parseInt(_1a.style.top);
if(isNaN(_20)){
_20="0";
}
if(isNaN(top)){
top="0";
}
_1a.startingPoint=this.subtractPoints(_1a.startingPoint,{x:_20,y:top});
}
this._prepareForDomChanges();
_19.onDragStart();
var _22=new Telerik.Web.DragDropEventArgs(_19.get_dragMode(),_19.get_dragDataType(),_19.getDragData(_1b));
var _23=this.get_events().getHandler("dragStart");
if(_23){
_23(this,_22);
}
this._recoverFromDomChanges();
this._wireEvents();
this._drag(true);
},_stopDragDrop:function(_24){
var ev=window._event;
if(this._activeDragSource!=null){
this._unwireEvents();
if(!_24){
_24=(this._underlyingTarget==null);
}
if(!_24&&this._underlyingTarget!=null){
this._underlyingTarget.drop(this._activeDragSource.get_dragMode(),this._activeDragSource.get_dragDataType(),this._activeDragSource.getDragData(this._activeContext));
}
this._activeDragSource.onDragEnd(_24);
var _26=this.get_events().getHandler("dragStop");
if(_26){
_26(this,Sys.EventArgs.Empty);
}
this._activeDragVisual.style.position=this._activeDragVisual.originalPosition;
this._activeDragSource=null;
this._activeContext=null;
this._activeDragVisual=null;
this._isDragging=false;
this._potentialTarget=null;
ev.preventDefault();
}
},_drag:function(_27){
var ev=window._event;
var _29={x:ev.clientX,y:ev.clientY};
document._lastPosition=_29;
var _2a=this.getScrollOffset(this._activeDragVisual,true);
var _2b=this.addPoints(this.subtractPoints(_29,this._activeDragVisual.startingPoint),_2a);
if(!_27&&parseInt(this._activeDragVisual.style.left)==_2b.x&&parseInt(this._activeDragVisual.style.top)==_2b.y){
return;
}
TelerikCommonScripts.setLocation(this._activeDragVisual,_2b);
this._prepareForDomChanges();
this._activeDragSource.onDrag();
this._recoverFromDomChanges();
this._potentialTarget=this._findPotentialTarget(this._activeDragSource,this._activeDragVisual);
var _2c=(this._potentialTarget!=this._underlyingTarget||this._potentialTarget==null);
if(_2c&&this._underlyingTarget!=null){
this._leaveTarget(this._activeDragSource,this._underlyingTarget);
}
if(this._potentialTarget!=null){
if(_2c){
this._underlyingTarget=this._potentialTarget;
this._enterTarget(this._activeDragSource,this._underlyingTarget);
}else{
this._moveInTarget(this._activeDragSource,this._underlyingTarget);
}
}else{
this._underlyingTarget=null;
}
},_wireEvents:function(){
$addHandler(document,"mouseup",this._mouseUpHandler);
$addHandler(document,"mousemove",this._documentMouseMoveHandler);
$addHandler(document.body,"dragover",this._documentDragOverHandler);
$addHandler(this._activeDragVisual,"dragstart",this._dragStartHandler);
$addHandler(this._activeDragVisual,"dragend",this._mouseUpHandler);
$addHandler(this._activeDragVisual,"drag",this._mouseMoveHandler);
},_unwireEvents:function(){
$removeHandler(this._activeDragVisual,"drag",this._mouseMoveHandler);
$removeHandler(this._activeDragVisual,"dragend",this._mouseUpHandler);
$removeHandler(this._activeDragVisual,"dragstart",this._dragStartHandler);
$removeHandler(document.body,"dragover",this._documentDragOverHandler);
$removeHandler(document,"mousemove",this._documentMouseMoveHandler);
$removeHandler(document,"mouseup",this._mouseUpHandler);
},registerDropTarget:function(_2d,_2e){
if(this._dropTargets==null){
this._dropTargets=[];
}
if(_2e){
Array.add(this._dropTargets,_2d);
}else{
Array.insert(this._dropTargets,0,_2d);
}
this._wireDropTargetEvents(_2d);
},unregisterDropTarget:function(_2f){
this._unwireDropTargetEvents(_2f);
if(this._dropTargets){
Array.remove(this._dropTargets,_2f);
}
},_wireDropTargetEvents:function(_30){
var _31=_30.get_dropTargetElement();
_31._dropTarget=_30;
$addHandler(_31,"dragenter",this._dragEnterHandler);
$addHandler(_31,"dragleave",this._dragLeaveHandler);
$addHandler(_31,"dragover",this._dragOverHandler);
$addHandler(_31,"drop",this._dropHandler);
},_unwireDropTargetEvents:function(_32){
var _33=_32.get_dropTargetElement();
if(_33._dropTarget){
_33._dropTarget=null;
$removeHandler(_33,"dragenter",this._dragEnterHandler);
$removeHandler(_33,"dragleave",this._dragLeaveHandler);
$removeHandler(_33,"dragover",this._dragOverHandler);
$removeHandler(_33,"drop",this._dropHandler);
}
},_onDragStart:function(ev){
window._event=ev;
document.selection.empty();
var dt=ev.dataTransfer;
if(!dt&&ev.rawEvent){
dt=ev.rawEvent.dataTransfer;
}
var _36=this._activeDragSource.get_dragDataType().toLowerCase();
var _37=this._activeDragSource.getDragData(this._activeContext);
if(_37){
if(_36!="text"&&_36!="url"){
_36="text";
if(_37.innerHTML!=null){
_37=_37.innerHTML;
}
}
dt.effectAllowed="move";
dt.setData(_36,_37.toString());
}
},_onMouseUp:function(ev){
window._event=ev;
this._stopDragDrop(false);
},_onDocumentMouseMove:function(ev){
window._event=ev;
this._dragDrop();
},_onDocumentDragOver:function(ev){
window._event=ev;
if(this._potentialTarget){
ev.preventDefault();
}
},_onMouseMove:function(ev){
window._event=ev;
this._drag();
},_onDragEnter:function(ev){
window._event=ev;
if(this._isDragging){
ev.preventDefault();
}else{
var _3d=Telerik.Web.IEDragDropManager._getDataObjectsForDropTarget(this._getDropTarget(ev.target));
for(var i=0;i<_3d.length;i++){
this._dropTarget.onDragEnterTarget(Telerik.Web.DragMode.Copy,_3d[i].type,_3d[i].value);
}
}
},_onDragLeave:function(ev){
window._event=ev;
if(this._isDragging){
ev.preventDefault();
}else{
var _40=Telerik.Web.IEDragDropManager._getDataObjectsForDropTarget(this._getDropTarget(ev.target));
for(var i=0;i<_40.length;i++){
this._dropTarget.onDragLeaveTarget(Telerik.Web.DragMode.Copy,_40[i].type,_40[i].value);
}
}
},_onDragOver:function(ev){
window._event=ev;
if(this._isDragging){
ev.preventDefault();
}else{
var _43=Telerik.Web.IEDragDropManager._getDataObjectsForDropTarget(this._getDropTarget(ev.target));
for(var i=0;i<_43.length;i++){
this._dropTarget.onDragInTarget(Telerik.Web.DragMode.Copy,_43[i].type,_43[i].value);
}
}
},_onDrop:function(ev){
window._event=ev;
if(!this._isDragging){
var _46=Telerik.Web.IEDragDropManager._getDataObjectsForDropTarget(this._getDropTarget(ev.target));
for(var i=0;i<_46.length;i++){
this._dropTarget.drop(Telerik.Web.DragMode.Copy,_46[i].type,_46[i].value);
}
}
ev.preventDefault();
},_getDropTarget:function(_48){
while(_48){
if(_48._dropTarget!=null){
return _48._dropTarget;
}
_48=_48.parentNode;
}
return null;
},_dragDrop:function(){
if(this._isDragging){
return;
}
this._isDragging=true;
this._activeDragVisual.dragDrop();
document.selection.empty();
},_moveInTarget:function(_49,_4a){
this._prepareForDomChanges();
_4a.onDragInTarget(_49.get_dragMode(),_49.get_dragDataType(),_49.getDragData(this._activeContext));
this._recoverFromDomChanges();
},_enterTarget:function(_4b,_4c){
this._prepareForDomChanges();
_4c.onDragEnterTarget(_4b.get_dragMode(),_4b.get_dragDataType(),_4b.getDragData(this._activeContext));
this._recoverFromDomChanges();
},_leaveTarget:function(_4d,_4e){
this._prepareForDomChanges();
_4e.onDragLeaveTarget(_4d.get_dragMode(),_4d.get_dragDataType(),_4d.getDragData(this._activeContext));
this._recoverFromDomChanges();
},_findPotentialTarget:function(_4f,_50){
var ev=window._event;
if(this._dropTargets==null){
return null;
}
var _52=_4f.get_dragDataType();
var _53=_4f.get_dragMode();
var _54=_4f.getDragData(this._activeContext);
var _55=this.getScrollOffset(document.body,true);
var x=ev.clientX+_55.x;
var y=ev.clientY+_55.y;
var _58={x:x-this._radius,y:y-this._radius,width:this._radius*2,height:this._radius*2};
var _59;
for(var i=0;i<this._dropTargets.length;i++){
_59=Telerik.Web.DomElement.getBounds(this._dropTargets[i].get_dropTargetElement());
if(Sys.UI.Control.overlaps(_58,_59)&&this._dropTargets[i].canDrop(_53,_52,_54)){
return this._dropTargets[i];
}
}
return null;
},_prepareForDomChanges:function(){
this._oldOffset=Telerik.Web.DomElement.getLocation(this._activeDragVisual);
},_recoverFromDomChanges:function(){
var _5b=Telerik.Web.DomElement.getLocation(this._activeDragVisual);
if(this._oldOffset.x!=_5b.x||this._oldOffset.y!=_5b.y){
this._activeDragVisual.startingPoint=this.subtractPoints(this._activeDragVisual.startingPoint,this.subtractPoints(this._oldOffset,_5b));
scrollOffset=this.getScrollOffset(this._activeDragVisual,true);
var _5c=this.addPoints(this.subtractPoints(document._lastPosition,this._activeDragVisual.startingPoint),scrollOffset);
TelerikCommonScripts.setLocation(this._activeDragVisual,_5c);
}
},addPoints:function(p1,p2){
return {x:p1.x+p2.x,y:p1.y+p2.y};
},subtractPoints:function(p1,p2){
return {x:p1.x-p2.x,y:p1.y-p2.y};
},getScrollOffset:function(_61,_62){
var _63=_61.scrollLeft;
var top=_61.scrollTop;
if(_62){
var _65=_61.parentNode;
while(_65!=null&&_65.scrollLeft!=null){
_63+=_65.scrollLeft;
top+=_65.scrollTop;
if(_65==document.body&&(_63!=0&&top!=0)){
break;
}
_65=_65.parentNode;
}
}
return {x:_63,y:top};
},getBrowserRectangle:function(){
var _66=window.innerWidth;
var _67=window.innerHeight;
if(_66==null){
_66=document.body.clientWidth;
}
if(_67==null){
_67=document.body.clientHeight;
}
return {x:0,y:0,width:_66,height:_67};
},getNextSibling:function(_68){
for(_68=_68.nextSibling;_68!=null;_68=_68.nextSibling){
if(_68.innerHTML!=null){
return _68;
}
}
return null;
},hasParent:function(_69){
return (_69.parentNode!=null&&_69.parentNode.tagName!=null);
}};
Telerik.Web.IEDragDropManager.registerClass("Telerik.Web.IEDragDropManager",Sys.Component);
Telerik.Web.IEDragDropManager._getDataObjectsForDropTarget=function(_6a){
if(_6a==null){
return [];
}
var ev=window._event;
var _6c=[];
var _6d=["URL","Text"];
var _6e;
for(var i=0;i<_6d.length;i++){
var dt=ev.dataTransfer;
if(!dt&&ev.rawEvent){
dt=ev.rawEvent.dataTransfer;
}
_6e=dt.getData(_6d[i]);
if(_6a.canDrop(Telerik.Web.DragMode.Copy,_6d[i],_6e)){
if(_6e){
Array.add(_6c,{type:_6d[i],value:_6e});
}
}
}
return _6c;
};
Telerik.Web.GenericDragDropManager=function(){
Telerik.Web.GenericDragDropManager.initializeBase(this);
this._dropTargets=null;
this._scrollEdgeConst=40;
this._scrollByConst=10;
this._scroller=null;
this._scrollDeltaX=0;
this._scrollDeltaY=0;
this._activeDragVisual=null;
this._activeContext=null;
this._activeDragSource=null;
this._oldOffset=null;
this._potentialTarget=null;
this._mouseUpHandler=null;
this._mouseMoveHandler=null;
this._keyPressHandler=null;
this._scrollerTickHandler=null;
};
Telerik.Web.GenericDragDropManager.prototype={initialize:function(){
Telerik.Web.GenericDragDropManager.callBaseMethod(this,"initialize");
this._mouseUpHandler=Function.createDelegate(this,this._onMouseUp);
this._mouseMoveHandler=Function.createDelegate(this,this._onMouseMove);
this._keyPressHandler=Function.createDelegate(this,this._onKeyPress);
this._scrollerTickHandler=Function.createDelegate(this,this._onScrollerTick);
if(Sys.Browser.agent===Sys.Browser.Safari){
Telerik.Web.GenericDragDropManager.__loadSafariCompatLayer(this);
}
this._scroller=new Telerik.Web.Timer();
this._scroller.set_interval(10);
this._scroller.add_tick(this._scrollerTickHandler);
},startDragDrop:function(_71,_72,_73){
this._activeDragSource=_71;
this._activeDragVisual=_72;
this._activeContext=_73;
Telerik.Web.GenericDragDropManager.callBaseMethod(this,"startDragDrop",[_71,_72,_73]);
},_stopDragDrop:function(_74){
this._scroller.set_enabled(false);
Telerik.Web.GenericDragDropManager.callBaseMethod(this,"_stopDragDrop",[_74]);
},_drag:function(_75){
Telerik.Web.GenericDragDropManager.callBaseMethod(this,"_drag",[_75]);
this._autoScroll();
},_wireEvents:function(){
$addHandler(document,"mouseup",this._mouseUpHandler);
$addHandler(document,"mousemove",this._mouseMoveHandler);
$addHandler(document,"keypress",this._keyPressHandler);
},_unwireEvents:function(){
$removeHandler(document,"keypress",this._keyPressHandler);
$removeHandler(document,"mousemove",this._mouseMoveHandler);
$removeHandler(document,"mouseup",this._mouseUpHandler);
},_wireDropTargetEvents:function(_76){
},_unwireDropTargetEvents:function(_77){
},_onMouseUp:function(e){
window._event=e;
this._stopDragDrop(false);
},_onMouseMove:function(e){
window._event=e;
this._drag();
},_onKeyPress:function(e){
window._event=e;
var k=e.keyCode?e.keyCode:e.rawEvent.keyCode;
if(k==27){
this._stopDragDrop(true);
}
},_autoScroll:function(){
var ev=window._event;
var _7d=this.getBrowserRectangle();
if(_7d.width>0){
this._scrollDeltaX=this._scrollDeltaY=0;
if(ev.clientX<_7d.x+this._scrollEdgeConst){
this._scrollDeltaX=-this._scrollByConst;
}else{
if(ev.clientX>_7d.width-this._scrollEdgeConst){
this._scrollDeltaX=this._scrollByConst;
}
}
if(ev.clientY<_7d.y+this._scrollEdgeConst){
this._scrollDeltaY=-this._scrollByConst;
}else{
if(ev.clientY>_7d.height-this._scrollEdgeConst){
this._scrollDeltaY=this._scrollByConst;
}
}
if(this._scrollDeltaX!=0||this._scrollDeltaY!=0){
this._scroller.set_enabled(true);
}else{
this._scroller.set_enabled(false);
}
}
},_onScrollerTick:function(){
var _7e=document.body.scrollLeft;
var _7f=document.body.scrollTop;
window.scrollBy(this._scrollDeltaX,this._scrollDeltaY);
var _80=document.body.scrollLeft;
var _81=document.body.scrollTop;
var _82=this._activeDragVisual;
var _83={x:parseInt(_82.style.left)+(_80-_7e),y:parseInt(_82.style.top)+(_81-_7f)};
TelerikCommonScripts.setLocation(_82,_83);
}};
Telerik.Web.GenericDragDropManager.registerClass("Telerik.Web.GenericDragDropManager",Telerik.Web.IEDragDropManager);
if(Sys.Browser.agent===Sys.Browser.Safari){
Telerik.Web.GenericDragDropManager.__loadSafariCompatLayer=function(ddm){
ddm._getScrollOffset=ddm.getScrollOffset;
ddm.getScrollOffset=function(_85,_86){
return {x:0,y:0};
};
ddm._getBrowserRectangle=ddm.getBrowserRectangle;
ddm.getBrowserRectangle=function(){
var _87=ddm._getBrowserRectangle();
var _88=ddm._getScrollOffset(document.body,true);
return {x:_87.x+_88.x,y:_87.y+_88.y,width:_87.width+_88.x,height:_87.height+_88.y};
};
};
}


if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();