app_faq.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. "use strict";
  2. var app_faq = {
  3. init: function(){
  4. $(".app-faq-item").on("click", function(){
  5. $(this).toggleClass("open");
  6. delayBeforeFire(function(){
  7. $(window).resize();
  8. },100);
  9. });
  10. $("#app_faq_open").on("click", function(){
  11. $(".app-faq .app-faq-item").addClass("open");
  12. delayBeforeFire(function(){
  13. $(window).resize();
  14. },100);
  15. });
  16. $("#app_faq_hide").on("click", function(){
  17. $(".app-faq .app-faq-item").removeClass("open");
  18. delayBeforeFire(function(){
  19. $(window).resize();
  20. },100);
  21. });
  22. $("#app_faq_remove").on("click", function(){
  23. var hl = $(".app-faq").find(".app-faq-highlight");
  24. hl.each(function(){
  25. var txt = $(this).html();
  26. $(this).after(txt);
  27. $(this).remove();
  28. });
  29. $("#app_faq_hide").trigger("click");
  30. });
  31. this.search();
  32. },
  33. search: function(){
  34. $("#app_faq_form").on("submit",function(){
  35. var keyword = $("#app_faq_search").val();
  36. if(keyword.length >= 3){
  37. $(".app-faq .app-faq-item").removeClass("open");
  38. $(".app-faq").removeHighlight();
  39. var items = $(".app-faq .app-faq-item-content:containsi('"+keyword+"')");
  40. items.highlight(keyword);
  41. items.each(function(){
  42. $(this).parent(".app-faq-item").addClass("open");
  43. });
  44. delayBeforeFire(function(){
  45. $(window).resize();
  46. },100);
  47. }
  48. return false;
  49. });
  50. }
  51. };
  52. $(function(){
  53. app_faq.init();
  54. });