1// Name: Compat.DragDrop.debug.js 2// Assembly: AjaxControlToolkit 3// Version: 18.1.0.0 4// FileVersion: 18.1.0.0 5Type.registerNamespace('Sys.Extended.UI'); 6 7Sys.Extended.UI.IDragSource = function() { 8} 9 10Sys.Extended.UI.IDragSource.prototype = { 11 // Type get_dragDataType() 12 get_dragDataType: function() { throw Error.notImplemented(); }, 13 14 // Object getDragData(Context) 15 getDragData: function() { throw Error.notImplemented(); }, 16 17 // DragMode get_dragMode() 18 get_dragMode: function() { throw Error.notImplemented(); }, 19 20 // void onDragStart() 21 onDragStart: function() { throw Error.notImplemented(); }, 22 23 // void onDrag() 24 onDrag: function() { throw Error.notImplemented(); }, 25 26 // void onDragEnd(Cancelled) 27 onDragEnd: function() { throw Error.notImplemented(); } 28} 29 30Sys.Extended.UI.IDragSource.registerInterface('Sys.Extended.UI.IDragSource'); 31 32Sys.Extended.UI.IDropTarget = function() { 33} 34 35Sys.Extended.UI.IDropTarget.prototype = { 36 get_dropTargetElement: function() { throw Error.notImplemented(); }, 37 // bool canDrop(DragMode, DataType, Data) 38 canDrop: function() { throw Error.notImplemented(); }, 39 40 // void drop(DragMode, DataType, Data) 41 drop: function() { throw Error.notImplemented(); }, 42 43 // void onDragEnterTarget(DragMode, DataType, Data) 44 onDragEnterTarget: function() { throw Error.notImplemented(); }, 45 46 // void onDragLeaveTarget(DragMode, DataType, Data) 47 onDragLeaveTarget: function() { throw Error.notImplemented(); }, 48 49 // void onDragInTarget(DragMode, DataType, Data) 50 onDragInTarget: function() { throw Error.notImplemented(); } 51} 52 53Sys.Extended.UI.IDropTarget.registerInterface('Sys.Extended.UI.IDropTarget'); 54 55Sys.Extended.UI.DragMode = function() { 56 throw Error.invalidOperation(); 57} 58 59Sys.Extended.UI.DragMode.prototype = { 60 Copy: 0, 61 Move: 1 62} 63 64Sys.Extended.UI.DragMode.registerEnum('Sys.Extended.UI.DragMode'); 65 66Sys.Extended.UI.DragDropEventArgs = function(dragMode, dragDataType, dragData) { 67 this._dragMode = dragMode; 68 this._dataType = dragDataType; 69 this._data = dragData; 70} 71 72Sys.Extended.UI.DragDropEventArgs.prototype = { 73 get_dragMode: function() { 74 return this._dragMode || null; 75 }, 76 77 get_dragDataType: function() { 78 return this._dataType || null; 79 }, 80 81 get_dragData: function() { 82 return this._data || null; 83 } 84} 85 86Sys.Extended.UI.DragDropEventArgs.registerClass('Sys.Extended.UI.DragDropEventArgs'); 87 88Sys.Extended.UI._DragDropManager = function() { 89 this._instance = null; 90 this._events = null; 91} 92 93Sys.Extended.UI._DragDropManager.prototype = { 94 add_dragStart: function(handler) { 95 this.get_events().addHandler('dragStart', handler); 96 }, 97 98 remove_dragStart: function(handler) { 99 this.get_events().removeHandler('dragStart', handler); 100 }, 101 102 get_events: function() { 103 if(!this._events) 104 this._events = new Sys.EventHandlerList(); 105 106 return this._events; 107 }, 108 109 add_dragStop: function(handler) { 110 this.get_events().addHandler('dragStop', handler); 111 }, 112 113 remove_dragStop: function(handler) { 114 this.get_events().removeHandler('dragStop', handler); 115 }, 116 117 _getInstance: function() { 118 if(!this._instance) { 119 if(Sys.Browser.agent === Sys.Browser.InternetExplorer) 120 this._instance = new Sys.Extended.UI.IEDragDropManager(); 121 else 122 this._instance = new Sys.Extended.UI.GenericDragDropManager(); 123 124 this._instance.initialize(); 125 this._instance.add_dragStart(Function.createDelegate(this, this._raiseDragStart)); 126 this._instance.add_dragStop(Function.createDelegate(this, this._raiseDragStop)); 127 } 128 129 return this._instance; 130 }, 131 132 startDragDrop: function(dragSource, dragVisual, context, useBuiltInDragAndDropFunctions) { 133 this._getInstance().startDragDrop(dragSource, dragVisual, context, useBuiltInDragAndDropFunctions); 134 }, 135 136 registerDropTarget: function(target) { 137 this._getInstance().registerDropTarget(target); 138 }, 139 140 unregisterDropTarget: function(target) { 141 this._getInstance().unregisterDropTarget(target); 142 }, 143 144 dispose: function() { 145 delete this._events; 146 147 Sys.Application.unregisterDisposableObject(this); 148 Sys.Application.removeComponent(this); 149 }, 150 151 _raiseDragStart: function(sender, eventArgs) { 152 var handler = this.get_events().getHandler('dragStart'); 153 if(handler) 154 handler(this, eventArgs); 155 }, 156 157 _raiseDragStop: function(sender, eventArgs) { 158 var handler = this.get_events().getHandler('dragStop'); 159 if(handler) 160 handler(this, eventArgs); 161 } 162} 163 164Sys.Extended.UI._DragDropManager.registerClass('Sys.Extended.UI._DragDropManager'); 165Sys.Extended.UI.DragDropManager = new Sys.Extended.UI._DragDropManager(); 166 167Sys.Extended.UI.IEDragDropManager = function() { 168 Sys.Extended.UI.IEDragDropManager.initializeBase(this); 169 170 this._dropTargets = null; 171 // Radius of the cursor used to determine what drop target we 172 // are hovering. Anything below the cursor's zone may be a 173 // potential drop target. 174 this._radius = 10; 175 this._useBuiltInDragAndDropFunctions = true; 176 this._activeDragVisual = null; 177 this._activeContext = null; 178 this._activeDragSource = null; 179 this._underlyingTarget = null; 180 this._oldOffset = null; 181 this._potentialTarget = null; 182 this._isDragging = false;
183 this._mouseUpHandler = null; 184 this._documentMouseMoveHandler = null; 185 this._documentDragOverHandler = null; 186 this._dragStartHandler = null; 187 this._mouseMoveHandler = null; 188 this._dragEnterHandler = null; 189 this._dragLeaveHandler = null; 190 this._dragOverHandler = null; 191 this._dropHandler = null; 192} 193 194Sys.Extended.UI.IEDragDropManager.prototype = { 195 196 add_dragStart: function(handler) { 197 this.get_events().addHandler("dragStart", handler); 198 }, 199 200 remove_dragStart: function(handler) { 201 this.get_events().removeHandler("dragStart", handler); 202 }, 203 204 add_dragStop: function(handler) { 205 this.get_events().addHandler("dragStop", handler); 206 }, 207 208 remove_dragStop: function(handler) { 209 this.get_events().removeHandler("dragStop", handler); 210 }, 211 212 initialize: function() { 213 Sys.Extended.UI.IEDragDropManager.callBaseMethod(this, 'initialize'); 214 215 this._mouseUpHandler = Function.createDelegate(this, this._onMouseUp); 216 this._documentMouseMoveHandler = Function.createDelegate(this, this._onDocumentMouseMove); 217 this._documentDragOverHandler = Function.createDelegate(this, this._onDocumentDragOver); 218 this._dragStartHandler = Function.createDelegate(this, this._onDragStart); 219 this._mouseMoveHandler = Function.createDelegate(this, this._onMouseMove); 220 this._dragEnterHandler = Function.createDelegate(this, this._onDragEnter); 221 this._dragLeaveHandler = Function.createDelegate(this, this._onDragLeave); 222 this._dragOverHandler = Function.createDelegate(this, this._onDragOver); 223 this._dropHandler = Function.createDelegate(this, this._onDrop); 224 }, 225 226 dispose: function() { 227 if(this._dropTargets) { 228 for(var i = 0; i < this._dropTargets; i++) 229 this.unregisterDropTarget(this._dropTargets[i]); 230 231 this._dropTargets = null; 232 } 233 234 Sys.Extended.UI.IEDragDropManager.callBaseMethod(this, 'dispose'); 235 }, 236 237 238 startDragDrop: function(dragSource, dragVisual, context, useBuiltInDragAndDropFunctions) { 239 var ev = window._event; 240 241 // Don't allow drag and drop if there is another active drag operation going on. 242 if(this._isDragging) 243 return; 244 245 this._underlyingTarget = null; 246 this._activeDragSource = dragSource; 247 this._activeDragVisual = dragVisual; 248 this._activeContext = context; 249 this._useBuiltInDragAndDropFunctions = typeof (useBuiltInDragAndDropFunctions) != 'undefined' ? useBuiltInDragAndDropFunctions : true; 250 251 var mousePosition = { x: ev.clientX, y: ev.clientY }; 252 253 // By default we use absolute positioning, unless a different type 254 // of positioning is set explicitly. 255 dragVisual.originalPosition = dragVisual.style.position; 256 dragVisual.style.position = "absolute"; 257 258 document._lastPosition = mousePosition; 259 dragVisual.startingPoint = mousePosition; 260 var scrollOffset = this.getScrollOffset(dragVisual, /* recursive */true); 261 262 dragVisual.startingPoint = this.addPoints(dragVisual.startingPoint, scrollOffset); 263 264 var left = parseInt(dragVisual.style.left), 265 top = parseInt(dragVisual.style.top); 266 267 if(isNaN(left)) 268 left = "0"; 269 if(isNaN(top)) 270 top = "0"; 271 272 dragVisual.startingPoint = this.subtractPoints(dragVisual.startingPoint, { x: left, y: top }); 273 274 // Monitor DOM changes. 275 this._prepareForDomChanges(); 276 dragSource.onDragStart(); 277 278 var eventArgs = new Sys.Extended.UI.DragDropEventArgs( 279 dragSource.get_dragMode(), 280 dragSource.get_dragDataType(), 281 dragSource.getDragData(context)); 282 283 var handler = this.get_events().getHandler('dragStart'); 284 if(handler) 285 handler(this, eventArgs); 286 287 this._recoverFromDomChanges(); 288 this._wireEvents(); 289 this._drag(/* isInitialDrag */true); 290 }, 291 292 _stopDragDrop: function(cancelled) { 293 var ev = window._event; 294 if(this._activeDragSource != null) { 295 this._unwireEvents(); 296 297 if(!cancelled) 298 // The drag operation is cancelled if there 299 // is no drop target. 300 cancelled = (this._underlyingTarget == null); 301 302 if(!cancelled && this._underlyingTarget != null) 303 this._underlyingTarget.drop(this._activeDragSource.get_dragMode(), this._activeDragSource.get_dragDataType(), this._activeDragSource.getDragData(this._activeContext)); 304 305 this._activeDragSource.onDragEnd(cancelled); 306 var handler = this.get_events().getHandler('dragStop'); 307 if(handler) 308 handler(this, Sys.EventArgs.Empty); 309 310 this._activeDragVisual.style.position = this._activeDragVisual.originalPosition; 311 this._activeDragSource = null; 312 this._activeContext = null; 313 this._activeDragVisual = null; 314 this._isDragging = false;
315 this._potentialTarget = null; 316 317 ev.preventDefault(); 318 } 319 }, 320 321 _drag: function(isInitialDrag) { 322 var ev = window._event, 323 mousePosition = { x: ev.clientX, y: ev.clientY }; 324 325 // NOTE: We store the event object to be able to determine the current 326 // mouse position in Mozilla in other event handlers such as keydown. 327 document._lastPosition = mousePosition; 328 329 var scrollOffset = this.getScrollOffset(this._activeDragVisual, /* recursive */true), 330 position = this.addPoints(this.subtractPoints(mousePosition, this._activeDragVisual.startingPoint), scrollOffset); 331 332 // Check if the visual moved at all. 333 if(!isInitialDrag && parseInt(this._activeDragVisual.style.left) == position.x && parseInt(this._activeDragVisual.style.top) == position.y) 334 return; 335 336 $common.setLocation(this._activeDragVisual, position); 337 338 // Monitor DOM changes. 339 this._prepareForDomChanges(); 340 this._activeDragSource.onDrag(); 341 this._recoverFromDomChanges(); 342 343 // Find a potential target. 344 this._potentialTarget = this._findPotentialTarget(this._activeDragSource, this._activeDragVisual); 345 346 var movedToOtherTarget = (this._potentialTarget != this._underlyingTarget || this._potentialTarget == null); 347 348 // Check if we are leaving an underlying target. 349 if(movedToOtherTarget && this._underlyingTarget != null) 350 this._leaveTarget(this._activeDragSource, this._underlyingTarget); 351 352 if(this._potentialTarget != null) { 353 // Check if we are entering a new target. 354 if(movedToOtherTarget) { 355 this._underlyingTarget = this._potentialTarget; 356 357 // Enter the new target. 358 this._enterTarget(this._activeDragSource, this._underlyingTarget); 359 } else { 360 this._moveInTarget(this._activeDragSource, this._underlyingTarget); 361 } 362 } else { 363 this._underlyingTarget = null; 364 } 365 }, 366 367 _wireEvents: function() { 368 if(this._useBuiltInDragAndDropFunctions) { 369 $addHandler(document, "mouseup", this._mouseUpHandler); 370 $addHandler(document, "mousemove", this._documentMouseMoveHandler); 371 $addHandler(document.body, "dragover", this._documentDragOverHandler); 372 373 $addHandler(this._activeDragVisual, "dragstart", this._dragStartHandler); 374 $addHandler(this._activeDragVisual, "dragend", this._mouseUpHandler); 375 $addHandler(this._activeDragVisual, "drag", this._mouseMoveHandler); 376 } else { 377 $addHandler(document, "mouseup", this._mouseUpHandler); 378 $addHandler(document, "mousemove", this._mouseMoveHandler); 379 } 380 }, 381 382 _unwireEvents: function() { 383 if(this._useBuiltInDragAndDropFunctions) { 384 $removeHandler(this._activeDragVisual, "drag", this._mouseMoveHandler); 385 $removeHandler(this._activeDragVisual, "dragend", this._mouseUpHandler); 386 $removeHandler(this._activeDragVisual, "dragstart", this._dragStartHandler); 387 388 $removeHandler(document.body, "dragover", this._documentDragOverHandler); 389 $removeHandler(document, "mousemove", this._documentMouseMoveHandler); 390 $removeHandler(document, "mouseup", this._mouseUpHandler); 391 } else { 392 $removeHandler(document, "mousemove", this._mouseMoveHandler); 393 $removeHandler(document, "mouseup", this._mouseUpHandler); 394 } 395 }, 396 397 registerDropTarget: function(dropTarget) { 398 if(this._dropTargets == null) 399 this._dropTargets = []; 400 401 Array.add(this._dropTargets, dropTarget); 402 403 this._wireDropTargetEvents(dropTarget); 404 }, 405 406 unregisterDropTarget: function(dropTarget) { 407 this._unwireDropTargetEvents(dropTarget); 408 if(this._dropTargets) 409 Array.remove(this._dropTargets, dropTarget); 410 }, 411 412 _wireDropTargetEvents: function(dropTarget) { 413 var associatedElement = dropTarget.get_dropTargetElement(); 414 415 associatedElement._dropTarget = dropTarget; 416 $addHandler(associatedElement, "dragenter", this._dragEnterHandler); 417 $addHandler(associatedElement, "dragleave", this._dragLeaveHandler); 418 $addHandler(associatedElement, "dragover", this._dragOverHandler); 419 $addHandler(associatedElement, "drop", this._dropHandler); 420 }, 421 422 _unwireDropTargetEvents: function(dropTarget) { 423 var associatedElement = dropTarget.get_dropTargetElement(); 424 425 // make sure that the handlers are not removed twice 426 if(associatedElement._dropTarget) { 427 associatedElement._dropTarget = null; 428 $removeHandler(associatedElement, "dragenter", this._dragEnterHandler); 429 $removeHandler(associatedElement, "dragleave", this._dragLeaveHandler); 430 $removeHandler(associatedElement, "dragover", this._dragOverHandler); 431 $removeHandler(associatedElement, "drop", this._dropHandler); 432 } 433 }, 434 435 436 _onDragStart: function(ev) { 437 window._event = ev; 438 document.selection.empty(); 439 440 var dt = ev.dataTransfer; 441 if(!dt && ev.rawEvent) 442 dt = ev.rawEvent.dataTransfer; 443 444 var dataType = this._activeDragSource.get_dragDataType().toLowerCase(), 445 data = this._activeDragSource.getDragData(this._activeContext); 446 447 if(data) { 448 // TODO: How do we want to deal with 'non-compatible types'? 449 if(dataType != "text" && dataType != "url") { 450 dataType = "text"; 451 452 if(data.innerHTML != null) 453 data = data.innerHTML; 454 } 455 456 dt.effectAllowed = "move"; 457 dt.setData(dataType, data.toString()); 458 } 459 }, 460 461 _onMouseUp: function(ev) { 462 window._event = ev; 463 this._stopDragDrop(false); 464 }, 465 466 _onDocumentMouseMove: function(ev) { 467 window._event = ev; 468 this._dragDrop(); 469 }, 470 471 _onDocumentDragOver: function(ev) { 472 window._event = ev; 473 if(this._potentialTarget) 474 ev.preventDefault(); 475 }, 476 477 _onMouseMove: function(ev) { 478 window._event = ev; 479 this._drag(); 480 }, 481 482 _onDragEnter: function(ev) { 483 window._event = ev; 484 if(this._isDragging) { 485 ev.preventDefault(); 486 //ev.returnValue = false;
487 } else { 488 // An external object is dragged to the drop target. 489 var dataObjects = Sys.Extended.UI.IEDragDropManager._getDataObjectsForDropTarget(this._getDropTarget(ev.target)); 490 491 for(var i = 0; i < dataObjects.length; i++) 492 this._dropTarget.onDragEnterTarget(Sys.Extended.UI.DragMode.Copy, dataObjects[i].type, dataObjects[i].value); 493 } 494 }, 495 496 _onDragLeave: function(ev) { 497 window._event = ev; 498 if(this._isDragging) { 499 ev.preventDefault(); 500 //ev.returnValue = false; 501 } else { 502 // An external object is dragged to the drop target. 503 var dataObjects = Sys.Extended.UI.IEDragDropManager._getDataObjectsForDropTarget(this._getDropTarget(ev.target)); 504 505 for(var i = 0; i < dataObjects.length; i++) 506 this._dropTarget.onDragLeaveTarget(Sys.Extended.UI.DragMode.Copy, dataObjects[i].type, dataObjects[i].value); 507 } 508 }, 509 510 _onDragOver: function(ev) { 511 window._event = ev; 512 if(this._isDragging) { 513 ev.preventDefault(); 514 } else { 515 // An external object is dragged over the drop target. 516 var dataObjects = Sys.Extended.UI.IEDragDropManager._getDataObjectsForDropTarget(this._getDropTarget(ev.target)); 517 518 for(var i = 0; i < dataObjects.length; i++) 519 this._dropTarget.onDragInTarget(Sys.Extended.UI.DragMode.Copy, dataObjects[i].type, dataObjects[i].value); 520 } 521 }, 522 523 _onDrop: function(ev) { 524 window._event = ev; 525 526 if(!this._isDragging) { 527 // An external object is dropped on the drop target. 528 var dataObjects = Sys.Extended.UI.IEDragDropManager._getDataObjectsForDropTarget(this._getDropTarget(ev.target)); 529 530 for(var i = 0; i < dataObjects.length; i++) 531 this._dropTarget.drop(Sys.Extended.UI.DragMode.Copy, dataObjects[i].type, dataObjects[i].value); 532 } 533 ev.preventDefault(); 534 }, 535 536 _getDropTarget: function(element) { 537 while(element) { 538 if(element._dropTarget != null) 539 return element._dropTarget; 540 541 element = element.parentNode; 542 } 543 544 return null; 545 }, 546 547 _dragDrop: function() { 548 if(this._isDragging) 549 return; 550 551 this._isDragging = true; 552 this._activeDragVisual.dragDrop(); 553 554 document.selection.empty(); 555 }, 556 557 _moveInTarget: function(dragSource, dropTarget) { 558 // Monitor DOM changes. 559 this._prepareForDomChanges(); 560 dropTarget.onDragInTarget(dragSource.get_dragMode(), dragSource.get_dragDataType(), dragSource.getDragData(this._activeContext)); 561 this._recoverFromDomChanges(); 562 }, 563 564 _enterTarget: function(dragSource, dropTarget) { 565 // Monitor DOM changes. 566 this._prepareForDomChanges(); 567 dropTarget.onDragEnterTarget(dragSource.get_dragMode(), dragSource.get_dragDataType(), dragSource.getDragData(this._activeContext)); 568 this._recoverFromDomChanges(); 569 }, 570 571 _leaveTarget: function(dragSource, dropTarget) { 572 // Monitor DOM changes. 573 this._prepareForDomChanges(); 574 dropTarget.onDragLeaveTarget(dragSource.get_dragMode(), dragSource.get_dragDataType(), dragSource.getDragData(this._activeContext)); 575 this._recoverFromDomChanges(); 576 }, 577 578 _findPotentialTarget: function(dragSource, dragVisual) { 579 var ev = window._event; 580 581 if(this._dropTargets == null) 582 return null; 583 584 var type = dragSource.get_dragDataType(), 585 mode = dragSource.get_dragMode(), 586 data = dragSource.getDragData(this._activeContext); 587 588 // Get the current cursor location. 589 var scrollOffset = this.getScrollOffset(document.body, /* recursive */true), 590 x = ev.clientX + scrollOffset.x, 591 y = ev.clientY + scrollOffset.y, 592 cursorRect = { x: x - this._radius, y: y - this._radius, width: this._radius * 2, height: this._radius * 2 }; 593 594 // Find any targets near the current cursor location. 595 var targetRect; 596 for(var i = 0; i < this._dropTargets.length; i++) { 597 targetRect = $common.getBounds(this._dropTargets[i].get_dropTargetElement()); 598 599 if($common.overlaps(cursorRect, targetRect) && this._dropTargets[i].canDrop(mode, type, data)) 600 return this._dropTargets[i]; 601 } 602 603 return null; 604 }, 605 606 _prepareForDomChanges: function() { 607 this._oldOffset = $common.getLocation(this._activeDragVisual); 608 }, 609 610 _recoverFromDomChanges: function() { 611 var newOffset = $common.getLocation(this._activeDragVisual); 612
613 if(this._oldOffset.x != newOffset.x || this._oldOffset.y != newOffset.y) { 614 this._activeDragVisual.startingPoint = this.subtractPoints(this._activeDragVisual.startingPoint, this.subtractPoints(this._oldOffset, newOffset)); 615 scrollOffset = this.getScrollOffset(this._activeDragVisual, /* recursive */true); 616 617 var position = this.addPoints(this.subtractPoints(document._lastPosition, this._activeDragVisual.startingPoint), scrollOffset); 618 $common.setLocation(this._activeDragVisual, position); 619 } 620 }, 621 622 addPoints: function(p1, p2) { 623 return { x: p1.x + p2.x, y: p1.y + p2.y }; 624 }, 625 626 subtractPoints: function(p1, p2) { 627 return { x: p1.x - p2.x, y: p1.y - p2.y }; 628 }, 629 630 // -- Drag and drop helper methods. 631 getScrollOffset: function(element, recursive) { 632 var left = element.scrollLeft, 633 top = element.scrollTop; 634 635 if(recursive) { 636 var parent = element.parentNode; 637 638 while(parent != null && parent.scrollLeft != null) { 639 left += parent.scrollLeft; 640 top += parent.scrollTop; 641 642 // Don't include anything below the body. 643 if(parent == document.body && (left != 0 && top != 0)) 644 break; 645 646 parent = parent.parentNode; 647 } 648 } 649 650 return { x: left, y: top }; 651 }, 652 653 getBrowserRectangle: function() { 654 var width = window.innerWidth, 655 height = window.innerHeight; 656 657 if(width == null) 658 width = document.documentElement.clientWidth; 659 660 if(height == null) 661 height = document.documentElement.clientHeight; 662 663 return { x: 0, y: 0, width: width, height: height }; 664 }, 665 666 getNextSibling: function(item) { 667 for(item = item.nextSibling; item != null; item = item.nextSibling) 668 if(item.innerHTML != null) 669 return item; 670 671 return null; 672 }, 673 674 hasParent: function(element) { 675 return (element.parentNode != null && element.parentNode.tagName != null); 676 } 677} 678 679Sys.Extended.UI.IEDragDropManager.registerClass('Sys.Extended.UI.IEDragDropManager', Sys.Component); 680 681Sys.Extended.UI.IEDragDropManager._getDataObjectsForDropTarget = function(dropTarget) { 682 if(dropTarget == null) 683 return []; 684 685 var ev = window._event, 686 dataObjects = [], 687 dataTypes = ["URL", "Text"], 688 data; 689 690 for(var i = 0; i < dataTypes.length; i++) { 691 var dt = ev.dataTransfer; 692 693 if(!dt && ev.rawEvent) 694 dt = ev.rawEvent.dataTransfer; 695 696 data = dt.getData(dataTypes[i]); 697 if(dropTarget.canDrop(Sys.Extended.UI.DragMode.Copy, dataTypes[i], data)) 698 if(data) 699 Array.add(dataObjects, { type: dataTypes[i], value: data }); 700 } 701 702 return dataObjects; 703} 704 705Sys.Extended.UI.GenericDragDropManager = function() { 706 Sys.Extended.UI.GenericDragDropManager.initializeBase(this); 707 708 this._dropTargets = null; 709 // Radius of the cursor used to determine what drop target we 710 // are hovering. Anything below the cursor's zone may be a 711 // potential drop target. 712 this._scrollEdgeConst = 40; 713 this._scrollByConst = 10; 714 this._scroller = null; 715 this._scrollDeltaX = 0; 716 this._scrollDeltaY = 0; 717 this._activeDragVisual = null; 718 this._activeContext = null; 719 this._activeDragSource = null; 720 this._oldOffset = null; 721 this._potentialTarget = null; 722 this._mouseUpHandler = null; 723 this._mouseMoveHandler = null; 724 this._keyPressHandler = null; 725 this._scrollerTickHandler = null; 726} 727 728Sys.Extended.UI.GenericDragDropManager.prototype = { 729 730 initialize: function() { 731 Sys.Extended.UI.GenericDragDropManager.callBaseMethod(this, "initialize"); 732 733 this._mouseUpHandler = Function.createDelegate(this, this._onMouseUp); 734 this._mouseMoveHandler = Function.createDelegate(this, this._onMouseMove); 735 this._keyPressHandler = Function.createDelegate(this, this._onKeyPress); 736 this._scrollerTickHandler = Function.createDelegate(this, this._onScrollerTick); 737 this._scroller = new Sys.Timer(); 738 this._scroller.set_interval(10); 739 this._scroller.add_tick(this._scrollerTickHandler); 740 }, 741 742 startDragDrop: function(dragSource, dragVisual, context) { 743 this._activeDragSource = dragSource; 744 this._activeDragVisual = dragVisual; 745 this._activeContext = context; 746 747 Sys.Extended.UI.GenericDragDropManager.callBaseMethod(this, "startDragDrop", [dragSource, dragVisual, context]); 748 }, 749 750 _stopDragDrop: function(cancelled) { 751 this._scroller.set_enabled(false); 752 753 Sys.Extended.UI.GenericDragDropManager.callBaseMethod(this, "_stopDragDrop", [cancelled]); 754 }, 755 756 _drag: function(isInitialDrag) { 757 Sys.Extended.UI.GenericDragDropManager.callBaseMethod(this, "_drag", [isInitialDrag]); 758 759 this._autoScroll(); 760 }, 761 762 _wireEvents: function() { 763 $addHandler(document, "mouseup", this._mouseUpHandler); 764 $addHandler(document, "mousemove", this._mouseMoveHandler); 765 $addHandler(document, "keypress", this._keyPressHandler); 766 }, 767 768 _unwireEvents: function() { 769 $removeHandler(document, "keypress", this._keyPressHandler); 770 $removeHandler(document, "mousemove", this._mouseMoveHandler); 771 $removeHandler(document, "mouseup", this._mouseUpHandler); 772 }, 773 774 _wireDropTargetEvents: function(dropTarget) { 775 }, 776 777 _unwireDropTargetEvents: function(dropTarget) { 778 }, 779 780 _onMouseUp: function(e) { 781 window._event = e; 782 this._stopDragDrop(false); 783 }, 784 785 _onMouseMove: function(e) { 786 window._event = e; 787 this._drag(); 788 }, 789 790 _onKeyPress: function(e) { 791 window._event = e; 792 // Escape. 793 var k = e.keyCode ? e.keyCode : e.rawEvent.keyCode; 794 if(k == 27) 795 this._stopDragDrop(/* cancel */ true); 796 }, 797 798 _autoScroll: function() { 799 var ev = window._event, 800 browserRect = this.getBrowserRectangle(); 801 802 if(browserRect.width > 0) { 803 this._scrollDeltaX = this._scrollDeltaY = 0; 804 805 if(ev.clientX < browserRect.x + this._scrollEdgeConst) 806 this._scrollDeltaX = -this._scrollByConst; 807 else if(ev.clientX > browserRect.width - this._scrollEdgeConst) 808 this._scrollDeltaX = this._scrollByConst; 809 810 if(ev.clientY < browserRect.y + this._scrollEdgeConst) 811 this._scrollDeltaY = -this._scrollByConst; 812 else if(ev.clientY > browserRect.height - this._scrollEdgeConst) 813 this._scrollDeltaY = this._scrollByConst; 814 815 if(this._scrollDeltaX != 0 || this._scrollDeltaY != 0) 816 this._scroller.set_enabled(true); 817 else 818 this._scroller.set_enabled(false); 819 } 820 }, 821 822 _onScrollerTick: function() { 823 var oldLeft = document.body.scrollLeft, 824 oldTop = document.body.scrollTop; 825 826 window.scrollBy(this._scrollDeltaX, this._scrollDeltaY); 827 var newLeft = document.body.scrollLeft, 828 newTop = document.body.scrollTop; 829 830 var dragVisual = this._activeDragVisual, 831 position = { x: parseInt(dragVisual.style.left) + (newLeft - oldLeft), y: parseInt(dragVisual.style.top) + (newTop - oldTop) }; 832 833 $common.setLocation(dragVisual, position); 834 } 835} 836 837Sys.Extended.UI.GenericDragDropManager.registerClass('Sys.Extended.UI.GenericDragDropManager', Sys.Extended.UI.IEDragDropManager);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.