Raise Z-index on drag; moved draggable specific JS code to dragreg.js.
This commit is contained in:
parent
37138619c0
commit
a97cb237f2
9
plemp.rb
9
plemp.rb
|
@ -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
|
||||
|
|
|
@ -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});
|
||||
}
|
||||
|
|
Reference in New Issue