2010-09-21 16:00:04 +02:00
|
|
|
$(document).ready(function(){
|
|
|
|
// Réglage des options
|
2010-09-23 12:59:56 +02:00
|
|
|
$('body').append('<img src="images/interface/link_edit.png" id="links-menu" />');
|
2010-09-24 19:59:16 +02:00
|
|
|
$('body').append('<img src="images/interface/link_add.png" id="links-add-menu" />');
|
2010-09-21 16:00:04 +02:00
|
|
|
$('#menu-bar').prepend($('#links-menu'));
|
2010-09-24 19:59:16 +02:00
|
|
|
$('#menu-bar').prepend($('#links-add-menu'));
|
|
|
|
$('#links-add-fancy').append('<form action="addLink.php" enctype="multipart/form-data" method="POST"><label for="urlField">URL : </label><input type="text" name="urlField" id="urlField"/><br/><label for="popupField">popup ? </label><input type="checkbox" name="popupField" id="popupField" checked="checked" value="1" /><br/><label for="imgField">Icône : </label><input type="file" name="imgField" id="imgField"/><br/><label for="titreField">Titre : </label><input type="text" name="titreField" id="titreField"/><br/><input type="submit" class="green-button" id="links-add-submit" value="Envoyer"/></form>');
|
2010-09-23 12:59:56 +02:00
|
|
|
|
2010-09-24 19:59:16 +02:00
|
|
|
// Apparition du menu d'ajout de lien
|
|
|
|
$('#links-add-menu').live('click', function(){
|
|
|
|
$.fancybox(
|
|
|
|
$('#links-add-fancy').html()
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2010-09-23 12:59:56 +02:00
|
|
|
// Apparition de la reserve de liens
|
|
|
|
$('#links-menu').live('click', function(){
|
2010-09-27 12:48:53 +02:00
|
|
|
$.get('modules/links/ajax/loadReserve.php', function(html){
|
2010-09-23 12:59:56 +02:00
|
|
|
$.fancybox(
|
|
|
|
html,
|
|
|
|
{
|
|
|
|
'autoDimensions' : false,
|
|
|
|
'width' : 400,
|
|
|
|
'height' : 'auto',
|
|
|
|
'showNavArrows' : false,
|
|
|
|
'transitionIn' : 'elastic'
|
|
|
|
}
|
|
|
|
);
|
2010-09-21 16:00:04 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2010-09-23 12:59:56 +02:00
|
|
|
// Passage Reserve => Liste
|
2010-09-23 17:50:26 +02:00
|
|
|
$('#reserveiconlist .iconitem').live('click', function(e){
|
2010-09-23 12:59:56 +02:00
|
|
|
e.preventDefault();
|
2010-09-27 12:48:53 +02:00
|
|
|
$.post("modules/links/ajax/reserveToList.php", {reserve: $(this).attr('id')});
|
2010-09-23 17:50:26 +02:00
|
|
|
$('.iconlist').last().append('<li class="iconitem" id="'+$(this).attr('id')+'">'+$(this).html()+'</li>');
|
2010-09-23 12:59:56 +02:00
|
|
|
$.fancybox.close();
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
//Passage Liste => Reserve
|
2010-09-23 17:50:26 +02:00
|
|
|
$('.iconitem').mouseover(function(){
|
2010-09-23 15:02:42 +02:00
|
|
|
$(this).children('.deleteLink').show();
|
|
|
|
});
|
2010-09-23 17:50:26 +02:00
|
|
|
$('.iconitem').mouseout(function(){
|
2010-09-23 15:02:42 +02:00
|
|
|
$(this).children('.deleteLink').hide();
|
|
|
|
});
|
2010-09-23 12:59:56 +02:00
|
|
|
|
2010-09-23 15:02:42 +02:00
|
|
|
$('.deleteLink').click(function(){
|
2010-09-27 12:48:53 +02:00
|
|
|
$.post("modules/links/ajax/listToReserve.php", {reserve: $(this).parent().attr('id')});
|
2010-09-23 15:02:42 +02:00
|
|
|
$(this).parent().fadeOut();
|
|
|
|
});
|
2010-09-23 12:59:56 +02:00
|
|
|
|
2010-09-21 16:00:04 +02:00
|
|
|
// 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;
|
2010-09-27 12:48:53 +02:00
|
|
|
$.post("modules/links/ajax/update-links-order.php", {order: linkOrder, label : label, itemMoved: itemMoved});
|
2010-09-22 16:02:40 +02:00
|
|
|
},
|
|
|
|
start: function(e) {
|
|
|
|
// have to remvoe click handler off item so drop doesn't click
|
|
|
|
$("a.popup").unbind("click");
|
2010-09-21 16:00:04 +02:00
|
|
|
}
|
|
|
|
}
|
2010-09-22 16:02:40 +02:00
|
|
|
).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);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2010-09-21 16:00:04 +02:00
|
|
|
|
|
|
|
|
|
|
|
});
|