|
1 $(function(){ |
|
2 |
|
3 $.fn.hasAttr = function(name) { |
|
4 return this.attr(name) !== undefined; |
|
5 }; |
|
6 |
|
7 //open modal |
|
8 $(document).on('click', 'a.open-modal', function(e){ |
|
9 e.preventDefault(); |
|
10 var modalRemote = $(this).attr('href'), |
|
11 typeMedia = $(this).attr('data-type-media'), |
|
12 modalTitleInfo = $(this).attr('data-title'), |
|
13 hideBibliotheque = $(this).hasAttr('data-hide-bibliotheque') ? true : false, |
|
14 titleFront; |
|
15 |
|
16 switch(typeMedia){ |
|
17 case 'video' : titleFront = '<i class="icon-film"></i> Vidéo - '+modalTitleInfo; break; |
|
18 case 'image' : titleFront = '<i class="icon-picture"></i> Image - '+modalTitleInfo; break; |
|
19 } |
|
20 $('#modal-template .modal-header h3').html(titleFront); |
|
21 |
|
22 $("#modal-template .modal-body").load(modalRemote, function() { |
|
23 $("#modal-template").modal("show"); |
|
24 if(hideBibliotheque) |
|
25 $("#modal-template").find(".bibliotheque-link").hide(); |
|
26 }); |
|
27 |
|
28 }); |
|
29 |
|
30 $('.popup').on('click', '.popup-content a', function(e){ |
|
31 e.preventDefault(); |
|
32 if($(this).hasClass('btn-cancel')){ |
|
33 $(this).parents('.popup').modal('hide'); |
|
34 } |
|
35 if($(this).hasClass('btn-previsualisation')){ |
|
36 var imgPrev = $('<img src="img/520x520.gif" alt="" />'); |
|
37 $('.previsualisation').empty().append(imgPrev); |
|
38 } |
|
39 }); |
|
40 |
|
41 //confirmation suppression |
|
42 $(document).on('click','.btn-delete', function(e){ |
|
43 e.preventDefault(); |
|
44 var titleMedia = $(this).attr('data-title'), |
|
45 textModal = $('<p>Êtes-vous sûr de vouloir supprimer <strong>'+titleMedia+'</strong> ?</p>'), |
|
46 eltDelete = $(this).attr('href'); |
|
47 $("#modal-confirm #btn-delete-modal").attr('data-id-elt-delete', eltDelete); |
|
48 $("#modal-confirm .modal-body").empty().append(textModal); |
|
49 $("#modal-confirm").modal('show'); |
|
50 }); |
|
51 |
|
52 $("#modal-confirm").on('click', '#btn-delete-modal', function(e){ |
|
53 e.preventDefault(); |
|
54 var idEltDelete = $(this).attr('data-id-elt-delete'); |
|
55 $(idEltDelete).remove(); |
|
56 $("#modal-confirm").modal('hide'); |
|
57 }); |
|
58 |
|
59 }); |