File "custom.js"
Full Path: /home/pumpbmko/public_html/wp-content/themes/pure-portfolio/assets/js/custom.js
File size: 7.6 KB
MIME-type: text/plain
Charset: utf-8
jQuery(function($) {
/* -----------------------------------------
Preloader
----------------------------------------- */
$('#preloader').delay(1000).fadeOut();
$('#loader').delay(1000).fadeOut("slow");
/* -----------------------------------------
Navigation
----------------------------------------- */
$('.menu-toggle').click(function() {
$(this).toggleClass('open');
});
/* -----------------------------------------
Sticky Header
----------------------------------------- */
const header = document.querySelector('.bottom-header-part');
window.onscroll = function() {
if (window.pageYOffset > 200) {
header.classList.add('fix-header');
} else {
header.classList.remove('fix-header');
}
};
$(document).ready(function() {
var divHeight = $('.bottom-header-part').height();
$('.bottom-header-outer-wrapper').css('min-height', divHeight + 'px');
});
/* -----------------------------------------
Keyboard Navigation
----------------------------------------- */
$(window).on('load resize', function() {
if ($(window).width() < 992 && $(window).width() >= 768) {
$('.main-navigation').find("a").unbind('keydown');
$('.main-navigation').find("li").last().bind('keydown', function(e) {
if (e.which === 9) {
e.preventDefault();
$('#masthead').find('.menu-toggle').focus();
}
});
} else if ($(window).width() < 768) {
$('.main-navigation').find("li").unbind('keydown');
$('.main-navigation').find("a").last().bind('keydown', function(e) {
if (e.which === 9) {
e.preventDefault();
$('#masthead').find('.menu-toggle').focus();
}
});
} else {
$('.main-navigation').find("li").unbind('keydown');
$('.main-navigation').find("a").unbind('keydown');
}
});
var primary_menu_toggle = $('#masthead .menu-toggle');
primary_menu_toggle.on('keydown', function(e) {
var tabKey = e.keyCode === 9;
var shiftKey = e.shiftKey;
if (primary_menu_toggle.hasClass('open')) {
if (shiftKey && tabKey) {
e.preventDefault();
$('.main-navigation').toggleClass('toggled');
primary_menu_toggle.removeClass('open');
};
}
});
$('.header-search-wrap').find(".search-submit").bind('keydown', function(e) {
var tabKey = e.keyCode === 9;
if (tabKey) {
e.preventDefault();
$('.header-search-icon').focus();
}
});
$('.header-search-icon').on('keydown', function(e) {
var tabKey = e.keyCode === 9;
var shiftKey = e.shiftKey;
if ($('.header-search-wrap').hasClass('show')) {
if (shiftKey && tabKey) {
e.preventDefault();
$('.header-search-wrap').removeClass('show');
$('.header-search-icon').focus();
}
}
});
/* -----------------------------------------
Search
----------------------------------------- */
var searchWrap = $('.header-search-wrap');
$(".header-search-icon").click(function(e) {
e.preventDefault();
searchWrap.toggleClass("show");
searchWrap.find('input.search-field').focus();
});
$(document).click(function(e) {
if (!searchWrap.is(e.target) && !searchWrap.has(e.target).length) {
$(".header-search-wrap").removeClass("show");
}
});
/* -----------------------------------------
Banner feature texts
----------------------------------------- */
if ( $(".pure-portfolio-main-banner-section").hasClass("featured-typed") ){
var typed = new Typed('#typed',{
stringsElement: '#typed-strings',
loop: true,
backDelay: 900,
backSpeed: 40,
typeSpeed: 40
});
}
/* -----------------------------------------
Progressbar
----------------------------------------- */
function animateElements() {
$('.progressbar').each(function() {
var elementPos = $(this).offset().top;
var topOfWindow = $(window).scrollTop();
var percent = $(this).find('.circle').attr('data-percent');
var percentage = parseInt(percent, 10) / parseInt(100, 10);
var animate = $(this).data('animate');
if (elementPos < topOfWindow + $(window).height() - 30 && !animate) {
$(this).data('animate', true);
$(this).find('.circle').circleProgress({
startAngle: -Math.PI / 2,
value: percent / 100,
emptyFill: "rgba(237,241,244, .3)",
}).on('circle-animation-progress', function(event, progress, stepValue) {
$(this).find('div').text((stepValue * 100).toFixed(1) + "%");
}).stop();
}
});
}
// Show animated elements
animateElements();
$(window).scroll(animateElements);
/* -----------------------------------------
Wow js
----------------------------------------- */
wow = new WOW(
{
boxClass: 'wow', // default
animateClass: 'animated', // default
offset: 100, // default
mobile: true, // default
live: true // default
}
)
wow.init();
/* -----------------------------------------
Magic Mouse js
----------------------------------------- */
$(document).ready(function(){
options = {
"cursorOuter": "circle-basic",
"hoverEffect": "circle-move",
"hoverItemMove": false,
"defaultCursor": false,
"outerWidth": 30,
"outerHeight": 30
}
magicMouse(options);
});
/* -----------------------------------------
Scroll Top
----------------------------------------- */
var scrollToTopBtn = $('.pure-portfolio-scroll-to-top');
$(window).scroll(function() {
if ($(window).scrollTop() > 400) {
scrollToTopBtn.addClass('show');
} else {
scrollToTopBtn.removeClass('show');
}
});
scrollToTopBtn.on('click', function(e) {
e.preventDefault();
$('html, body').animate({
scrollTop: 0
}, '300');
});
(function($) { "use strict";
$(document).ready(function(){"use strict";
//Scroll back to top
var progressPath = document.querySelector('.progress-wrap path');
var pathLength = progressPath.getTotalLength();
progressPath.style.transition = progressPath.style.WebkitTransition = 'none';
progressPath.style.strokeDasharray = pathLength + ' ' + pathLength;
progressPath.style.strokeDashoffset = pathLength;
progressPath.getBoundingClientRect();
progressPath.style.transition = progressPath.style.WebkitTransition = 'stroke-dashoffset 10ms linear';
var updateProgress = function () {
var scroll = $(window).scrollTop();
var height = $(document).height() - $(window).height();
var progress = pathLength - (scroll * pathLength / height);
progressPath.style.strokeDashoffset = progress;
}
updateProgress();
$(window).scroll(updateProgress);
});
})(jQuery);
});