chslider.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. $(document).ready(function() {
  2. var $newSlideConf = $('.post_gallery');
  3. var items = parseInt($newSlideConf.attr('data-items'));
  4. var speed = parseInt($newSlideConf.attr('data-speed'));
  5. var autoPlay = parseInt($newSlideConf.attr('data-autoplay'));
  6. var time = parseInt($newSlideConf.attr('data-time'));
  7. var loop = parseInt($newSlideConf.attr('data-loop'));
  8. var arrow = parseInt($newSlideConf.attr('data-arrow'));
  9. var pagination = parseInt($newSlideConf.attr('data-pagination'));
  10. var move = parseInt($newSlideConf.attr('data-move'));
  11. var pausehover = parseInt($newSlideConf.attr('data-pausehover'));
  12. var md = parseInt($newSlideConf.attr('data-md'));
  13. var sm = parseInt($newSlideConf.attr('data-sm'));
  14. var xs = parseInt($newSlideConf.attr('data-xs'));
  15. var xxs = parseInt($newSlideConf.attr('data-xxs'));
  16. if(autoPlay==1) {
  17. if(time){
  18. autoPlay = time;
  19. }else{
  20. autoPlay = '3000';
  21. }
  22. }else{
  23. autoPlay = false;
  24. }
  25. if(pausehover){pausehover = true}else{pausehover=false}
  26. if(move){move = false}else{move=true}
  27. if(arrow){arrow =true}else{arrow=false}
  28. if(pagination==1){pagination = true}else{pagination=false}
  29. if(loop==1){loop = true}else{loop=false}
  30. var newSlide = $(".post_gallery .newSlide");
  31. newSlide.owlCarousel({
  32. autoplay : autoPlay ,
  33. smartSpeed: speed,
  34. loop: loop,
  35. autoplayHoverPause: pausehover,
  36. scrollPerPage: move,
  37. nav: arrow,
  38. dots : pagination,
  39. responsive:{
  40. 0:{
  41. items:xxs,
  42. },
  43. 480:{
  44. items:xs,
  45. },
  46. 768:{
  47. items:sm,
  48. nav:false,
  49. },
  50. 992:{
  51. items:md,
  52. },
  53. 1200:{
  54. items:items,
  55. }
  56. }
  57. });
  58. checkClasses();
  59. newSlide.on('translated.owl.carousel', function(event) {
  60. checkClasses();
  61. });
  62. function checkClasses(){
  63. var total = $('.post_gallery .newSlide .owl-stage .owl-item.active').length;
  64. $('.post_gallery ').each(function(){
  65. $(this).find('.owl-item').removeClass('firstActiveItem');
  66. $(this).find('.owl-item').removeClass('lastActiveItem');
  67. $(this).find('.owl-item.active').each(function(index){
  68. if (index === 0) { $(this).addClass('firstActiveItem'); }
  69. if (index === total - 1 && total>1) {
  70. $(this).addClass('lastActiveItem');
  71. }
  72. })
  73. });
  74. }
  75. });