Created
September 12, 2020 01:51
-
-
Save Inontran/2b831621c8f994db57b25074dc3c4de4 to your computer and use it in GitHub Desktop.
функция создание каруселей
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $.fn.owlCarouselStart = function(){ | |
| var options = { | |
| loop: false, | |
| nav: false, | |
| dots: false, | |
| autoplay: false, | |
| margin: GUTTER, | |
| }; | |
| var navContainer = this.attr('data-nav'); | |
| var nav = (typeof navContainer === 'undefined') ? false : true; | |
| var dotsContainer = this.attr('data-dots'); | |
| var dots = (typeof dotsContainer === 'undefined') ? false : true; | |
| if( this.hasClass('carousel_js-1') ){ | |
| if( this.find('.carousel__item').length > 1 ){ | |
| options.nav = nav; | |
| options.dots = dots; | |
| options.navContainer = navContainer ? navContainer : false; | |
| options.dotsContainer = dotsContainer ? dotsContainer : false; | |
| var option_responsive = {}; | |
| option_responsive[BREAKPOINT_XS] = { | |
| items: 1 | |
| }; | |
| option_responsive[BREAKPOINT_SM] = { | |
| items: 1 | |
| }; | |
| option_responsive[BREAKPOINT_MD] = { | |
| items: 2 | |
| }; | |
| options.responsive = option_responsive; | |
| this.owlCarousel(options); | |
| } else{ | |
| this.removeClass('owl-carousel'); | |
| } | |
| return true; | |
| } | |
| // инициализация каруселей с элементами по сетке | |
| this.find('> .row').addClass('owl-carousel').addClass('mx-0'); | |
| var classList = this.find('.owl-carousel > div').eq(0).attr('class').split(/\s+/); | |
| var cols = {}; | |
| for (var i = 0; i < classList.length; i++) | |
| { | |
| if(classList[i].indexOf('col-xl') >= 0) | |
| { | |
| cols[BREAKPOINT_XL] = new Array; | |
| cols[BREAKPOINT_XL]['items'] = (COUNT_COLS / parseInt(classList[i].replace(/col-xl-/g,""))); | |
| this.find('.owl-carousel > div').removeClass(classList[i]); | |
| } | |
| else if(classList[i].indexOf('col-lg') >= 0) | |
| { | |
| cols[BREAKPOINT_LG] = new Array; | |
| cols[BREAKPOINT_LG]['items'] = (COUNT_COLS / parseInt(classList[i].replace(/col-lg-/g,""))); | |
| this.find('.owl-carousel > div').removeClass(classList[i]); | |
| } | |
| else if(classList[i].indexOf('col-md') >= 0) | |
| { | |
| cols[BREAKPOINT_MD] = new Array; | |
| cols[BREAKPOINT_MD]['items'] = (COUNT_COLS / parseInt(classList[i].replace(/col-md-/g,""))); | |
| this.find('.owl-carousel > div').removeClass(classList[i]); | |
| } | |
| else if(classList[i].indexOf('col-sm') >= 0) | |
| { | |
| cols[BREAKPOINT_SM] = new Array; | |
| cols[BREAKPOINT_SM]['items'] = (COUNT_COLS / parseInt(classList[i].replace(/col-sm-/g,""))); | |
| this.find('.owl-carousel > div').removeClass(classList[i]); | |
| } | |
| else if(classList[i].indexOf('col-') >= 0) | |
| { | |
| cols[BREAKPOINT_XS] = new Array; | |
| cols[BREAKPOINT_XS]['items'] = (COUNT_COLS / parseInt(classList[i].replace(/col-/g,""))); | |
| this.find('.owl-carousel > div').removeClass(classList[i]); | |
| } | |
| } | |
| options.responsive = cols; | |
| // this.find('.owl-carousel > div').css({ | |
| // 'padding-left': GUTTER/2, | |
| // 'padding-right': GUTTER/2, | |
| // }); | |
| this.find('.owl-carousel').owlCarousel(options); | |
| return this; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment