summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/MochiKit/DragAndDrop.js
Unidiff
Diffstat (limited to 'frontend/gamma/js/MochiKit/DragAndDrop.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/gamma/js/MochiKit/DragAndDrop.js14
1 files changed, 7 insertions, 7 deletions
diff --git a/frontend/gamma/js/MochiKit/DragAndDrop.js b/frontend/gamma/js/MochiKit/DragAndDrop.js
index 62777c5..cf84f77 100644
--- a/frontend/gamma/js/MochiKit/DragAndDrop.js
+++ b/frontend/gamma/js/MochiKit/DragAndDrop.js
@@ -1,35 +1,35 @@
1/*** 1/***
2MochiKit.DragAndDrop 1.5 2MochiKit.DragAndDrop 1.5
3 3
4See <http://mochikit.com/> for documentation, downloads, license, etc. 4See <http://mochikit.com/> for documentation, downloads, license, etc.
5 5
6Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 6Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
7 Mochi-ized By Thomas Herve (_firstname_@nimail.org) 7 Mochi-ized By Thomas Herve (_firstname_@nimail.org)
8 8
9***/ 9***/
10 10
11MochiKit.Base._module('DragAndDrop', '1.5', ['Base', 'Iter', 'DOM', 'Signal', 'Visual', 'Position']); 11MochiKit.Base.module(MochiKit, 'DragAndDrop', '1.5', ['Base', 'Iter', 'DOM', 'Signal', 'Visual', 'Position']);
12 12
13MochiKit.DragAndDrop.Droppables = { 13MochiKit.DragAndDrop.Droppables = {
14 /*** 14 /***
15 15
16 Manage all droppables. Shouldn't be used, use the Droppable object instead. 16 Manage all droppables. Shouldn't be used, use the Droppable object instead.
17 17
18 ***/ 18 ***/
19 drops: [], 19 drops: [],
20 20
21 remove: function (element) { 21 remove: function (element) {
22 this.drops = MochiKit.Base.filter(function (d) { 22 this.drops = MochiKit.Base.filter(function (d) {
23 return d.element != MochiKit.DOM.getElement(element); 23 return d.element != MochiKit.DOM.getElement(element);
24 }, this.drops); 24 }, this.drops);
25 }, 25 },
26 26
27 register: function (drop) { 27 register: function (drop) {
28 this.drops.push(drop); 28 this.drops.push(drop);
29 }, 29 },
30 30
31 unregister: function (drop) { 31 unregister: function (drop) {
32 this.drops = MochiKit.Base.filter(function (d) { 32 this.drops = MochiKit.Base.filter(function (d) {
33 return d != drop; 33 return d != drop;
34 }, this.drops); 34 }, this.drops);
35 }, 35 },
@@ -285,50 +285,51 @@ MochiKit.DragAndDrop.Draggables = {
285 disc(this.eventMouseUp); 285 disc(this.eventMouseUp);
286 disc(this.eventMouseMove); 286 disc(this.eventMouseMove);
287 disc(this.eventKeypress); 287 disc(this.eventKeypress);
288 } 288 }
289 }, 289 },
290 290
291 activate: function (draggable) { 291 activate: function (draggable) {
292 // allows keypress events if window is not currently focused 292 // allows keypress events if window is not currently focused
293 // fails for Safari 293 // fails for Safari
294 window.focus(); 294 window.focus();
295 this.activeDraggable = draggable; 295 this.activeDraggable = draggable;
296 }, 296 },
297 297
298 deactivate: function () { 298 deactivate: function () {
299 this.activeDraggable = null; 299 this.activeDraggable = null;
300 }, 300 },
301 301
302 updateDrag: function (event) { 302 updateDrag: function (event) {
303 if (!this.activeDraggable) { 303 if (!this.activeDraggable) {
304 return; 304 return;
305 } 305 }
306 var pointer = event.mouse(); 306 var pointer = event.mouse();
307 // Mozilla-based browsers fire successive mousemove events with 307 // Mozilla-based browsers fire successive mousemove events with
308 // the same coordinates, prevent needless redrawing (moz bug?) 308 // the same coordinates, prevent needless redrawing (moz bug?)
309 if (this._lastPointer && (MochiKit.Base.repr(this._lastPointer.page) == 309 if (this._lastPointer &&
310 MochiKit.Base.repr(pointer.page))) { 310 this._lastPointer.page.x == pointer.page.x &&
311 this._lastPointer.page.y == pointer.page.y) {
311 return; 312 return;
312 } 313 }
313 this._lastPointer = pointer; 314 this._lastPointer = pointer;
314 this.activeDraggable.updateDrag(event, pointer); 315 this.activeDraggable.updateDrag(event, pointer);
315 }, 316 },
316 317
317 endDrag: function (event) { 318 endDrag: function (event) {
318 if (!this.activeDraggable) { 319 if (!this.activeDraggable) {
319 return; 320 return;
320 } 321 }
321 this._lastPointer = null; 322 this._lastPointer = null;
322 this.activeDraggable.endDrag(event); 323 this.activeDraggable.endDrag(event);
323 this.activeDraggable = null; 324 this.activeDraggable = null;
324 }, 325 },
325 326
326 keyPress: function (event) { 327 keyPress: function (event) {
327 if (this.activeDraggable) { 328 if (this.activeDraggable) {
328 this.activeDraggable.keyPress(event); 329 this.activeDraggable.keyPress(event);
329 } 330 }
330 }, 331 },
331 332
332 notify: function (eventName, draggable, event) { 333 notify: function (eventName, draggable, event) {
333 MochiKit.Signal.signal(this, eventName, draggable, event); 334 MochiKit.Signal.signal(this, eventName, draggable, event);
334 } 335 }
@@ -421,89 +422,88 @@ MochiKit.DragAndDrop.Draggable.prototype = {
421 this._isScrollChild = MochiKit.DOM.isChildNode(this.element, options.scroll); 422 this._isScrollChild = MochiKit.DOM.isChildNode(this.element, options.scroll);
422 } 423 }
423 424
424 MochiKit.Style.makePositioned(this.element); // fix IE 425 MochiKit.Style.makePositioned(this.element); // fix IE
425 426
426 this.delta = this.currentDelta(); 427 this.delta = this.currentDelta();
427 this.options = options; 428 this.options = options;
428 this.dragging = false; 429 this.dragging = false;
429 430
430 this.eventMouseDown = MochiKit.Signal.connect(this.handle, 431 this.eventMouseDown = MochiKit.Signal.connect(this.handle,
431 'onmousedown', this, this.initDrag); 432 'onmousedown', this, this.initDrag);
432 MochiKit.DragAndDrop.Draggables.register(this); 433 MochiKit.DragAndDrop.Draggables.register(this);
433 }, 434 },
434 435
435 /** @id MochiKit.DragAndDrop.destroy */ 436 /** @id MochiKit.DragAndDrop.destroy */
436 destroy: function () { 437 destroy: function () {
437 MochiKit.Signal.disconnect(this.eventMouseDown); 438 MochiKit.Signal.disconnect(this.eventMouseDown);
438 MochiKit.DragAndDrop.Draggables.unregister(this); 439 MochiKit.DragAndDrop.Draggables.unregister(this);
439 }, 440 },
440 441
441 /** @id MochiKit.DragAndDrop.currentDelta */ 442 /** @id MochiKit.DragAndDrop.currentDelta */
442 currentDelta: function () { 443 currentDelta: function () {
443 var s = MochiKit.Style.getStyle; 444 var s = MochiKit.Style.getStyle;
444 return [ 445 return [
445 parseInt(s(this.element, 'left') || '0'), 446 parseInt(s(this.element, 'left') || '0', 10),
446 parseInt(s(this.element, 'top') || '0')]; 447 parseInt(s(this.element, 'top') || '0', 10)];
447 }, 448 },
448 449
449 /** @id MochiKit.DragAndDrop.initDrag */ 450 /** @id MochiKit.DragAndDrop.initDrag */
450 initDrag: function (event) { 451 initDrag: function (event) {
451 if (!event.mouse().button.left) { 452 if (!event.mouse().button.left) {
452 return; 453 return;
453 } 454 }
454 // abort on form elements, fixes a Firefox issue 455 // abort on form elements, fixes a Firefox issue
455 var src = event.target(); 456 var src = event.target();
456 var tagName = (src.tagName || '').toUpperCase(); 457 var tagName = (src.tagName || '').toUpperCase();
457 if (tagName === 'INPUT' || tagName === 'SELECT' || 458 if (tagName === 'INPUT' || tagName === 'SELECT' ||
458 tagName === 'OPTION' || tagName === 'BUTTON' || 459 tagName === 'OPTION' || tagName === 'BUTTON' ||
459 tagName === 'TEXTAREA') { 460 tagName === 'TEXTAREA') {
460 return; 461 return;
461 } 462 }
462 463
463 if (this._revert) { 464 if (this._revert) {
464 this._revert.cancel(); 465 this._revert.cancel();
465 this._revert = null; 466 this._revert = null;
466 } 467 }
467 468
468 var pointer = event.mouse(); 469 var pointer = event.mouse();
469 var pos = MochiKit.Position.cumulativeOffset(this.element); 470 var pos = MochiKit.Position.cumulativeOffset(this.element);
470 this.offset = [pointer.page.x - pos.x, pointer.page.y - pos.y]; 471 this.offset = [pointer.page.x - pos.x, pointer.page.y - pos.y];
471 472
472 MochiKit.DragAndDrop.Draggables.activate(this); 473 MochiKit.DragAndDrop.Draggables.activate(this);
473 event.stop(); 474 event.stop();
474 }, 475 },
475 476
476 /** @id MochiKit.DragAndDrop.startDrag */ 477 /** @id MochiKit.DragAndDrop.startDrag */
477 startDrag: function (event) { 478 startDrag: function (event) {
478 this.dragging = true; 479 this.dragging = true;
479 if (this.options.selectclass) { 480 if (this.options.selectclass) {
480 MochiKit.DOM.addElementClass(this.element, 481 MochiKit.DOM.addElementClass(this.element,
481 this.options.selectclass); 482 this.options.selectclass);
482 } 483 }
483 if (this.options.zindex) { 484 if (this.options.zindex) {
484 this.originalZ = parseInt(MochiKit.Style.getStyle(this.element, 485 this.originalZ = MochiKit.Style.getStyle(this.element, 'z-index');
485 'z-index') || '0');
486 this.element.style.zIndex = this.options.zindex; 486 this.element.style.zIndex = this.options.zindex;
487 } 487 }
488 488
489 if (this.options.ghosting) { 489 if (this.options.ghosting) {
490 this._clone = this.element.cloneNode(true); 490 this._clone = this.element.cloneNode(true);
491 this.ghostPosition = MochiKit.Position.absolutize(this.element); 491 this.ghostPosition = MochiKit.Position.absolutize(this.element);
492 this.element.parentNode.insertBefore(this._clone, this.element); 492 this.element.parentNode.insertBefore(this._clone, this.element);
493 } 493 }
494 494
495 if (this.options.scroll) { 495 if (this.options.scroll) {
496 if (this.options.scroll == window) { 496 if (this.options.scroll == window) {
497 var where = this._getWindowScroll(this.options.scroll); 497 var where = this._getWindowScroll(this.options.scroll);
498 this.originalScrollLeft = where.left; 498 this.originalScrollLeft = where.left;
499 this.originalScrollTop = where.top; 499 this.originalScrollTop = where.top;
500 } else { 500 } else {
501 this.originalScrollLeft = this.options.scroll.scrollLeft; 501 this.originalScrollLeft = this.options.scroll.scrollLeft;
502 this.originalScrollTop = this.options.scroll.scrollTop; 502 this.originalScrollTop = this.options.scroll.scrollTop;
503 } 503 }
504 } 504 }
505 505
506 MochiKit.DragAndDrop.Droppables.prepare(this.element); 506 MochiKit.DragAndDrop.Droppables.prepare(this.element);
507 MochiKit.DragAndDrop.Draggables.notify('start', this, event); 507 MochiKit.DragAndDrop.Draggables.notify('start', this, event);
508 if (this.options.starteffect) { 508 if (this.options.starteffect) {
509 this.options.starteffect(this.element); 509 this.options.starteffect(this.element);