;(function($) { $(document).ready( function() { // MENU if ($(this).width() > 990) { $('.main').addClass('desk'); } $('.btn-menu').on('click', function() { $(this).toggleClass('active'); $('.mob-menu').slideToggle(300); }); $('.btn-submenu').on('click', function() { var sub = $(this).parent().siblings('.submenu, .mob-submenu, .megamenu'); $(this).toggleClass('active'); sub.slideToggle(300); }); $('.menu > li').each(function() { var sub = $(this).children('.submenu').size(); if (sub > 0) $(this).addClass('with-sub'); }); $(window).resize(function() { if ($('.btn-menu').css('display') === 'block') { $('.main').removeClass('desk'); } else { $('.main').addClass('desk'); $('.menu, .submenu, .b-search').removeAttr('style'); } }); // FORMS: SEARCH, COMMENT $('.btn-search').on('click', function() { $(this).toggleClass('active'); $('.b-search').fadeToggle(300); }); $('.search-submit, .comment-submit').on('click', function() { $(this).parent().submit(); }); $('.search-form').on('click', '.search-text-remove', function() { $(this).siblings('.search-text').val(''); }); // TABS (function() { $('.b-tabs').on('click', 'li', function() { var title = $(this), tab = title.parent().siblings().children().eq(title.index()); if (title.parent().parent().hasClass('a-slide')) { var curTab = tab.siblings('.active'); curTab.addClass('cur-tab').siblings().removeClass('cur-tab'); } title.addClass('active').siblings().removeClass('active'); tab.addClass('active').siblings().removeClass('active'); }); }()); // MESSAGES (function() { $(document).on('click', '.message-close', function() { $(this).parent() .animate({'opacity':'0'}, 220, function() { $(this).hide(200); }); }) }()); // SPOILER $('.spoiler-title').on('click', function() { $(this) .toggleClass('active') .next().slideToggle(250); }); $('.b-accordion .spoiler-title').on('click', function() { $(this).parent().siblings() .children('.spoiler-title').removeClass('active') .next('.spoiler-content').slideUp(250); }); // PROGRESS BAR $('.b-progress-bar').each(function() { var cap = parseInt($(this).attr('data-capacity'), 10), val = parseInt($(this).attr('data-value'), 10), len = 100 * (val / cap) + '%'; $(this).find('.progress-line').css('width', len); }); // TEAM $('.member-photo') .on('mouseenter', function() { $(this).children('.b-social').stop().fadeIn(200); }) .on('mouseleave', function() { $(this).children('.b-social').stop().fadeOut(200); }); $('.b-member.m-compact') .on('mouseenter', function() { $(this).children('.member-meta').stop().fadeIn(200); }) .on('mouseleave', function() { $(this).children('.member-meta').stop().fadeOut(200); }); // PORTFOLIO $('.work-preview a').on('click', function() { $(this).parent().trigger('click'); }); // CAROUSEL $.fn.carousel = function(op) { var op, ui = {}; op = $.extend({ speed: 500, autoChange: false, interval: 5000 }, op); ui.carousel = this; ui.items = ui.carousel.find('.carousel-item'); ui.itemsLen = ui.items.length; // CREATE CONTROLS ui.ctrl = $('
', {'class': 'carousel-control'}); ui.prev = $('
', {'class': 'carousel-prev'}); ui.next = $('
', {'class': 'carousel-next'}); ui.pagList = $('
    ', {'class': 'carousel-pagination'}); ui.pagItem = $('
  • '); for (var i = 0; i < ui.itemsLen; i++) { ui.pagItem.clone().appendTo(ui.pagList); } ui.prev.appendTo(ui.ctrl); ui.next.appendTo(ui.ctrl); ui.pagList.appendTo(ui.ctrl); ui.ctrl.appendTo(ui.carousel); ui.carousel.find('.carousel-pagination li').eq(0).addClass('active'); ui.carousel.find('.carousel-item').each(function() { $(this).hide(); }); ui.carousel.find('.carousel-item').eq(0).show().addClass('active'); // CHANGE ITEM var changeImage = function(direction, context) { var current = ui.carousel.find('.carousel-item.active'); if (direction == 'index') { if(current.index() === context.index()) return false; context.addClass('active').siblings().removeClass('active'); ui.items.eq(context.index()).addClass('current').fadeIn(op.speed, function() { current.removeClass('active').hide(); $(this).addClass('active').removeClass('current'); }); } if (direction == 'prev') { if (current.index() == 0) { ui.carousel.find('.carousel-item:last').addClass('current').fadeIn(op.speed, function() { current.removeClass('active').hide(); $(this).addClass('active').removeClass('current'); }); } else { current.prev().addClass('current').fadeIn(op.speed, function() { current.removeClass('active').hide(); $(this).addClass('active').removeClass('current'); }); } } if (direction == undefined) { if (current.index() == ui.itemsLen - 1) { ui.carousel.find('.carousel-item:first').addClass('current').fadeIn(300, function() { current.removeClass('active').hide(); $(this).addClass('active').removeClass('current'); }); } else { current.next().addClass('current').fadeIn(300, function() { current.removeClass('active').hide(); $(this).addClass('active').removeClass('current'); }); } } ui.carousel.find('.carousel-pagination li').eq( ui.carousel.find('.carousel-item.current').index() ).addClass('active').siblings().removeClass('active'); }; ui.carousel .on('click', 'li', function() { changeImage('index', $(this)); }) .on('click', '.carousel-prev', function() { changeImage('prev'); }) .on('click', '.carousel-next', function() { changeImage(); }); // AUTO CHANGE if (op.autoChange) { var changeInterval = setInterval(changeImage, op.interval); ui.carousel .on('mouseenter', function() { clearInterval(changeInterval); }) .on('mouseleave', function() { changeInterval = setInterval(changeImage, op.interval); }); } return this; }; $('.b-carousel').each(function() { $(this).carousel({ autoChange: true }); }); // BUTTON UP var btnUp = $('
    ', {'class':'btn-up'}); btnUp.appendTo('body'); $(document).on('click', '.btn-up', function() { $('html, body').animate({ scrollTop: 0 }, 700); }); $(window).on('scroll', function() { if ($(this).scrollTop() > 200) $('.btn-up').addClass('active'); else $('.btn-up').removeClass('active'); }); //Map if( $('#map_canvas').length > 0 ){ $('#map_canvas').gMap({ maptype: 'ROADMAP', scrollwheel: false, zoom: 18, markers: [ { address: $('#map_canvas').data('address'), // Your Adress Here html: '', popup: false, } ], }); } }); })(jQuery);