1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
| /**
* TinyMCE
*/
function editeurTexte() {
tinymce.init({
mode: 'textareas',
selector:'textarea.description',
plugins: 'textcolor',
menubar: false,
toolbar: 'bold italic underline | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist |',
});
}
/**
* Action au clic sur le bouton Modifier
* Je récupère le formulaire pour modifier
*/
function modifierProjet(id) {
var route = '{{ path("modifier_projet_ajax", { "id": "PLACEHOLDER" }) }}';
route = route.replace("PLACEHOLDER", id);
return $.ajax({
type:"GET",
url: route,
success: function(data){
/* Pop-up */
$('.modal.modal-creation-projet-active')
.modal('show');
$('.modal-creation-projet-active .modal-body')
.empty()
.append(data);
/* TinyMCE */
editeurTexte();
$('form[name=creationProjet]').submit(function (e) {
e.preventDefault();
/* Fonction creationProjetSubmit() */
creationProjetSubmit();
});
}
});
}
/**
* Action à l'envoi du formulaire
* Je récupère les données du formulaire et je crée un Projet
*/
function creationProjetSubmit() {
var url = '{{ path("nouveau_projet_ajax") }}';
return $.ajax({
type:"POST",
data: $('form[name=creationProjet]').serialize(),
url: url,
cache: false,
success: function(data){
/* Pop-up */
$('.modal.modal-creation-projet-active')
.modal('show');
$('.modal-creation-projet-active .modal-body')
.empty()
.append(data);
$('.btn-modifier-projet').click(function (e) {
e.preventDefault();
/* On récupère l'id du projet dans le bouton modifier */
var id = $(this).attr('id');
/* Fonction modifierProjet(id) */
modifierProjet(id);
});
}
});
}
/**
* Action au clic sur le bouton "Nouveau projet"
* Je récupère mon formulaire de création
*/
function nouveauProjet() {
var route = '{{ path("nouveau_projet") }}';
return $.ajax({
type: 'GET',
url: route,
success: function(data) {
/* Pop-up */
$('.modal.modal-creation-projet-active')
.modal('show');
$('.modal-creation-projet-active .modal-body')
.empty()
.append(data);
/* Fonction TinyMCE */
editeurTexte();
$('form[name=creationProjet]').submit(function (e) {
e.preventDefault();
/* Fonction creationProjetSubmit() */
creationProjetSubmit();
});
}
});
}
/***********************************
* Départ de l'action de création d'un projet
************************************/
$('.a-nouveau-projet').click(function (e) {
e.preventDefault();
/* Fonction nouveauProjet() */
nouveauProjet();
}); |
Partager