Raise Z-index on drag; moved draggable specific JS code to dragreg.js.

This commit is contained in:
Paul van Tilburg 2010-09-10 18:34:16 +02:00
parent 37138619c0
commit a97cb237f2
2 changed files with 15 additions and 10 deletions

View File

@ -115,15 +115,8 @@ module Plemp::Views
else
span.draggable(:id => id, :style => default_style) { em "#{id}: Unsupported file type!" }
end
script :type => "text/javascript" do
<<-JS
new Draggable('#{id}', { scroll: window });
Draggables.addObserver(new DragRegObserver($('#{id}')));
$('#{id}').appear({duration: 2.0});
JS
end
script(:type => "text/javascript") { "setup_draggable('#{id}')" }
end
end
span(:onClick => "alert(maxZIndex()); return false;" ) { "test" }
end
end

View File

@ -13,6 +13,18 @@ DragRegObserver.prototype = {
}
}
function maxZIndex() {
return $$('.draggable').map(function(d) { return d.getStyle("z-index") }).max();
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});
}