( function ( $ ) {
$(function() {
$(document).ready(function(){
$('.m-bellows').bellows();
$(".video").fitVids();
//Portfolio item
//==================================================================
//==================================================================
$(".portfolio-item-block").click(function() {
var current_portfolio_item = this;
if ($("body").width() >= 734) {
if ($(this).is(".open")) {
$(".portfolio-item-block").css("margin-bottom", 0);
$(".details").fadeOut();
$(".portfolio-item-block").removeClass("open");
} else {
$(".portfolio-item-block").css("margin-bottom", 0);
$(".portfolio-item-block").removeClass("open");
$(".details").fadeOut();
$(".portfolio-list").addClass("static");
$(current_portfolio_item).addClass("open");
$("html, body").animate({scrollTop: $(current_portfolio_item).position().top + $(current_portfolio_item).height() + 700 }, 500);
if($(current_portfolio_item).attr("data-item") == 1)
{
$(current_portfolio_item).css("margin-bottom", $(".details", current_portfolio_item).height() + 120);
$(current_portfolio_item).next(".portfolio-item-block").css("margin-bottom", $(".details", current_portfolio_item).height() + 120);
$(current_portfolio_item).next(".portfolio-item-block").next(".portfolio-item-block").css("margin-bottom", $(".details", current_portfolio_item).height() + 120);
}
if($(current_portfolio_item).attr("data-item") == 2)
{
$(current_portfolio_item).css("margin-bottom", $(".details", current_portfolio_item).height() + 120);
$(current_portfolio_item).prev(".portfolio-item-block").css("margin-bottom", $(".details", current_portfolio_item).height() + 120);
$(current_portfolio_item).next(".portfolio-item-block").css("margin-bottom", $(".details", current_portfolio_item).height() + 120);
}
if($(current_portfolio_item).attr("data-item") == 3)
{
$(current_portfolio_item).css("margin-bottom", $(".details", current_portfolio_item).height() + 120);
$(current_portfolio_item).prev(".portfolio-item-block").css("margin-bottom", $(".details", current_portfolio_item).height() + 120);
$(current_portfolio_item).prev(".portfolio-item-block").prev(".portfolio-item-block").css("margin-bottom", $(".details", current_portfolio_item).height() + 120);
}
$(".details", current_portfolio_item).fadeIn(50);
}
}
else
{
if ($(this).is(".open")) {
$(".portfolio-item-block").css("margin-bottom", 0).removeClass("open");
$(".details").fadeOut();
} else {
$(".portfolio-item-block").css("margin-bottom", 0).removeClass("open");
$(".details").fadeOut();
$(".portfolio-list").addClass("static");
$(current_portfolio_item).addClass("open");
$(current_portfolio_item).css("margin-bottom", $(".details", current_portfolio_item).height() + 120);
$(".details", current_portfolio_item).fadeIn();
}
}
});
$(".btn-close").click(function(e) {
e.stopPropagation();
e.preventDefault();
$(".portfolio-item-block").css("margin-bottom", 0);
$(".details").fadeOut();
$(".portfolio-item-block").removeClass("open");
});
$(".details").click(function(e) {
e.stopPropagation();
return false;
});
//shrink top header
//==================================================================
//==================================================================
var topHeader = (function() {
var docElem = document.documentElement,
header = document.querySelector( '.top-header' ),
didScroll = false,
changeHeaderOn = 480,
visibleHeaderOn = 300;
function init() {
window.addEventListener( 'scroll', function( event ) {
if( !didScroll ) {
didScroll = true;
setTimeout( scrollPage, 5 );
}
}, false );
}
function scrollPage() {
var sy = scrollY();
if ( sy >= visibleHeaderOn )
$(".top-header").addClass('active-header');
else
$(".top-header").removeClass('active-header');
if ( sy >= changeHeaderOn ) {
$(".top-header").addClass('top-header-shrink');
$(".logo").addClass("logopos");
$(".menuwrapper").addClass("menupos");
$("select").addClass("dw-menu");
}
else {
$(".top-header").removeClass('top-header-shrink');
$(".logo").removeClass("logopos");
$(".menuwrapper").removeClass("menupos");
$("select").removeClass("dw-menu");
}
didScroll = false;
}
function scrollY() {
return window.pageYOffset || docElem.scrollTop;
}
init();
})();
//header text visibility
//===================================================================
//===================================================================
$(window).scroll( function() {
var value = $(this).scrollTop();
if ( value > 150 ){
$(".home-inner-wrap").addClass("read");
$(".jms-arrows-prev").addClass("jms-arrows-prev-disable");
$(".jms-arrows-next").addClass("jms-arrows-next-disable");
}
else{
$(".home-inner-wrap").removeClass("read");
$(".jms-arrows-prev").removeClass("jms-arrows-prev-disable");
$(".jms-arrows-next").removeClass("jms-arrows-next-disable");
}
});
//Mobile menu
//=================================================================
//=================================================================
$(document).ready(function() {
// Create the dropdown bases
$("").appendTo(".menu");
// Create default option "Go to..."
$("", {
"selected": "selected",
"value": "",
"text": "Go to..."
}).appendTo(".menu select");
// Populate dropdowns with the first menu items
$(".menu li a").each(function() {
var el = $(this);
$("", {
"value": el.attr("href"),
"text": el.text()
}).appendTo(".menu select");
});
//make responsive dropdown menu actually work
$(".menu select").change(function() {
//window.location = $(this).find("option:selected").val();
var el = $(this).find("option:selected").val();
var elWrapped = $(el);
scrollToDiv(elWrapped,64);
return false;
});
});
//service grid
//====================================================================
//====================================================================
$(".service-grid").hover(
function () {
$(this).children(".service-details").stop().fadeTo(400, 0.9);
},
function () {
$(this).children(".service-details").stop().fadeTo(400, 0);
}
);
//Menu smooth scroll
//======================================================================
//======================================================================
$('.w-icon-link').click(function(){
var el = $(this).attr('href');
var elWrapped = $(el);
scrollToDiv(elWrapped,64);
return false;
});
$('.menu li a').click(function(){
$(".menu li a").removeClass('active');
$(this).addClass('active');
var el = $(this).attr('href');
var elWrapped = $(el);
scrollToDiv(elWrapped,64);
return false;
});
function scrollToDiv(element,navheight){
var offset = element.offset();
var offsetTop = offset.top;
var totalScroll = offsetTop-navheight;
$('body,html').animate({
scrollTop: totalScroll
}, 1200);
}
//active menu selector
//==============================================================
//==============================================================
var lastId = $("#header");
var topMenu = $("#header");
var topMenuHeight = topMenu.outerHeight() + 66;
// All list items
var menuItems = topMenu.find("a");
// Anchors corresponding to menu items
var scrollItems = menuItems.map(function () {
var item = $(this).attr("href");
if (item.charAt(0) == '#') {
return item;
}
});
$(window).resize(function () {
topMenuHeight = topMenu.outerHeight() + 66;
});
$(window).scroll(function () {
var fromTop = $(this).scrollTop() + topMenuHeight;
// Get id of current scroll item
var cur = menuItems.map(function (val, i) {
var item = $(this).attr("href");
if (item.charAt(0) == '#' ) {
if ($(''+item).offset().top < fromTop){
return $(''+item);
}
}
});
// Get the id of the current element
cur = cur[cur.length - 1];
var id = cur && cur.length ? cur[0].id : "";
if (lastId !== id) {
lastId = id;
topMenu.find("a").removeClass("active");
menuItems
.parent()
.end().filter("[href=#" + id + "]").addClass("active");
}
});
//toggle team skill
//====================================================================
//====================================================================
$("#member1").click(function () {$header = $(".team1-skill").slideToggle(500);$header.addClass("team-skill-active");});
$("#member2").click(function () {$header = $(".team2-skill").slideToggle(500);$header.addClass("team-skill-active");});
$("#member3").click(function () {$header = $(".team3-skill").slideToggle(500);$header.addClass("team-skill-active");});
$("#member4").click(function () {$header = $(".team4-skill").slideToggle(500);$header.addClass("team-skill-active");});
$("#member5").click(function () {$header = $(".team5-skill").slideToggle(500);$header.addClass("team-skill-active");});
// BACK TO TOP
//=====================================================================
//=====================================================================
$(window).scroll(function(){
if($(window).scrollTop() > 200)
$("#back-to-top").fadeIn(200);
else
$("#back-to-top").fadeOut(200);
});
$('#back-to-top, .back-to-top').click(function() {
$('html, body').animate({ scrollTop:0 }, '800');
return false;
});
//twitter feed
//===================================================================
//===================================================================
var user = $( '.twitter_author' ).data('user');
if( user ){
$(function(){
$('#tweets').tweetable({
username: user, //twitter username
time: true,
rotate: true,
speed: 7000,
limit: 5,
replies: true,
position: 'append',
failed: "Sorry, twitter is currently unavailable for this user.",
loading: "Loading tweets...",
html5: true,
onComplete:function($ul){
$('time').timeago();
}
});
});
}
});
//END DOCUMENT.READY FUNCTION
// BEGIN WINDOW.LOAD FUNCTION
$(window).load(function() {
//preloader
//================================================================
//=================================================================
$("#status").fadeOut();
$("#preloader").delay(350).fadeOut("slow");
//initialize teem slider
//==================================================================
//==================================================================
$("#teem-slider").flexisel({
visibleItems: 3,
enableResponsiveBreakpoints: true,
clone : false,
responsiveBreakpoints: {
portrait: {
changePoint:749,//resolution change point
visibleItems: 1//visible item
},
landscape: {
changePoint:750,//resolution change point
visibleItems: 3//visible item
},
tablet: {
changePoint:959,//resolution change point
visibleItems: 3//visible item
}
}
});
//initialize portfolio slider
//===================================================================
//===================================================================
$("#portfolio-slider").flexisel({
visibleItems: 2,
enableResponsiveBreakpoints: true,
clone : false,
responsiveBreakpoints: {
portrait: {
changePoint:749,//resolution change point
visibleItems: 1//visible item
},
landscape: {
changePoint:750,//resolution change point
visibleItems: 2//visible item
},
tablet: {
changePoint:959,//resolution change point
visibleItems: 2//visible item
}
}
});
//initialize testimonial slider
//=================================================================
//=================================================================
$("#testimonial-slider").flexisel({
visibleItems: 1,
enableResponsiveBreakpoints: true,
clone : true,
responsiveBreakpoints: {
portrait: {
changePoint:480,//resolution change point
visibleItems: 1//visible item
},
landscape: {
changePoint:640,//resolution change point
visibleItems: 1//visible item
},
tablet: {
changePoint:768,//resolution change point
visibleItems: 1//visible item
}
}
});
//initialize clients slider
//================================================================
//================================================================
$("#clients-slider").flexisel({
visibleItems: 4,
enableResponsiveBreakpoints: true,//responsive layout
autoPlay : true,//auto play
clone : true,
responsiveBreakpoints: {
portrait: {
changePoint:480,//resolution change point
visibleItems: 1//visible item
},
landscape: {
changePoint:640,//resolution change point
visibleItems: 3//visible item
},
tablet: {
changePoint:768,//resolution change point
visibleItems: 3//visible item
}
}
});
});
//common function for image hover and image count in cycle plugin
//=================================================================
//=================================================================
// on mouse over
$(".content-area").hover(function () {
$(this).find(".imageCover").stop().animate({
opacity: 0
}, "slow");
$(this).find(".infoBlk").stop().animate({
backgroundColor: "#333333"
}, "slow");
},
// on mouse out
function () {
$(this).find(".imageCover").stop().animate({
opacity: 1
}, "slow");
$(this).find(".infoBlk").stop().animate({
backgroundColor: "#fff"
}, "slow");
$(this).find(".infoCont").slideUp();
$(this).find(".infoBlk .infoLink").removeClass('current');
});
//slideToggle
$('.content-area .infoBlk').click(function() {
$(this).toggleClass('current');
$(this).parents('.content-area').find(".infoCont").slideToggle();
});
//count total images
$('.content-area').each(function() {
$(this).find('.slideInfo .totalImg').html($(this).find('.workImgCont img').length);
});
//on image click
$('.imageCover').click(function() {
var currentImgInSlides = $(this).next('.workImgCont').find('img:visible').next().index()+1;
if(currentImgInSlides === 0)
{
$(this).parents('.content-area').find('.slideInfo .currentImg').html(1);
}
else
{
$(this).parents('.content-area').find('.slideInfo .currentImg').html(currentImgInSlides);
}
});
//init $ cycle plugin for future work slider
$('.workImgCont').each(function() {
$(this).cycle({
fx:'scrollHorz',
next: $(this).parents('.content-area').find('.imageCover'),
timeout: 0,
speed:200,
});
});
//init $ cycle plugin for blog post slider
$('.blog-imagecycle').each(function() {
$(this).cycle({
fx:'scrollHorz',
next: $(this).parents('.thumb').find('.imageCover'),
timeout: 0,
pager:'#nav-blog',
});
});
});
}( jQuery));