$(function() { //*****************************************************************// //1. Слайдер для топа //*****************************************************************// var sliderzAllElement = $("#sliderzTop .content .element").size(); //Узнаем количетсов элементов в слайдере var sliderzNowPosition = 1; //Текущяя позиция слайдера var sliderzAppendContent; //HTML-Контент с дотами var sliderzAutoPlay = 1; //1-играть, 0-пауза $('#sliderzTop .element').hide(); //Скрываем все элементы $('#sliderzTop .element:eq(0)').fadeIn(1800); //Показываем анимационно 1-вый div //$('.bgoto').live('click', function() { $('#sliderzTop .bgoto').live('click', function() { //Позиция к которой прокрутить слайдер var gotox = $(this).attr('slidenum'); sliderzNowPosition = gotox - 1; //Скрываем все элементы $('#sliderzTop .element').hide(); //Вычесляем что показать if (sliderzNowPosition >= sliderzAllElement) sliderzNowPosition = 1; else sliderzNowPosition ++; //Показываем анимационно нужный div $('#sliderzTop .element:eq('+(sliderzNowPosition - 1)+')').fadeIn(1000); //Выделяем нужный дот $('#sliderzTop .navelement a').removeClass('act'); //удаляем все активне классы $('#sliderzTop .navelement a:eq('+(sliderzNowPosition - 1)+')').addClass('act'); }); //Создаем список дотов ul li contentAppendSliderz = '
'; $("#sliderzTop").append(contentAppendSliderz); //Автопрокрутка var refreshId = setInterval(function(){ if (sliderzAutoPlay == 0) return false; //Скрываем все элементы $('#sliderzTop .element').hide(); //Вычесляем что показать if (sliderzNowPosition >= sliderzAllElement) sliderzNowPosition = 1; else sliderzNowPosition ++; //Показываем анимационно нужный div $('#sliderzTop .element:eq('+(sliderzNowPosition - 1)+')').fadeIn(1000); //Выделяем нужный дот $('#sliderzTop .navelement a').removeClass('act'); //удаляем все активне классы $('#sliderzTop .navelement a:eq('+(sliderzNowPosition - 1)+')').addClass('act'); }, 7200); //Приостановка таймера $('#sliderzTop').hover(function(){ sliderzAutoPlay = 0; /* пауза */ }, function(){ sliderzAutoPlay = 1; /* играть */ }); //*****************************************************************// //2. Слайдер для подвала //*****************************************************************// var sliderzAllElementBottom = $("#sliderzBottom .content .element").size(); //Узнаем количетсов элементов в слайдере var sliderzNowPositionBottom = 1; //Текущяя позиция слайдера var sliderzAutoPlayBottom = 1; //1-играть, 0-пауза $('#sliderzBottom .content').hide(); //Скрываем контейнер со слайдами $('#sliderzBottom .content').fadeIn(720); //Скрываем контейнер Показываем анимационно 1-вый div //Включение, выключение кнопок (act,noact) sliderzButtonEnabledDisabled(); $("#sliderzBottom .bredo").show(1); $("#sliderzBottom .bredo").click(function(){ /* Анимация кнопки (начало) */ /* $( "#sliderzBottom .bredo" ).animate({ left: "22px" }, 100 ) .animate({ left: "34px" }, 100 ) .animate({ left: "30px" }, 100 ) */ //Скрываем все элементы //$('#sliderzBottom .element').hide(); //Вычесляем что показать (для autoplay) if (sliderzNowPositionBottom <= 1) sliderzNowPositionBottom = 1; else sliderzNowPositionBottom --; //Включение, выключение кнопок (act,noact) sliderzButtonEnabledDisabled(); //Смещяем контейнер $( "#sliderzBottom .content" ).animate({ scrollLeft: "-=1006"}, 300); }); $("#sliderzBottom .bnext").show(1); $("#sliderzBottom .bnext").click(function(){ /* Анимация кнопки */ /* $( "#sliderzBottom .bnext" ).animate({ right: "22px" }, 100 ) .animate({ right: "34px" }, 100 ) .animate({ right: "30px" }, 100 ) */ //Скрываем все элементы //$('#sliderzBottom .element').hide(); //Вычесляем что показать (для autoplay) if (sliderzNowPositionBottom >= sliderzAllElementBottom) sliderzNowPositionBottom = sliderzAllElementBottom; else sliderzNowPositionBottom ++; //Включение, выключение кнопок (act,noact) sliderzButtonEnabledDisabled(); //Смещяем контейнер $( "#sliderzBottom .content" ).animate({ scrollLeft: "+=1006"}, 300); }); //Автопрокрутка /* var refreshId = setInterval(function(){ if (sliderzAutoPlayBottom == 0) return false; //Скрываем все элементы $('#sliderzBottom .element').hide(); //Вычесляем что показать if (sliderzNowPositionBottom >= sliderzAllElementBottom) sliderzNowPositionBottom = 1; else sliderzNowPositionBottom ++; //Показываем анимационно нужный div $('#sliderzBottom .element:eq('+(sliderzNowPositionBottom - 1)+')').fadeIn(1000); //Выделяем нужный дот $('#sliderzBottom .navelement a').removeClass('act'); //удаляем все активне классы $('#sliderzBottom .navelement a:eq('+(sliderzNowPositionBottom - 1)+')').addClass('act'); }, 5400); */ //Приостановка таймера //$('#sliderzBottom').hover(function(){ sliderzAutoPlayBottom = 0; /* пауза */ }, //function(){ sliderzAutoPlayBottom = 1; /* играть */ }); // Функция включения (активна, не активна), выключени кнопок function sliderzButtonEnabledDisabled(){ //alert(sliderzAllElementBottom + "/" + sliderzNowPositionBottom); // Условие выключения кнопки (предыдущее) if (sliderzNowPositionBottom <= 1) $("#sliderzBottom .bredo").addClass("bdisabled"); // alert('Выключаем Redo'); else $("#sliderzBottom .bredo").removeClass("bdisabled"); // Условие выключения кнопки (далее)... if (sliderzNowPositionBottom >= sliderzAllElementBottom) $("#sliderzBottom .bnext").addClass("bdisabled"); // alert('Выключаем Next'); else $("#sliderzBottom .bnext").removeClass("bdisabled"); } //*****************************************************************// //3. Делаем возможность клика по любой части баннера-ссылки // что бы не ломать верстку, сделали на JS //*****************************************************************// $('div.banner-links-element').live('click', function() { var hrefFromLink = $(this).find("a").attr("href"); window.location.href = hrefFromLink; }); //*****************************************************************// //4. Переключатели табов на карточке товара (детальная страница) //*****************************************************************// $('#content div.content-catalog-detail-tab').live('click', function() { var indexThisElement = $(this).index(); $('#content div.content-catalog-detail-tab').removeClass("act"); $('#content div.content-catalog-detail-box').hide(); $('#content div.content-catalog-detail-box').eq( indexThisElement ).show(); $(this).addClass("act"); }); $('#popup div.content-catalog-detail-tab').live('click', function() { var indexThisElement = $(this).index(); $('#popup div.content-catalog-detail-tab').removeClass("act"); $('#popup div.content-catalog-detail-box').hide(); $('#popup div.content-catalog-detail-box').eq( indexThisElement ).show(); $(this).addClass("act"); }); //*****************************************************************// //5. Скроллинг (для детальной карточки товара) - рядом с фильтром // Также данному контейнеру устанавливаем max-height // вариант 1) по высоте карточки товара // вариант 2) по высоте фильтра, если он больше карточки товара //*****************************************************************// $(window).load(function(){ // Значения высот var heightDetailProduct = $("div.content-catalog-list-column-right-box-left-element.ForjQueryDocumentReady").height()-40; var heightFilterAccessories = $("div.content-catalog-detail-column-right.ForjQueryDocumentReady").height()-40; // Выбираем наибольшую высоту var heightMax = Math.max(heightDetailProduct, heightFilterAccessories); var docHeight = $("#content").height(); $("div.scrollbar.content-catalog-accessories-wrap").css("max-height", docHeight); if($('.content-catalog-detail-column-right').css('display')== 'block'){ $(".content-catalog-filter ").css("height", docHeight); $(".content-catalog-detail-wrap").css('padding-bottom','0'); } // в) Запускаем скроллинг $("div.scrollbar.content-catalog-accessories-wrap").mCustomScrollbar({ scrollButtons:{ // запретить кнопки enable:false, set_height:true, }, callbacks: { whileScrolling: function() { var posTop = $('.mCSB_dragger').position().top + $('.mCSB_dragger').height(); var total = $('.mCSB_draggerContainer').height() - 100; if (posTop >= total && !window.load) { window.load = true; if (window.nextPage) { $.ajax({ url: window.nextPage + '&ajax=accessories', success: function(body) { window.load = false; $('.content-catalog-accessories').append(body); $("div.scrollbar.content-catalog-accessories-wrap").mCustomScrollbar('update'); } }); } } } } }); }); //*****************************************************************// //6. Работа с вслывающим window-fixed // (закрыть его по щелчку вне области окна) // (при щелчке на новом элементе, мы предварительно скрываем все окна) //*****************************************************************// // Div по центру экрана $.fn.alignCenterScreen = function() { this.css("position", "absolute"); this.css("top", ($(window).height() - this.outerHeight()) / 2); // + $(document).scrollTop() + "px" this.css("left", ($(window).width() - this.outerWidth()) / 2); // + $(document).scrollLeft() + "px" return this }; // Открыть окно $('a.fixed-window-dialog-open').live('click', function(){ var dataValueAjaxId = $(this).attr("data-ajax-id"); alert(dataValueAjaxId); BX.ajax.insertToNode('/index.php?edit=Y&bxajaxid=' + dataValueAjaxId, 'comp_' + dataValueAjaxId); return false; /* var dataValueAjaxId = $(this).attr("data-ajax-id"); $.ajax({ url: "/index.php?edit=Y&bxajaxid=" + dataValueAjaxId, cache: false, success: function(html){ $("body").append(html); var userWindowWidth = $( "html" ).width(); var userWindowHeight = $( "html" ).height(); $("div.fixed-window-content").css("max-wdith", (userWindowWidth-200)+'px'); $("div.fixed-window-content").css("max-height", (userWindowHeight-200)+'px'); $("div.fixed-window").alignCenterScreen(); $("div.fixed-window").fadeIn("fast"); } }); */ }); // Изменяем размеры диалога при изменении размеров окна $(window).resize(function() { var userWindowWidth = $( "html" ).width(); var userWindowHeight = $( "html" ).height(); $("div.fixed-window-content").css("max-wdith", (userWindowWidth-200)+'px'); $("div.fixed-window-content").css("max-height", (userWindowHeight-200)+'px'); $("div.fixed-window").alignCenterScreen(); }); // Закрыть окно при клике вне онка $(document).click( function(event){ if( $(event.target).closest("div.fixed-window-container").length ) return; $("div.fixed-window-wrap").fadeOut(150, function(){ $( "div.fixed-window-black-opacity" ).remove(); $( "div.fixed-window-wrap" ).remove(); }); event.stopPropagation(); }); //Закрыть окно (иконка) $("div.fixed-window-close").live('click', function() { $("div.fixed-window-wrap").fadeOut(150, function(){ $( "div.fixed-window-black-opacity" ).remove(); $( "div.fixed-window-wrap" ).remove(); }); }); });