Каков будет скрипт, открывающий закрывающий блок в модальном окне?
В самом модальном окне контент загружается через ajax
Модельное окно открывается по скрипту:
$('.popup-post-modal-open').bind('click', DimaPopup);
$('.popup-background').bind('click', Popupclose);
function DimaPopup(e){
e.preventDefault();
$('.popup-background').css('opacity', '1');
$('.popup-background').css('visibility', 'visible');
var url = $(this).attr('href');
// А вот так просто меняется ссылка
if(url != window.location){
window.history.pushState(null, null, url);
}
$('.popup-loader').fadeIn(100);
$('.popup-post').addClass('active');
window.setTimeout(function(){$('.popup-post').scrollTop(0);},50);
$('#content_owerflow').addClass('active');
$('body').addClass('html_noscroll');
$('body').css('padding-right', '17px');
$.ajax(
{
type : 'POST',
url : 'https://' + location.host + '/wp-admin/admin-ajax.php',
data: { action: 'popup_post', popup_post_id:$(this).parents('.title').children('.post-click-popup').children('span').text()
},
success: function(data){
$('.post-generat-content').eq(0).html(data);
$('.popup-loader').fadeOut(100);
$('.close').bind('click', Popupclose);
},
error: function(error)
{
console.log('Ошибка');
}
});
}
var window_location = window.location.href;
function Popupclose() {
$('.popup-background').css('opacity', '0');
$('.popup-background').css('visibility', 'hidden');
$('.popup-post').removeClass('active');
window.history.pushState(null, null, window_location);
$('body').removeClass('html_noscroll');
$('body').css('padding-right', '0');
}
window.addEventListener('popstate', function(e) {
$('.popup-background').css('opacity', '0');
$('.popup-background').css('visibility', 'hidden');
$('.popup-post').removeClass('active');
$('body').removeClass('html_noscroll');
$('body').css('padding-right', '0');
var url = $(this).attr('href');
if(url != window.history.back){
window.history.pushState(null, null, null);
}
});
Спасибо!