custom.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. $(window).scroll(function() {
  2. if ($(window).scrollTop() >= 41) {
  3. $('body').addClass('header-fixed');
  4. } else {
  5. $('body').removeClass('header-fixed');
  6. }
  7. });
  8. //mobile touch
  9. $(document).ready(function($) {
  10. $( ".carousel" ).carousel();
  11. });
  12. $(document).ready(function($) {
  13. $('a[data-action=customize_theme]').click(function() {
  14. setTimeout(function(){
  15. if ($('.modal-body').hasClass('cstm-customized-theme') == true)
  16. {
  17. $('.modal-body').parent().parent().addClass('only-cstm-theme')
  18. $('.modal-body').parent().addClass('only-cstm-theme')
  19. }
  20. }, 100);
  21. });
  22. // browser window scroll (in pixels) after which the "back to top" link is shown
  23. var offset = 300,
  24. //browser window scroll (in pixels) after which the "back to top" link opacity is reduced
  25. offset_opacity = 1200,
  26. //duration of the top scrolling animation (in ms)
  27. scroll_top_duration = 700,
  28. //grab the "back to top" link
  29. $back_to_top = $('.cd-top');
  30. //hide or show the "back to top" link
  31. $(window).scroll(function() {
  32. ($(this).scrollTop() > offset) ? $back_to_top.addClass('cd-is-visible'): $back_to_top.removeClass('cd-is-visible cd-fade-out');
  33. if ($(this).scrollTop() > offset_opacity) {
  34. $back_to_top.addClass('cd-fade-out');
  35. }
  36. });
  37. //smooth scroll to top
  38. $back_to_top.on('click', function(event) {
  39. event.preventDefault();
  40. $('body,html').animate({
  41. scrollTop: 0,
  42. }, scroll_top_duration);
  43. });
  44. $('div#recommended_products_slider').owlCarousel({
  45. margin: 10,
  46. responsiveClass: true,
  47. items: 4,
  48. loop: true,
  49. autoPlay: 7000,
  50. stopOnHover: true,
  51. navigation: true,
  52. responsive: {
  53. 0: {
  54. items: 1,
  55. nav: false
  56. },
  57. 500: {
  58. items: 2,
  59. nav: false
  60. },
  61. 700: {
  62. items: 3,
  63. margin: 10,
  64. nav: false
  65. },
  66. 1000: {
  67. items: 4,
  68. nav: false,
  69. loop: false
  70. },
  71. 1500: {
  72. items: 4,
  73. nav: false,
  74. loop: false
  75. }
  76. }
  77. });
  78. // Grid/List switching code
  79. $(".oe_website_sale .shift_list_view").click(function(e) {
  80. $(".oe_website_sale .shift_grid_view").removeClass('active')
  81. $(this).addClass('active')
  82. $('#products_grid').addClass("list-view-box");
  83. $('.oe_website_sale .oe_subdescription').addClass('o_hidden');
  84. localStorage.setItem("product_view", "list");
  85. });
  86. $(".oe_website_sale .shift_grid_view").click(function(e) {
  87. $(".oe_website_sale .shift_list_view").removeClass('active')
  88. $(this).addClass('active')
  89. $('#products_grid').removeClass("list-view-box");
  90. $('.oe_website_sale .oe_subdescription').removeClass('o_hidden');
  91. localStorage.setItem("product_view", "grid");
  92. });
  93. if (localStorage.getItem("product_view") == 'list') {
  94. $(".oe_website_sale .shift_grid_view").removeClass('active')
  95. $(".oe_website_sale .shift_list_view").addClass('active')
  96. $('.oe_website_sale .oe_subdescription').addClass('o_hidden');
  97. $('#products_grid').addClass("list-view-box");
  98. }
  99. if (localStorage.getItem("product_view") == 'grid') {
  100. $(".oe_website_sale .shift_list_view").removeClass('active')
  101. $(".oe_website_sale .shift_grid_view").addClass('active')
  102. $('.oe_website_sale .oe_subdescription').removeClass('o_hidden');
  103. $('#products_grid').removeClass("list-view-box");
  104. }
  105. // Grid/List switching code ends
  106. // Switched to review section
  107. $('p.review').click(function() {
  108. $('body').animate({scrollTop: $(this).offset().top}, 1800);
  109. $('ul#description_reviews_tabs > li').removeClass('active')
  110. $('div#description_reviews_tabs_contents > div').removeClass('active')
  111. $('ul#description_reviews_tabs > li:nth-child(2)').addClass('active')
  112. $('div#description_reviews_tabs_contents > div:nth-child(2)').addClass('active')
  113. });
  114. // Toggle global search
  115. $('.st-toggle').on('click', function (e) {
  116. $('.search-toggle').toggleClass("search-toggle-open");
  117. });
  118. });
  119. // For Megamenu
  120. $(document).on('click', '.mega-dropdown-menu', function(e) {
  121. e.stopPropagation()
  122. });
  123. //Equal height
  124. $(window).load(function() {
  125. equal_height_all();
  126. });
  127. function equal_height_all() {
  128. function resetHeight() {
  129. var maxHeight = 0;
  130. jQuery(".cs-product .pwp-info .pwpi-title").height("auto").each(function() {
  131. maxHeight = $(this).height() > maxHeight ? $(this).height() : maxHeight;
  132. }).height(maxHeight);
  133. }
  134. resetHeight();
  135. jQuery(window).resize(function() {
  136. resetHeight();
  137. });
  138. }
  139. $(document).ready(function(){
  140. $(".li-mega-menu > a").click(function(){
  141. $(this).parent().parent().toggleClass("mob-open");
  142. });
  143. });
  144. //mobile Touch