| author | ymh <ymh.work@gmail.com> |
| Tue, 12 May 2015 14:36:11 +0200 | |
| changeset 198 | b7d90dd57afc |
| parent 174 | a1656f70f1c9 |
| permissions | -rw-r--r-- |
| 9 | 1 |
$(function(){ |
2 |
||
3 |
$.fn.hasAttr = function(name) { |
|
4 |
return this.attr(name) !== undefined; |
|
5 |
}; |
|
6 |
||
| 174 | 7 |
$('.modal').on('show', function () { |
8 |
var halfWidth = $(this).width() / 2; |
|
9 |
$(this).css({ |
|
10 |
'margin-left' : - halfWidth +'px' |
|
11 |
}); |
|
12 |
}); |
|
13 |
||
| 9 | 14 |
//open modal |
15 |
$(document).on('click', 'a.open-modal', function(e){ |
|
16 |
e.preventDefault(); |
|
17 |
var modalRemote = $(this).attr('href'), |
|
18 |
typeMedia = $(this).attr('data-type-media'), |
|
19 |
modalTitleInfo = $(this).attr('data-title'), |
|
20 |
hideBibliotheque = $(this).hasAttr('data-hide-bibliotheque') ? true : false, |
|
| 66 | 21 |
hideAddNew = $(this).hasAttr('data-hide-add-new') ? true : false, |
| 78 | 22 |
isIframe = $(this).hasAttr('data-iframe') ? true : false, |
| 9 | 23 |
titleFront; |
24 |
||
25 |
switch(typeMedia){ |
|
26 |
case 'video' : titleFront = '<i class="icon-film"></i> Vidéo - '+modalTitleInfo; break; |
|
27 |
case 'image' : titleFront = '<i class="icon-picture"></i> Image - '+modalTitleInfo; break; |
|
28 |
} |
|
29 |
$('#modal-template .modal-header h3').html(titleFront); |
|
| 78 | 30 |
|
31 |
if(isIframe){ |
|
| 9 | 32 |
if(hideBibliotheque) |
33 |
$("#modal-template").find(".bibliotheque-link").hide(); |
|
| 66 | 34 |
if(hideAddNew) |
35 |
$("#modal-template").find(".add-new").hide(); |
|
| 9 | 36 |
|
| 78 | 37 |
$("#modal-template .modal-body").html('<iframe src="' + modalRemote + '" seamless="seamless" width="580" height="440"></iframe>'); |
38 |
$("#modal-template").modal("show"); |
|
39 |
} |
|
40 |
else{ |
|
41 |
$("#modal-template .modal-body").load(modalRemote, function() { |
|
42 |
$("#modal-template").modal("show"); |
|
43 |
if(hideBibliotheque) |
|
44 |
$("#modal-template").find(".bibliotheque-link").hide(); |
|
45 |
if(hideAddNew) |
|
46 |
$("#modal-template").find(".add-new").hide(); |
|
47 |
}); |
|
48 |
} |
|
| 9 | 49 |
}); |
50 |
||
51 |
$('.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
|
52 |
|
|
2542e988f80c
no-prevent class on bibliotheque
Anthony Ly <anthonyly.com@gmail.com>
parents:
66
diff
changeset
|
53 |
if($(this).hasClass('no-prevent')){ |
|
2542e988f80c
no-prevent class on bibliotheque
Anthony Ly <anthonyly.com@gmail.com>
parents:
66
diff
changeset
|
54 |
return true; |
|
2542e988f80c
no-prevent class on bibliotheque
Anthony Ly <anthonyly.com@gmail.com>
parents:
66
diff
changeset
|
55 |
}else{ |
|
2542e988f80c
no-prevent class on bibliotheque
Anthony Ly <anthonyly.com@gmail.com>
parents:
66
diff
changeset
|
56 |
e.preventDefault(); |
|
2542e988f80c
no-prevent class on bibliotheque
Anthony Ly <anthonyly.com@gmail.com>
parents:
66
diff
changeset
|
57 |
} |
| 9 | 58 |
if($(this).hasClass('btn-cancel')){ |
59 |
$(this).parents('.popup').modal('hide'); |
|
60 |
} |
|
|
74
22aca5b735a2
edit and preview buttons on project div home page
Anthony Ly <anthonyly.com@gmail.com>
parents:
70
diff
changeset
|
61 |
|
| 9 | 62 |
}); |
63 |
||
| 78 | 64 |
// empty modal when closed |
65 |
$("#modal-template .modal-header .close").click(function(e){ |
|
66 |
$("#modal-template .modal-body").html(''); |
|
67 |
}); |
|
68 |
||
| 9 | 69 |
//confirmation suppression |
70 |
$(document).on('click','.btn-delete', function(e){ |
|
71 |
e.preventDefault(); |
|
72 |
var titleMedia = $(this).attr('data-title'), |
|
| 42 | 73 |
urlDelete = $(this).attr('href'); |
74 |
$("#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
|
75 |
$("#modal-confirm .modal-body").find('.titleMedia').text(titleMedia); |
| 9 | 76 |
$("#modal-confirm").modal('show'); |
77 |
}); |
|
78 |
||
|
21
abd04f346dbe
delete row on enter key press in modal
Anthony Ly <anthonyly.com@gmail.com>
parents:
9
diff
changeset
|
79 |
$("#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
|
80 |
$("#modal-confirm #btn-delete-modal").focus(); |
| 9 | 81 |
}); |
82 |
|
|
83 |
}); |