Accueil/js/jquery.links.js

70 lines
2.0 KiB
JavaScript

$(document).ready(function(){
// Réglage des options
$('body').append('<img src="images/interface/link_edit.png" id="links-menu" />');
$('#menu-bar').prepend($('#links-menu'));
// Apparition de la reserve de liens
$('#links-menu').live('click', function(){
$.get('ajax/loadReserve.php', function(html){
$.fancybox(
html,
{
'autoDimensions' : false,
'width' : 400,
'height' : 'auto',
'showNavArrows' : false,
'transitionIn' : 'elastic'
}
);
});
});
// Passage Reserve => Liste
$('#reserveiconlist .item').live('click', function(e){
e.preventDefault();
$.post("ajax/reserveToList.php", {reserve: $(this).attr('id')});
$('.iconlist').last().append('<li class="item" id="'+$(this).attr('id')+'">'+$(this).html()+'</li>');
$.fancybox.close();
});
//Passage Liste => Reserve
$('.item').mouseover(function(){
$(this).children('.deleteLink').show();
});
$('.item').mouseout(function(){
$(this).children('.deleteLink').hide();
});
$('.deleteLink').click(function(){
$.post("ajax/listToReserve.php", {reserve: $(this).parent().attr('id')});
$(this).parent().fadeOut();
});
// Mouvement des liens avec enregistrement
$(".iconlist").sortable(
{
connectWith: '.iconlist',
update: function(event,ui){
var linkOrder = $(this).sortable('toArray').toString();
var label = $(ui.item).parent()[0].id;
var itemMoved = $(ui.item)[0].id;
$.post("ajax/update-links-order.php", {order: linkOrder, label : label, itemMoved: itemMoved});
},
start: function(e) {
// have to remvoe click handler off item so drop doesn't click
$("a.popup").unbind("click");
}
}
).disableSelection().mouseout(function(){
// reattach the item click handler
$('a.popup').unbind("click").bind("click", function(e){
e.preventDefault();
var url = $(this).attr('href');
spawnURL(url);
});
});
});