You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
146 lines
6.5 KiB
146 lines
6.5 KiB
$(function() {
|
|
$(".container").attr("id", "faq-container"), $(".footer-text").addClass("container"), $("nav div.container").removeAttr("id"), $("#add-question-btn").on("click", function(e) {
|
|
e.preventDefault()
|
|
var t, a, n
|
|
t = $.trim($("#question").val()), a = $.trim($("#question-subject").val()), n = tinymce.get("answer").getContent(), "Choisissez un sujet de question ..." == a || "" == t || "" == n || "" == a ? app._notify("error", "Merci de remplir les champs suivants.") : $.ajax({
|
|
url: app.get_vars().baseurl + "faqs/faqs/add_question",
|
|
type: "POST",
|
|
data: {
|
|
question: t,
|
|
subject: a,
|
|
answer: n
|
|
},
|
|
success: function(e) {
|
|
1 == e && (app._notify("success", "Question ajoutée avec succès"), $("#add-question-btn").prop("disabled", !0), window.setTimeout(function() {
|
|
window.location.href = app.get_vars().baseurl + "faqs"
|
|
}, 2e3))
|
|
}
|
|
})
|
|
}), $("#faq_table").dataTable({
|
|
"language":fr_onload_lang.oLanguage
|
|
});
|
|
$("#faq_table tbody tr.rowfaq_table").length
|
|
$("#faq_table").on("click", ".delete-btn", function() {
|
|
var e = this.id
|
|
$(this).closest("tr").attr("id")
|
|
$.ajax({
|
|
url: app.get_vars().baseurl + "faqs/faqs/get_question",
|
|
type: "POST",
|
|
data: {
|
|
question: e
|
|
},
|
|
success: function(e) {
|
|
$(".question-txt").html("<p><b>Question : </b> " + e.question + "</p><p><b>Réponse : </b> " + e.reply + "</p>")
|
|
}
|
|
}), bootbox.dialog({
|
|
title: "Confirmer la suppression de la question",
|
|
className: "my-modal-with-sm event-normal-registration-modal table",
|
|
message: $("#delete-question"),
|
|
cache: !1,
|
|
show: !1,
|
|
buttons: [{
|
|
label: "RETOUR",
|
|
className: "btn btn-default",
|
|
callback: function() {
|
|
$("#delete-question").empty(), window.setTimeout(function() {
|
|
window.location.href = app.get_vars().baseurl + "faqs"
|
|
}, 500)
|
|
}
|
|
}, {
|
|
label: "CONFIRMER",
|
|
className: "btn btn-primary",
|
|
callback: function() {
|
|
$.ajax({
|
|
url: app.get_vars().baseurl + "faqs/faqs/delete_question",
|
|
type: "POST",
|
|
data: {
|
|
question: e
|
|
},
|
|
success: function(e) {
|
|
1 == e && (app._notify("success", "Supprimé avec succès"), window.setTimeout(function() {
|
|
window.location.href = app.get_vars().baseurl + "faqs"
|
|
}, 2e3))
|
|
}
|
|
})
|
|
}
|
|
}]
|
|
}).on("shown.bs.modal", function() {}).on("hide.bs.modal", function() {
|
|
$("#delete-question").empty()
|
|
}).modal("show")
|
|
}), $("#faq_table").on("click", ".edit-btn", function() {
|
|
var e = this.id
|
|
$(this).closest("tr").attr("id")
|
|
$.ajax({
|
|
url: app.get_vars().baseurl + "faqs/faqs/get_question",
|
|
type: "POST",
|
|
data: {
|
|
question: e
|
|
},
|
|
success: function(e) {
|
|
$("#edit-question-subject").val(e.subject_id), $("#editquestion").val(e.question), tinymce.init({
|
|
selector: "#edit-answer",
|
|
height: 300,
|
|
theme: "modern",
|
|
language: "fr_FR",
|
|
force_br_newlines: !0,
|
|
force_p_newlines: !1,
|
|
forced_root_block: "",
|
|
file_browser_callback_types: "file image media",
|
|
plugins: ["autolink lists link charmap anchor preview"],
|
|
toolbar: "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | PreviewButton"
|
|
}), tinyMCE.get("edit-answer").setContent(e.reply)
|
|
}
|
|
}), bootbox.dialog({
|
|
title: "Modifier la question",
|
|
className: "my-modal-with-sm event-normal-registration-modal table",
|
|
message: $("#edit-question"),
|
|
cache: !1,
|
|
show: !1,
|
|
buttons: [{
|
|
label: "RETOUR",
|
|
className: "btn btn-default",
|
|
callback: function() {
|
|
$("#edit-question").empty()
|
|
}
|
|
}, {
|
|
label: "METTRE À JOUR",
|
|
className: "btn btn-primary",
|
|
callback: function() {
|
|
var t, a, n
|
|
a = $("#edit-question-subject").val(), t = $("#editquestion").val(), n = tinymce.get("edit-answer").getContent(), "" == t || "" == a || "" == n ? app._notify("error", "Merci de remplir les champs suivants.") : $.ajax({
|
|
url: app.get_vars().baseurl + "faqs/faqs/edit_question",
|
|
type: "POST",
|
|
data: {
|
|
qid: e,
|
|
question: t,
|
|
subject: a,
|
|
answer: n
|
|
},
|
|
success: function(e) {
|
|
1 == e && window.setTimeout(app._notify("success", "Modification réussie"), 2e3)
|
|
}
|
|
})
|
|
}
|
|
}]
|
|
}).on("shown.bs.modal", function() {
|
|
$("#edit-question").show()
|
|
}).on("hide.bs.modal", function() {
|
|
window.setTimeout(function() {
|
|
window.location.href = app.get_vars().baseurl + "faqs"
|
|
}, 500)
|
|
}).modal("show"), $(document).on("focusin", function(e) {
|
|
$(e.target).closest(".mce-container").length && e.stopImmediatePropagation()
|
|
})
|
|
}), tinymce.init({
|
|
selector: "#answer",
|
|
height: 300,
|
|
theme: "modern",
|
|
language: "fr_FR",
|
|
force_br_newlines: !0,
|
|
force_p_newlines: !1,
|
|
forced_root_block: "",
|
|
file_browser_callback_types: "file image media",
|
|
plugins: ["autolink lists link charmap anchor preview"],
|
|
toolbar: "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | PreviewButton"
|
|
})
|
|
})
|