forked from qwerty/tupali
49 lines
1.1 KiB
JavaScript
Executable File
49 lines
1.1 KiB
JavaScript
Executable File
$(document).ready(function(){
|
|
/* This code is executed after the DOM has been completely loaded */
|
|
|
|
var tmp;
|
|
|
|
$('.note').each(function(){
|
|
/* Finding the biggest z-index value of the notes */
|
|
tmp = $(this).css('z-index');
|
|
if(tmp>zIndex) zIndex = tmp;
|
|
})
|
|
|
|
/* A helper function for converting a set of elements to draggables: */
|
|
make_draggable($('.note'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
var zIndex = 200;
|
|
|
|
function make_draggable(elements)
|
|
{
|
|
/* Elements is a jquery object: */
|
|
|
|
elements.draggable({
|
|
//containment:'parent',
|
|
start:function(e,ui){ ui.helper.css('z-index',++zIndex); },
|
|
stop:function(e,ui){
|
|
var left = ui.position.left;
|
|
var top = ui.position.top;
|
|
var index = zIndex;
|
|
/// var id = parseInt(ui.helper.find('span.data').html());
|
|
var id = ui.helper.find('span.data').html();
|
|
/* Sending the z-index and positon of the note to update_position.php via AJAX GET: */
|
|
var datos = [['id',id],['x',left],['y',top],['z',index]];
|
|
var formulario = id.split("-", 1);
|
|
xajax_notes('','mover',datos,'');
|
|
xajax_ultimos_registros(document.getElementById('ultimo_id').value,formulario[0]);
|
|
}
|
|
});
|
|
} |