$(function () { { // показываем блок "Подробнее" для SEO $('.mainSelect .more').click(function () { $('#more_popup').show(); return false; }); $('#more_popup .close').click(function () { $('#more_popup').hide(); return false; }); } $('#collectionSelectNew').change(function () { document.location.href = _current_url + $(this).val() + '.html'; }); $('#collectionSelectMebel').change(function () { var tempVal = $(this).val(); tempVal = tempVal.replace(/-/g, " "); document.location.href = _current_url + '?action=view&collection=' + tempVal; }); $('.mainSelect').appendTo($('body')); { // скроллер на главной странице $('.catalogueScroll').smoothDivScroll({ visibleHotSpots: "always", autoScroll: 'always', autoScrollDirection: "endlessloopright", autoScrollStep: 1, autoScrollInterval: 50 }); $('.catalogueScroll').hover(function () { $(this).smoothDivScroll("stopAutoScroll"); return false; }, function () { $(this).smoothDivScroll("startAutoScroll"); }); $('.scrollingLeft').hover(function () { $('.catalogueScroll') .smoothDivScroll('setOption', { autoScrollDirection: 'endlessloopleft', autoScrollStep: 5, autoScrollInterval: 10 }) .smoothDivScroll("startAutoScroll"); return false; }, function () { $('.catalogueScroll') .smoothDivScroll('setOption', { autoScrollDirection: 'endlessloopright', autoScrollStep: 1, autoScrollInterval: 50 }) .smoothDivScroll("stopAutoScroll"); }); $('.scrollingRight').hover(function () { $('.catalogueScroll') .smoothDivScroll('setOption', { autoScrollStep: 5, autoScrollInterval: 10 }) .smoothDivScroll("startAutoScroll"); return false; }, function () { $('.catalogueScroll') .smoothDivScroll('setOption', { autoScrollStep: 1, autoScrollInterval: 50 }) .smoothDivScroll("stopAutoScroll"); }); } { // фильтр var _ajaxSelectTimer = null; $('.foot .btn').click(function () { var _form = $(this).parents('form');; $('input[name=action]', _form).val('view'); _form.submit(); return false; }); /* считаем количество коллекций */ var ajaxCountCollections = function () { $('.mainSelect').addClass('ajaxSelect'); var _form = $('.mainSelect form'); $('input[name=action]', _form).val('ajaxCountCollections'); $.get(_form.attr('action'), _form.serialize(), function (data) { $('.selectResultCount').html(data); $('.mainSelect').removeClass('ajaxSelect'); if (parseInt(data) > 0) { $('.foot .btn').removeClass('inert'); } else { $('.foot .btn').addClass('inert'); } }); } var filterCheckboxClick = function (ckeckbox) { clearTimeout(_ajaxSelectTimer); var _this = ckeckbox, _parent = $(_this).parents('li'), _name = $(_this).attr('name').replace('[', '_').replace(']', ''); if ($(_this).is(':checked')) { $('.checked_items', _parent).append('' + $(_this).attr('rel') + ''); $('.' + _name).click(function () { _this.click(); }); } else { $('.' + _name, _parent).remove(); } if ( $('.mainSelectList input:checked').length ){ $('.selectBtns .clear_btn').show(); } else { $('.selectBtns .clear_btn').hide(); } _ajaxSelectTimer = setTimeout(ajaxCountCollections, 300); } $('.mainSelect input').click(function () { filterCheckboxClick(this); }); $('.mainSelect input:checked').each(function () { filterCheckboxClick(this); }); $('.selectBtns .clear_btn').click(function () { $('.checked_items .checked').each( function() { _this = $(this); _this.click(); }); if ( $('input[name="is_new"]:checked').length ) { _this = $('input[name="is_new"]:checked'); _this.click(); filterCheckboxClick(_this); } return false; }); } var _initVerticalCatalogPreview = function () { if ($('.jcarousel-skin-bg LI').length > 4) { $('.jcarousel-skin-bg').jcarousel({scroll: 1, vertical: true}); } $('.jcarousel-skin-bg A').click(function () { if ( !($(this).parent().hasClass('current')) ) { $('.photoIn').removeClass('show'); $(this).parent().addClass('current').siblings().removeClass('current'); $('.photoIn IMG').remove(); $('.photoIn').append(''); $('.photoIn').imagesLoaded( function() { //console.log('imagesLoaded'); $('.photoIn').addClass('show'); if (mobile === false) { $('.photoIn').sliding_background({ width: $('.photoIn IMG').width(), height: $('.photoIn IMG').height() }); } }); return false; } }); } _initVerticalCatalogPreview(); $('.photoIn').imagesLoaded( function() { $('.jcarousel-skin-bg').addClass('show'); $('.photoIn').addClass('show'); if (mobile === false) { $('.photoIn').sliding_background({ width: $('.photoIn IMG').width(), height: $('.photoIn IMG').height() }); } }); var _carouselDescription = null, _carouselWorks = null; $('.jcarousel-skin-works').jcarousel({ scroll: 3, start: $('.jcarousel-skin-works LI').index($('.jcarousel-skin-works LI.current')) + 1, initCallback: function (carousel) { _carouselWorks = carousel; } }) $('.jcarousel-skin-description').jcarousel({ scroll: 1, start: $('.jcarousel-skin-description LI').index($('.jcarousel-skin-description LI.current')) + 1, initCallback: function (carousel) { _carouselDescription = carousel; } }) $('.jcarousel-skin-description .slider>span').click(function(){ if($(this).parent().prev('.info').is(':visible')){ $(this).parent().prev('.info').slideUp(200); $(this).html('О коллекции'); }else{ $(this).parent().prev('.info').slideDown(200); $(this).html('Свернуть'); } }) { // $('.jcarousel-skin-works A').click(function () { historyPage.GoTo($(this).attr('href'), 'catalog'); return false; }) historyPage.addCallBack(function (url) { var _parentCatalogLi = $('.jcarousel-skin-works a[href="' + url + '"]').parents('LI:first'), position = $('.jcarousel-skin-works LI').index(_parentCatalogLi); $.get(_current_url + url, {'action' : 'getCollectionData'}, function (object) { //alert('d') $('.jcarousel-skin-works LI.current').removeClass('current'); _parentCatalogLi.addClass('current'); $('.photoIn').removeClass('show'); $('.photoIn IMG').remove(); $('.photoIn').append(''); $('.photoIn').imagesLoaded( function() { //console.log('imagesLoaded'); $('.photoIn').addClass('show'); $('.photoIn').sliding_background({ width: $('.photoIn IMG').width(), height: $('.photoIn IMG').height() }); $('.jcarousel-skin-bg').replaceWith(''); if (object.images.length > 1) { for(var i = 0, length = object.images.length; i < length; i++) { $('.jcarousel-skin-bg').append('
  • ') } } // перелистываем описание на текущий пункт if (object.description) { var _current = $('.jcarousel-skin-description .jcarousel-item-' + (position + 1)); $('.info', _current).html(object.description); $('.slider', _current).show(); } _carouselDescription.scroll(position + 1, 1000); _carouselWorks.scroll(position - 2, 1000); /* var _posDescription = $('.jcarousel-skin-description .jcarousel-item-' + (position + 1)).position().left; _carouselDescription.animate(-_posDescription, 1000); var _posWorks = _carouselWorks.pos(position); _carouselWorks.animate(_posWorks, 1000); */ _initVerticalCatalogPreview(); $('.jcarousel-skin-bg').addClass('show'); }) }, 'json'); }, 'catalog'); var hash_temp = location.toString().split('#'); if ( hash_temp[1] ) { historyPage.GoTo(hash_temp[1], 'catalog'); } } }); (function($) { $.fn.sliding_background = function(options){ var config = $.extend({ width: 0, height: 0 }, options || {}); var $window = $(window); var $background = this; var $image = $background.find('img'); var moving = false; var start= 0; var cur = 0; var wc = 0; var hc = 0; var c = 0; var scroll = null; var max_x = 0; var max_y = 0; var win_width = 0; var win_height = 0; var automoving = false; var shift = 0; var reflow = function() { win_width = $window.width(); win_height = $window.height(); wc = win_width / config.width; hc = win_height / config.height; c = wc > hc ? wc : hc; scroll = wc > hc ? 'v' : wc == hc ? null : 'h'; max_x = -(config.width * c - win_width); max_y = -(config.height * c - win_height); $image.width(config.width * c); $image.height(config.height * c); $background.move(); }; this.move = function(e){ if (scroll == 'h') { if (e) shift = e.pageX - start + cur; shift = shift > 0 ? 0 : shift < max_x ? max_x : shift; $image.css('top', 0); $image.css('left', shift); } if (scroll == 'v') { if (e) shift = e.pageY - start + cur; shift = shift > 0 ? 0 : shift < max_y ? max_y : shift; $image.css('left', 0); $image.css('top', shift); } }; this.automove = function(e){ if (!automoving && !moving) { var px = e.pageX / win_width; var py = e.pageY / win_height; if (scroll == 'h') { shift = Math.round(max_x * px); $image.css('top', 0); $image.stop(true, false).animate({"left": shift}, { duration: 600, easing: 'easeOutExpo' }); } if (scroll == 'v') { shift = Math.round(max_y * py); $image.css('left', 0); $image.stop(true, false).animate({"top": shift}, { duration: 600, easing: 'easeOutExpo' }); } automoving = true; setTimeout(function(){ automoving = false }, 10); } }; $(document).mouseup(function(e){ moving = false; $background.automove(e); //return false; }); $(document).mousemove(function(e){ if (moving) { $background.move(e); } else { $background.automove(e); } }); reflow(); this.show(); $(window).resize(reflow); }; })(jQuery);