(function ($) { "use strict"; if (!$.apusThemeExtensions) $.apusThemeExtensions = {}; function ApusThemeCore() { var self = this; // self.init(); }; ApusThemeCore.prototype = { /** * Initialize */ init: function() { var self = this; self.preloadSite(); // slick init self.initSlick($("[data-carousel=slick]")); // Unveil init setTimeout(function(){ self.layzyLoadImage(); }, 200); // isoto self.initIsotope(); // Sticky Header self.initHeaderSticky('main-sticky-header'); if ( $('#main-container .layout-type-half-map').length <= 0 ) { self.initHeaderSticky('header-mobile'); } // back to top self.backToTop(); // popup image self.popupImage(); $('[data-toggle="tooltip"]').tooltip(); self.initMobileMenu(); self.mainMenuInit(); self.dashboardMenu(); $(window).resize(function(){ setTimeout(function(){ self.dashboardMenu(); }, 50); }); self.advanceFilter(); $('.more').on('click', function(){ $('.wrapper-morelink').toggleClass('active'); }); $(document.body).on('click', '.nav [data-toggle="dropdown"]' ,function(){ if ( this.href && this.href != '#'){ window.location.href = this.href; } }); self.loadExtension(); }, /** * Extensions: Load scripts */ loadExtension: function() { var self = this; if ($.apusThemeExtensions.shop) { $.apusThemeExtensions.shop.call(self); } if ($.apusThemeExtensions.job_map) { $.apusThemeExtensions.job_map.call(self); } if ($.apusThemeExtensions.job) { $.apusThemeExtensions.job.call(self); } }, initSlick: function(element) { var self = this; element.each( function(){ var config = { infinite: false, arrows: $(this).data( 'nav' ), dots: $(this).data( 'pagination' ), slidesToShow: 4, slidesToScroll: 4, prevArrow:"", nextArrow:"", }; var slick = $(this); if( $(this).data('items') ){ config.slidesToShow = $(this).data( 'items' ); config.slidesToScroll = $(this).data( 'items' ); } if( $(this).data('infinite') ){ config.infinite = true; } if( $(this).data('autoplay') ){ config.autoplay = true; config.autoplaySpeed = 1500; config.pauseOnHover = true; } if( $(this).data('disable_draggable') ){ config.touchMove = false; config.draggable = false; config.swipe = false; config.swipeToSlide = false; } if( $(this).data('centermode') ){ config.centerMode = true; } if( $(this).data('centerpadding') ){ config.centerPadding = $(this).data('centerpadding');; } if( $(this).data('vertical') ){ config.vertical = true; } if( $(this).data('rows') ){ config.rows = $(this).data( 'rows' ); } if( $(this).data('asnavfor') ){ config.asNavFor = $(this).data( 'asnavfor' ); } if( $(this).data('slidestoscroll') ){ config.slidesToScroll = $(this).data( 'slidestoscroll' ); } if( $(this).data('focusonselect') ){ config.focusOnSelect = $(this).data( 'focusonselect' ); } if ($(this).data('large')) { var desktop = $(this).data('large'); } else { var desktop = config.items; } if ($(this).data('smalldesktop')) { var smalldesktop = $(this).data('smalldesktop'); } else { if ($(this).data('large')) { var smalldesktop = $(this).data('large'); } else{ var smalldesktop = config.items; } } if ($(this).data('medium')) { var medium = $(this).data('medium'); } else { var medium = config.items; } if ($(this).data('smallmedium')) { var smallmedium = $(this).data('smallmedium'); } else { var smallmedium = 2; } if ($(this).data('extrasmall')) { var extrasmall = $(this).data('extrasmall'); } else { var extrasmall = 2; } if ($(this).data('smallest')) { var smallest = $(this).data('smallest'); } else { var smallest = 1; } if ($(this).data('slidestoscroll_large')) { var slidestoscroll_desktop = $(this).data('slidestoscroll_large'); } else { var slidestoscroll_desktop = config.slidesToScroll; } if ($(this).data('slidestoscroll_smalldesktop')) { var slidestoscroll_smalldesktop = $(this).data('slidestoscroll_smalldesktop'); } else { if ($(this).data('slidestoscroll_large')) { var slidestoscroll_smalldesktop = $(this).data('slidestoscroll_large'); } else{ var slidestoscroll_smalldesktop = config.items; } } if ($(this).data('slidestoscroll_medium')) { var slidestoscroll_medium = $(this).data('slidestoscroll_medium'); } else { var slidestoscroll_medium = config.items; } if ($(this).data('slidestoscroll_smallmedium')) { var slidestoscroll_smallmedium = $(this).data('slidestoscroll_smallmedium'); } else { var slidestoscroll_smallmedium = smallmedium; } if ($(this).data('slidestoscroll_extrasmall')) { var slidestoscroll_extrasmall = $(this).data('slidestoscroll_extrasmall'); } else { var slidestoscroll_extrasmall = extrasmall; } if ($(this).data('slidestoscroll_smallest')) { var slidestoscroll_smallest = $(this).data('slidestoscroll_smallest'); } else { var slidestoscroll_smallest = smallest; } config.responsive = [ { breakpoint: 321, settings: { slidesToShow: smallest, slidesToScroll: slidestoscroll_smallest, } }, { breakpoint: 480, settings: { slidesToShow: extrasmall, slidesToScroll: slidestoscroll_extrasmall, } }, { breakpoint: 769, settings: { slidesToShow: smallmedium, slidesToScroll: slidestoscroll_smallmedium } }, { breakpoint: 981, settings: { slidesToShow: medium, slidesToScroll: slidestoscroll_medium } }, { breakpoint: 1200, settings: { slidesToShow: smalldesktop, slidesToScroll: slidestoscroll_smalldesktop } }, { breakpoint: 1501, settings: { slidesToShow: desktop, slidesToScroll: slidestoscroll_desktop } } ]; if ( $('html').attr('dir') == 'rtl' ) { config.rtl = true; } $(this).slick( config ); } ); // Fix slick in bootstrap tabs $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { var target = $(e.target).attr("href"); var $slick = $("[data-carousel=slick]", target); if ($slick.length > 0 && $slick.hasClass('slick-initialized')) { $slick.slick('refresh'); } self.layzyLoadImage(); }); }, layzyLoadImage: function() { $(window).off('scroll.unveil resize.unveil lookup.unveil'); var $images = $('.image-wrapper:not(.image-loaded) .unveil-image'); // Get un-loaded images only if ($images.length) { $images.unveil(1, function() { $(this).load(function() { $(this).parents('.image-wrapper').first().addClass('image-loaded'); $(this).removeAttr('data-src'); $(this).removeAttr('data-srcset'); $(this).removeAttr('data-sizes'); }); }); } var $images = $('.product-image:not(.image-loaded) .unveil-image'); // Get un-loaded images only if ($images.length) { $images.unveil(1, function() { $(this).load(function() { $(this).parents('.product-image').first().addClass('image-loaded'); }); }); } }, initIsotope: function() { $('.isotope-items').each(function(){ var $container = $(this); $container.imagesLoaded( function(){ $container.isotope({ itemSelector : '.isotope-item', transformsEnabled: true, // Important for videos masonry: { columnWidth: $container.data('columnwidth') } }); }); }); /*---------------------------------------------- * Apply Filter *----------------------------------------------*/ $('.isotope-filter li a').on('click', function(){ var parentul = $(this).parents('ul.isotope-filter').data('related-grid'); $(this).parents('ul.isotope-filter').find('li a').removeClass('active'); $(this).addClass('active'); var selector = $(this).attr('data-filter'); $('#'+parentul).isotope({ filter: selector }, function(){ }); return(false); }); }, initHeaderSticky: function(main_sticky_class) { if ( $('.' + main_sticky_class).length ) { if ( typeof Waypoint !== 'undefined' ) { if ( $('.' + main_sticky_class) && typeof Waypoint.Sticky !== 'undefined' ) { var sticky = new Waypoint.Sticky({ element: $('.' + main_sticky_class)[0], wrapper: '