Changeset 563
- Timestamp:
- 01/24/06 00:13:12 (3 years ago)
- Files:
-
- mochikit/branches/scriptaculous/MochiKit/DragAndDrop.js (modified) (14 diffs)
- mochikit/branches/scriptaculous/MochiKit/Signal.js (copied) (copied from mochikit/trunk/MochiKit/Signal.js)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
mochikit/branches/scriptaculous/MochiKit/DragAndDrop.js
r558 r563 15 15 dojo.require('MochiKit.Effect'); 16 16 dojo.require('MochiKit.Iter'); 17 dojo.require('MochiKit.Signal'); 17 18 } 18 19 … … 22 23 JSAN.use("MochiKit.Effect", []); 23 24 JSAN.use("MochiKit.Iter", []); 25 JSAN.use("MochiKit.Signal", []); 24 26 } 25 27 … … 28 30 typeof(MochiKit.DOM) == 'undefined' || 29 31 typeof(MochiKit.Effect) == 'undefined' || 32 typeof(MochiKit.Signal) == 'undefined' || 30 33 typeof(MochiKit.Iter) == 'undefined') { 31 34 throw ""; 32 35 } 33 36 } catch (e) { 34 throw "MochiKit.DragAndDrop depends on MochiKit.Base, MochiKit.DOM, MochiKit.Effect and MochiKit.Iter!";37 throw "MochiKit.DragAndDrop depends on MochiKit.Base, MochiKit.DOM, MochiKit.Effect, MochiKit.Signal and MochiKit.Iter!"; 35 38 } 36 39 … … 121 124 MochiKit.Position.prepare(); 122 125 123 if (this.last_active.isAffected([MochiKit.Event.pointerX(event), 124 MochiKit.Event.pointerY(event)], element)) { 126 if (this.last_active.isAffected([event.cursor.x, event.cursor.y], element)) { 125 127 if (this.last_active.options.ondrop) { 126 128 this.last_active.options.ondrop(element, … … 264 266 register: function (draggable) { 265 267 if (this.drags.length === 0) { 266 this.eventMouseUp = MochiKit.DOM.bindAsEventListener( 267 this.endDrag, this); 268 this.eventMouseMove = MochiKit.DOM.bindAsEventListener( 269 this.updateDrag, this); 270 this.eventKeypress = MochiKit.DOM.bindAsEventListener( 271 this.keyPress, this); 272 273 MochiKit.Event.observe(document, 'mouseup', this.eventMouseUp); 274 MochiKit.Event.observe(document, 'mousemove', this.eventMouseMove); 275 MochiKit.Event.observe(document, 'keypress', this.eventKeypress); 268 this.eventMouseUp = MochiKit.Base.bind(this.endDrag, this); 269 this.eventMouseMove = MochiKit.Base.bind(this.updateDrag, this); 270 this.eventKeypress = MochiKit.Base.bind(this.keyPress, this); 271 MochiKit.Signal.connect(document, 'onmouseup', this.eventMouseUp); 272 MochiKit.Signal.connect(document, 'onmousemove', this.eventMouseMove); 273 MochiKit.Signal.connect(document, 'onkeypress', this.eventKeypress); 276 274 } 277 275 this.drags.push(draggable); … … 283 281 }, this.drags); 284 282 if (this.drags.length === 0) { 285 MochiKit. Event.stopObserving(document, 'mouseup',286 this.eventMouseUp);287 MochiKit. Event.stopObserving(document, 'mousemove',288 this.eventMouseMove);289 MochiKit. Event.stopObserving(document, 'keypress',290 this.eventKeypress);283 MochiKit.Signal.disconnect(document, 'onmouseup', 284 this.eventMouseUp); 285 MochiKit.Signal.disconnect(document, 'onmousemove', 286 this.eventMouseMove); 287 MochiKit.Signal.disconnect(document, 'onkeypress', 288 this.eventKeypress); 291 289 } 292 290 }, … … 307 305 return; 308 306 } 309 var pointer = [MochiKit.Event.pointerX(event), 310 MochiKit.Event.pointerY(event)]; 307 var pointer = [event.cursor.x, event.cursor.y]; 311 308 // Mozilla-based browsers fire successive mousemove events with 312 309 // the same coordinates, prevent needless redrawing (moz bug?) … … 424 421 this.dragging = false; 425 422 426 this.eventMouseDown = MochiKit.DOM.bindAsEventListener(this.initDrag, 427 this); 428 MochiKit.Event.observe(this.handle, 'mousedown', this.eventMouseDown); 423 this.eventMouseDown = MochiKit.Base.bind(this.initDrag, this); 424 MochiKit.Signal.connect(this.handle, 'onmousedown', this.eventMouseDown); 429 425 MochiKit.DragAndDrop.Draggables.register(this); 430 426 }, 431 427 432 428 destroy: function () { 433 MochiKit. Event.stopObserving(this.handle, 'mousedown',434 this.eventMouseDown);429 MochiKit.Signal.disconnect(this.handle, 'onmousedown', 430 this.eventMouseDown); 435 431 MochiKit.DragAndDrop.Draggables.unregister(this); 436 432 }, … … 443 439 444 440 initDrag: function (event) { 445 if (! MochiKit.Event.isLeftClick(event)) {441 if (!event.isLeftClick) { 446 442 return; 447 443 } 448 444 // abort on form elements, fixes a Firefox issue 449 var src = MochiKit.Event.element(event);445 var src = event.target; 450 446 if (src.tagName && ( 451 447 src.tagName == 'INPUT' || … … 461 457 } 462 458 463 var pointer = [MochiKit.Event.pointerX(event), 464 MochiKit.Event.pointerY(event)]; 459 var pointer = [event.cursor.x, event.cursor.y]; 465 460 var pos = MochiKit.Position.cumulativeOffset(this.element); 466 461 this.offset = MochiKit.Base.map(function (i) { … … 469 464 470 465 MochiKit.DragAndDrop.Draggables.activate(this); 471 MochiKit.Event.stop(event);466 event.stop(); 472 467 }, 473 468 … … 515 510 window.scrollBy(0, 0); 516 511 } 517 MochiKit.Event.stop(event);512 event.stop(); 518 513 }, 519 514 … … 567 562 568 563 keyPress: function (event) { 569 if (event.key Code != MochiKit.Event.KEY_ESC) {564 if (event.keyString != "KEY_ESCAPE") { 570 565 return; 571 566 } 572 567 this.finishDrag(event, false); 573 MochiKit.Event.stop(event);568 event.stop(); 574 569 }, 575 570 … … 579 574 } 580 575 this.finishDrag(event, true); 581 MochiKit.Event.stop(event);576 event.stop(); 582 577 }, 583 578
