new header

This commit is contained in:
Jerry
2022-07-26 15:26:16 +02:00
parent c3016b95aa
commit 4827adde21
17 changed files with 946 additions and 1150 deletions

View File

@@ -26,7 +26,7 @@ $scripts = [];
window.top.location = lawCartaDomain + '/catalog';
}
</script>
<script src="<?= get_lawcarta_url()?>/assets/front-settings<?php if(isset($_GET['law']) && $_GET['law'] == 1 ):?>?law=1<?php endif;?>"></script>
<script src="http://localhost:8001/assets/front-settings<?php if(isset($_GET['law']) && $_GET['law'] == 1 ):?>?law=1<?php endif;?>"></script>
<?php
$baseTemplate = basename( get_page_template() );
if ($baseTemplate == 'page_home.php'):?>
@@ -112,86 +112,241 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
$the_page = sanitize_post( $GLOBALS['wp_the_query']->get_queried_object() );
$slug = $the_page->post_name;
if ($slug != 'publish-your-book'):?>
<header>
<div id="header-menu" class="cont">
<a href="<?= site_url(); ?>" class="main-logo"><img alt="Logo test" src="<?= get_theme_file_uri('/assets/img/logo.svg'); ?>"></a>
<header class="header">
<div class="cont">
<div class="header-cont">
<button class="header-menu-toggle header-btn mobile">
<span class="icon-menu"></span>
</button>
<a href="#" class="logo">
<picture>
<source media="(min-width: 600px)" srcset="<?= get_lawcarta_url()?>/img/logo.svg" width="130" height="23">
<img src="<?= get_lawcarta_url()?>/img/logo-mobile.svg" alt="Logo" width="36" height="36">
</picture>
</a>
<div class="desktop-menu">
</div>
<div class="header-search">
<div class="search-input with-btn">
<div class="si-flex">
<div class="close-search">
<button class="header-btn">
<span class="icon-back"></span>
</button>
</div>
<div class="left">
<span class="icon-search hide-sm"></span>
<button class="button clear link">
<span class="icon-close"></span>
</button>
<input type="text" class="form-control" placeholder="Search books and study materials">
</div>
<div class="right">
<button class="button action">
<span class="icon-search"></span>
</button>
</div>
</div>
</div>
<button class="header-btn open-search">
<span class="icon-search"></span>
</button>
</div>
<div class="header-right-menu"></div>
</div>
<div class="mobile-menu">
<div class="mm-bg"></div>
<button class="close-header-menu header-btn">
<span class="icon-close"></span>
</button>
<div class="mm-cont">
<div class="mobile-links-cont">
</div>
<!-- <div class="acc-manage">
<span class="label">Manage account:</span>
<a href="#" class="menu-link">Other Account</a>
</div> -->
<div class="mm-links">
<?php
if (has_nav_menu('top')) {
wp_nav_menu([
'menu' => 'top',
'menu_class' => 'navTab nav',
'container' => 'div',
'container_class' => 'header-menu',
'depth' => 1,
'walker' => new LawCarta_Walker_Nav_Menu(),
'icon_wrap' => 'i',
'theme_location' => 'top',
]);
</div>
<div class="mobile-sign-cont"></div>
</div>
</div>
</div>
<script>
(function(){
function drawHeader() {
let appUrl = 'https://app.livecarta.com';
let wpUrl = 'https://livecarta.com';
let isGuest = true;
let sharedAccounts = [];
let showAccountAccess = true;
let showAdmin = true;
let showConfirmationNotice = false;
let showRoyaltiesAndSales = true;
let currentPage = location.pathname;
if (typeof frontSettings !== 'undefined') {
appUrl = frontSettings.appUrl;
wpUrl = frontSettings.wordPressUrl;
isGuest = frontSettings.isGuest;
}
if (!isGuest) {
sharedAccounts = frontSettings.sharedAccounts;
showAccountAccess = frontSettings.showAccountAccess;
showAdmin = frontSettings.showAdmin;
showConfirmationNotice = frontSettings.showConfirmationNotice;
showRoyaltiesAndSales = frontSettings.showRoyaltiesAndSales;
}
let linksObject = {
home: wpUrl,
dashboard: appUrl + '/dashboard',
catalog: appUrl + '/catalog',
library: appUrl + '/library',
bundles: appUrl + '/bundle',
features: wpUrl + '/features',
blog: wpUrl + '/blog',
aboutUs: wpUrl + '/about-us',
cart: appUrl + '/checkout/cart',
login: appUrl + '/user/login',
signUp: appUrl + '/user/registration',
profile: appUrl + '/user/registration/profile',
royalties: appUrl + '/report/royalties',
order: appUrl + '/report/transactions',
accountAccess: appUrl + '/user/registration/account-access',
accountManage: appUrl + '/user/account/<id>/manage',
admin: appUrl + '/admin',
logout: appUrl + '/user/logout'
};
let isPageSelected = {
home: currentPage === '/' ? ' selected' : '',
features: currentPage.indexOf('/features') === 0 ? ' selected' : '',
blog: currentPage.indexOf('/blog') === 0 ? ' selected' : '',
aboutUs: currentPage.indexOf('/about-us') === 0 ? ' selected' : ''
}
let desktopLinks = '';
if (isGuest) desktopLinks += '<a href="' + linksObject.home + '" class="menu-link movable' + isPageSelected.home +'">Home</a>';
if (!isGuest) desktopLinks += '<a href="' + linksObject.dashboard + '" class="menu-link movable">Dashboard</a>';
desktopLinks += '<a href="' + linksObject.catalog + '" class="menu-link movable">Catalog</a>';
if (!isGuest) desktopLinks += '<a href="' + linksObject.library + '" class="menu-link movable">My Library</a>';
if (!isGuest) desktopLinks += '<a href="' + linksObject.bundles + '" class="menu-link movable">Bundles</a>';
if (isGuest) desktopLinks += '<a href="' + linksObject.features + '" class="menu-link movable' + isPageSelected.features +'">Features</a>';
desktopLinks += '<a href="' + linksObject.blog + '" class="menu-link movable' + isPageSelected.blog +'">Blog</a>';
if (isGuest) desktopLinks += '<a href="' + linksObject.aboutUs + '" class="menu-link movable' + isPageSelected.aboutUs +'">About Us</a>';
document.querySelector('.desktop-menu').innerHTML = desktopLinks;
let hrmHtml = '';
let mmSign = '';
if (isGuest) {
hrmHtml += `
<div class="desktop-sign-cont">
<a href="` + linksObject.login + `" class="sign-link button action">Log In</a>
<a href="` + linksObject.signUp + `" class="sign-link button secondary">Sign Up</a>
</div>
`;
mmSign += `
<a href="` + linksObject.login + `" class="sign-link button action">Log In</a>
<a href="` + linksObject.signUp + `" class="sign-link button secondary">Sign Up</a>
`;
}
if (!isGuest) {
hrmHtml += `
<button class="header-btn circle header-menu-toggle">
<span class="icon-profile"></span>
</button>
`;
}
hrmHtml += `
<a class="header-btn circle" href="` + linksObject.cart + `">
<span class="icon-shop"></span>
</a>
`;
document.querySelector('.header-right-menu').innerHTML = hrmHtml;
document.querySelector('.mobile-sign-cont').innerHTML = mmSign;
let mmHtml = '';
if (!isGuest) {
mmHtml += '<a href="' + linksObject.profile + '" class="menu-link">My Profile</a>';
if (showRoyaltiesAndSales) mmHtml += '<a href="' + linksObject.royalties + '" class="menu-link">Royalties and Sales</a>';
mmHtml += '<a href="' + linksObject.order + '" class="menu-link">Order History</a>';
if (showAccountAccess) mmHtml += '<a href="' + linksObject.accountAccess + '" class="menu-link">Account Access</a>';
if (showAdmin) mmHtml += '<a href="' + linksObject.admin + '" class="menu-link">Admin</a>';
mmHtml += '<a href="' + linksObject.logout + '" class="menu-link">Logout</a>';
}
document.querySelector('.mm-links').innerHTML = mmHtml;
}
?>
</div>
<div class="mobile-menu">
<a href="#" class="btn-toggle-menu">
<i class="icon-menu" title="Menu"></i>
<i class="icon-close" title="Close"></i>
</a>
</div>
<div class="mobile-nav" style="display: none;">
<div class="mm-bg">
<?php
if (has_nav_menu('top')) {
wp_nav_menu([
'menu' => 'top',
'menu_class' => 'navTab nav',
'container' => 'div',
'container_class' => 'header-menu',
'depth' => 1,
'walker' => new LawCarta_Walker_Nav_Menu(),
'icon_wrap' => 'i',
'theme_location' => 'top',
]);
}
?>
window.addEventListener('DOMContentLoaded', (event) => {
let headerSearch = document.querySelector('.header-search .form-control');
let headerSearchCont = document.querySelector('.header-search .search-input');
let mobileMenu = document.querySelector('.header .mobile-menu');
let mobileCont = document.querySelector('.mobile-links-cont');
let desktopCont = document.querySelector('.desktop-menu');
drawHeader();
headerSearch.addEventListener('focus', () => {
headerSearchCont?.classList.add('open');
});
headerSearch.addEventListener('blur', () => {
headerSearchCont?.classList.remove('open');
});
const moveMenu = function(){
let menuItems = document.querySelectorAll('.menu-link.movable');
let contToMoveTo = window.innerWidth >= 992 ? desktopCont : mobileCont;
menuItems.forEach(item => contToMoveTo.appendChild(item));
}
moveMenu();
window.addEventListener('resize', moveMenu, {passive: true});
window.addEventListener('orientationchange', moveMenu, {passive: true});
document.addEventListener('click', event => {
if (event.target?.closest('.open-search')) {
headerSearchCont?.classList.add('open-search-panel');
headerSearchCont.querySelector('.form-control').focus();
}
if (event.target?.closest('.close-search')) {
headerSearchCont?.classList.remove('open-search-panel');
}
if (event.target?.closest('.header-menu-toggle') ||
event.target?.closest('.close-header-menu') ||
event.target?.closest('.mm-bg')) {
setTimeout(() => {
mobileMenu?.classList.toggle('open');
}, 1);
}
if (!event.target.closest('.mobile-menu.open')) {
mobileMenu?.classList.remove('open');
}
})
});
})();
</script>
<!-- <div class="header-menu static">-->
<!-- <ul id="w3" class="navTab nav">-->
<!-- <li><a href="http://lawcarta.loc/casebook/lib">My Library</a></li>-->
<!-- <li><a href="http://lawcarta.loc/course">Courses</a></li>-->
<!-- <li><a class="header-menu-point nav-shop" href="http://lawcarta.loc/checkout/cart">My Cart (0) <i class="icon-shop"></i></a></li>-->
<!-- </ul>-->
<!-- </div>-->
<!---->
<!-- <div class="sign-block">-->
<!---->
<!-- <ul id="w4" class="signed-user-block nav">-->
<!-- <li class="dropdown">-->
<!-- <a class="signed-user dropdown-toggle" href="#" data-toggle="dropdown">Zheka <span class="icon-account-settings"></span> <span class="icon-caret"></span></a>-->
<!-- <ul id="w5" class="dropdown-menu">-->
<!-- <li>-->
<!-- <a href="http://lawcarta.loc/user/registration/profile" tabindex="-1">My Profile</a></li>-->
<!-- <li>-->
<!-- <a href="http://lawcarta.loc/report/royalties" tabindex="-1">Royalties</a>-->
<!-- </li>-->
<!-- <li>-->
<!-- <a href="http://lawcarta.loc/report/transactions" tabindex="-1">Transaction History</a></li>-->
<!-- <li>-->
<!-- <a href="http://lawcarta.loc/user/admin/index?sort=-created_at" tabindex="-1">Admin</a>-->
<!-- </li>-->
<!-- <li>-->
<!-- <a href="http://lawcarta.loc/user/logout" data-method="post" tabindex="-1">Logout</a>-->
<!-- </li>-->
<!-- </ul>-->
<!-- </li>-->
<!-- </ul>-->
<!-- </div>-->
<!-- <div class="sign-block">-->
<!-- <a href="#" class="button bordered">LOGIN</a>-->
<!-- <a href="#" class="button bordered">REGISTER</a>-->
<!-- </div>-->
</div>
</div>
<?php
$post = get_post();
if($post && $post->post_type == 'post'){
@@ -200,54 +355,6 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
$slug = basename(get_permalink());
}
?>
<iframe src="<?= get_lawcarta_url()?>/menu?slug=<?=$slug?>" style="display: none;"></iframe>
<script type="application/javascript">
var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
var eventer = window[eventMethod];
var messageEvent = eventMethod === "attachEvent" ? "onmessage" : "message";
eventer(messageEvent, function (ev) {
if (ev.origin.indexOf('<?= get_lawcarta_url()?>') !== -1) {
// document.getElementById('header-menu').insertAdjacentHTML('beforeend', ev.data);
$('body').append('<div id="header-parser"></div>');
$('#header-parser').append(ev.data);
var inHTML;
if ($('#header-parser .header-menu').length){
$('.header-menu ul').each(function(){
$(this).append($('#header-parser .header-menu ul').html());
});
}
if ($('#header-parser .sign-block').length){
inHTML = $('#header-parser .sign-block')[0].outerHTML;
$('header .cont').append(inHTML);
$('.mobile-nav .mm-bg').append(inHTML);
}
if ($('#header-parser #is-guest').length){
$('#header-parser #is-guest').appendTo($('header .cont'));
}
// $('#header-parser').hide();
$('#header-parser').remove();
if ($('#is-guest').text() == 'true') {
$('.guest-data').css('display', 'inline-block');
$('.mobile-nav .guest-data').css('display', 'block');
} else {
$('.home-label').text('Dashboard').attr('href', '<?= get_lawcarta_url()?>/dashboard');
if (typeof isHomeTemplate != 'undefined' && isHomeTemplate === true) {
window.location.href = lawCartaDomain + '/dashboard';
}
}
}
});
jQuery('.btn-toggle-menu').on('click', function (e) {
e.preventDefault();
jQuery(this).toggleClass('on');
jQuery('.mobile-nav').toggleClass('show');
});
</script>
<script src="<?= get_lawcarta_url()?>/assets/url-track"></script>
<script src="<?= get_lawcarta_url()?>/assets/fireworks"></script>
<script src="<?= get_lawcarta_url()?>/assets/redirect-popup"></script>