Accueil/js/jquery.links.js
2010-09-21 14:00:04 +00:00

40 lines
1.4 KiB
JavaScript

$(document).ready(function(){
// Réglage des options
$('body').append('<a href="#links" id="links-menu"><img src="images/interface/link_edit.png" /></a><div style="display:none;"><div id="links"></div></div>');
$('#menu-bar').prepend($('#links-menu'));
$('#links').append('<h3>Quel lien &agrave; ajouter?</h3><br/><input type="text" id="linkChoice" name="linkChoice"/><span id="links-submit" class="green-button">Enregistrer</span>');
$('#links-menu').fancybox({
'zoomSpeedIn' : 600,
'zoomSpeedOut' : 500,
'easingIn' : 'easeOutBack',
'easingOut' : 'easeInBack',
'hideOnContentClick': false,
'padding' : 15
});
$('#links-submit').live('click', function(){
var link = $('#linkChoice').val();
if(link != '' || link != null){
$.get('ajax/update.php', {id:'links', link: link}, function(msg){
location.reload();
});
}else{
$('#links').append('<span class="error">links can\'t be empty.</span>');
}
});
// 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});
}
}
).disableSelection();
});