This repository has been archived on 2020-04-11. You can view files and clone it, but cannot push or open issues or pull requests.
plemp/public/dragreg.js

31 lines
928 B
JavaScript

var DragRegObserver = Class.create();
DragRegObserver.prototype = {
initialize: function(element) {
this.element = $(element);
},
onStart: function() {},
onEnd: function (eventName, draggable, event) {
if (Draggables.activeDraggable.element == this.element) {
elem = draggable.element;
new Ajax.Request(BaseUrl + 'savepos/' + elem.id +
'/' + elem.style.top + '/' + elem.style.left);
}
}
}
function new_ZIndex() {
cur_index = $$('.draggable').map(function(d) { return d.getStyle("z-index") }).max();
return parseInt(cur_index) + 1
}
function setup_draggable(id) {
drag = new Draggable(id, { scroll: window });
old_endeffect = drag.options.endeffect;
drag.options.endeffect = function(element) {
old_endeffect(element);
element.style.zIndex = new_ZIndex();
}
Draggables.addObserver(new DragRegObserver($(id)));
$(id).appear({duration: 2.0});
}