( function( $ ) {
"use strict";
$(document).ready(function($){
var $container = $('#portfolio'),
colwidth = function () {
var w = $container.width(),
columnnum = 1,
columnwidth = 0;
if (w > 1200) {
columnnum = 4;
} else if (w > 900) {
columnnum = 4;
} else if (w > 600) {
columnnum = 3;
} else if (w > 300) {
columnnum = 1;
}
columnwidth = math.floor(w/columnnum);
$container.find('.portfolio-item').each(function() {
var $item = $(this),
multiplier_w = $item.attr('class').match(/item-w(\d)/),
multiplier_h = $item.attr('class').match(/item-h(\d)/),
width = multiplier_w ? columnwidth*multiplier_w[1]-4 : columnwidth-4,
height = multiplier_h ? columnwidth*multiplier_h[1]*1.13-4 : columnwidth*1.13-4;
$item.css({
width: width,
height: height
});
});
return columnwidth;
}
function refreshwaypoints() {
settimeout(function() {
}, 1000);
}
$('nav.portfolio-filter ul a').on('click', function() {
var selector = $(this).attr('data-filter');
$container.isotope({ filter: selector }, refreshwaypoints());
$('nav.portfolio-filter ul a').removeclass('active');
$(this).addclass('active');
return false;
});
function setportfolio() {
setcolumns();
$container.isotope('relayout');
}
var isotope = function () {
$container.isotope({
resizable: true,
itemselector: '.portfolio-item',
masonry: {
columnwidth: colwidth(),
gutterwidth: 0
}
});
};
isotope();
$(window).smartresize(isotope);
$.fn.viewportchecker = function(useroptions){
// define options and extend with user.
var options = {
classtoadd: 'visible',
offset: 100,
callbackfunction: function(elem){}
};
$.extend(options, useroptions);
// cache the given element and height of the browser
var $elem = this,
windowheight = $(window).height();
this.checkelements = function(){
// set some vars to check with
var scrollelem = ((navigator.useragent.tolowercase().indexof('webkit') != -1) ? 'body' : 'html'),
viewporttop = $(scrollelem).scrolltop(),
viewportbottom = (viewporttop + windowheight);
$elem.each(function(){
var $obj = $(this);
// if class already exists; quit
if ($obj.hasclass(options.classtoadd)){
return;
}
// define the top position of the element and include the offset which makes is appear earlier or later
var elemtop = math.round( $obj.offset().top ) + options.offset,
elembottom = elemtop + ($obj.height());
// add class if in viewport
if ((elemtop < viewportbottom) && (elembottom > viewporttop)){
$obj.addclass(options.classtoadd);
// do the callback function. callback will send the jquery object as parameter
options.callbackfunction($obj);
}
});
};
// run checkelements on load and scroll.
$(window).on( 'scroll', this.checkelements );
this.checkelements();
// on resize change the height var.
$(window).on( 'resize', function(e){
windowheight = e.currenttarget.innerheight;
});
};
// search in header.
if( $('.search-icon').length > 0 ) {
$('.search-icon').on('click', function(e){
e.preventdefault();
$('.search-box-wrap').slidetoggle();
});
}
// sidr menu.
$('#mobile-trigger').sidr({
timing: 'ease-in-out',
speed: 500,
source: '#mob-menu',
name: 'sidr-main'
});
// counter up.
$('.counter-nos').counterup({
delay: 10,
time: 1000
});
// fixed header.
$(window).on('scroll', function() {
if( $(window).scrolltop() > $('.site-header').offset().top && !($('.site-header').hasclass('fixed'))){
$('.site-header').addclass('fixed');
}
else if ( 0 === $(window).scrolltop() ) {
$('.site-header').removeclass('fixed');
}
});
// slick carousel.
$(".testimonial-carousel-wrapper").slick({
dots: true,
infinite: true,
slidestoshow: 3,
slidestoscroll: 3,
dots: false,
responsive: [
{
breakpoint: 1024,
settings: {
slidestoshow: 2,
slidestoscroll: 2,
infinite: true
}
},
{
breakpoint: 600,
settings: {
slidestoshow: 1,
slidestoscroll: 1
}
}
],
prevarrow: '',
nextarrow : ''
});
// skil bar.
jquery('.skillbar').each(function(){
jquery(this).find('.skillbar-bar').animate({
width:jquery(this).attr('data-percent')
},3000);
});
// lighbox.
jquery('a[data-gal]').each(function() {
jquery(this).attr('rel', jquery(this).data('gal'));
});
jquery("a[data-gal^='prettyphoto']").prettyphoto({animationspeed:'slow',slideshow:false,overlay_gallery: false,theme:'light_square',social_tools:false,deeplinking:false});
});
} )( jquery );