jQuery(document).ready(function($) {
var animateZoomOut = 'animated zoomOut';
var animateZoomIn = 'animated zoomIn';
var animateFadeIn = 'animated fadeIn';
var animateEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
var roomSelected;
$('.room-styles .room-style').on('click', function() {
console.log('df');
$('.room-style').removeClass('active');
$(this).addClass('active');
roomSelected = $(this).parents('.room-item');
if($('.rooms').hasClass('open')) {
$('.room-item').each(function(index){
if(!$(this).is(roomSelected)) {
$(this).addClass(animateZoomOut).one(animateEnd, function() {
$(this).removeClass(animateZoomOut);
$(this).hide();
});
}
});
$('.btn-choose-room').show();
$('.rooms').removeClass('open');
}
$( "a.manufacturer" ).first().removeClass('active').click();
return false;
});
$('.btn-choose-room').on('click', function() {
$('.room-item').each(function(index){
if(!$(this).is(roomSelected)) {
$(this).show();
$(this).addClass(animateZoomIn).one(animateEnd, function() {
$(this).removeClass(animateZoomIn);
});
}
});
$('.rooms').addClass('open');
$(this).hide();
});
$('a.manufacturer').on('click', function() {
if($(this).hasClass('active')) return false;
var selectedManufacturer = $(this),
showroom = $('.showroom-block');
var roomStyle = $('.room-styles .active').data('roomStyle'),
manufacturer_name = $(this).text();
manufacturer_id = $(this).data('manufacturerId');
$('.collection-item a').tooltipster('hide');
$('.loader').css('display', 'inline');
showroom.css('opacity', '0.2');
$.ajax({
url: '/wp-content/themes/selldom/inc/showroom-ajax.php',
type: 'POST',
dataType: 'html',
data: {
roomStyle: roomStyle,
manufacturer_name: manufacturer_name,
manufacturer_id: manufacturer_id
},
})
.done(function(data) {
$('.loader').hide();
showroom.css('opacity', '1');
$('.collections').html(data);
$('.tooltip').tooltipster({ animation: 'grow', autoClose: false });
showroom.show();
$('.collection-item a').first().click();
showroom.addClass(animateFadeIn).one(animateEnd, function(){
showroom.removeClass(animateFadeIn);
});
});
$('a.manufacturer').removeClass('active');
$(selectedManufacturer).addClass('active');
$('#show-img').css('background', 'none');
if((roomStyle == 'std') || (roomStyle == 'stl') ) {
$('.colorpicker').show();
} else {
$('.colorpicker').hide();
}
return false;
});
$('body').on({
click: function() {
$('.showroom-main-image img').attr('src', $(this).attr('href'));
$('.collection-selected-title').html($(this).data('title'));
$('.collection-selected-more').attr('href', $(this).data('link'));
$('.collection-item a').removeClass('active');
$(this).addClass('active');
$('.collection-item a').tooltipster('hide');
$(this).tooltipster('show');
return false;
},
mouseleave: function() {
if( !$(this).hasClass('active') )
$(this).tooltipster('hide');
return false;
}
}, '.collection-item a');
$( "a.manufacturer" ).first().click();
$(".colorpicker").colorPicker({
onSelect: function(ui, color){
$('#show-img').css('background', color);
}
});
});