You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
152 lines
4.0 KiB
152 lines
4.0 KiB
// Main JS File
|
|
|
|
// Start Wrapper
|
|
jQuery(document).ready(function ($) {
|
|
$(window).load(function () {
|
|
|
|
$('[data-em]').each( function() {
|
|
var address = $(this).attr('data-em');
|
|
$(this).attr('href', 'mailto:'+address+'@protonvpn.com');
|
|
if ($(this).text()==='') {
|
|
$(this).text(address+'@protonvpn.com');
|
|
}
|
|
});
|
|
|
|
var $list_items = $('.pagination li');
|
|
$list_items.addClass('btn btn-secondary');
|
|
$list_items.each(function() {
|
|
var $this = $(this);
|
|
if ($this.find('.dots').length !== 0) {
|
|
$this.addClass('no-pointer-cursor');
|
|
}
|
|
});
|
|
|
|
|
|
// Nav setup
|
|
function setupNav() {
|
|
// Prevent menu text from jumping by applying dynamic padding
|
|
$('#navbar-main .nav-link').each( function() {
|
|
$(this).css('width', '');
|
|
var w = $(this).outerWidth();
|
|
$(this).css('width', w+10);
|
|
});
|
|
}
|
|
|
|
// cat nav, hide uncategorized
|
|
$('#cat-nav .cat-item-1').remove();
|
|
|
|
// Header
|
|
function vpnHeader() {
|
|
var scrollTop = $(window).scrollTop();
|
|
var opacity = (scrollTop < 100) ? scrollTop : 100;
|
|
opacity = opacity/100;
|
|
|
|
if (opacity>=1) {
|
|
$('#topbar, #navbar-main').addClass('active');
|
|
}
|
|
else {
|
|
$('#topbar, #navbar-main').removeClass('active');
|
|
}
|
|
}
|
|
|
|
// Mobile Nav
|
|
function mobileNav() {
|
|
$('.navbar-toggler').on('click', function() {
|
|
$('#navbar-mobile, #navbar-mobile-overlay').toggleClass('show');
|
|
return false;
|
|
});
|
|
|
|
$('#navbar-mobile-overlay').on('click', function() {
|
|
$('#navbar-mobile, #navbar-mobile-overlay').removeClass('show');
|
|
return false;
|
|
});
|
|
}
|
|
|
|
$(window).on('scroll', vpnHeader);
|
|
$(window).on('load', vpnHeader);
|
|
$(window).on('resize', function() {
|
|
vpnHeader();
|
|
setupNav();
|
|
});
|
|
|
|
// Init
|
|
$(window).ready( function () {
|
|
vpnHeader();
|
|
setupNav();
|
|
mobileNav();
|
|
});
|
|
|
|
// HT fade in #ht-to-top
|
|
$(function () {
|
|
$(window).scroll(function () {
|
|
if ($(this).scrollTop() > 100) {
|
|
$('#ht-to-top').fadeIn('1000');
|
|
} else {
|
|
$('#ht-to-top').fadeOut('1000');
|
|
}
|
|
});
|
|
|
|
// scroll body to 0px on click
|
|
$('#ht-to-top').click(function () {
|
|
$('body,html').animate({
|
|
scrollTop: 0
|
|
}, 800);
|
|
return false;
|
|
});
|
|
});
|
|
|
|
// Search icon setup
|
|
$('.ht-kb-article-search').append('<span class="fa fa-spin fa-spinner"></span>');
|
|
|
|
// Search event
|
|
var searchLoader, searchCheck = false;
|
|
$( "#s" ).on('keypress', function() {
|
|
|
|
clearTimeout(searchLoader);
|
|
clearTimeout(searchCheck);
|
|
|
|
searchLoader = setTimeout( function() {
|
|
if ($('#s').hasClass('live-search-loading')) {
|
|
$('.ht-kb-article-search').addClass('loading');
|
|
}
|
|
else {
|
|
$('.ht-kb-article-search').removeClass('loading');
|
|
}
|
|
}, 100);
|
|
|
|
searchCheck = setTimeout( function() {
|
|
if ($('#s').hasClass('live-search-loading')) {
|
|
$('.ht-kb-article-search').addClass('loading');
|
|
}
|
|
else {
|
|
$('.ht-kb-article-search').removeClass('loading');
|
|
}
|
|
}, 2500);
|
|
|
|
});
|
|
|
|
// Comment form styles
|
|
$('#respond textarea, #respond input[type="text"], #respond input[type="password"], #respond input[type="email"], #respond input[type="url"]').addClass('form-control');
|
|
$('#respond .form-submit').addClass('text-right');
|
|
$('#respond #submit').addClass('btn btn-success');
|
|
$('#commentform .comment-form-email .required').text("(not published)");
|
|
|
|
// 404 search styles
|
|
$('.error404 .search-field').addClass('form-control');
|
|
$('.error404 .search-submit').addClass('btn btn-success');
|
|
$('.search .search-field').addClass('form-control');
|
|
$('.search .search-submit').addClass('btn btn-success');
|
|
|
|
// comment form order
|
|
if ( $('.comment-form-email').length ) {
|
|
var respond = $('.comment-form-comment').detach();
|
|
respond.insertAfter('.comment-form-email');
|
|
}
|
|
|
|
// Entry/Post Classes
|
|
$('.entry table').addClass('table');
|
|
|
|
|
|
});
|
|
})
|
|
// End Wrapper
|