tupali_fork/librerias/notas/script.js
2017-12-04 08:34:57 -05:00

64 lines
1.6 KiB
JavaScript

$('.dropdown-toggle').click(function (){
dropDownFixPosition($('button'),$('.dropdown-menu'));
});
function dropDownFixPosition(button,dropdown){
var dropDownTop = button.offset().top + button.outerHeight();
dropdown.css('top', dropDownTop + "px");
dropdown.css('left', button.offset().left + "px");
}
$(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'));
$("#muestraInfo").on("hidden.bs.modal", function () {
document.getElementById('modal_landing').className= 'modal-dialog modal-lg';
});
});
var zIndex = 0;
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]);
}
});
}