| author | Anthony Ly <anthonyly.com@gmail.com> |
| Fri, 07 Jun 2013 17:56:17 +0200 | |
| changeset 102 | 172abe53cf6c |
| parent 78 | 5dddae65a99a |
| child 174 | a1656f70f1c9 |
| 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, |
|
| 66 | 14 |
hideAddNew = $(this).hasAttr('data-hide-add-new') ? true : false, |
| 78 | 15 |
isIframe = $(this).hasAttr('data-iframe') ? true : false, |
| 9 | 16 |
titleFront; |
17 |
||
18 |
switch(typeMedia){ |
|
19 |
case 'video' : titleFront = '<i class="icon-film"></i> Vidéo - '+modalTitleInfo; break; |
|
20 |
case 'image' : titleFront = '<i class="icon-picture"></i> Image - '+modalTitleInfo; break; |
|
21 |
} |
|
22 |
$('#modal-template .modal-header h3').html(titleFront); |
|
| 78 | 23 |
|
24 |
if(isIframe){ |
|
| 9 | 25 |
if(hideBibliotheque) |
26 |
$("#modal-template").find(".bibliotheque-link").hide(); |
|
| 66 | 27 |
if(hideAddNew) |
28 |
$("#modal-template").find(".add-new").hide(); |
|
| 9 | 29 |
|
| 78 | 30 |
$("#modal-template .modal-body").html('<iframe src="' + modalRemote + '" seamless="seamless" width="580" height="440"></iframe>'); |
31 |
$("#modal-template").modal("show"); |
|
32 |
} |
|
33 |
else{ |
|
34 |
$("#modal-template .modal-body").load(modalRemote, function() { |
|
35 |
$("#modal-template").modal("show"); |
|
36 |
if(hideBibliotheque) |
|
37 |
$("#modal-template").find(".bibliotheque-link").hide(); |
|
38 |
if(hideAddNew) |
|
39 |
$("#modal-template").find(".add-new").hide(); |
|
40 |
}); |
|
41 |
} |
|
| 9 | 42 |
}); |
43 |
||
44 |
$('.popup').on('click', '.popup-content a', function(e){ |
|
|
70
2542e988f80c
no-prevent class on bibliotheque
Anthony Ly <anthonyly.com@gmail.com>
parents:
66
diff
changeset
|
45 |
|
|
2542e988f80c
no-prevent class on bibliotheque
Anthony Ly <anthonyly.com@gmail.com>
parents:
66
diff
changeset
|
46 |
if($(this).hasClass('no-prevent')){ |
|
2542e988f80c
no-prevent class on bibliotheque
Anthony Ly <anthonyly.com@gmail.com>
parents:
66
diff
changeset
|
47 |
return true; |
|
2542e988f80c
no-prevent class on bibliotheque
Anthony Ly <anthonyly.com@gmail.com>
parents:
66
diff
changeset
|
48 |
}else{ |
|
2542e988f80c
no-prevent class on bibliotheque
Anthony Ly <anthonyly.com@gmail.com>
parents:
66
diff
changeset
|
49 |
e.preventDefault(); |
|
2542e988f80c
no-prevent class on bibliotheque
Anthony Ly <anthonyly.com@gmail.com>
parents:
66
diff
changeset
|
50 |
} |
| 9 | 51 |
if($(this).hasClass('btn-cancel')){ |
52 |
$(this).parents('.popup').modal('hide'); |
|
53 |
} |
|
|
74
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
54 |
|
| 9 | 55 |
}); |
56 |
||
| 78 | 57 |
// empty modal when closed |
58 |
$("#modal-template .modal-header .close").click(function(e){ |
|
59 |
$("#modal-template .modal-body").html(''); |
|
60 |
}); |
|
61 |
||
| 9 | 62 |
//confirmation suppression |
63 |
$(document).on('click','.btn-delete', function(e){ |
|
64 |
e.preventDefault(); |
|
65 |
var titleMedia = $(this).attr('data-title'), |
|
| 42 | 66 |
urlDelete = $(this).attr('href'); |
67 |
$("#modal-confirm #btn-delete-modal").attr('href', urlDelete).focus(); |
|
|
55
cedadc7d039a
modal delete in html title update
Anthony Ly <anthonyly.com@gmail.com>
parents:
42
diff
changeset
|
68 |
$("#modal-confirm .modal-body").find('.titleMedia').text(titleMedia); |
| 9 | 69 |
$("#modal-confirm").modal('show'); |
70 |
}); |
|
71 |
||
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
9
diff
changeset
|
72 |
$("#modal-confirm").on('shown', function() { |
|
74
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
73 |
$("#modal-confirm #btn-delete-modal").focus(); |
| 9 | 74 |
}); |
75 |
|
|
76 |
}); |