;(function($) {
    'use strict'
    var tflThemeShortcodes = {
        // Main init function
        init : function() {
            this.config();
            this.events();
        },
        // Define vars for caching
        config : function() {
            this.config = {
                $window : $( window ),
                $document : $( document ),
            };
        },
        // Events
        events : function() {
            var self = this;
            // Run on document ready
            self.config.$document.on( 'ready', function() {
                self.tfl_testimonials();
                self.tfl_brands();
                self.tfl_video_box();
                self.tfl_scroll_btn();
                self.tfl_tabs_video();
                self.tfl_list_member();
                self.tfl_blogs_slider();
                self.tfl_slider();
                // self.tfl_go_top();
            } );
            // Run on Window Load
            self.config.$window.on( 'load', function() {
            } );
        },
        tfl_slider: function() {
            if( $().slick ) {
                var arr_sliders = $('.tfl-inner-sliders');
                arr_sliders.each( function()  {
                    var $container = $( this ),
                    arrows = ($container.data('nav') == 'yes') ? true : false,
                    dots = ($container.data('dots') == 'yes') ? true : false,
                    autoplay = ($container.data('autoplay') == 'yes') ? true : false;
                    $($container).slick({
                        slidesToShow: 1,
                        // infinite: true,
                        arrows: arrows,
                        dots: dots,
                        autoplay: autoplay,
                        autoplaySpeed: 5000,
                        focusOnSelect: true,
                        centerPadding: '30px',
                        // infinite: true,
                        useTransform: true,
                        cssEase: 'cubic-bezier(0.77, 0, 0.18, 1)',
                        prevArrow: '<i class="fa fa-angle-left" aria-hidden="true"></i>',
                        nextArrow: '<i class="fa fa-angle-right" aria-hidden="true"></i>',
                    });
                });
            };
        },
        // tfl_go_top: function() {
        //     var $go_top = $('.go-top');
        //     $(window).scroll(function() {
        //         if ( $(this).scrollTop() > 800 ) {
        //             $go_top.addClass('show');
        //         } else {
        //             $go_top.removeClass('show');
        //         }
        //     }); 
        //     $go_top.on('click', function() {            
        //         $("html, body").animate({ scrollTop: 0 }, 1000 , 'easeInOutExpo');
        //         return false;
        //     });
        // },
        tfl_list_member: function() {
            if( $().slick ) {
                var nav = $('.nav-member'),
                info = $('.info-member');
                $(nav).slick({
                    slidesToShow: 2,
                    slidesToScroll: 1,
                    // fade: true,
                    asNavFor: info,
                    vertical: true,
                    // verticalSwiping: true,
                    arrows: true,
                    cssEase: 'cubic-bezier(0.77, 0, 0.18, 1)',
                    prevArrow: '<i class="fa fa-arrow-up" aria-hidden="true"></i>',
                    nextArrow: '<i class="fa fa-arrow-down" aria-hidden="true"></i>',
                });
                $(info).slick({
                    slidesToShow: 1,
                    slidesToScroll: 1,
                    asNavFor: nav,
                    focusOnSelect: true,
                    dots: false,
                    arrows: false,
                    asNavFor: nav,
                });
            }
        },
        tfl_tabs_video: function() {
            $('.tfl-video-nav-item').on( 'click', function() {
                var id = $(this).data('id'),
                $container = $(this).closest('.tfl-inner-tabs_videos');
                $container.find('.tfl-nav_videos .tfl-video-nav-item').removeClass('active');
                $container.find('.tfl-panel_video-item').removeClass('active');
                $(this).addClass('active');
                $container.find('.tfl-panels_video #'+id).addClass('active');
            });

            // $('.tfl-inner-acco?rdion .tfl-panel:first-child .tfl-panel-title').click();
        },
        tfl_scroll_btn: function() {
            $('.tfl-inner-scroll_btn .scroll-btn').on( 'click', function() {
                $('body,html').animate({ scrollTop: $(window).scrollTop() + 300 }, 800);
            });
        },
        tfl_video_box: function() {
            if( $().magnificPopup ) {
                $('.tfl-section-video_box a').magnificPopup({
                    disableOn: 700,
                    type: 'iframe',
                    mainClass: 'mfp-fade',
                    removalDelay: 320,
                    preloader: false
                });
                $('.tfl-panels_video a.play-btn').magnificPopup({
                    disableOn: 700,
                    type: 'iframe',
                    mainClass: 'mfp-fade',
                    removalDelay: 320,
                    preloader: false
                });
            }
        },
        tfl_testimonials: function() {
            if( $().slick ) {
                var arr_testimonials = $('.tfl-inner-testimonials');
                arr_testimonials.each( function()  {
                    var $container = $( this );
                    var slidesToShow = $container.data('slidestoshow'),
                    arrows = ($container.data('nav') == 'yes') ? true : false,
                    dots = ($container.data('dots') == 'yes') ? true : false,
                    autoplay = ($container.data('autoplay') == 'yes') ? true : false;
                    $($container).slick({
                        slidesToShow: slidesToShow,
                        infinite: true,
                        arrows: arrows,
                        dots: dots,
                        autoplay: autoplay,
                        autoplaySpeed: 2000,
                        focusOnSelect: true,
                        centerPadding: '30px',
                        infinite: true,
                        useTransform: true,
                        cssEase: 'cubic-bezier(0.77, 0, 0.18, 1)',
                        prevArrow: '<i class="fa fa-arrow-circle-o-left" aria-hidden="true"></i>',
                        nextArrow: '<i class="fa fa-arrow-circle-o-right" aria-hidden="true"></i>',
                        responsive: [
                            {
                              breakpoint: 768,
                              centerPadding: '30px',
                              settings: {
                                arrows: false,
                                slidesToShow: 1
                              }
                            },
                            {
                              breakpoint: 480,
                              centerPadding: '30px',
                              settings: {
                                arrows: false,
                                slidesToShow: 1
                              }
                            }
                        ]
                    });
                });
            };
        },
        tfl_brands: function() {
            if( $().slick ) {
                var arr_brands = $('.tfl-inner-brands');
                arr_brands.each( function()  {
                    var $container = $( this );
                    var slidesToShow = $container.data('cols'),
                    autoplay = ($container.data('autoplay') == 'yes') ? true : false;
                    $($container).slick({
                        slidesToShow: slidesToShow,
                        infinite: true,
                        focusOnSelect: true,
                        centerPadding: '30px',
                        infinite: true,
                        arrows: false,
                        dots: false,
                        autoplay: autoplay,
                        autoplaySpeed: 2000,
                        responsive: [
                            {
                              breakpoint: 992,
                              settings: {
                                arrows: false,
                                slidesToShow: 3
                              }
                            },
                            {
                              breakpoint: 768,
                              settings: {
                                arrows: false,
                                slidesToShow: 2
                              }
                            },
                            {
                              breakpoint: 480,
                              settings: {
                                arrows: false,
                                slidesToShow: 1
                              }
                            }
                        ]
                    });
                });
            };
        },
        tfl_blogs_slider: function() {
            if( $().slick ) {
                var arr_blogs = $('.tfl-inner-blog.has-slider');
                arr_blogs.each( function()  {
                    var $container = $( this );
                    var slidesToShow = $container.data('cols'),
                    nav = ($container.data('nav') == 'yes') ? true : false,
                    dots = ($container.data('dots') == 'yes') ? true : false,
                    autoplay = ($container.data('autoplay') == 'yes') ? true : false;
                    $($container).slick({
                        slidesToShow: slidesToShow,
                        infinite: true,
                        focusOnSelect: true,
                        centerPadding: '30px',
                        infinite: true,
                        arrows: nav,
                        dots: dots,
                        autoplay: autoplay,
                        autoplaySpeed: 2000,
                        responsive: [
                            {
                              breakpoint: 768,
                              settings: {
                                arrows: false,
                                slidesToShow: 2
                              }
                            },
                            {
                              breakpoint: 480,
                              settings: {
                                arrows: false,
                                slidesToShow: 1
                              }
                            }
                        ]
                    });
                });
            };
        },
    }; // end tflThemeShortcodes
    tflThemeShortcodes.init();
})(jQuery);