script.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. $(document).ready(function(){
  2. //slider
  3. const slider = $("#slider").owlCarousel({
  4. nav: true,
  5. items:2,
  6. loop:true,
  7. margin:15,
  8. responsive:{
  9. 600:{
  10. items:5
  11. },
  12. }
  13. });
  14. //dropdown
  15. function initializeCheckboxDropdown(containerId) {
  16. var dropdown = $('#' + containerId + ' .dropdown-menu');
  17. dropdown.find('.dropdown-item input[type="checkbox"]').on('change', function(){
  18. var selectedItems = [];
  19. dropdown.find('.dropdown-item input:checked').each(function(){
  20. selectedItems.push($(this).val());
  21. });
  22. $('#' + containerId + ' .dropdown-toggle').text(selectedItems.length > 0 ? selectedItems.join(', ') : 'Выберите элементы');
  23. });
  24. $(document).on('click', function(event){
  25. if(!dropdown.is(event.target) && dropdown.has(event.target).length === 0){
  26. dropdown.removeClass('show');
  27. $(".dropdown-toggle").removeAttr('style');
  28. }
  29. });
  30. $('#' + containerId + ' .dropdown-toggle').on('click', function(){
  31. dropdown.toggleClass('show');
  32. $(this).css({
  33. 'border': "2px solid #146aff",
  34. 'background': "#fff",
  35. });
  36. });
  37. }
  38. initializeCheckboxDropdown('dropdown1');
  39. initializeCheckboxDropdown('dropdown2');
  40. //gallery
  41. $(".gallery").find("img").each((i,e)=>{
  42. $(e).click(function(){
  43. $("#gallery_wrapper").attr("src", $(this).attr("src"));
  44. });
  45. });
  46. //sidebar
  47. $("#switch_sidebar").click(function(){
  48. $(".sidebar").toggleClass("closed");
  49. });
  50. });