Diffstat (limited to 'frontend/gamma/js/MochiKit/DragAndDrop.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/MochiKit/DragAndDrop.js | 14 |
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,59 +1,59 @@ /*** MochiKit.DragAndDrop 1.5 See <http://mochikit.com/> for documentation, downloads, license, etc. Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) Mochi-ized By Thomas Herve (_firstname_@nimail.org) ***/ -MochiKit.Base._module('DragAndDrop', '1.5', ['Base', 'Iter', 'DOM', 'Signal', 'Visual', 'Position']); +MochiKit.Base.module(MochiKit, 'DragAndDrop', '1.5', ['Base', 'Iter', 'DOM', 'Signal', 'Visual', 'Position']); MochiKit.DragAndDrop.Droppables = { /*** Manage all droppables. Shouldn't be used, use the Droppable object instead. ***/ drops: [], remove: function (element) { this.drops = MochiKit.Base.filter(function (d) { return d.element != MochiKit.DOM.getElement(element); }, this.drops); }, register: function (drop) { this.drops.push(drop); }, unregister: function (drop) { this.drops = MochiKit.Base.filter(function (d) { return d != drop; }, this.drops); }, prepare: function (element) { MochiKit.Base.map(function (drop) { if (drop.isAccepted(element)) { if (drop.options.activeclass) { MochiKit.DOM.addElementClass(drop.element, drop.options.activeclass); } drop.options.onactive(drop.element, element); } }, this.drops); }, findDeepestChild: function (drops) { var deepest = drops[0]; for (var i = 1; i < drops.length; ++i) { if (MochiKit.DOM.isChildNode(drops[i].element, deepest.element)) { deepest = drops[i]; } } return deepest; }, @@ -261,98 +261,99 @@ MochiKit.DragAndDrop.Draggables = { Manage draggables elements. Not intended to direct use. ***/ drags: [], register: function (draggable) { if (this.drags.length === 0) { var conn = MochiKit.Signal.connect; this.eventMouseUp = conn(document, 'onmouseup', this, this.endDrag); this.eventMouseMove = conn(document, 'onmousemove', this, this.updateDrag); this.eventKeypress = conn(document, 'onkeypress', this, this.keyPress); } this.drags.push(draggable); }, unregister: function (draggable) { this.drags = MochiKit.Base.filter(function (d) { return d != draggable; }, this.drags); if (this.drags.length === 0) { var disc = MochiKit.Signal.disconnect; disc(this.eventMouseUp); disc(this.eventMouseMove); disc(this.eventKeypress); } }, activate: function (draggable) { // allows keypress events if window is not currently focused // fails for Safari window.focus(); this.activeDraggable = draggable; }, deactivate: function () { this.activeDraggable = null; }, updateDrag: function (event) { if (!this.activeDraggable) { return; } var pointer = event.mouse(); // Mozilla-based browsers fire successive mousemove events with // the same coordinates, prevent needless redrawing (moz bug?) - if (this._lastPointer && (MochiKit.Base.repr(this._lastPointer.page) == - MochiKit.Base.repr(pointer.page))) { + if (this._lastPointer && + this._lastPointer.page.x == pointer.page.x && + this._lastPointer.page.y == pointer.page.y) { return; } this._lastPointer = pointer; this.activeDraggable.updateDrag(event, pointer); }, endDrag: function (event) { if (!this.activeDraggable) { return; } this._lastPointer = null; this.activeDraggable.endDrag(event); this.activeDraggable = null; }, keyPress: function (event) { if (this.activeDraggable) { this.activeDraggable.keyPress(event); } }, notify: function (eventName, draggable, event) { MochiKit.Signal.signal(this, eventName, draggable, event); } }; /** @id MochiKit.DragAndDrop.Draggable */ MochiKit.DragAndDrop.Draggable = function (element, options) { var cls = arguments.callee; if (!(this instanceof cls)) { return new cls(element, options); } this.__init__(element, options); }; MochiKit.DragAndDrop.Draggable.prototype = { /*** A draggable object. Simple instantiate : new MochiKit.DragAndDrop.Draggable('myelement'); ***/ __class__ : MochiKit.DragAndDrop.Draggable, __init__: function (element, /* optional */options) { var v = MochiKit.Visual; var b = MochiKit.Base; @@ -397,137 +398,136 @@ MochiKit.DragAndDrop.Draggable.prototype = { /** @id MochiKit.DragAndDrop.scrollSpeed */ scrollSpeed: 15, // false, or xy or [x, y] or function (x, y){return [x, y];} /** @id MochiKit.DragAndDrop.snap */ snap: false }, options); var d = MochiKit.DOM; this.element = d.getElement(element); if (options.handle && (typeof(options.handle) == 'string')) { this.handle = d.getFirstElementByTagAndClassName(null, options.handle, this.element); } if (!this.handle) { this.handle = d.getElement(options.handle); } if (!this.handle) { this.handle = this.element; } if (options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) { options.scroll = d.getElement(options.scroll); this._isScrollChild = MochiKit.DOM.isChildNode(this.element, options.scroll); } MochiKit.Style.makePositioned(this.element); // fix IE this.delta = this.currentDelta(); this.options = options; this.dragging = false; this.eventMouseDown = MochiKit.Signal.connect(this.handle, 'onmousedown', this, this.initDrag); MochiKit.DragAndDrop.Draggables.register(this); }, /** @id MochiKit.DragAndDrop.destroy */ destroy: function () { MochiKit.Signal.disconnect(this.eventMouseDown); MochiKit.DragAndDrop.Draggables.unregister(this); }, /** @id MochiKit.DragAndDrop.currentDelta */ currentDelta: function () { var s = MochiKit.Style.getStyle; return [ - parseInt(s(this.element, 'left') || '0'), - parseInt(s(this.element, 'top') || '0')]; + parseInt(s(this.element, 'left') || '0', 10), + parseInt(s(this.element, 'top') || '0', 10)]; }, /** @id MochiKit.DragAndDrop.initDrag */ initDrag: function (event) { if (!event.mouse().button.left) { return; } // abort on form elements, fixes a Firefox issue var src = event.target(); var tagName = (src.tagName || '').toUpperCase(); if (tagName === 'INPUT' || tagName === 'SELECT' || tagName === 'OPTION' || tagName === 'BUTTON' || tagName === 'TEXTAREA') { return; } if (this._revert) { this._revert.cancel(); this._revert = null; } var pointer = event.mouse(); var pos = MochiKit.Position.cumulativeOffset(this.element); this.offset = [pointer.page.x - pos.x, pointer.page.y - pos.y]; MochiKit.DragAndDrop.Draggables.activate(this); event.stop(); }, /** @id MochiKit.DragAndDrop.startDrag */ startDrag: function (event) { this.dragging = true; if (this.options.selectclass) { MochiKit.DOM.addElementClass(this.element, this.options.selectclass); } if (this.options.zindex) { - this.originalZ = parseInt(MochiKit.Style.getStyle(this.element, - 'z-index') || '0'); + this.originalZ = MochiKit.Style.getStyle(this.element, 'z-index'); this.element.style.zIndex = this.options.zindex; } if (this.options.ghosting) { this._clone = this.element.cloneNode(true); this.ghostPosition = MochiKit.Position.absolutize(this.element); this.element.parentNode.insertBefore(this._clone, this.element); } if (this.options.scroll) { if (this.options.scroll == window) { var where = this._getWindowScroll(this.options.scroll); this.originalScrollLeft = where.left; this.originalScrollTop = where.top; } else { this.originalScrollLeft = this.options.scroll.scrollLeft; this.originalScrollTop = this.options.scroll.scrollTop; } } MochiKit.DragAndDrop.Droppables.prepare(this.element); MochiKit.DragAndDrop.Draggables.notify('start', this, event); if (this.options.starteffect) { this.options.starteffect(this.element); } }, /** @id MochiKit.DragAndDrop.updateDrag */ updateDrag: function (event, pointer) { if (!this.dragging) { this.startDrag(event); } MochiKit.Position.prepare(); MochiKit.DragAndDrop.Droppables.show(pointer, this.element); MochiKit.DragAndDrop.Draggables.notify('drag', this, event); this.draw(pointer); this.options.onchange(this); if (this.options.scroll) { this.stopScrolling(); var p, q; if (this.options.scroll == window) { var s = this._getWindowScroll(this.options.scroll); p = new MochiKit.Style.Coordinates(s.left, s.top); q = new MochiKit.Style.Coordinates(s.left + s.width, s.top + s.height); } else { p = MochiKit.Position.page(this.options.scroll); |