{namespace owl=Comsolit\OwlSlider\ViewHelpers} window.onload = function() { var sliderId = '{settings.slider_id}'; var anchorElements = document .getElementById(sliderId ? 'sync2_' + sliderId : 'sync2') .getElementsByTagName('a'); for (var i in anchorElements) { anchorElements[i].onclick = function() { if(this.target === '') { window.open(this.href, '_self', false); } else { window.open(this.href, this.target); } } } } jQuery(document).ready(function() { var sliderId = '{settings.slider_id}'; var sync1 = sliderId ? jQuery('#sync1_' + sliderId) : jQuery('#sync1'); var sync2 = sliderId ? jQuery('#sync2_' + sliderId) : jQuery('#sync2'); sync1.owlCarousel({ items: 1, itemsDesktop: false, itemsDesktopSmall: false, itemsTablet: false, itemsTabletSmall: false, itemsMobile: false, itemsCustom: false, singleItem: true, transitionStyle: , afterAction: syncPosition, responsiveRefreshRate: , }); sync2.owlCarousel({ items: , itemsDesktop: , itemsDesktopSmall: , itemsTablet: , itemsTabletSmall: , itemsMobile: , itemsCustom: , singleItem: , beforeInit: ? random(sync2) : '', transitionStyle: false, afterInit: function(el) { el.find('.owl-item').eq(0).addClass('synced'); } }); //Sort random function function random(owlSelector){ owlSelector.children().sort(function(){ return Math.round(Math.random()) - 0.5; }).each(function(){ $(this).appendTo(owlSelector); }); } function syncPosition(el) { var current = this.currentItem; sync2 .find('.owl-item') .removeClass('synced') .eq(current) .addClass('synced'); if(sync2.data('owlCarousel') !== undefined) { center(current) } } sync2.on('click', '.owl-item', function(e) { e.preventDefault(); var number = jQuery(this).data('owlItem'); sync1.trigger('owl.goTo',number); }); function center(number) { var sync2visible = sync2.data('owlCarousel').owl.userItems; var num = number; var found = false; for(var i in sync2visible) { if(num === sync2visible[i]) { var found = true; } } if(found === false) { if(num > sync2visible[sync2visible.length - 1]) { sync2.trigger('owl.goTo', num - sync2visible.length + 2) } else { if(num - 1 === -1) { num = 0; } sync2.trigger('owl.goTo', num); } } else if(num === sync2visible[sync2visible.length - 1]) { sync2.trigger('owl.goTo', sync2visible[1]) } else if(num === sync2visible[0]) { sync2.trigger('owl.goTo', num - 1) } } });