File: /home/u547966/brikov.ru/www/wp-content/themes/brikov/assets/js/jquery.main.js
$(document).ready(function(){
initMainGallery();
initPhotos();
$('.gallery-photo').galleryScroll();
$('.gallery-container').fadeGallery();
initPortfolio();
intervalID = setInterval(autoScrollGallery, 3000);
$('.gallery-holder .gallery li').mouseleave(function(){intervalID = setInterval(autoScrollGallery, 3000);});
$('.gallery-holder .gallery li').mouseover(function(){clearInterval(intervalID);});
jQuery.easing.def = "easeOutExpo";
});
$(document).ready(function() {
$('#menu-menuport span .menu-image-title').removeClass('menu-image-title');
$('#menu-menuport span').addClass('info');
});
function initPortfolio(){
$('.text-container-holder03 .holder li').each(function(){
$(this).find('img').addClass('grey');
//$(this).find('a').append('<img src="' + $(this).find('.grey').attr('src') + '" alt="" width="189" height="378" class="color" />');
});
$('.text-container-holder03 .holder li').mouseenter(function(event){
var _h = $(this).find('.info').outerHeight();
$(this).find('.color').stop().animate({'opacity':1}, 400, function(){
$(this).parents('li').find('.info').stop().animate({'margin-top':-_h}, 300);
});
});
$('.text-container-holder03 .holder li').mouseleave(function(event){
$(this).find('.color').stop().animate({'opacity':0}, 400, function(){
$(this).parents('li').find('.info').stop().animate({'margin-top':0}, 300);
});
});
$(window).scroll(function(){
if ($(window).scrollTop() > 168){
if (!$('.nav-box').hasClass('sticky')) {
$('.top').fadeIn(400);
$('.nav-box').addClass('sticky');
$('#nav a').css('width', 'auto');
}
} else {
if ($('.nav-box').hasClass('sticky')) {
$('.top').fadeOut(400);
$('.nav-box').removeClass('sticky');
$('#nav a').css('width', 'auto');
}
}
});
}
jQuery.fn.galleryScroll = function(_options){
// defaults options
var _options = jQuery.extend({
btPrev: 'http://brikov.ru/templates/default/js/a.prev',
btNext: 'http://brikov.ru/templates/default/js/a.next',
holderList: 'div.gallery',
scrollElParent: 'ul',
scrollEl: 'li',
slideNum: '.switcher',
duration : 1000,
step: 1,
circleSlide: true,
disableClass: 'disable',
funcOnclick: null,
autoSlide: false,
innerMargin:0,
stepWidth:false
},_options);
return this.each(function(){
var _this = jQuery(this);
var _holderBlock = jQuery(_options.holderList,_this);
var _gWidth = _holderBlock.width();
var _animatedBlock = jQuery(_options.scrollElParent,_holderBlock);
var _liWidth = jQuery(_options.scrollEl,_animatedBlock).outerWidth(true);
var _liSum = jQuery(_options.scrollEl,_animatedBlock).length * _liWidth;
var _margin = -_options.innerMargin;
var f = 0;
var _step = 0;
var _autoSlide = _options.autoSlide;
var _timerSlide = null;
if (!_options.step) _step = _gWidth; else _step = _options.step*_liWidth;
if (_options.stepWidth) _step = _options.stepWidth;
if (!_options.circleSlide) {
if (_options.innerMargin == _margin)
jQuery(_options.btPrev,_this).addClass('prev-'+_options.disableClass);
}
if (_options.slideNum && !_options.step) {
var _lastSection = 0;
var _sectionWidth = 0;
while(_sectionWidth < _liSum)
{
_sectionWidth = _sectionWidth + _gWidth;
if(_sectionWidth > _liSum) {
_lastSection = _sectionWidth - _liSum;
}
}
}
if (_autoSlide) {
_timerSlide = setTimeout(function(){
autoSlide(_autoSlide);
}, _autoSlide);
_animatedBlock.hover(function(){
clearTimeout(_timerSlide);
}, function(){
_timerSlide = setTimeout(function(){
autoSlide(_autoSlide)
}, _autoSlide);
});
}
// click button 'Next'
jQuery(_options.btNext,_this).bind('click',function(){
jQuery(_options.btPrev,_this).removeClass('prev-'+_options.disableClass);
if (!_options.circleSlide) {
if (_margin + _step > _liSum - _gWidth - _options.innerMargin) {
if (_margin != _liSum - _gWidth - _options.innerMargin) {
_margin = _liSum - _gWidth + _options.innerMargin;
jQuery(_options.btNext,_this).addClass('next-'+_options.disableClass);
_f2 = 0;
}
} else {
_margin = _margin + _step;
if (_margin == _liSum - _gWidth - _options.innerMargin) {
jQuery(_options.btNext,_this).addClass('next-'+_options.disableClass);_f2 = 0;
}
}
} else {
if (_margin + _step > _liSum - _gWidth + _options.innerMargin) {
if (_margin != _liSum - _gWidth + _options.innerMargin) {
_margin = _liSum - _gWidth + _options.innerMargin;
} else {
_f2 = 1;
_margin = -_options.innerMargin;
}
} else {
_margin = _margin + _step;
_f2 = 0;
}
}
_animatedBlock.animate({marginLeft: -_margin+"px"}, {queue:false,duration: _options.duration });
if (_timerSlide) {
clearTimeout(_timerSlide);
_timerSlide = setTimeout(function(){
autoSlide(_options.autoSlide)
}, _options.autoSlide);
}
if (_options.slideNum && !_options.step) jQuery.fn.galleryScroll.numListActive(_margin,jQuery(_options.slideNum, _this),_gWidth,_lastSection);
if (jQuery.isFunction(_options.funcOnclick)) {
_options.funcOnclick.apply(_this);
}
return false;
});
// click button 'Prev'
var _f2 = 1;
jQuery(_options.btPrev, _this).bind('click',function(){
jQuery(_options.btNext,_this).removeClass('next-'+_options.disableClass);
if (_margin - _step >= -_step - _options.innerMargin && _margin - _step <= -_options.innerMargin) {
if (_f2 != 1) {
_margin = -_options.innerMargin;
_f2 = 1;
} else {
if (_options.circleSlide) {
_margin = _liSum - _gWidth + _options.innerMargin;
f=1;_f2=0;
} else {
_margin = -_options.innerMargin
}
}
} else if (_margin - _step < -_step + _options.innerMargin) {
_margin = _margin - _step;
f=0;
}
else {_margin = _margin - _step;f=0;};
if (!_options.circleSlide && _margin == _options.innerMargin) {
jQuery(this).addClass('prev-'+_options.disableClass);
_f2=0;
}
if (!_options.circleSlide && _margin == -_options.innerMargin) jQuery(this).addClass('prev-'+_options.disableClass);
_animatedBlock.animate({marginLeft: -_margin + "px"}, {queue:false, duration: _options.duration});
if (_options.slideNum && !_options.step) jQuery.fn.galleryScroll.numListActive(_margin,jQuery(_options.slideNum, _this),_gWidth,_lastSection);
if (_timerSlide) {
clearTimeout(_timerSlide);
_timerSlide = setTimeout(function(){
autoSlide(_options.autoSlide)
}, _options.autoSlide);
}
if (jQuery.isFunction(_options.funcOnclick)) {
_options.funcOnclick.apply(_this);
}
return false;
});
if (_liSum <= _gWidth) {
jQuery(_options.btPrev,_this).addClass('prev-'+_options.disableClass).unbind('click');
jQuery(_options.btNext,_this).addClass('next-'+_options.disableClass).unbind('click');
}
// auto slide
function autoSlide(autoSlideDuration){
if (_options.circleSlide) {
jQuery(_options.btNext,_this).trigger('click');
}
};
// Number list
jQuery.fn.galleryScroll.numListCreate = function(_elNumList, _liSumWidth, _width, _section){
var _numListElC = '';
var _num = 1;
var _difference = _liSumWidth + _section;
while(_difference > 0)
{
_numListElC += '<li><a href="">'+_num+'</a></li>';
_num++;
_difference = _difference - _width;
}
jQuery(_elNumList).html('<ul>'+_numListElC+'</ul>');
};
jQuery.fn.galleryScroll.numListActive = function(_marginEl, _slideNum, _width, _section){
if (_slideNum) {
jQuery('a',_slideNum).removeClass('active');
var _activeRange = _width - _section-1;
var _n = 0;
if (_marginEl != 0) {
while (_marginEl > _activeRange) {
_activeRange = (_n * _width) -_section-1 + _options.innerMargin;
_n++;
}
}
var _a = (_activeRange+_section+1 + _options.innerMargin)/_width - 1;
jQuery('a',_slideNum).eq(_a).addClass('active');
}
};
if (_options.slideNum && !_options.step) {
jQuery.fn.galleryScroll.numListCreate(jQuery(_options.slideNum, _this), _liSum, _gWidth,_lastSection);
jQuery.fn.galleryScroll.numListActive(_margin, jQuery(_options.slideNum, _this),_gWidth,_lastSection);
numClick();
};
function numClick() {
jQuery(_options.slideNum, _this).find('a').click(function(){
jQuery(_options.btPrev,_this).removeClass('prev-'+_options.disableClass);
jQuery(_options.btNext,_this).removeClass('next-'+_options.disableClass);
var _indexNum = jQuery(_options.slideNum, _this).find('a').index(jQuery(this));
_margin = (_step*_indexNum) - _options.innerMargin;
f=0; _f2=0;
if (_indexNum == 0) _f2=1;
if (_margin + _step > _liSum) {
_margin = _margin - (_margin - _liSum) - _step + _options.innerMargin;
if (!_options.circleSlide) jQuery(_options.btNext, _this).addClass('next-'+_options.disableClass);
}
_animatedBlock.animate({marginLeft: -_margin + "px"}, {queue:false, duration: _options.duration});
if (!_options.circleSlide && _margin==0) jQuery(_options.btPrev,_this).addClass('prev-'+_options.disableClass);
jQuery.fn.galleryScroll.numListActive(_margin, jQuery(_options.slideNum, _this),_gWidth,_lastSection);
if (_timerSlide) {
clearTimeout(_timerSlide);
_timerSlide = setTimeout(function(){
autoSlide(_options.autoSlide)
}, _options.autoSlide);
}
return false;
});
};
jQuery(window).resize(function(){
_gWidth = _holderBlock.width();
_liWidth = jQuery(_options.scrollEl,_animatedBlock).outerWidth(true);
_liSum = jQuery(_options.scrollEl,_animatedBlock).length * _liWidth;
if (!_options.step) _step = _gWidth; else _step = _options.step*_liWidth;
if (_options.slideNum && !_options.step) {
var _lastSection = 0;
var _sectionWidth = 0;
while(_sectionWidth < _liSum)
{
_sectionWidth = _sectionWidth + _gWidth;
if(_sectionWidth > _liSum) {
_lastSection = _sectionWidth - _liSum;
}
};
jQuery.fn.galleryScroll.numListCreate(jQuery(_options.slideNum, _this), _liSum, _gWidth,_lastSection);
jQuery.fn.galleryScroll.numListActive(_margin, jQuery(_options.slideNum, _this),_gWidth,_lastSection);
numClick();
};
//if (_margin == _options.innerMargin) jQuery(this).addClass(_options.disableClass);
if (_liSum - _gWidth < _margin - _options.innerMargin) {
if (!_options.circleSlide) jQuery(_options.btNext, _this).addClass('next-'+_options.disableClass);
_animatedBlock.animate({marginLeft: -(_liSum - _gWidth + _options.innerMargin)}, {queue:false, duration: _options.duration});
};
});
});
}
jQuery.fn.fadeGallery = function(_options){
var _options = jQuery.extend({
slideElements:'.gallery li',
pagerLinks:'ul.switcher a',
btnNext:'http://brikov.ru/templates/default/js/a.next',
btnPrev:'http://brikov.ru/templates/default/js/a.prev',
btnPlayPause:'a.play-pause',
pausedClass:'paused',
playClass:'playing',
activeClass:'active',
pauseOnHover:true,
autoRotation:true,
autoHeight:false,
switchTime:5000,
duration:650,
event:'click'
},_options);
return this.each(function(){
var _this = jQuery(this);
var _slides = jQuery(_options.slideElements, _this);
var _pagerLinks = jQuery(_options.pagerLinks, _this);
var _btnPrev = jQuery(_options.btnPrev, _this);
var _btnNext = jQuery(_options.btnNext, _this);
var _btnPlayPause = jQuery(_options.btnPlayPause, _this);
var _pauseOnHover = _options.pauseOnHover;
var _autoRotation = _options.autoRotation;
var _activeClass = _options.activeClass;
var _pausedClass = _options.pausedClass;
var _playClass = _options.playClass;
var _autoHeight = _options.autoHeight;
var _duration = _options.duration;
var _switchTime = _options.switchTime;
var _controlEvent = _options.event;
var _hover = false;
var _prevIndex = 0;
var _currentIndex = 0;
var _slideCount = _slides.length;
var _timer;
if(!_slideCount) return;
_slides.hide().eq(_currentIndex).show();
if(_autoRotation) _this.removeClass(_pausedClass).addClass(_playClass);
else _this.removeClass(_playClass).addClass(_pausedClass);
if(_btnPrev.length) {
_btnPrev.bind(_controlEvent,function(){
prevSlide();
return false;
});
}
if(_btnNext.length) {
_btnNext.bind(_controlEvent,function(){
nextSlide();
return false;
});
}
if(_pagerLinks.length) {
_pagerLinks.each(function(_ind){
jQuery(this).bind(_controlEvent,function(){
if(_currentIndex != _ind) {
_prevIndex = _currentIndex;
_currentIndex = _ind;
switchSlide();
}
return false;
});
});
}
if(_btnPlayPause.length) {
_btnPlayPause.bind(_controlEvent,function(){
if(_this.hasClass(_pausedClass)) {
_this.removeClass(_pausedClass).addClass(_playClass);
_autoRotation = true;
autoSlide();
} else {
if(_timer) clearTimeout(_timer);
_this.removeClass(_playClass).addClass(_pausedClass);
}
return false;
});
}
function prevSlide() {
_prevIndex = _currentIndex;
if(_currentIndex > 0) _currentIndex--;
else _currentIndex = _slideCount-1;
switchSlide();
}
function nextSlide() {
_prevIndex = _currentIndex;
if(_currentIndex < _slideCount-1) _currentIndex++;
else _currentIndex = 0;
switchSlide();
}
function refreshStatus() {
if(_pagerLinks.length) _pagerLinks.removeClass(_activeClass).eq(_currentIndex).addClass(_activeClass);
_slides.eq(_prevIndex).removeClass(_activeClass);
_slides.eq(_currentIndex).addClass(_activeClass);
}
function switchSlide() {
_slides.eq(_prevIndex).fadeOut(_duration);
_slides.eq(_currentIndex).fadeIn(_duration);
refreshStatus();
autoSlide();
}
function autoSlide() {
if(!_autoRotation || _hover) return;
if(_timer) clearTimeout(_timer);
_timer = setTimeout(nextSlide,_switchTime+_duration);
}
if(_pauseOnHover) {
_this.hover(function(){
_hover = true;
if(_timer) clearTimeout(_timer);
},function(){
_hover = false;
autoSlide();
});
}
refreshStatus();
autoSlide();
});
}
function initMainGallery(){
var _lis = $('.gallery-holder .gallery li');
_lis.eq(1).addClass('box-prev');
_lis.eq(2).addClass('active');
_lis.eq(3).addClass('box-next');
//$('.gallery-holder .active .next').live('click', function(){
$('.gallery-holder .active .next').live('click', function(){
//$(".gallery-holder .active").on('click', '.next', function(){
if($('.gallery-holder .gallery li, .gallery-holder .gallery li *').is(':animated')){
return false;
}
$('.gallery-holder .box-prev').animate({'left':-1960, 'opacity':0}, 500, function(){
$(this).removeClass('box-prev');
});
$('.gallery-holder .active').animate({'left':-980, 'opacity':0.3}, 500, function(){
$(this).removeClass('active');
$(this).addClass('box-prev');
});
$('.gallery-holder .active .prev, .gallery-holder .active .next, .gallery-holder .active .color').fadeOut(300);
$('.gallery-holder .active .info').slideUp(300);
$('.gallery-holder .box-next').animate({'left':0, 'opacity':1}, 500, function(){
$(this).find('.next').fadeIn(500);
$(this).find('.prev').fadeIn(500);
$(this).find('.color').fadeIn(500, function(){
$(this).parents('li').find('.info').slideDown(500);
$(this).parents('li').removeClass('box-next');
$(this).parents('li').addClass('active');
});
});
$('.gallery-holder .box-next').next().css({'left':1962, 'opacity':0, 'display':'block'});
$('.gallery-holder .box-next').next().animate({'left':982, 'opacity':0.3}, 500, function(){
$(this).addClass('box-next');
$('.gallery-holder .gallery ul').append($('.gallery-holder .gallery ul').find('li:first-child'));
});
return false;
});
$('.gallery-holder .active .prev').live('click', function(){
//$('.gallery-holder .active').on('click','.prev', function(){
if($('.gallery-holder .gallery li, .gallery-holder .gallery li *').is(':animated')){
return false;
}
$('.gallery-holder .box-next').animate({'left':1962, 'opacity':0}, 500, function(){
$(this).removeClass('box-next');
});
$('.gallery-holder .active').animate({'left':982, 'opacity':0.3}, 500, function(){
$(this).removeClass('active');
$(this).addClass('box-next');
});
$('.gallery-holder .active .prev, .gallery-holder .active .next, .gallery-holder .active .color').fadeOut(300);
$('.gallery-holder .active .info').slideUp(300);
$('.gallery-holder .box-prev').animate({'left':0, 'opacity':1}, 500, function(){
$(this).find('.next').fadeIn(500);
$(this).find('.prev').fadeIn(500);
$(this).find('.color').fadeIn(500, function(){
$(this).parents('li').find('.info').slideDown(500);
$(this).parents('li').removeClass('box-prev');
$(this).parents('li').addClass('active');
});
});
$('.gallery-holder .box-prev').prev().css({'left':-1960, 'opacity':0, 'display':'block'});
$('.gallery-holder .box-prev').prev().animate({'left':-980, 'opacity':0.3}, 500, function(){
$(this).addClass('box-prev');
$('.gallery-holder .gallery ul').prepend($('.gallery-holder .gallery ul').find('li:last-child'));
});
return false;
});
}
function initPhotos(){
var i = 10;
$('.photo-holder > a').mouseenter(function(){
i++;
$(this).css('z-index', i);
});
};
function autoScrollGallery() {
var _lis = $('.gallery-holder .gallery li');
_lis.eq(1).addClass('box-prev');
_lis.eq(2).addClass('active');
_lis.eq(3).addClass('box-next');
if($('.gallery-holder .gallery li, .gallery-holder .gallery li *').is(':animated')){
return false;
}
$('.gallery-holder .box-prev').animate({'left':-1960, 'opacity':0}, 900, function(){
$(this).removeClass('box-prev');
});
$('.gallery-holder .active').animate({'left':-980, 'opacity':0.3}, 900, function(){
$(this).removeClass('active');
$(this).addClass('box-prev');
});
$('.gallery-holder .active .prev, .gallery-holder .active .next, .gallery-holder .active .color').fadeOut(300);
$('.gallery-holder .active .info').slideUp(600);
$('.gallery-holder .box-next').animate({'left':0, 'opacity':1}, 900, function(){
$(this).find('.next').fadeIn(500);
$(this).find('.prev').fadeIn(500);
$(this).find('.info').slideDown(2300);
$(this).find('.color').fadeIn(3000, function(){
$(this).parents('li').removeClass('box-next');
$(this).parents('li').addClass('active');
});
});
$('.gallery-holder .box-next').next().css({'left':1962, 'opacity':0, 'display':'block'});
$('.gallery-holder .box-next').next().animate({'left':982, 'opacity':0.3}, 900, function(){
$(this).addClass('box-next');
$('.gallery-holder .gallery ul').append($('.gallery-holder .gallery ul').find('li:first-child'));
});
return false;
}
//Homepage TEXT link
$(function() {
$('.ganri_list li').click(function() {
if($(this).hasClass('current')) return;
var index = $('li', $(this).parent()).removeClass('current').index(this);
$(this).addClass('current').parents('div.ganri_block').find('.ganri_box').hide().eq(index).fadeIn(300);
return false;
});
});