$(document).keypress(function(e) { $('#collapseQ40').show(); if(e.which == 13) { var b = $("#srch-term").val(); if (b == "") { } else { window.location.href = "faq?word=" + b } } }); $(document).ready(function() { $("#mainQ1").attr("aria-expanded","true"); $('#collapse1').addClass('show'); $('#collapseQ1').addClass('show'); var hash = window.location.hash; var pairs = hash.split('&'); var lVal = pairs[0]; var vVal = pairs[1]; var main = $('button[data-target$="'+lVal+'"]'); var sub = $('button[data-target$="'+vVal+'"]'); if (main.length > 0){ main.click(); sub.click(); } $(main).on('shown.bs.collapse', function(e) { var $card = $(this).closest('.card'); $('html,body').animate({ scrollTop: $card.offset().top }, 500); }); $(document).on('click', '.helpful-yes', function(event) { event.preventDefault(); /* Act on the event */ helpfulYes(this); }); $(document).on('click', '.helpful-no', function(event) { event.preventDefault(); /* Act on the event */ helpfulNo(this); }); $(document).on('click', '.show-collapse', function(event) { event.preventDefault(); /* Act on the event */ showcollapse(this) }); }); var faq = { suggestion: function(b) { var a = { url: function(c) { return "faqs/faqs/suggestion" }, getValue: function(c) { return c.question }, list: { match: { enabled: true } }, template: { type: "custom", method: function(c, d) { return "
" + d.question + "
" } }, ajaxSettings: { dataType: "json", method: "GET", data: { dataType: "json" } }, preparePostData: function(c) { c.phrase = $(b).val(); return c }, requestDelay: 400 }; if ($(b).val() != null) { $(b).easyAutocomplete(a) } } }; $(function() { $('.searchQ').prop('disabled', true); $('input[type="text"]').on('input change',function() { $('.searchQ').prop('disabled', false); }); faq.suggestion("#srch-term"); $('input:text').focus(function(){ $(this).val(''); $('.searchQ').prop('disabled', true); $('.searchQ').removeClass("disabled_btn"); }); // $(".container").attr("id", "faq-container"); $(".footer-text").addClass("container"); $("nav div.container").removeAttr("id"); $.urlParam = function(b) { var c = new RegExp("[?&]" + b + "=([^&#]*)").exec(window.location.href); if (c == null) { return null } else { return decodeURI(c[1]) || 0 } }; var a = $.urlParam("cat_id"); if (a == null) { $("#selected").show(); $("#cat").addClass("active-identifier") } else { $("#selected" + a).show(); $("#cat_" + a).addClass("active-identifier") } $("#add-question-btn").click(function(f) { f.preventDefault(); var d, c, b; d = $.trim($("#question").val()); c = $.trim($("#question-subject").val()); b = tinymce.get("answer").getContent(); if (c == "Choisissez un sujet de question ..." || d == "" || b == "" || c == "") { app._notify("error", "Merci de remplir les champs suivants.") } else { $.ajax({ url: app.get_vars().baseurl + "faqs/faqs/add_question", type: "POST", data: { question: d, subject: c, answer: b }, success: function(e) { if (e == 1) { app._notify("success", "Question ajoutée avec succès"); window.setTimeout(function() { window.location.href = app.get_vars().baseurl + "faqs" }, 2000) } } }) } }); $(".searchQ").click(function() { var b = $("#srch-term").val(); if (b == "") { } else { window.location.href = "faq?word=" + b } }) }); function helpfulYes(key) { var b = $(key).data('id'); var c = $(".helpful-yes"+b).val(); $.ajax({ url: "faqs/faqs/helpful_yes", type: "POST", data: { answer: c, question: b }, success: function(d) { if (d == 1) { $(".helpful-yes"+b).prop("disabled", true); $(".helpful-no"+b).prop("disabled", true); app._notify("success", "Merci") } else { $(".helpful-yes"+b).addClass("btn-outline-warning") } } }); } function helpfulNo(key) { var b = $(key).data('id'); var c = $("#helpful-no").val(); $.ajax({ url: "faqs/faqs/helpful_no", type: "POST", data: { answer: c, question: b }, success: function(d) { if (d == 1) { $(".helpful-no"+b).prop("disabled", true); $(".helpful-yes"+b).prop("disabled", true); app._notify("success", "Merci") } else { $(".helpful-no"+b).addClass("btn-outline-warning") } } }) } function showcollapse(k) { $('.searchQ').addClass("disabled_btn"); $('.activeQ').collapse("hide"); var a = $(k).data('id'); var b = $(k).attr('id'); $('#'+a).collapse("show"); $('#'+b).collapse("show"); $('#'+b).addClass("activeQ"); }