| author | Anthony Ly <anthonyly.com@gmail.com> |
| Tue, 21 May 2013 16:40:05 +0200 | |
| changeset 22 | 0e02c3a28491 |
| parent 21 | abd04f346dbe |
| child 42 | 95e64fb6730f |
| permissions | -rw-r--r-- |
| 9 | 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'); |
|
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
9
diff
changeset
|
47 |
$("#modal-confirm #btn-delete-modal").attr('data-id-elt-delete', eltDelete).focus(); |
| 9 | 48 |
$("#modal-confirm .modal-body").empty().append(textModal); |
49 |
$("#modal-confirm").modal('show'); |
|
50 |
}); |
|
51 |
||
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
9
diff
changeset
|
52 |
$("#modal-confirm").on('shown', function() { |
|
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
9
diff
changeset
|
53 |
$("#modal-confirm #btn-delete-modal").focus() |
|
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
9
diff
changeset
|
54 |
}); |
|
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
9
diff
changeset
|
55 |
|
| 9 | 56 |
$("#modal-confirm").on('click', '#btn-delete-modal', function(e){ |
57 |
e.preventDefault(); |
|
58 |
var idEltDelete = $(this).attr('data-id-elt-delete'); |
|
59 |
$(idEltDelete).remove(); |
|
60 |
$("#modal-confirm").modal('hide'); |
|
61 |
}); |
|
62 |
|
|
63 |
}); |