Nicolas Bally 17f6826d83 assets
2011-07-05 21:51:05 +02:00

81 lines
1.6 KiB
JavaScript

function after_load_document(){
$( ".menu_item_row" ).draggable({
revert:"invalid",
handle:".grip",
zIndex: 2700,
opacity: 0.35,
cursorAt: { left: 400 },
//snap: true,
//snapTolerance: 40,
helper: 'clone',
start: function(event, ui) {
$( this ).css("background", "#F9F9F9" );
$( this ).next().droppable( "option", "disabled", true );
$( this ).prev().droppable( "option", "disabled", true );
},
drag: function(){
},
stop: function(){
$( this ).next().droppable( "option", "disabled", false );
$( this ).prev().droppable( "option", "disabled", false );
$( this ).css("background", "white" );
}
});
$(".receptable").droppable({
hoverClass:"hoverhighlight",
tolerance : "pointer",
drop: function( event, ui ) {
ui.draggable.fadeOut();
set_busy();
$.ajax({
url:"/admin/menu_items/"+ui.draggable.attr("data-menu_item_id")+".js",
type: "PUT",
data: {
reorder : true,
menu_item : {
parent_id : $(this).attr("data-parent_id")
}
},
success : function (){
after_load_document();
}
});
}
});
$(".receptable_position").droppable({
hoverClass:"hoverhighlight_position",
tolerance : "pointer",
drop: function( event, ui ) {
ui.draggable.fadeOut();
set_busy();
$.ajax({
url:"/admin/menu_items/"+ui.draggable.attr("data-menu_item_id")+".js",
type: "PUT",
data: {
reorder : true,
menu_item : {
position : $(this).attr("data-position")
}
},
success : function (){
after_load_document();
}
});
}
});
}
$(document).ready(function(){
after_load_document();
});