| author | Anthony Ly <anthonyly.com@gmail.com> |
| Tue, 04 Jun 2013 12:50:33 +0200 | |
| changeset 74 | 22aca5b735a2 |
| parent 70 | 2542e988f80c |
| child 78 | 5dddae65a99a |
| 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, |
| 9 | 15 |
titleFront; |
16 |
||
17 |
switch(typeMedia){ |
|
18 |
case 'video' : titleFront = '<i class="icon-film"></i> Vidéo - '+modalTitleInfo; break; |
|
19 |
case 'image' : titleFront = '<i class="icon-picture"></i> Image - '+modalTitleInfo; break; |
|
20 |
} |
|
21 |
$('#modal-template .modal-header h3').html(titleFront); |
|
22 |
||
23 |
$("#modal-template .modal-body").load(modalRemote, function() { |
|
24 |
$("#modal-template").modal("show"); |
|
25 |
if(hideBibliotheque) |
|
26 |
$("#modal-template").find(".bibliotheque-link").hide(); |
|
| 66 | 27 |
if(hideAddNew) |
28 |
$("#modal-template").find(".add-new").hide(); |
|
| 9 | 29 |
}); |
30 |
||
31 |
}); |
|
32 |
||
33 |
$('.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
|
34 |
|
|
2542e988f80c
no-prevent class on bibliotheque
Anthony Ly <anthonyly.com@gmail.com>
parents:
66
diff
changeset
|
35 |
if($(this).hasClass('no-prevent')){ |
|
2542e988f80c
no-prevent class on bibliotheque
Anthony Ly <anthonyly.com@gmail.com>
parents:
66
diff
changeset
|
36 |
return true; |
|
2542e988f80c
no-prevent class on bibliotheque
Anthony Ly <anthonyly.com@gmail.com>
parents:
66
diff
changeset
|
37 |
}else{ |
|
2542e988f80c
no-prevent class on bibliotheque
Anthony Ly <anthonyly.com@gmail.com>
parents:
66
diff
changeset
|
38 |
e.preventDefault(); |
|
2542e988f80c
no-prevent class on bibliotheque
Anthony Ly <anthonyly.com@gmail.com>
parents:
66
diff
changeset
|
39 |
} |
| 9 | 40 |
if($(this).hasClass('btn-cancel')){ |
41 |
$(this).parents('.popup').modal('hide'); |
|
42 |
} |
|
|
74
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
43 |
|
| 9 | 44 |
}); |
45 |
||
46 |
//confirmation suppression |
|
47 |
$(document).on('click','.btn-delete', function(e){ |
|
48 |
e.preventDefault(); |
|
49 |
var titleMedia = $(this).attr('data-title'), |
|
| 42 | 50 |
urlDelete = $(this).attr('href'); |
51 |
$("#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
|
52 |
$("#modal-confirm .modal-body").find('.titleMedia').text(titleMedia); |
| 9 | 53 |
$("#modal-confirm").modal('show'); |
54 |
}); |
|
55 |
||
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
9
diff
changeset
|
56 |
$("#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
|
57 |
$("#modal-confirm #btn-delete-modal").focus(); |
| 9 | 58 |
}); |
59 |
|
|
60 |
}); |