File: /var/www/bharti-foundation.stgviitor.com/wp-content/themes/lifeline/assets/js/lifeline-script.js
function sideHeader() {
jQuery('body').toggleClass('sidemenu-active');
jQuery('.sidemenu li.menu-item-has-children > a').on('click', function () {
jQuery(this).parent().siblings('li').children('ul').slideUp();
jQuery(this).parent().siblings('li').removeClass('active');
jQuery(this).parent().children('ul').slideToggle();
jQuery(this).parent().toggleClass('active');
return false;
});
}
jQuery(document).ready(function ($) {
var wowAnimate = document.querySelectorAll('.wow');
if (wowAnimate) {
if ($(wowAnimate).length > 0) {
var WOW = window.WOW;
new WOW().init();
}
}
const event_toggle = document.querySelector('[data-js="event-toggle"]');
// When Toggle Event exists
if (event_toggle) {
// Toggle Event
var event_toggleInit = function () {
event_toggle.offsetHeight;
$('.event-box .event-desc').hide();
$('.event-box:first').addClass('active').children('.event-desc').slideDown(500);
$('.event-box').on('click', function () {
if ($(this).children('.event-desc').is(':hidden')) {
$('.event-box').children('.event-desc').slideUp(500).removeClass('active');
$(this).children('.event-desc').slideDown(500).addClass('active');
}
});
};
event_toggleInit();
}
$("#press_room").on("click", function () {
var thiss = $(this);
var $data = $(this).attr("data-load") + "&action=lifeline_ajax&subaction=press_room";
$.ajax({
url: lifeline_data.ajaxurl,
type: "POST",
data: "data=" + $data,
beforeSend: function () {
thiss.children("i").addClass("fa-spin");
},
success: function (res) {
thiss.children("i").removeClass("fa-spin");
if (res.success == true) {
thiss.prev(".blog-list-wrap").append(res.data.post);
thiss.replaceWith(res.data.button);
}
}
});
});
var box = $("body").find(".custom-banner-box");
if (box.length >= 1) {
var box_par = box.parent().parent();
box_par.children(".hover_script").eq(1).children(".custom-banner-box").addClass("active");
$(".custom-banner-box").on("mouseover", function () {
$(".custom-banner-box").removeClass("active");
$(this).addClass("active");
});
}
$('body').on('click', '#loadMore a' , function(e){
e.preventDefault();
if($(this).text() == "No more posts") return;
$(this).text('LOADING MORE');
var that = this;
var link = jQuery(this).attr('href');
$.get(link, function(data) {
var cat = $('<div></div>').html(data).find(".post-listing");
jQuery('.post-listing').append($(cat).html());
var newLink = $('<div></div>').html(data).find("#loadMore");
var newerLink = $('<div></div>').html(data).find("#loadMore a").attr('href');
if($(newLink).html()){
$(that).removeClass("loader");
$(that).removeClass("loader-btn");
$(that).attr('href',newerLink);
$(that).text("LOAD MORE");
}else{
jQuery('#loadMore').html("<a href='#'>No more posts</a>");
}
});
});
$('.humbrgr-menu-btn').on('click', function () {
$('.menus-wraper').addClass('menu-slide');
});
$('.close-menu-btn').on('click', function () {
$('.menus-wraper').removeClass('menu-slide');
});
$("body").on("click",".event-down-arrow",function(e){
e.preventDefault();
window.scrollBy( 0, 500 );
});
$("select.filter-categories").niceSelect();
$("select.filter-regions").niceSelect();
$("body").on("change",".filter-categories",function(){
var categoires = $(this).val();
var title = $(".lif-team-item").data("title");
var data = categoires + "&action=lifeline_ajax&subaction=lif_team_categories";
$.ajax({
url:lifeline_data.ajaxurl,
type:"POST",
data: "data=" + data + "&title=" + title,
beforeSend: function() {
console.log( 'loading....' );
},
success: function( res ) {
if( res.success == true ) {
$(".lif-team.style2 .lif-team-row").empty();
$(".lif-team.style2 .lif-team-row").html( res.data.post );
$(".lif-team.style2").siblings(".pagination-wrap").remove();
}
}
});
});
$("body").on("change",".filter-regions",function(){
var regions = $(this).val();
var title = $(".lif-team-item").data("title");
var data = regions + "&action=lifeline_ajax&subaction=lif_team_regions";
$.ajax({
url:lifeline_data.ajaxurl,
type:"POST",
data: "data=" + data + "&title=" + title,
beforeSend: function() {
console.log( 'loading....' );
},
success: function( res ) {
if( res.success == true ) {
$(".lif-team.style2 .lif-team-row").empty();
$(".lif-team.style2 .lif-team-row").html( res.data.post );
$(".lif-team.style2").siblings(".pagination-wrap").remove();
}
}
});
});
$("body").on("keyup",".filter-search input",function(e){
e.preventDefault();
let keycode = (event.keyCode ? event.keyCode : event.which);
if ( keycode == '13' ) {
var name = $("#team-search").val();
if( name != '' ) {
var title = $(".lif-team-item").data("title");
var data = name + "&action=lifeline_ajax&subaction=lif_team_names";
$.ajax({
url:lifeline_data.ajaxurl,
type:"POST",
data: "data=" + data + "&title=" + title,
beforeSend: function() {
console.log( 'loading....' );
},
success: function( res ) {
if( res.success == true ) {
$(".lif-team.style2 .lif-team-row").empty();
$(".lif-team.style2 .lif-team-row").html( res.data.post );
$(".lif-team.style2").siblings(".pagination-wrap").remove();
}
}
});
} else {
alert( 'Please fill the field' );
}
}
});
$("body").on("click",".filter-search a",function(e){
e.preventDefault();
var name = $("#team-search").val();
if( name != '' ) {
var title = $(".lif-team-item").data("title");
var data = name + "&action=lifeline_ajax&subaction=lif_team_names";
$.ajax({
url:lifeline_data.ajaxurl,
type:"POST",
data: "data=" + data + "&title=" + title,
beforeSend: function() {
console.log( 'loading....' );
},
success: function( res ) {
if( res.success == true ) {
$(".lif-team.style2 .lif-team-row").empty();
$(".lif-team.style2 .lif-team-row").html( res.data.post );
$(".lif-team.style2").siblings(".pagination-wrap").remove();
}
}
});
} else {
alert( 'Please fill the field' );
}
});
if ( $.isFunction($.fn.slick) ) {
$('.product-gallery-for').slick({
slidesToShow: 1,
slidesToScroll: 1,
arrows: false,
fade: true,
draggable:false,
swipe:false,
asNavFor: '.product-gallery-nav'
});
$('.product-gallery-nav').slick({
slidesToShow: 3,
slidesToScroll: 1,
asNavFor: '.product-gallery-for',
dots: false,
arrows: false,
centerMode: false,
vertical: false,
focusOnSelect: true
});
}
$("body").on( "click", "#mini-popups", function(e){
e.preventDefault();
$(".popup-items").css({"transform" : "translateX(0%)" });
});
$("body").on('click', '.cross-bar', function(){
$(".popup-items").css({"transform" : "translateX(100%)"});
});
});