all.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /**
  2. * @version 7.9 [rev.7.9.01]
  3. */
  4. $(function () {
  5. $.fn.scrollToTop = function () {
  6. $(this).hide().removeAttr("href");
  7. if ($(window).scrollTop() != "0") {
  8. $(this).fadeIn("slow")
  9. }
  10. var scrollDiv = $(this);
  11. $(window).scroll(function () {
  12. if ($(window).scrollTop() == "0") {
  13. $(scrollDiv).fadeOut("slow")
  14. } else {
  15. $(scrollDiv).fadeIn("slow")
  16. }
  17. });
  18. $(this).click(function () {
  19. $("html, body").animate({
  20. scrollTop: 0
  21. }, "slow")
  22. })
  23. };
  24. $('#category-select-btn').click(function (e) {
  25. e.preventDefault();
  26. $('#category-select-content').slideToggle('1000');
  27. });
  28. $('#category-select-content').find('a').click(function (e) {
  29. e.preventDefault();
  30. var categoryName = $(this).attr('data-category-name');
  31. var categoryId = $(this).attr('data-id');
  32. var searchForm = $(this).closest('form');
  33. searchForm.find('input[name="parent_id"]').val(categoryId);
  34. $('#category-select-btn').find('span').text(categoryName);
  35. $('#category-select-content').hide('1000');
  36. });
  37. // mobile search box hide / show on scroll
  38. var senseSpeed = 5;
  39. var previousScroll = 0;
  40. $(window).scroll(function (e) {
  41. var scroller = $(this).scrollTop();
  42. if ((scroller - senseSpeed) > previousScroll) {
  43. // downscroll code
  44. $('#mobile-navigation').find('.mobile-search').slideUp(200, 'linear');
  45. } else if ((scroller + senseSpeed) < previousScroll) {
  46. // upscroll code
  47. $('#mobile-navigation').find('.mobile-search').slideDown(200, 'linear');
  48. }
  49. previousScroll = scroller;
  50. });
  51. $('#browse-btn').click(function (e) {
  52. e.preventDefault();
  53. $('#browse-content').toggle('1000');
  54. $(this).toggleClass('active');
  55. if ($(this).hasClass('active')) {
  56. $(this).find('i').attr('class', 'fa fa-angle-up');
  57. }
  58. else {
  59. $(this).find('i').attr('class', 'fa fa-angle-down');
  60. }
  61. });
  62. $(".scroll-top").scrollToTop();
  63. });