jQuery(function($){
function detectLanguageChange(){
var currentLanguage=localStorage.getItem('wpml_current_language');
var newLanguage=$('html').attr('lang');
if(currentLanguage!==newLanguage &&
(newLanguage.toLowerCase()==='en-us'||newLanguage.toLowerCase()==='zh-hans')){
localStorage.setItem('wpml_current_language', newLanguage);
localStorage.removeItem('source_archive_new');
}}
detectLanguageChange();
$(document).on('wpml_language_changed', function(){
detectLanguageChange();
});
});
jQuery(function($){
$(document).on('blur','#is-search-input-851, #is-search-input-646, #is-search-input-6085',function(){
localStorage.removeItem("source_archive_new");
});
$(document).on('click', '.share_view_download .share', function(e){
e.preventDefault();
$(this).parents('.resource_tolkit_block').find('.resource_share_wrapper').slideToggle('fast');
});
$(document).on('click', '#af-yes', function(e){
if($(this).attr("data-event")){
return false;
}else{
$(this).attr('data-event',1);
$('#af-no').attr('data-event',2);
add_help_ar(1);
}});
$(document).on('click', '#af-no', function(e){
if($(this).attr("data-event")){
return false;
}else{
$(this).attr('data-event',2);
$('#af-yes').attr('data-event',1);
add_help_ar(2);
}});
$(document).on('click', '.pp-post-title a, .pp-post-thumbnail-wrap a', function(e){
var html_val=$(this).parent().prev().prev().html()
localStorage.setItem("source_archive_new", html_val);
});
var bSourceArchive=localStorage.getItem("source_archive_new");
if(bSourceArchive==null||bSourceArchive=='undefined'){
$('.default_breadcrumb').removeClass('hide_before_load');
$('.new_breadcrumb').show();
$('#post_cat_id_ne').removeClass('hide_before_load');
$('.details_post_breadcrumbs').hide();
custom_methods('.new_breadcrumb','.last_category_item_1');
}else{
$('.new_breadcrumb').hide();
$('.details_post_breadcrumbs').not('.new_breadcrumb').html('<div class="append-breadcrumb">'+ bSourceArchive + '</div>');
setTimeout(custom_methods('.append-breadcrumb','.last_category_item_2'),1000);
}});
function custom_methods(parent,child){
var value='';
var slug='';
var post_id='';
var child_lenght=jQuery(child).length;
if(child_lenght!=0){
jQuery(child).each(function(){
value=jQuery(this).text();
slug=jQuery(this).attr('data-tax');
post_id=jQuery('body').attr('data-id');
return false;
});}else{
var post_id=jQuery('body').attr('data-id');
}
var value_l=jQuery(child).length;
var data={
action: 'dementiahub_get_title',
catgory_name: value,
slug:slug,
post_id:post_id,
};
jQuery.ajax({
url: dementiahub_ajax_hook.ajaxurl,
data: data,
type: 'POST',
beforeSend: function(xhr){
},
success: function(data){
if(data){
jQuery('#related_article_dementia').removeClass('related_article_hide');
jQuery('#related_articles').html(data);
jQuery('.related_articles').slick({
dots: false,
arrows: true,
infinite: true,
speed: 300,
slidesToShow: 4,
slidesToScroll: 1,prevArrow: '<div class="slick-prev"><i class="fa fa-angle-left" aria-hidden="true"></i></div>',
nextArrow: '<div class="slick-next"><i class="fa fa-angle-right" aria-hidden="true"></i></div>',
responsive: [
{
breakpoint: 1024,
settings: {
slidesToShow: 3,
slidesToScroll: 1,
infinite: true
}},
{
breakpoint: 600,
settings: {
slidesToShow: 2,
slidesToScroll: 1
}},
{
breakpoint: 480,
settings: {
slidesToShow: 2,
slidesToScroll: 1
}},
{
breakpoint: 413,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}}
]
});
}else{
jQuery('#related_article_dementia').addClass('related_article_hide');
}}
});
}
function add_help_ar(type){
var post_id=jQuery('body').attr('data-id');
var data={
action: 'add_help_data',
type: type,
post_id:post_id,
};
jQuery.ajax({
url: dementiahub_ajax_hook.ajaxurl,
data: data,
type: 'POST',
beforeSend: function(xhr){
},
success: function(data){
if(data){
}else{
}}
});
};