$(document).ready(function () {
$('.bottom-right .browse').click(function () {
$('.category-list').slideToggle();
});
$('.desc').readmore({
speed: 75,
collapsedHeight: 105,
moreLink: 'Read more',
lessLink: 'Close'
});
// OWL Carousel
var sync1 = $('#sync1'),
sync2 = $('#sync2'),
duration = 300,
thumbs = 5;
// Sync nav
sync1.on('click', '.owl-next', function () {
sync2.trigger('next.owl.carousel')
});
sync1.on('click', '.owl-prev', function () {
sync2.trigger('prev.owl.carousel')
});
// Start Carousel
sync1.owlCarousel({
// rtl: true,
center: true,
loop: true,
items: 1,
margin: 0,
nav: false
})
.on('dragged.owl.carousel', function (e) {
if (e.relatedTarget.state.direction == 'left') {
sync2.trigger('next.owl.carousel')
} else {
sync2.trigger('prev.owl.carousel')
}
});
sync2.owlCarousel({
// rtl: true,
// loop: true,
items: thumbs,
margin: 20,
nav: true,
navText: ['', ''],
responsive: {
0:{
items:3
},
600:{
items:4
},
1199:{
items:5,
nav: false
}
}
})
.on('click', '.owl-item', function () {
// var i = $(this).index() - (thumbs + 1);
var i = $(this).index();
sync2.trigger('to.owl.carousel', [i, duration, true]);
sync1.trigger('to.owl.carousel', [i, duration, true]);
});
// var sync1 = $("#sync1");
// var sync2 = $("#sync2");
// var duration = 300;
// var thumbs = 4;
//
// sync1.owlCarousel({
// items: 1,
// singleItem: true,
// slideSpeed: 1000,
// // navigation: true,
// pagination: false,
// afterAction: syncPosition,
// responsiveRefreshRate: 200
// });
//
// sync2.owlCarousel({
// items: thumbs,
// pagination: false,
// responsiveRefreshRate: 100,
// margin: 20,
// // navigation: true,
// // navigationText: ['', ''],
// afterInit: function (el) {
// el.find(".owl-item").eq(0).addClass("synced");
// }
// })
// .on("click", ".owl-item", function (e) {
// e.preventDefault();
// var number = $(this).data('owlItem');
// sync1.trigger("owl.goTo", number);
// });
//
// function syncPosition(el) {
// var current = this.currentItem;
// $("#sync2")
// .find(".owl-item")
// .removeClass("synced")
// .eq(current)
// .addClass("synced")
// if ($("#sync2").data("owlCarousel") !== undefined) {
// center(current)
// }
// }
//
// function center(number) {
// var sync2visible = sync2.data("owlCarousel").owl.visibleItems;
// 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)
// }
// }
// End of Owl Carousel
$('.mobile-search').click(function(e) {
e.preventDefault();
$('#body-wrapper').removeClass('left');
$('#mobile-menu-wrapper').removeClass('left');
$('#search').slideToggle();
$('.overlay').removeClass('show');
$('.menu-text').text('MENU');
$('.menu-toggle i').removeClass('fa-times').addClass('fa-bars');
});
$('.menu-toggle').click(function (e) {
if (($('.menu-text').text()) == 'MENU') {
$('.menu-text').text('CLOSE');
$('.menu-toggle i').removeClass('fa-bars').addClass('fa-times');
$('html, body').addClass('overf');
} else if (($('.menu-text').text()) == 'CLOSE') {
$('.menu-text').text('MENU');
$('.menu-toggle i').removeClass('fa-times').addClass('fa-bars');
$('html, body').removeClass('overf');
}
e.preventDefault();
$('#body-wrapper').toggleClass('left');
$('#mobile-menu-wrapper').toggleClass('left');
$('.overlay').toggleClass('show');
$('#search').hide();
});
$('.overlay').click(function(e) {
$('#body-wrapper').removeClass('left');
$('#mobile-menu-wrapper').removeClass('left');
$(this).removeClass('show');
$('#search').hide();
$('.menu-text').text('MENU');
$('.menu-toggle i').removeClass('fa-times').addClass('fa-bars');
$('html, body').removeClass('overf');
});
$('.dropdown').click(function(e) {
e.preventDefault();
$(this).parent().toggleClass('active');
$(this).parent().find('ul').slideToggle();
});
$('#messageStack li img').click(function(e) {
$(this).parent().fadeOut();
});
var maxHeight = -1;
$('.category .sub-category .bottom h2').each(function() {
maxHeight = maxHeight > $(this).height() ? maxHeight : $(this).height();
});
$('.category .sub-category .bottom h2').each(function() {
$(this).height(maxHeight);
});
// lazyload images
$("img.lazy").lazyload({
effect: "fadeIn",
threshold: 200,
placeholder: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUSEhzULWZYAAAACklEQVR42mNgAAAAAgAB5Sfe/AAAAABJRU5ErkJggg=="
});
})
function selectChangeUrl(obj) {
var url = obj.options[obj.selectedIndex].getAttribute('data-url');
window.location = url;
}