@ -0,0 +1,6 @@ |
||||
<?php |
||||
|
||||
include_module('author'); |
||||
include_component('author', 'author-archive'); |
||||
|
||||
?> |
@ -0,0 +1,211 @@ |
||||
<?php |
||||
if (!defined('ABSPATH')) { |
||||
exit; |
||||
} |
||||
|
||||
function count_nested_replies($comment_id) { |
||||
$count = 0; |
||||
$replies = get_comments(array( |
||||
'post_id' => get_the_ID(), |
||||
'status' => 'approve', |
||||
'parent' => $comment_id, |
||||
'order' => 'ASC' |
||||
)); |
||||
|
||||
if ($replies) { |
||||
$count += count($replies); |
||||
foreach ($replies as $reply) { |
||||
$count += count_nested_replies($reply->comment_ID); |
||||
} |
||||
} |
||||
|
||||
return $count; |
||||
} |
||||
|
||||
if (post_password_required()) { |
||||
return; |
||||
} |
||||
|
||||
if (!is_user_logged_in()) { |
||||
?> |
||||
<div class="comment-block"> |
||||
<p class="comment-block_text"> |
||||
<a href="#modal"><?php pll_e('Войдите'); ?></a>, <?php pll_e('чтобы оставлять комментарии'); ?> |
||||
</p> |
||||
</div> |
||||
<?php |
||||
} |
||||
|
||||
$top_level_comments = get_comments(array( |
||||
'post_id' => get_the_ID(), |
||||
'status' => 'approve', |
||||
'parent' => 0, |
||||
'order' => 'ASC' |
||||
)); |
||||
|
||||
if ($top_level_comments) { |
||||
echo '<div class="comment-block_wrapper">'; |
||||
|
||||
foreach ($top_level_comments as $comment) { |
||||
?> |
||||
<div class="comment-block" id="comment-<?php echo $comment->comment_ID; ?>">
|
||||
<div class="comment-user"> |
||||
<?php echo get_avatar($comment, 50); ?> |
||||
<div class="comment-user_text"> |
||||
<h6><?php echo get_comment_author($comment); ?></h6>
|
||||
<span><?php echo get_comment_date('d F Y', $comment); ?></span>
|
||||
</div> |
||||
</div> |
||||
<p><?php echo get_comment_text($comment); ?></p>
|
||||
<div class="comment-btns"> |
||||
<button class="reply-to-comment" data-comment-id="<?php echo $comment->comment_ID; ?>" data-post-id="<?php echo get_the_ID(); ?>" data-reply-to="<?php echo esc_attr(get_comment_author($comment)); ?>">
|
||||
<svg width="11" height="8" viewBox="0 0 11 8" fill="none" xmlns="http://www.w3.org/2000/svg"> |
||||
<path d="M9.5 3H3.25C2.00736 3 1 4.00736 1 5.25V5.25C1 6.49264 2.00736 7.5 3.25 7.5H3.5" stroke="#666666"></path> |
||||
<path d="M7 0.5L9.5 3L7 5.5" stroke="#666666"></path> |
||||
</svg> |
||||
<?php pll_e('Ответить'); ?> |
||||
</button> |
||||
<button class="comment-like-btn<?php echo is_user_liked_comment($comment->comment_ID) ? ' active' : ''; ?>" data-comment-id="<?php echo $comment->comment_ID; ?>">
|
||||
<svg width="15" height="13" viewBox="0 0 15 13" fill="none" xmlns="http://www.w3.org/2000/svg"> |
||||
<path d="M10.7745 1C8.67239 1 7.7426 2.5355 7.54047 3.30325C7.39224 2.5355 6.49748 1 4.10427 1C1.11276 1 -0.221288 4.85199 2.40639 8.14801C4.50853 10.7848 6.705 11.8147 7.54047 12C8.47026 11.8279 10.8311 10.761 12.8363 7.87004C15.3427 4.25632 13.4022 1 10.7745 1Z" <?php echo is_user_liked_comment($comment->comment_ID) ? 'stroke="#ff0000" fill="rgba(255, 0, 0, 0.7)"' : 'stroke="#666666"'; ?>></path>
|
||||
</svg> |
||||
<?php echo get_comment_likes_count($comment->comment_ID); ?> |
||||
</button> |
||||
<?php |
||||
comment_reply_link(array( |
||||
'reply_text' => pll__('Ответить'), |
||||
'depth' => 1, |
||||
'max_depth' => get_option('thread_comments_depth'), |
||||
'before' => '<span style="display:none;">', |
||||
'after' => '</span>', |
||||
), $comment->comment_ID, get_the_ID()); |
||||
?> |
||||
</div> |
||||
<div class="reply-form-container" id="reply-form-<?php echo $comment->comment_ID; ?>" style="display: none;"></div>
|
||||
</div> |
||||
<?php |
||||
|
||||
$all_nested_replies = get_all_nested_replies($comment->comment_ID); |
||||
|
||||
if (!empty($all_nested_replies)) { |
||||
$total_reply_count = count($all_nested_replies); |
||||
?> |
||||
<button class="answer-btn"> |
||||
<svg width="15" height="10" viewBox="0 0 15 10" fill="none" xmlns="http://www.w3.org/2000/svg"> |
||||
<path d="M14 1.41406L7.5 7.91406L1 1.41406" stroke="#76CE75" stroke-width="2"></path> |
||||
</svg> |
||||
<?php echo $total_reply_count; ?> |
||||
<span> |
||||
<?php echo ($total_reply_count == 1) ? pll__('ответ') : pll__('ответа'); ?> |
||||
</span> |
||||
</button> |
||||
<?php |
||||
|
||||
foreach ($all_nested_replies as $reply) { |
||||
?> |
||||
<div class="comment-block answer-block" id="comment-<?php echo $reply->comment_ID; ?>">
|
||||
<div class="comment-user"> |
||||
<?php echo get_avatar($reply, 50); ?> |
||||
<div class="comment-user_text"> |
||||
<h6><?php echo get_comment_author($reply); ?></h6>
|
||||
<span><?php echo get_comment_date('d F Y', $reply); ?></span>
|
||||
</div> |
||||
</div> |
||||
<p><?php echo get_comment_text($reply); ?></p>
|
||||
<div class="comment-btns"> |
||||
<button class="reply-to-comment" data-comment-id="<?php echo $reply->comment_ID; ?>" data-post-id="<?php echo get_the_ID(); ?>" data-reply-to="<?php echo esc_attr(get_comment_author($reply)); ?>">
|
||||
<svg width="11" height="8" viewBox="0 0 11 8" fill="none" xmlns="http://www.w3.org/2000/svg"> |
||||
<path d="M9.5 3H3.25C2.00736 3 1 4.00736 1 5.25V5.25C1 6.49264 2.00736 7.5 3.25 7.5H3.5" stroke="#666666"></path> |
||||
<path d="M7 0.5L9.5 3L7 5.5" stroke="#666666"></path> |
||||
</svg> |
||||
<?php pll_e('Ответить'); ?> |
||||
</button> |
||||
<button class="comment-like-btn<?php echo is_user_liked_comment($reply->comment_ID) ? ' active' : ''; ?>" data-comment-id="<?php echo $reply->comment_ID; ?>">
|
||||
<svg width="15" height="13" viewBox="0 0 15 13" fill="none" xmlns="http://www.w3.org/2000/svg"> |
||||
<path d="M10.7745 1C8.67239 1 7.7426 2.5355 7.54047 3.30325C7.39224 2.5355 6.49748 1 4.10427 1C1.11276 1 -0.221288 4.85199 2.40639 8.14801C4.50853 10.7848 6.705 11.8147 7.54047 12C8.47026 11.8279 10.8311 10.761 12.8363 7.87004C15.3427 4.25632 13.4022 1 10.7745 1Z" <?php echo is_user_liked_comment($reply->comment_ID) ? 'stroke="#ff0000" fill="rgba(255, 0, 0, 0.7)"' : 'stroke="#666666"'; ?>></path>
|
||||
</svg> |
||||
<?php echo get_comment_likes_count($reply->comment_ID); ?> |
||||
</button> |
||||
<?php |
||||
comment_reply_link(array( |
||||
'reply_text' => pll__('Ответить'), |
||||
'depth' => 2, |
||||
'max_depth' => get_option('thread_comments_depth'), |
||||
'before' => '<span style="display:none;">', |
||||
'after' => '</span>', |
||||
), $reply->comment_ID, get_the_ID()); |
||||
?> |
||||
</div> |
||||
<div class="reply-form-container" id="reply-form-<?php echo $reply->comment_ID; ?>" style="display: none;"></div>
|
||||
</div> |
||||
<?php |
||||
} |
||||
} |
||||
} |
||||
|
||||
echo '</div>'; |
||||
} |
||||
|
||||
function get_all_nested_replies($comment_id) { |
||||
$all_replies = array(); |
||||
|
||||
$direct_replies = get_comments(array( |
||||
'post_id' => get_the_ID(), |
||||
'status' => 'approve', |
||||
'parent' => $comment_id, |
||||
'order' => 'ASC' |
||||
)); |
||||
|
||||
$all_replies = array_merge($all_replies, $direct_replies); |
||||
|
||||
foreach ($direct_replies as $reply) { |
||||
$deeper_replies = get_all_nested_replies_recursive($reply->comment_ID); |
||||
$all_replies = array_merge($all_replies, $deeper_replies); |
||||
} |
||||
|
||||
return $all_replies; |
||||
} |
||||
|
||||
function get_all_nested_replies_recursive($comment_id) { |
||||
$replies = get_comments(array( |
||||
'post_id' => get_the_ID(), |
||||
'status' => 'approve', |
||||
'parent' => $comment_id, |
||||
'order' => 'ASC' |
||||
)); |
||||
|
||||
$all_replies = $replies; |
||||
|
||||
foreach ($replies as $reply) { |
||||
$deeper_replies = get_all_nested_replies_recursive($reply->comment_ID); |
||||
$all_replies = array_merge($all_replies, $deeper_replies); |
||||
} |
||||
|
||||
return $all_replies; |
||||
} |
||||
|
||||
if (is_user_logged_in()) { |
||||
$commenter = wp_get_current_commenter(); |
||||
$args = array( |
||||
'fields' => array( |
||||
'author' => '', |
||||
'email' => '', |
||||
'url' => '', |
||||
'cookies' => '', |
||||
), |
||||
'comment_field' => '<div class="comment-form-comment"><textarea id="comment" name="comment" placeholder="' . pll__('Ваш комментарий') . '" required></textarea></div>', |
||||
'title_reply' => pll__('Оставить комментарий'), |
||||
'title_reply_to' => pll__('Ответить %s'), |
||||
'class_submit' => 'comment-submit-btn', |
||||
'submit_button' => '<button name="%1$s" type="submit" id="%2$s" class="%3$s">%4$s</button>', |
||||
'submit_field' => '<div class="form-submit">%1$s %2$s</div>', |
||||
'cancel_reply_link' => pll__('Отменить'), |
||||
'id_form' => 'commentform', |
||||
'id_submit' => 'submit', |
||||
'title_reply_before' => '<h3 id="reply-title" class="comment-reply-title">', |
||||
'title_reply_after' => '</h3>', |
||||
); |
||||
|
||||
comment_form($args); |
||||
} |
||||
?> |
@ -1,5 +1,11 @@ |
||||
{ |
||||
"require": { |
||||
"timber/timber": "^2.1" |
||||
"timber/timber": "^2.1", |
||||
"mindkomm/timber-integration-woocommerce": "^1.0" |
||||
}, |
||||
"config": { |
||||
"allow-plugins": { |
||||
"composer/installers": true |
||||
} |
||||
} |
||||
} |
||||
|
@ -1,2 +1,263 @@ |
||||
<?php |
||||
|
||||
add_action('template_redirect', 'redirect_non_logged_in_users'); |
||||
|
||||
function redirect_non_logged_in_users() { |
||||
// URL личного кабинета (замените 'your-account-page-slug' на ваш slug) |
||||
$account_page_slug = 'my-account-3'; |
||||
$account_page_slug__2 = 'my-account'; |
||||
// Проверяем, находится ли пользователь на странице личного кабинета |
||||
if (is_page($account_page_slug) && !is_user_logged_in() || is_page($account_page_slug__2) && !is_user_logged_in() ) { |
||||
wp_redirect(home_url()); // Перенаправляем на главную страницу |
||||
exit; |
||||
} |
||||
} |
||||
|
||||
add_action('init', 'register_pets'); |
||||
function register_pets(){ |
||||
register_post_type('pets', array( |
||||
'labels' => array( |
||||
'name' => 'Питомцы', // Основное название типа записи |
||||
'singular_name' => 'Питомец', // отдельное название записи типа Book |
||||
'add_new' => 'Добавить нового', |
||||
'add_new_item' => 'Добавить нового питомца', |
||||
'edit_item' => 'Редактировать питомца', |
||||
'new_item' => 'Новый питомец', |
||||
'view_item' => 'Посмотреть питомца', |
||||
'search_items' => 'Найти питомца', |
||||
'not_found' => 'Питомцев не найдено', |
||||
'not_found_in_trash' => 'В корзине книг не найдено', |
||||
'parent_item_colon' => '', |
||||
'menu_name' => 'Питомцы' |
||||
|
||||
), |
||||
'public' => false, |
||||
'show_ui' => true, |
||||
'supports' => array('title','editor') |
||||
) ); |
||||
} |
||||
|
||||
function get_pet_card($item){ |
||||
?> |
||||
<?php |
||||
|
||||
switch (get_field('weight')){ |
||||
case ('below_1_5'): |
||||
$w = esc_html__('from 0,5 kg to 1,5 kg', 'woodmart' ); |
||||
break; |
||||
case ('1_5-3'): |
||||
$w = esc_html__('from 1.5 to 3 kg', 'woodmart' ); |
||||
break; |
||||
case ('3-5'): |
||||
$w = esc_html__('from 3 to 5 kg', 'woodmart' ); |
||||
break; |
||||
case ('5-8'): |
||||
$w = esc_html__('from 5 to 8 kg', 'woodmart' ); |
||||
break; |
||||
case ('8-11'): |
||||
$w = esc_html__('from 8 to 11 kg', 'woodmart' ); |
||||
break; |
||||
case ('11-15'): |
||||
$w = esc_html__('from 11 to 15 kg', 'woodmart' ); |
||||
break; |
||||
case ('15-20'): |
||||
$w = esc_html__('from 15 to 20 kg', 'woodmart' ); |
||||
break; |
||||
case ('20-25'): |
||||
$w = esc_html__('from 20 to 25 kg', 'woodmart' ); |
||||
break; |
||||
|
||||
|
||||
case ('25-35'): |
||||
$w = esc_html__('from 25 to 35 kg', 'woodmart' ); |
||||
break; |
||||
|
||||
|
||||
case ('more_35'): |
||||
$w = esc_html__('More than 35 kg', 'woodmart' ); |
||||
break; |
||||
|
||||
} |
||||
switch (get_field('old')){ |
||||
case ('normal'): |
||||
$old = esc_html__('Adult (from 1 year to 7 years)', 'woodmart' ); |
||||
break; |
||||
case ('old'): |
||||
$old = esc_html__('Elderly (from 7 to 12 years)', 'woodmart' ); |
||||
break; |
||||
case ('very_old'): |
||||
$old = esc_html__('Aging (12 years and older)', 'woodmart' ); |
||||
break; |
||||
case ('baby'): |
||||
$old = esc_html__('Baby (from 0 to 1 year)' ); |
||||
break; |
||||
} |
||||
|
||||
switch (get_field('activity')){ |
||||
case ('low'): |
||||
$act = esc_html__('Low', 'woodmart' ); |
||||
break; |
||||
case ('moderate'): |
||||
$act = esc_html__('Moderate', 'woodmart' ); |
||||
break; |
||||
case ('high'): |
||||
$act = esc_html__('High', 'woodmart' ); |
||||
break; |
||||
|
||||
} |
||||
?> |
||||
<div class="cabinet-card cabinet-card--green"> |
||||
<div class="cabinet-card__content"> |
||||
<div class="cabinet-card__pet"> |
||||
<div class="cabinet-card-pet__icon"> |
||||
<div class="cabinet-card-pet-icon__content"> |
||||
<img src="<?= get_template_directory_uri();?>/gp-include/assets/lk/img/pet/mini-<?php echo get_field('type', $item) ?>.png" alt="">
|
||||
</div> |
||||
</div> |
||||
|
||||
<p class="cabinet-card-pet__name"><?php echo get_the_title($item) ?></p>
|
||||
</div> |
||||
|
||||
<div class="cabinet-card__element"> |
||||
<p class="cabinet-card__label"><?php echo esc_html__('Breed', 'woodmart' ) ?>:</p>
|
||||
<p class="cabinet-card__text"><?php echo get_field('breed', $item) ?></p>
|
||||
</div> |
||||
<div class="cabinet-card__element"> |
||||
<p class="cabinet-card__label"><?php echo esc_html__('Weight', 'woodmart' ) ?>:</p>
|
||||
<p class="cabinet-card__text"><?php echo $w; ?></p>
|
||||
</div> |
||||
<?php if ($old): ?> |
||||
<div class="cabinet-card__element"> |
||||
<p class="cabinet-card__label"><?php echo esc_html__('Age', 'woodmart' ) ?>:</p>
|
||||
<p class="cabinet-card__text"><?php echo $old; ?></p>
|
||||
</div> |
||||
|
||||
<?php |
||||
else: |
||||
?> |
||||
<?php |
||||
$zero = ''; |
||||
if (intval(get_field('month', $item)) < 10){ |
||||
$zero = '0'; |
||||
} |
||||
?> |
||||
<div class="cabinet-card__element"> |
||||
<p class="cabinet-card__label"><?php echo esc_html__('Birhtday', 'woodmart' ) ?>:</p>
|
||||
<p class="cabinet-card__text"><?php echo get_field('day', $item) . '.' . $zero . get_field('month', $item) . '.' . get_field('year', $item); ?></p>
|
||||
</div> |
||||
<?php |
||||
endif; |
||||
?> |
||||
<div class="cabinet-card__element"> |
||||
<p class="cabinet-card__label"><?php echo esc_html__('Activity', 'woodmart' ) ?>:</p>
|
||||
<p class="cabinet-card__text"><?php echo $act; ?></p>
|
||||
</div> |
||||
<?php |
||||
if (get_field('type', $item) == 'cat' && get_field('sterilized', $item)): |
||||
?> |
||||
<div class="cabinet-card__element"> |
||||
<p class="cabinet-card__label"><?php echo esc_html__('Sterilized', 'woodmart' ) ?></p>
|
||||
|
||||
</div> |
||||
<?php |
||||
endif; |
||||
?> |
||||
<div class="cabinet-card__element"> |
||||
<button class="cabinet-card__button" data-edit="<?php echo get_the_ID($item); ?>">
|
||||
<?php echo esc_html__('Edit', 'woodmart' ) ?> |
||||
</button> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<?php |
||||
} |
||||
|
||||
|
||||
// Подключение скриптов и стилей |
||||
// add_action('wp_enqueue_scripts', 'enqueue_checkout_scripts'); |
||||
// function enqueue_checkout_scripts() { |
||||
// if (is_checkout()) { |
||||
// wp_enqueue_style('custom-checkout', get_template_directory_uri() . '/modules/shop/components/checkout/assets/css/checkout.css', [], '1.0.1'); |
||||
// wp_enqueue_script('custom-checkout', get_template_directory_uri() . '/modules/shop/components/checkout/assets/js/script.js', ['jquery'], '1.0.1', true); |
||||
// wp_localize_script('custom-checkout', 'wc_checkout_params', [ |
||||
// 'ajax_url' => admin_url('admin-ajax.php'), |
||||
// 'nonce' => wp_create_nonce('wc_checkout_nonce') |
||||
// ]); |
||||
// } |
||||
// } |
||||
|
||||
// // AJAX-обработчик для обновления количества |
||||
// add_action('wp_ajax_update_cart_quantity', 'update_cart_quantity_callback'); |
||||
// add_action('wp_ajax_nopriv_update_cart_quantity', 'update_cart_quantity_callback'); |
||||
// function update_cart_quantity_callback() { |
||||
// check_ajax_referer('wc_checkout_nonce', 'nonce'); |
||||
|
||||
// $cart_item_key = sanitize_text_field($_POST['cart_item_key']); |
||||
// $quantity = intval($_POST['quantity']); |
||||
|
||||
// if ($quantity > 0) { |
||||
// WC()->cart->set_quantity($cart_item_key, $quantity); |
||||
// } else { |
||||
// WC()->cart->remove_cart_item($cart_item_key); |
||||
// } |
||||
|
||||
// WC()->cart->calculate_totals(); |
||||
|
||||
// // Подготовка фрагментов |
||||
// $fragments = []; |
||||
|
||||
// // Обновление списка товаров |
||||
// ob_start(); |
||||
// wc_get_template('checkout/form-checkout.php', [], '', get_template_directory() . '/woocommerce/'); |
||||
// $fragments['.order-your__products'] = ob_get_clean(); |
||||
|
||||
// // Обновление секции итогов |
||||
// ob_start(); |
||||
// woocommerce_checkout_coupon_form(); |
||||
// woocommerce_order_review(); |
||||
// $fragments['.order-your__calculation'] = ob_get_clean(); |
||||
|
||||
// // Подготовка цен для каждого товара |
||||
// $item_prices = []; |
||||
// foreach (WC()->cart->get_cart() as $item_key => $item) { |
||||
// $item_prices[$item_key] = WC()->cart->get_product_subtotal($item['data'], $item['quantity']); |
||||
// } |
||||
|
||||
// wp_send_json_success([ |
||||
// 'fragments' => $fragments, |
||||
// 'item_prices' => $item_prices, |
||||
// 'cart_total' => WC()->cart->get_cart_total() |
||||
// ]); |
||||
// } |
||||
|
||||
// // AJAX-обработчик для удаления товара |
||||
// add_action('wp_ajax_remove_cart_item', 'remove_cart_item_callback'); |
||||
// add_action('wp_ajax_nopriv_remove_cart_item', 'remove_cart_item_callback'); |
||||
// function remove_cart_item_callback() { |
||||
// check_ajax_referer('wc_checkout_nonce', 'nonce'); |
||||
|
||||
// $cart_item_key = sanitize_text_field($_POST['cart_item_key']); |
||||
// WC()->cart->remove_cart_item($cart_item_key); |
||||
// WC()->cart->calculate_totals(); |
||||
|
||||
// // Подготовка фрагментов |
||||
// $fragments = []; |
||||
|
||||
// // Обновление списка товаров |
||||
// ob_start(); |
||||
// wc_get_template('checkout/form-checkout.php', [], '', get_template_directory() . '/woocommerce/'); |
||||
// $fragments['.order-your__products'] = ob_get_clean(); |
||||
|
||||
// // Обновление секции итогов |
||||
// ob_start(); |
||||
// woocommerce_checkout_coupon_form(); |
||||
// woocommerce_order_review(); |
||||
// $fragments['.order-your__calculation'] = ob_get_clean(); |
||||
|
||||
// wp_send_json_success([ |
||||
// 'fragments' => $fragments, |
||||
// 'cart_total' => WC()->cart->get_cart_total() |
||||
// ]); |
||||
// } |
||||
|
||||
|
||||
|
@ -0,0 +1,185 @@ |
||||
<?php |
||||
|
||||
add_filter('woocommerce_currency_symbol', 'change_aed_currency_symbol', 10, 2); |
||||
|
||||
function change_aed_currency_symbol($currency_symbol, $currency) { |
||||
if ($currency == 'AED') { |
||||
$currency_symbol = 'AED'; |
||||
} |
||||
return $currency_symbol; |
||||
} |
||||
|
||||
add_filter('timber/context', function($context) { |
||||
// Передаем все нужные константы в контекст Twig |
||||
$context['CONSTANTS'] = [ |
||||
'DOMAIN' => defined('SITE_DOMAIN') ? SITE_DOMAIN : null, |
||||
]; |
||||
|
||||
return $context; |
||||
}); |
||||
|
||||
|
||||
// Отключаем канонические ссылки и hreflang от Yoast SEO |
||||
add_filter('wpseo_canonical', '__return_false'); |
||||
add_filter('wpseo_opengraph_url', '__return_false'); // Отключаем OG URL |
||||
add_filter('wpseo_add_x_default_hreflang', '__return_false'); // Отключаем hreflang от Yoast |
||||
add_filter('wpseo_disable_adjacent_rel_links', '__return_true'); // Отключаем соседние rel-ссылки |
||||
|
||||
// Добавляем каноническую ссылку |
||||
add_action('wp_head', 'custom_canonical_url', 5); |
||||
function custom_canonical_url() { |
||||
if (!is_admin()) { |
||||
// Защищаем от дублирования |
||||
static $canonical_added = false; |
||||
if ($canonical_added) { |
||||
return; |
||||
} |
||||
$canonical_added = true; |
||||
|
||||
// Формируем текущий URL без лишних параметров |
||||
$current_url = trailingslashit(home_url($_SERVER['REQUEST_URI'])); |
||||
// Удаляем возможные параметры запроса, если они не нужны |
||||
$current_url = strtok($current_url, '?'); |
||||
echo '<link rel="canonical" href="' . esc_url($current_url) . '" />' . "\n"; |
||||
} |
||||
} |
||||
|
||||
add_action('wp_head', 'add_facebook_pixel'); |
||||
function add_facebook_pixel() { |
||||
?> |
||||
<!-- Meta Pixel Code --> |
||||
<script> |
||||
!function(f,b,e,v,n,t,s) |
||||
{if(f.fbq)return;n=f.fbq=function(){n.callMethod? |
||||
n.callMethod.apply(n,arguments):n.queue.push(arguments)}; |
||||
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0'; |
||||
n.queue=[];t=b.createElement(e);t.async=!0; |
||||
t.src=v;s=b.getElementsByTagName(e)[0]; |
||||
s.parentNode.insertBefore(t,s)}(window, document,'script', |
||||
'https://connect.facebook.net/en_US/fbevents.js'); |
||||
fbq('init', '1791804684725971'); |
||||
fbq('track', 'PageView'); |
||||
</script> |
||||
<noscript> |
||||
<img height="1" width="1" style="display:none" |
||||
src="https://www.facebook.com/tr?id=1791804684725971&ev=PageView&noscript=1"/> |
||||
</noscript> |
||||
<!-- End Meta Pixel Code --> |
||||
<?php |
||||
} |
||||
|
||||
add_action('woocommerce_thankyou', 'send_purchase_to_metrika'); |
||||
function send_purchase_to_metrika($order_id) { |
||||
if (!$order_id) return; // Проверка, что заказ существует |
||||
|
||||
$order = wc_get_order($order_id); |
||||
if ($order->get_status() !== 'processing' && $order->get_status() !== 'completed') return; // Отправляем только для оплаченных заказов |
||||
|
||||
$items = []; |
||||
foreach ($order->get_items() as $item) { |
||||
$product = $item->get_product(); |
||||
$items[] = [ |
||||
'id' => $product->get_id(), |
||||
'name' => $product->get_name(), |
||||
'price' => $product->get_price(), |
||||
'quantity' => $item->get_quantity() |
||||
]; |
||||
} |
||||
|
||||
// Получаем валюту заказа |
||||
$currency = $order->get_currency(); |
||||
?> |
||||
<script> |
||||
window.dataLayer = window.dataLayer || []; |
||||
dataLayer.push({ |
||||
'ecommerce': { |
||||
'purchase': { |
||||
'actionField': { |
||||
'id': '<?php echo $order_id; ?>',
|
||||
'revenue': '<?php echo $order->get_total(); ?>',
|
||||
'currency': '<?php echo $currency; ?>'
|
||||
}, |
||||
'products': <?php echo json_encode($items); ?> |
||||
} |
||||
} |
||||
}); |
||||
|
||||
// Яндекс.Метрика |
||||
yaCounter96481053.reachGoal('purchase', { |
||||
'order_id': '<?php echo $order_id; ?>',
|
||||
'order_price': '<?php echo $order->get_total(); ?>',
|
||||
'currency': '<?php echo $currency; ?>',
|
||||
'items': <?php echo json_encode($items); ?> |
||||
}); |
||||
|
||||
// Facebook Pixel |
||||
fbq('track', 'Purchase', { |
||||
value: <?php echo $order->get_total(); ?>,
|
||||
currency: '<?php echo $currency; ?>',
|
||||
content_ids: [<?php echo implode(',', array_column($items, 'id')); ?>],
|
||||
content_type: 'product' |
||||
}); |
||||
</script> |
||||
<?php |
||||
} |
||||
|
||||
// Отключаем кэширование для страниц товаров |
||||
add_action('template_redirect', function() { |
||||
if (is_product()) { |
||||
header('Cache-Control: no-cache, no-store, must-revalidate'); |
||||
header('Pragma: no-cache'); |
||||
header('Expires: 0'); |
||||
} |
||||
}); |
||||
|
||||
// Обработчик AJAX |
||||
add_action('wp_ajax_woocommerce_ajax_add_to_cart', 'woocommerce_ajax_add_to_cart'); |
||||
add_action('wp_ajax_nopriv_woocommerce_ajax_add_to_cart', 'woocommerce_ajax_add_to_cart'); |
||||
|
||||
function woocommerce_ajax_add_to_cart() { |
||||
error_log('AJAX handler called'); // Отладка: логируем вызов |
||||
|
||||
$product_id = isset($_POST['product_id']) ? absint($_POST['product_id']) : 0; |
||||
$quantity = isset($_POST['quantity']) ? absint($_POST['quantity']) : 1; |
||||
|
||||
error_log('Received product_id: ' . $product_id . ', quantity: ' . $quantity); // Отладка |
||||
|
||||
if (!$product_id) { |
||||
error_log('Invalid product_id received'); // Отладка |
||||
wp_send_json_error(array('message' => 'Неверный ID товара')); |
||||
wp_die(); |
||||
} |
||||
|
||||
$passed_validation = apply_filters('woocommerce_add_to_cart_validation', true, $product_id, $quantity); |
||||
|
||||
if ($passed_validation) { |
||||
$added = WC()->cart->add_to_cart($product_id, $quantity); |
||||
if ($added) { |
||||
error_log('Product added to cart: ' . $product_id); // Отладка |
||||
// Подготавливаем фрагменты корзины |
||||
ob_start(); |
||||
woocommerce_mini_cart(); |
||||
$mini_cart = ob_get_clean(); |
||||
|
||||
// Фрагменты для стандартной корзины и кастомного счетчика |
||||
$fragments = array( |
||||
'div.widget_shopping_cart_content' => '<div class="widget_shopping_cart_content">' . $mini_cart . '</div>', |
||||
'.mini-profile__button--counter' => '<div class="mini-profile__button--counter">' . WC()->cart->get_cart_contents_count() . '</div>' |
||||
); |
||||
|
||||
wp_send_json_success(array( |
||||
'message' => 'Товар успешно добавлен в корзину', |
||||
'fragments' => apply_filters('woocommerce_add_to_cart_fragments', $fragments), |
||||
'cart_hash' => apply_filters('woocommerce_add_to_cart_hash', WC()->cart->get_cart_hash(), array()) |
||||
)); |
||||
} else { |
||||
error_log('Failed to add product to cart: ' . $product_id); // Отладка |
||||
wp_send_json_error(array('message' => 'Не удалось добавить товар в корзину')); |
||||
} |
||||
} else { |
||||
error_log('Validation failed for product: ' . $product_id); // Отладка |
||||
wp_send_json_error(array('message' => 'Ошибка валидации товара')); |
||||
} |
||||
|
||||
wp_die(); |
||||
} |
@ -1,4 +1,5 @@ |
||||
<?php |
||||
|
||||
include_module('blog'); |
||||
include_component('blog', 'archive'); |
||||
|
||||
|
@ -0,0 +1,728 @@ |
||||
|
||||
|
||||
/* Where home */ |
||||
.where-home { |
||||
padding: 162px 0 37px; |
||||
color: var(--background); |
||||
} |
||||
|
||||
.authors h1{ |
||||
font-size: 82px; |
||||
font-weight: bold; |
||||
line-height: 96px; |
||||
color:#fff; |
||||
margin-bottom: 41px; |
||||
text-transform: uppercase; |
||||
} |
||||
|
||||
.where-home h1 { |
||||
font-size: 82px; |
||||
font-weight: bold; |
||||
line-height: 96px; |
||||
margin-bottom: 41px; |
||||
text-transform: uppercase; |
||||
} |
||||
|
||||
.where-home p { |
||||
max-width: 928px; |
||||
color: #FFF; |
||||
font-size: 36px; |
||||
font-weight: bold; |
||||
line-height: 40px; |
||||
text-transform: uppercase; |
||||
} |
||||
/* Where home end */ |
||||
|
||||
/* Find us */ |
||||
.find-us { |
||||
color: var(--background); |
||||
padding-bottom: 24px; |
||||
} |
||||
|
||||
.find-us h2 { |
||||
padding: 10px 0; |
||||
font-size: 36px; |
||||
font-weight: bold; |
||||
line-height: 40px; |
||||
text-transform: uppercase; |
||||
margin-bottom: 24px; |
||||
} |
||||
|
||||
.find-us ul { |
||||
display: grid; |
||||
grid-template-columns: repeat(2, minmax(0, 1fr)); |
||||
gap: 36px; |
||||
} |
||||
|
||||
.find-us h3 { |
||||
font-size: 24px; |
||||
font-weight: bold; |
||||
line-height: 28px; |
||||
margin-bottom: 8px; |
||||
text-transform: uppercase; |
||||
} |
||||
|
||||
.find-us p { |
||||
font-size: 24px; |
||||
font-weight: 500; |
||||
line-height: 32px; |
||||
} |
||||
/* Find us end */ |
||||
|
||||
/* Location */ |
||||
.location { |
||||
padding-bottom: 35px; |
||||
} |
||||
|
||||
.location h2 { |
||||
padding: 10px 0; |
||||
margin-bottom: 37px; |
||||
text-align: right; |
||||
font-size: 36px; |
||||
font-weight: bold; |
||||
line-height: 40px; |
||||
text-transform: uppercase; |
||||
color: var(--main_white); |
||||
} |
||||
|
||||
.location iframe { |
||||
height: 783px; |
||||
width: 100%; |
||||
border-radius: 64px; |
||||
} |
||||
/* Location end */ |
||||
|
||||
/* Sell form */ |
||||
.sell-form { |
||||
padding-bottom: 31px; |
||||
} |
||||
|
||||
.sell-form__container { |
||||
background: var(--main_white); |
||||
border-radius: 64px; |
||||
padding: 64px 105px 38px; |
||||
color: var(--grey-black); |
||||
display: flex; |
||||
flex-direction: column; |
||||
gap: 48px; |
||||
} |
||||
|
||||
.sell-form h2 { |
||||
font-size: 36px; |
||||
font-weight: bold; |
||||
line-height: 40px; |
||||
text-transform: uppercase; |
||||
} |
||||
|
||||
.sell-form p { |
||||
text-transform: uppercase; |
||||
font-size: 24px; |
||||
font-weight: bold; |
||||
line-height: 28px; |
||||
} |
||||
|
||||
.sell-form form { |
||||
display: flex; |
||||
flex-direction: column; |
||||
align-items: center; |
||||
gap: 16px; |
||||
} |
||||
|
||||
.sell-form form button { |
||||
background: var(--main_black); |
||||
padding: 11px 70px; |
||||
color: var(--main_white); |
||||
text-transform: uppercase; |
||||
border-radius: 16px; |
||||
font-size: 20px; |
||||
font-weight: 600; |
||||
line-height: 24px; |
||||
border: 1px solid var(--main_black); |
||||
} |
||||
|
||||
.sell-form form button:hover { |
||||
background: var(--main_white); |
||||
color: var(--main_black); |
||||
} |
||||
/* Sell form end */ |
||||
|
||||
/* Breadcrumb */ |
||||
.breadcrumb { |
||||
padding: 20px 0 24px; |
||||
} |
||||
|
||||
.breadcrumb .container { |
||||
color: var(--main_white); |
||||
font-size: 14px; |
||||
font-weight: 500; |
||||
line-height: 16px; |
||||
} |
||||
|
||||
.breadcrumb a { |
||||
display: inline; |
||||
} |
||||
/* Breadcrumb end */ |
||||
|
||||
/* Authors */ |
||||
.authors { |
||||
padding-bottom: 120px; |
||||
} |
||||
|
||||
.authors h2 { |
||||
font-weight: bold; |
||||
font-size: 64px; |
||||
line-height: 120%; |
||||
color: white; |
||||
text-transform: uppercase; |
||||
margin-bottom: 36px; |
||||
} |
||||
|
||||
.authors ul { |
||||
display: flex; |
||||
flex-wrap: wrap; |
||||
align-items: stretch; |
||||
justify-content: center; |
||||
gap: 24px; |
||||
} |
||||
|
||||
.authors li { |
||||
background: #F5F5F5; |
||||
border-radius: 48px; |
||||
display: flex; |
||||
flex-direction: column; |
||||
align-items: center; |
||||
text-align: center; |
||||
width: calc(100% / 3 - 16px); |
||||
} |
||||
|
||||
.authors a { |
||||
padding: 52px 17px 57px; |
||||
width: 100%; |
||||
height: 100%; |
||||
display: flex; |
||||
flex-direction: column; |
||||
align-items: center; |
||||
} |
||||
|
||||
.authors .main-img { |
||||
width: 200px; |
||||
height: 200px; |
||||
border-radius: 50%; |
||||
overflow: hidden; |
||||
flex-shrink: 0; |
||||
margin-bottom: 31px; |
||||
} |
||||
|
||||
.authors .main-img img { |
||||
width: 100%; |
||||
height: 100%; |
||||
object-fit: cover; |
||||
} |
||||
|
||||
.authors-name { |
||||
font-size: 24px; |
||||
font-weight: bold; |
||||
text-transform: uppercase; |
||||
line-height: 28px; |
||||
color: #121212; |
||||
margin-bottom: 5px; |
||||
} |
||||
|
||||
.authors-type { |
||||
color: #121212; |
||||
font-size: 24px; |
||||
font-weight: 500; |
||||
line-height: 32px; |
||||
margin-bottom: 31px; |
||||
} |
||||
|
||||
.authors p { |
||||
color: #666666; |
||||
font-weight: 500; |
||||
font-size: 20px; |
||||
line-height: 24px; |
||||
} |
||||
/* Authors end */ |
||||
|
||||
/* author-head */ |
||||
.author-head { |
||||
padding-bottom: 36px; |
||||
} |
||||
|
||||
.author-head-content { |
||||
display: flex; |
||||
align-items: center; |
||||
gap: 31px; |
||||
margin-bottom: 17.5px; |
||||
} |
||||
|
||||
.author-head .main-img { |
||||
width: 278px; |
||||
height: 278px; |
||||
flex-shrink: 0; |
||||
border-radius: 48px; |
||||
overflow: hidden; |
||||
} |
||||
|
||||
.author-head .main-img img { |
||||
width: 100%; |
||||
height: 100%; |
||||
object-fit: cover; |
||||
} |
||||
|
||||
.author-name { |
||||
font-size: 24px; |
||||
font-weight: bold; |
||||
line-height: 28px; |
||||
color: white; |
||||
margin-bottom: 5px; |
||||
text-transform: uppercase; |
||||
} |
||||
|
||||
.author-type { |
||||
font-size: 24px; |
||||
font-weight: 500; |
||||
line-height: 32px; |
||||
color: white; |
||||
margin-bottom: 5px; |
||||
} |
||||
|
||||
.author-description { |
||||
font-size: 24px; |
||||
font-weight: 500; |
||||
line-height: 32px; |
||||
color: white; |
||||
margin-bottom: 45px; |
||||
} |
||||
|
||||
.author-head p { |
||||
font-size: 20px; |
||||
font-weight: 500; |
||||
line-height: 24px; |
||||
color: white; |
||||
} |
||||
|
||||
.author-head h2 { |
||||
font-size: 64px; |
||||
font-weight: bold; |
||||
line-height: 120%; |
||||
color: white; |
||||
} |
||||
/* author-head end */ |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.home-title { |
||||
font-size: 82px; |
||||
font-weight: bold; |
||||
line-height: 96px; |
||||
color: var(--main_white); |
||||
margin-bottom: 16px; |
||||
} |
||||
|
||||
.home-description { |
||||
font-size: 32px; |
||||
font-weight: bold; |
||||
line-height: 40px; |
||||
color: var(--main_white); |
||||
text-transform: uppercase; |
||||
margin-bottom: 68px; |
||||
} |
||||
|
||||
.home-swp { |
||||
position: relative; |
||||
} |
||||
|
||||
.home-swp__btn { |
||||
position: absolute; |
||||
bottom: 22px; |
||||
left: 50%; |
||||
transform: translateX(-50%); |
||||
z-index: 2; |
||||
display: flex; |
||||
align-items: center; |
||||
gap: 24px; |
||||
} |
||||
|
||||
.home-swp__btn button { |
||||
border: 1px solid var(--main_black); |
||||
background: var(--main_white); |
||||
width: 56px; |
||||
height: 56px; |
||||
display: flex; |
||||
align-items: center; |
||||
justify-content: center; |
||||
border-radius: 20px; |
||||
} |
||||
|
||||
.home-swp .swiper-slide:not(.swiper-slide-active) { |
||||
height: 0; |
||||
overflow: hidden; |
||||
} |
||||
|
||||
.home-card { |
||||
border-radius: 60px; |
||||
overflow: hidden; |
||||
display: flex; |
||||
align-items: flex-start; |
||||
gap: 24px; |
||||
position: relative; |
||||
} |
||||
|
||||
.home-card.bg-yellow { |
||||
background: var(--orange_80); |
||||
} |
||||
|
||||
.home-card.bg-green { |
||||
background: var(--green_90); |
||||
} |
||||
|
||||
.home-card.bg-violet { |
||||
background: var(--violet_90); |
||||
} |
||||
|
||||
.home-card__img { |
||||
width: 395px; |
||||
border-radius: 60px; |
||||
overflow: hidden; |
||||
height: 393px; |
||||
flex-shrink: 0; |
||||
} |
||||
|
||||
.home-card__img img { |
||||
width: 100%; |
||||
height: 100%; |
||||
object-fit: cover; |
||||
} |
||||
|
||||
.home-card__content { |
||||
padding: 32px 79px 0 0; |
||||
} |
||||
|
||||
.home-card__content-title { |
||||
font-size: 36px; |
||||
font-weight: bold; |
||||
line-height: 40px; |
||||
text-transform: uppercase; |
||||
max-width: 660px; |
||||
margin-bottom: 10px; |
||||
color: var(--interface_title); |
||||
} |
||||
|
||||
.home-card__content-description { |
||||
color: var(--interface_title); |
||||
margin-bottom: 10px; |
||||
font-size: 20px; |
||||
font-weight: 500; |
||||
line-height: 24px; |
||||
display: -webkit-box; |
||||
-webkit-line-clamp: 3; |
||||
-webkit-box-orient: vertical; |
||||
overflow: hidden; |
||||
text-overflow: ellipsis; |
||||
} |
||||
|
||||
.home-card__content-body { |
||||
display: flex; |
||||
align-items: center; |
||||
flex-wrap: wrap; |
||||
gap: 12px; |
||||
} |
||||
|
||||
.home-card__content-body__alerts { |
||||
display: flex; |
||||
align-items: center; |
||||
flex-wrap: wrap; |
||||
gap: 12px; |
||||
} |
||||
|
||||
.home-card__content-body__alerts li { |
||||
background: var(--interface_hover); |
||||
color: var(--background); |
||||
border-radius: 16px; |
||||
padding: 6px 8px; |
||||
font-size: 16px; |
||||
font-weight: 500; |
||||
line-height: 20px; |
||||
} |
||||
|
||||
.home-card__content-body__day { |
||||
color: var(--interface_hover); |
||||
font-size: 14px; |
||||
font-weight: 500; |
||||
line-height: 16px; |
||||
} |
||||
|
||||
.home-card__content-body__time { |
||||
font-size: 14px; |
||||
font-weight: 500; |
||||
line-height: 16px; |
||||
color: var(--interface_hover); |
||||
} |
||||
|
||||
.home-card__content-body__data { |
||||
display: flex; |
||||
align-items: center; |
||||
gap: 12px; |
||||
} |
||||
|
||||
.home-card__content-body__data>div { |
||||
display: flex; |
||||
align-items: center; |
||||
gap: 4px; |
||||
font-size: 14px; |
||||
font-weight: 500; |
||||
line-height: 16px; |
||||
color: var(--interface_hover); |
||||
} |
||||
|
||||
.home-card__content-body__data>div .main-img { |
||||
width: 32px; |
||||
height: 32px; |
||||
border-radius: 50%; |
||||
object-fit: cover; |
||||
} |
||||
|
||||
.home-card__content-body__link { |
||||
border: 1px solid #000000; |
||||
border-radius: 28px; |
||||
background: var(--main_white); |
||||
position: absolute; |
||||
right: 37px; |
||||
bottom: 26px; |
||||
padding: 8.5px 16px 12.5px; |
||||
font-style: 20px; |
||||
font-weight: 500; |
||||
line-height: 24px; |
||||
} |
||||
/* Home end */ |
||||
|
||||
|
||||
/* Anons */ |
||||
.anons { |
||||
background: var(--main_white); |
||||
border-radius: 60px; |
||||
padding: 51px 0; |
||||
} |
||||
|
||||
.anons-theme__title { |
||||
color: var(--main_black); |
||||
font-size: 24px; |
||||
font-weight: bold; |
||||
line-height: 28px; |
||||
text-transform: uppercase; |
||||
margin-bottom: 20px; |
||||
} |
||||
|
||||
.anons-theme { |
||||
margin-bottom: 60px; |
||||
} |
||||
|
||||
.anons-theme ul { |
||||
max-width: 1022px; |
||||
display: flex; |
||||
flex-wrap: wrap; |
||||
gap: 12px; |
||||
} |
||||
|
||||
.anons-theme ul a { |
||||
font-size: 20px; |
||||
font-weight: 600; |
||||
line-height: 24px; |
||||
color: var(--main_black); |
||||
padding: 4px 24px; |
||||
border: 1px solid #000; |
||||
border-radius: 20px; |
||||
} |
||||
|
||||
.anons-theme ul a:hover, |
||||
.anons-theme ul a.active { |
||||
background: var(--main_black); |
||||
color: var(--main_white); |
||||
} |
||||
|
||||
.anons-best { |
||||
margin-bottom: 60px; |
||||
} |
||||
|
||||
.anons-best__title { |
||||
font-size: 36px; |
||||
line-height: 40px; |
||||
font-weight: bold; |
||||
color: var(--main_black); |
||||
margin-bottom: 20px; |
||||
} |
||||
|
||||
.anons-best__card-wrap { |
||||
display: grid; |
||||
grid-template-columns: repeat(3, minmax(0, 1fr)); |
||||
gap: 24px; |
||||
} |
||||
|
||||
.anons-best__card { |
||||
padding-top: 293px; |
||||
border-radius: 48px; |
||||
overflow: hidden; |
||||
position: relative; |
||||
z-index: 1; |
||||
} |
||||
|
||||
.anons-best__card.light { |
||||
padding-top: 0; |
||||
border-radius: 0; |
||||
} |
||||
|
||||
.anons-best__card .main-img { |
||||
position: absolute; |
||||
top: 0; |
||||
left: 0; |
||||
width: 100%; |
||||
height: 360px; |
||||
z-index: -1; |
||||
} |
||||
|
||||
.anons-best__card .main-img img { |
||||
width: 100%; |
||||
height: 100%; |
||||
object-fit: cover; |
||||
} |
||||
|
||||
.anons-best__card.light .main-img { |
||||
position: static; |
||||
height: 265px; |
||||
} |
||||
.anons-best__card.light .main-img img { |
||||
border-radius: 30px; |
||||
} |
||||
|
||||
.anons-best__card-alerts { |
||||
position: absolute; |
||||
top: 21px; |
||||
left: 17px; |
||||
width: calc(100% - 34px); |
||||
display: flex; |
||||
flex-wrap: wrap; |
||||
gap: 7px; |
||||
z-index: 1; |
||||
} |
||||
|
||||
.anons-best__card-alerts li { |
||||
padding: 6px 8px; |
||||
font-size: 16px; |
||||
line-height: 20px; |
||||
font-weight: 500; |
||||
color: var(--background); |
||||
background: var(--main_black); |
||||
border-radius: 30px; |
||||
} |
||||
|
||||
.anons-best__card-body { |
||||
background: var(--accent-1); |
||||
padding: 30px 17px 22px; |
||||
border-radius: 48px 48px 0 0; |
||||
color: var(--main_white); |
||||
position: relative; |
||||
height: 100%; |
||||
} |
||||
|
||||
.anons-best__card.light .anons-best__card-body { |
||||
background: transparent; |
||||
color: var(--main_black); |
||||
padding: 12px 0 34px; |
||||
} |
||||
|
||||
.anons-best__card-body__title { |
||||
font-size: 28px; |
||||
font-weight: bold; |
||||
line-height: 32px; |
||||
text-transform: uppercase; |
||||
margin-bottom: 14px; |
||||
} |
||||
|
||||
.anons-best__card.light .anons-best__card-body__title { |
||||
font-size: 26px; |
||||
} |
||||
|
||||
.anons-best__card-body__datas { |
||||
display: flex; |
||||
align-items: center; |
||||
flex-wrap: wrap; |
||||
gap: 6px 10px; |
||||
max-width: 264px; |
||||
} |
||||
|
||||
.anons-best__card.light .anons-best__card-body__datas { |
||||
color: var(--placeholder); |
||||
} |
||||
|
||||
.anons-best__card-body__datas p { |
||||
font-size: 14px; |
||||
line-height: 16px; |
||||
font-weight: 500; |
||||
} |
||||
|
||||
.anons-best__card-body__datas ul { |
||||
display: flex; |
||||
align-items: center; |
||||
gap: 10px; |
||||
} |
||||
|
||||
.anons-best__card-body__datas ul li { |
||||
display: flex; |
||||
align-items: center; |
||||
gap: 4px; |
||||
font-size: 14px; |
||||
line-height: 16px; |
||||
font-weight: 500; |
||||
} |
||||
|
||||
.anons-best__card-body__datas ul .logo img { |
||||
width: 24px; |
||||
height: 24px; |
||||
border-radius: 50%; |
||||
object-fit: cover; |
||||
} |
||||
|
||||
.anons-article { |
||||
margin-bottom: 40px; |
||||
} |
||||
|
||||
.anons-article__title { |
||||
font-size: 36px; |
||||
line-height: 40px; |
||||
font-weight: bold; |
||||
color: var(--main_black); |
||||
margin-bottom: 20px; |
||||
} |
||||
|
||||
.anons-article__card-wrap { |
||||
display: grid; |
||||
grid-template-columns: repeat(3, minmax(0, 1fr)); |
||||
gap: 40px 25px; |
||||
} |
||||
|
||||
.anons-article__more-link { |
||||
display: flex; |
||||
align-items: center; |
||||
justify-content: center; |
||||
} |
||||
|
||||
.anons-article__more-link a { |
||||
background: var(--accent-3); |
||||
color: var(--main_white); |
||||
border-radius: 20px; |
||||
border: 1px solid var(--main_white); |
||||
padding: 16px 24px; |
||||
font-size: 20px; |
||||
font-weight: 600; |
||||
line-height: 24px; |
||||
text-transform: uppercase; |
||||
} |
||||
/* Anons end */ |
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,120 @@ |
||||
/* Стили для мобильных устройств */ |
||||
@media only screen and (max-width: 576px) { |
||||
.anons-best__title { |
||||
font-size: 26px; |
||||
line-height: 32px; |
||||
margin-bottom: 12px; |
||||
} |
||||
|
||||
.anons-best__card { |
||||
padding-top: 205px; |
||||
} |
||||
|
||||
.anons-best__card .main-img { |
||||
height: 300px; |
||||
} |
||||
|
||||
.anons-best__card-body { |
||||
padding: 20px 17px; |
||||
} |
||||
|
||||
.anons-best__card-body__title { |
||||
font-size: 20px; |
||||
line-height: 24px; |
||||
margin-bottom: 16px; |
||||
} |
||||
|
||||
.anons-best__card.light .main-img { |
||||
height: 197px; |
||||
} |
||||
|
||||
.anons-best__card.light .anons-best__card-body__title { |
||||
font-size: 20px; |
||||
line-height: 24px; |
||||
} |
||||
|
||||
|
||||
|
||||
.authors { |
||||
padding-bottom: 138px; |
||||
} |
||||
|
||||
.authors h2 { |
||||
font-size: 32px; |
||||
line-height: 38px; |
||||
margin-bottom: 15px; |
||||
} |
||||
|
||||
.authors li { |
||||
border-radius: 24px; |
||||
width: 100%; |
||||
} |
||||
|
||||
.authors a { |
||||
padding: 32px 17px 52px; |
||||
} |
||||
|
||||
.authors .main-img { |
||||
width: 180px; |
||||
height: 180px; |
||||
margin-bottom: 20px; |
||||
} |
||||
|
||||
.authors-name { |
||||
font-size: 20px; |
||||
line-height: 24px; |
||||
} |
||||
|
||||
.authors-type { |
||||
font-size: 18px; |
||||
line-height: 24px; |
||||
margin-bottom: 20px; |
||||
} |
||||
|
||||
.authors p { |
||||
font-size: 16px; |
||||
line-height: 20px; |
||||
} |
||||
|
||||
.author-head { |
||||
padding-bottom: 15px; |
||||
} |
||||
|
||||
.author-head-content { |
||||
margin-bottom: 23px; |
||||
} |
||||
|
||||
.author-head .main-img { |
||||
width: 100%; |
||||
} |
||||
|
||||
.author-head h2 { |
||||
font-size: 32px; |
||||
line-height: 38px; |
||||
} |
||||
|
||||
.author-name { |
||||
font-size: 20px; |
||||
line-height: 24px; |
||||
} |
||||
|
||||
.author-type { |
||||
font-size: 18px; |
||||
line-height: 24px; |
||||
} |
||||
|
||||
.author-description { |
||||
font-size: 18px; |
||||
line-height: 24px; |
||||
margin-bottom: 24px; |
||||
} |
||||
|
||||
.author-head p { |
||||
font-size: 16px; |
||||
line-height: 20px; |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,44 @@ |
||||
/* Стили для планшетов */ |
||||
@media only screen and (max-width: 992px) { |
||||
|
||||
.authors h2 { |
||||
font-size: 48px; |
||||
margin-bottom: 24px; |
||||
} |
||||
|
||||
.authors li { |
||||
border-radius: 32px; |
||||
width: calc(50% - 12px); |
||||
} |
||||
|
||||
.authors .main-img { |
||||
margin-bottom: 24px; |
||||
} |
||||
|
||||
.author { |
||||
padding-bottom: 24px; |
||||
} |
||||
|
||||
.author h2 { |
||||
font-size: 48px; |
||||
} |
||||
|
||||
.author-head-content { |
||||
flex-direction: column; |
||||
align-items: flex-start; |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
/* Стили для планшетов */ |
||||
@media only screen and (max-width: 992px) { |
||||
|
||||
.author { |
||||
padding: 188px 0 36px; |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
} |
After Width: | Height: | Size: 225 B |
After Width: | Height: | Size: 216 KiB |
After Width: | Height: | Size: 167 KiB |
After Width: | Height: | Size: 261 KiB |
After Width: | Height: | Size: 261 KiB |
After Width: | Height: | Size: 247 KiB |
After Width: | Height: | Size: 429 KiB |
After Width: | Height: | Size: 458 B |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 190 KiB |
After Width: | Height: | Size: 911 B |
After Width: | Height: | Size: 676 B |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 439 B |
After Width: | Height: | Size: 391 B |
After Width: | Height: | Size: 389 B |
After Width: | Height: | Size: 391 B |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 246 B |
After Width: | Height: | Size: 929 B |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 246 B |
After Width: | Height: | Size: 244 B |
After Width: | Height: | Size: 246 B |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 458 B |
After Width: | Height: | Size: 460 B |
After Width: | Height: | Size: 1.4 KiB |
@ -0,0 +1,46 @@ |
||||
jQuery(document).ready(function ($) { |
||||
$('#ajax-load-author').on('submit', function (e) { |
||||
e.preventDefault(); |
||||
var form = $(this); |
||||
var currentPage = parseInt($('#page_num').val()); |
||||
var totalPosts = parseInt(form.data('total')); |
||||
var postsPerPage = 9; |
||||
|
||||
console.log('Current page before load:', currentPage); |
||||
console.log('Total posts:', totalPosts); |
||||
console.log('Posts loaded before request:', postsPerPage); |
||||
|
||||
var data = { |
||||
action: 'get_author_posts', |
||||
page_num: currentPage, |
||||
author_id: form.data('author') |
||||
}; |
||||
|
||||
console.log('Sending AJAX request with data:', data); |
||||
|
||||
$.ajax({ |
||||
url: '/wp-admin/admin-ajax.php', |
||||
type: 'POST', |
||||
data: data, |
||||
success: function (response) { |
||||
console.log('AJAX response received'); |
||||
$(".anons-article__card-wrap").append(response); |
||||
|
||||
$('#page_num').val(currentPage + 1); |
||||
console.log('New page number:', currentPage + 1); |
||||
|
||||
// Считаем общее количество загруженных постов
|
||||
var currentlyDisplayed = $('.anons-article__card-wrap .anons-best__card').length; |
||||
console.log('Actually displayed posts:', currentlyDisplayed); |
||||
|
||||
if (currentlyDisplayed >= totalPosts) { |
||||
console.log('Hiding load more button - all posts loaded'); |
||||
form.hide(); |
||||
} |
||||
}, |
||||
error: function (error) { |
||||
console.error('AJAX error:', error); |
||||
} |
||||
}); |
||||
}); |
||||
});
|
@ -0,0 +1,48 @@ |
||||
// const homeSwp = new Swiper('.home-swp .swiper', {
|
||||
// slidesPerView: 1,
|
||||
// spaceBetween: 0,
|
||||
// effect: 'fade',
|
||||
// loop: true,
|
||||
// navigation: {
|
||||
// nextEl: '.home-swp__btn-next',
|
||||
// prevEl: '.home-swp__btn-prev',
|
||||
// }
|
||||
// })
|
||||
|
||||
// const textsSwp = new Swiper('.texts-swp .swiper', {
|
||||
// slidesPerView: 1,
|
||||
// spaceBetween: 0,
|
||||
// loop: true,
|
||||
// effect: 'fade',
|
||||
// navigation: {
|
||||
// nextEl: '.texts-swp__next',
|
||||
// prevEl: '.texts-swp__prev'
|
||||
// },
|
||||
// pagination: {
|
||||
// el: ".texts-swp__pagination",
|
||||
// clickable: true,
|
||||
// }
|
||||
// })
|
||||
|
||||
// comment
|
||||
// let answerbtns = document.querySelectorAll('.answer-btn');
|
||||
// let answerbtnicons = document.querySelectorAll('.answer-btn svg');
|
||||
// let answerblocks = document.querySelectorAll('.answer-block');
|
||||
|
||||
// answerbtns.forEach((answerbtn, index) => {
|
||||
// answerbtn.addEventListener('click', () => {
|
||||
// let answerbtnicon = answerbtnicons[index];
|
||||
// let answerblock = answerblocks[index];
|
||||
|
||||
// answerblock.classList.toggle('active');
|
||||
// answerbtnicon.classList.toggle('active');
|
||||
|
||||
// let buttonText = answerbtn.querySelector('span');
|
||||
// if (buttonText.textContent === 'Ответ') {
|
||||
// buttonText.textContent = 'Свернуть';
|
||||
// } else {
|
||||
// buttonText.textContent = 'ответ';
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
// comment
|
@ -0,0 +1,54 @@ |
||||
<?php |
||||
|
||||
include_component('blog', 'featured-slider'); |
||||
include_module('forms'); |
||||
include_component('forms', 'discount'); |
||||
|
||||
$context = Timber::context(); |
||||
|
||||
$context['blog_title'] = get_field('blog_title', 'options'); |
||||
$context['blog_desc'] = get_field('blog_desc', 'options'); |
||||
$context['post_count'] = wp_count_posts()->publish; |
||||
$context['total_pages'] = ceil($context['post_count'] / get_option('posts_per_page')); |
||||
|
||||
$context['sub_title'] = get_field('sub_title', 383); |
||||
$context['sub_text'] = get_field('sub_text', 383); |
||||
|
||||
$authors = Timber::get_posts([ |
||||
'post_type' => 'blog_author', |
||||
'posts_per_page' => -1, |
||||
'orderby' => 'menu_order', |
||||
'order' => 'ASC', |
||||
]); |
||||
|
||||
$authors_arr = iterator_to_array($authors); |
||||
foreach ($authors_arr as $author) { |
||||
$author_id = $author->ID; |
||||
$query = new WP_Query([ |
||||
'post_type' => 'post', |
||||
'posts_per_page' => -1, |
||||
'meta_query' => [ |
||||
[ |
||||
'key' => 'post_author', |
||||
'value' => $author_id, |
||||
'compare' => '=' |
||||
] |
||||
] |
||||
]); |
||||
$author->post_count = $query->found_posts; |
||||
$author->position = get_field('post', $author_id); |
||||
$author->posts = Timber::get_posts([ |
||||
'post_type' => 'post', |
||||
'posts_per_page' => -1, |
||||
'meta_query' => [ |
||||
[ |
||||
'key' => 'post_author', |
||||
'value' => $author_id, |
||||
'compare' => '=' |
||||
] |
||||
] |
||||
]); |
||||
} |
||||
$context['authors'] = $authors_arr; |
||||
|
||||
Timber::render('blog_author/author-archive.twig', $context); |
@ -0,0 +1,41 @@ |
||||
<?php |
||||
|
||||
$context = Timber::get_context(); |
||||
|
||||
$author = Timber::get_post(); |
||||
$author_id = $author->ID; |
||||
|
||||
|
||||
$author->position = get_field('post', $author_id); |
||||
|
||||
$count_query = new WP_Query([ |
||||
'post_type' => 'post', |
||||
'post_status' => 'publish', |
||||
'posts_per_page' => -1, |
||||
'meta_query' => [ |
||||
[ |
||||
'key' => 'post_author', |
||||
'value' => $author_id, |
||||
'compare' => '=' |
||||
] |
||||
] |
||||
]); |
||||
$author->post_count = $count_query->found_posts; |
||||
|
||||
$author->posts = Timber::get_posts([ |
||||
'post_type' => 'post', |
||||
'post_status' => 'publish', |
||||
'posts_per_page' => 9, |
||||
'meta_query' => [ |
||||
[ |
||||
'key' => 'post_author', |
||||
'value' => $author_id, |
||||
'compare' => '=' |
||||
] |
||||
] |
||||
]); |
||||
|
||||
$context['author'] = $author; |
||||
$context['total_pages'] = ceil($author->post_count / 9); |
||||
|
||||
Timber::render('blog_author/author-single.twig', $context); |
@ -0,0 +1,35 @@ |
||||
<?php |
||||
|
||||
include_module('author'); |
||||
|
||||
function get_author_posts() { |
||||
$author_id = isset($_POST['author_id']) ? sanitize_text_field($_POST['author_id']) : ''; |
||||
|
||||
$all_posts = Timber::get_posts([ |
||||
'post_type' => 'post', |
||||
'post_status' => 'publish', |
||||
'posts_per_page' => -1, |
||||
'meta_query' => [ |
||||
[ |
||||
'key' => 'post_author', |
||||
'value' => $author_id, |
||||
'compare' => '=' |
||||
] |
||||
] |
||||
]); |
||||
|
||||
if ($all_posts instanceof \Timber\PostQuery || $all_posts instanceof \Timber\PostCollection) { |
||||
$all_posts = $all_posts->get_posts(); |
||||
} |
||||
|
||||
$remaining_posts = array_slice($all_posts, 9); |
||||
|
||||
$context = Timber::context(); |
||||
$context['posts'] = $remaining_posts; |
||||
|
||||
Timber::render('blog_author/author-posts-list.twig', $context); |
||||
wp_die(); |
||||
} |
||||
|
||||
add_action('wp_ajax_get_author_posts', 'get_author_posts'); |
||||
add_action('wp_ajax_nopriv_get_author_posts', 'get_author_posts'); |
@ -1,3 +1,68 @@ |
||||
main{ |
||||
padding-top: 72px; |
||||
} |
||||
|
||||
.block-lists_text p { |
||||
font-size: 18px!important; |
||||
} |
||||
|
||||
.user a{ |
||||
display: flex; |
||||
align-items: center; |
||||
gap: 5px; |
||||
} |
||||
|
||||
.user a{ |
||||
display:flex; |
||||
gap:5px; |
||||
} |
||||
|
||||
.user img{ |
||||
width:30px; |
||||
border-radius:100px; |
||||
} |
||||
|
||||
.anons-best__card-body__datas .logo a{ |
||||
display: flex; |
||||
align-items: center; |
||||
gap:5px; |
||||
margin-top: 10px; |
||||
} |
||||
|
||||
.comment-submit-btn{ |
||||
border: 1px solid #000000; |
||||
border-radius: 28px; |
||||
background: var(--main_white); |
||||
|
||||
padding: 8.5px 16px 8.5px; |
||||
font-size: 20px; |
||||
font-weight: 500; |
||||
line-height: 24px; |
||||
margin-top: 15px; |
||||
transition: all .5s; |
||||
} |
||||
|
||||
.comment-reply-title , .logged-in-as{ |
||||
margin: 10px 0; |
||||
} |
||||
|
||||
.comment-block.answer-block.active{ |
||||
margin-top: 15px; |
||||
} |
||||
|
||||
.comment-form-comment textarea{ |
||||
padding: 28px 48px; |
||||
border-radius: 24px; |
||||
background: #f5f5f5 !important; |
||||
} |
||||
|
||||
.comment-respond{ |
||||
margin-top: 30px; |
||||
} |
||||
|
||||
|
||||
.reply-form-container textarea{ |
||||
background-color: #fff !important; |
||||
margin-top: 2rem; |
||||
width: 100%; |
||||
} |
@ -0,0 +1,10 @@ |
||||
@media(max-width:600px) { |
||||
.article-content h2 { |
||||
max-width: 661px; |
||||
font-size: 24px!important; |
||||
line-height: 40px; |
||||
font-weight: bold; |
||||
text-transform: uppercase; |
||||
color: var(--grey-black); |
||||
} |
||||
} |
@ -0,0 +1,198 @@ |
||||
// comment
|
||||
let answerbtns = document.querySelectorAll('.answer-btn'); |
||||
let answerbtnicons = document.querySelectorAll('.answer-btn svg'); |
||||
|
||||
// При загрузке страницы проверяем активные кнопки
|
||||
document.addEventListener('DOMContentLoaded', function() { |
||||
// Для каждой кнопки ответов
|
||||
answerbtns.forEach((answerbtn) => { |
||||
// Находим родительский контейнер, чтобы искать ответы только для этого комментария
|
||||
const buttonParent = answerbtn.parentElement; |
||||
|
||||
// Находим все блоки ответов для этого комментария (после текущей кнопки)
|
||||
const answerBlocks = getRelatedAnswerBlocks(answerbtn); |
||||
if (answerBlocks.length === 0) return; |
||||
|
||||
// Проверяем, должны ли быть ответы развернуты (если у кнопки или любого ответа есть класс active)
|
||||
const shouldBeActive = answerbtn.querySelector('svg').classList.contains('active') ||
|
||||
Array.from(answerBlocks).some(block => block.classList.contains('active')); |
||||
|
||||
if (shouldBeActive) { |
||||
// Активируем все ответы только для этого комментария
|
||||
answerBlocks.forEach(block => { |
||||
block.classList.add('active'); |
||||
}); |
||||
|
||||
// Обновляем состояние кнопки
|
||||
answerbtn.querySelector('svg').classList.add('active'); |
||||
|
||||
// Обновляем текст кнопки
|
||||
let buttonText = answerbtn.querySelector('span'); |
||||
if (buttonText) { |
||||
buttonText.textContent = 'Свернуть'; |
||||
} |
||||
} else { |
||||
// Скрываем все ответы
|
||||
answerBlocks.forEach(block => { |
||||
block.classList.remove('active'); |
||||
}); |
||||
|
||||
// Обновляем состояние кнопки
|
||||
answerbtn.querySelector('svg').classList.remove('active'); |
||||
|
||||
// Обновляем текст кнопки в зависимости от количества ответов
|
||||
let buttonText = answerbtn.querySelector('span'); |
||||
if (buttonText) { |
||||
const count = answerBlocks.length; |
||||
buttonText.textContent = count === 1 ? 'ответ' : 'ответа'; |
||||
} |
||||
} |
||||
}); |
||||
}); |
||||
|
||||
// Функция для получения блоков ответов, связанных с данной кнопкой
|
||||
function getRelatedAnswerBlocks(answerBtn) { |
||||
// Получаем следующий блок комментариев (если он есть)
|
||||
let currentElement = answerBtn; |
||||
let answerBlocks = []; |
||||
|
||||
// Собираем все блоки ответов до следующего основного комментария или кнопки ответов
|
||||
while ((currentElement = currentElement.nextElementSibling) !== null) { |
||||
if (currentElement.classList.contains('comment-block') && !currentElement.classList.contains('answer-block')) { |
||||
// Достигли следующего основного комментария, прерываем сбор
|
||||
break; |
||||
} else if (currentElement.classList.contains('answer-btn')) { |
||||
// Достигли следующей кнопки ответов, прерываем сбор
|
||||
break; |
||||
} else if (currentElement.classList.contains('answer-block')) { |
||||
// Это блок ответа, добавляем в коллекцию
|
||||
answerBlocks.push(currentElement); |
||||
} |
||||
} |
||||
|
||||
return answerBlocks; |
||||
} |
||||
|
||||
// Обработчики нажатия на кнопки ответов
|
||||
answerbtns.forEach((answerbtn) => { |
||||
answerbtn.addEventListener('click', () => { |
||||
// Получаем все блоки ответов для этого комментария
|
||||
const answerBlocks = getRelatedAnswerBlocks(answerbtn); |
||||
if (answerBlocks.length === 0) return; |
||||
|
||||
// Определяем, развернуты ли ответы сейчас
|
||||
const isCurrentlyActive = answerbtn.querySelector('svg').classList.contains('active'); |
||||
|
||||
// Переключаем состояние
|
||||
if (isCurrentlyActive) { |
||||
// Скрываем все ответы
|
||||
answerBlocks.forEach(block => { |
||||
block.classList.remove('active'); |
||||
}); |
||||
|
||||
// Обновляем состояние кнопки
|
||||
answerbtn.querySelector('svg').classList.remove('active'); |
||||
|
||||
// Обновляем текст кнопки
|
||||
let buttonText = answerbtn.querySelector('span'); |
||||
if (buttonText) { |
||||
const count = answerBlocks.length; |
||||
buttonText.textContent = count === 1 ? 'ответ' : 'ответа'; |
||||
} |
||||
} else { |
||||
// Показываем все ответы
|
||||
answerBlocks.forEach(block => { |
||||
block.classList.add('active'); |
||||
}); |
||||
|
||||
// Обновляем состояние кнопки
|
||||
answerbtn.querySelector('svg').classList.add('active'); |
||||
|
||||
// Обновляем текст кнопки
|
||||
let buttonText = answerbtn.querySelector('span'); |
||||
if (buttonText) { |
||||
buttonText.textContent = 'Свернуть'; |
||||
} |
||||
} |
||||
}); |
||||
}); |
||||
|
||||
// Обработка нажатия на кнопку "Ответить" на комментарий
|
||||
document.addEventListener('DOMContentLoaded', function() { |
||||
// Получаем все кнопки "Ответить" на странице
|
||||
const replyButtons = document.querySelectorAll('.reply-to-comment'); |
||||
|
||||
// Добавляем обработчик на каждую кнопку
|
||||
replyButtons.forEach(button => { |
||||
button.addEventListener('click', function() { |
||||
// Получаем ID комментария, на который отвечаем
|
||||
const commentId = this.getAttribute('data-comment-id'); |
||||
const postId = this.getAttribute('data-post-id'); |
||||
const replyToName = this.getAttribute('data-reply-to'); |
||||
|
||||
// Получаем контейнер для формы ответа
|
||||
const replyFormContainer = document.getElementById('reply-form-' + commentId); |
||||
|
||||
// Если форма уже открыта, скрываем её
|
||||
if (replyFormContainer.style.display !== 'none') { |
||||
replyFormContainer.style.display = 'none'; |
||||
return; |
||||
} |
||||
|
||||
// Скрываем все открытые формы ответов
|
||||
document.querySelectorAll('.reply-form-container').forEach(container => { |
||||
container.style.display = 'none'; |
||||
}); |
||||
|
||||
// Клонируем основную форму комментариев
|
||||
const originalForm = document.getElementById('commentform'); |
||||
if (originalForm) { |
||||
const clonedForm = originalForm.cloneNode(true); |
||||
|
||||
// Изменяем атрибуты формы для ответа
|
||||
clonedForm.id = 'commentform-reply-' + commentId; |
||||
|
||||
// Добавляем скрытое поле с ID родительского комментария
|
||||
const hiddenInput = document.createElement('input'); |
||||
hiddenInput.type = 'hidden'; |
||||
hiddenInput.name = 'comment_parent'; |
||||
hiddenInput.value = commentId; |
||||
clonedForm.appendChild(hiddenInput); |
||||
|
||||
// Изменяем заголовок формы
|
||||
const formTitle = clonedForm.querySelector('.comment-reply-title'); |
||||
if (formTitle) { |
||||
formTitle.textContent = 'Ответить ' + replyToName; |
||||
} |
||||
|
||||
// Добавляем кнопку отмены
|
||||
const cancelButton = document.createElement('button'); |
||||
cancelButton.type = 'button'; |
||||
cancelButton.className = 'cancel-reply-btn'; |
||||
cancelButton.textContent = 'Отменить'; |
||||
cancelButton.addEventListener('click', function() { |
||||
replyFormContainer.style.display = 'none'; |
||||
}); |
||||
|
||||
// Добавляем кнопку отмены в форму
|
||||
const submitContainer = clonedForm.querySelector('.form-submit'); |
||||
if (submitContainer) { |
||||
submitContainer.appendChild(cancelButton); |
||||
} |
||||
|
||||
// Очищаем контейнер и добавляем клонированную форму
|
||||
replyFormContainer.innerHTML = ''; |
||||
replyFormContainer.appendChild(clonedForm); |
||||
|
||||
// Показываем форму
|
||||
replyFormContainer.style.display = 'block'; |
||||
|
||||
// Фокусируемся на текстовой области
|
||||
const textarea = clonedForm.querySelector('textarea'); |
||||
if (textarea) { |
||||
textarea.focus(); |
||||
} |
||||
} |
||||
}); |
||||
}); |
||||
}); |
@ -0,0 +1,200 @@ |
||||
/* Editorial */ |
||||
.editorial { |
||||
padding-bottom: 68px; |
||||
} |
||||
|
||||
.editorial-head { |
||||
position: relative; |
||||
z-index: 1; |
||||
max-width: 841px; |
||||
margin-bottom: 37px; |
||||
} |
||||
|
||||
.editorial-head__title { |
||||
font-size: 82px; |
||||
line-height: 96px; |
||||
font-weight: bold; |
||||
color: var(--main_white); |
||||
text-transform: uppercase; |
||||
} |
||||
|
||||
.editorial-head__img { |
||||
position: absolute; |
||||
z-index: -1; |
||||
top: -14px; |
||||
right: -20px; |
||||
width: 221px; |
||||
} |
||||
|
||||
.editorial-head__star { |
||||
position: absolute; |
||||
top: 8.26px; |
||||
right: -13.5px; |
||||
transform: translateX(100%); |
||||
width: 87.5px; |
||||
} |
||||
|
||||
.editorial-card__wrap { |
||||
display: grid; |
||||
grid-template-columns: repeat(2, minmax(0, 1fr)); |
||||
gap: 31px 25px; |
||||
position: relative; |
||||
z-index: 1; |
||||
} |
||||
|
||||
.editorial-card { |
||||
border: 2px solid var(--creme-white); |
||||
border-radius: 30px; |
||||
display: flex; |
||||
align-items: stretch; |
||||
overflow: hidden; |
||||
background: var(--linear); |
||||
backdrop-filter: blur(28px); |
||||
} |
||||
|
||||
.editorial-card .main-img { |
||||
min-height: 282px; |
||||
width: 207px; |
||||
border-radius: 29px; |
||||
overflow: hidden; |
||||
flex-shrink: 0; |
||||
} |
||||
|
||||
.editorial-card:hover .main-img img{ |
||||
width: 120%; |
||||
height: 120%; |
||||
} |
||||
|
||||
.editorial-card .main-img img { |
||||
width: 100%; |
||||
height: 100%; |
||||
object-fit: cover; |
||||
transition: all .5s; |
||||
} |
||||
|
||||
.editorial-card__content { |
||||
padding: 42px 19px 19px 35px; |
||||
} |
||||
|
||||
.editorial-card__content-alerts { |
||||
display: flex; |
||||
flex-wrap: wrap; |
||||
align-items: center; |
||||
gap: 7px; |
||||
margin-bottom: 17px; |
||||
} |
||||
|
||||
.editorial-card__content-alerts a { |
||||
background: var(--main_black); |
||||
border-radius: 16px; |
||||
padding: 6px 8px; |
||||
font-size: 16px; |
||||
font-weight: 500; |
||||
line-height: 20px; |
||||
color: var(--background); |
||||
} |
||||
|
||||
.editorial-card__content-title { |
||||
font-size: 28px; |
||||
font-weight: bold; |
||||
line-height: 32px; |
||||
color: var(--grey-black); |
||||
text-transform: uppercase; |
||||
margin-bottom: 17px; |
||||
} |
||||
|
||||
.editorial-card__content-data { |
||||
display: flex; |
||||
flex-wrap: wrap; |
||||
gap: 5px 16px; |
||||
color: var(--interface_hover); |
||||
font-size: 16px; |
||||
font-weight: 500; |
||||
line-height: 20px; |
||||
} |
||||
|
||||
.editorial-card__content-data ul { |
||||
display: flex; |
||||
align-items: center; |
||||
gap: 16px; |
||||
} |
||||
|
||||
.editorial-card__content-data li { |
||||
display: flex; |
||||
align-items: center; |
||||
gap: 5px; |
||||
} |
||||
|
||||
.editorial-card__content-data .logo img { |
||||
width: 24px; |
||||
height: 24px; |
||||
border-radius: 50%; |
||||
object-fit: cover; |
||||
} |
||||
/* Editorial end */ |
||||
|
||||
@media (max-width: 1200px) { |
||||
.editorial-card__wrap { |
||||
grid-template-columns: repeat(1, minmax(0, 1fr)); |
||||
} |
||||
} |
||||
|
||||
@media (max-width: 992px) { |
||||
.editorial { |
||||
padding-bottom: 36px; |
||||
} |
||||
|
||||
.editorial-head { |
||||
margin-bottom: 36px; |
||||
max-width: 313px; |
||||
} |
||||
|
||||
.editorial-head__title { |
||||
font-size: 32px; |
||||
line-height: 38px; |
||||
} |
||||
|
||||
.editorial-head__img { |
||||
width: 100px; |
||||
top: -14px; |
||||
right: -22.5px; |
||||
} |
||||
|
||||
.editorial-head__star { |
||||
display: none; |
||||
} |
||||
} |
||||
|
||||
@media (max-width: 576px) { |
||||
.editorial-card { |
||||
flex-direction: column; |
||||
border-radius: 30px; |
||||
position: relative; |
||||
} |
||||
|
||||
.editorial-card .main-img { |
||||
width: 100%; |
||||
height: 203px; |
||||
} |
||||
|
||||
.editorial-card__content { |
||||
padding: 17px 13px 24px; |
||||
} |
||||
|
||||
.editorial-card__content-alerts { |
||||
position: absolute; |
||||
top: 13px; |
||||
left: 8px; |
||||
width: calc(100% - 16px); |
||||
} |
||||
|
||||
.editorial-card__content-title { |
||||
font-size: 20px; |
||||
line-height: 24px; |
||||
margin-bottom: 17px; |
||||
} |
||||
|
||||
.editorial-card__content-data { |
||||
gap: 5px 16px; |
||||
} |
||||
} |
After Width: | Height: | Size: 439 B |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 391 B |
After Width: | Height: | Size: 246 B |
After Width: | Height: | Size: 389 B |
After Width: | Height: | Size: 244 B |
@ -1,23 +1,22 @@ |
||||
<?php |
||||
|
||||
|
||||
add_filter('timber/context', function($context) { |
||||
$current_category = get_queried_object(); // Получаем текущую категорию |
||||
|
||||
// Простой запрос для получения последних постов |
||||
$args = array( |
||||
'post_type' => 'post', |
||||
'posts_per_page' => 3, // Количество постов |
||||
'orderby' => 'meta_value_num', |
||||
'key' => 'post_views', // Поле плагина для подсчёта просмотров |
||||
'order' => 'DESC', // Сортировка по убыванию |
||||
|
||||
// Условие для фильтрации по текущей категории |
||||
'category__in' => $current_category ? array($current_category->term_id) : '', |
||||
'posts_per_page' => 3, |
||||
'orderby' => 'date', |
||||
'order' => 'DESC' |
||||
); |
||||
|
||||
$most_read_query = new WP_Query($args); |
||||
$most_read = new Timber\PostQuery($most_read_query); |
||||
|
||||
$context['most_read'] = $most_read; |
||||
|
||||
// Добавляем отладочную информацию |
||||
global $wpdb; |
||||
$debug_info = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM {$wpdb->postmeta} WHERE meta_key LIKE '%view%' LIMIT 5"); |
||||
$context['debug_info'] = $debug_info; |
||||
|
||||
return $context; |
||||
}); |
||||
}); |
After Width: | Height: | Size: 391 B |
After Width: | Height: | Size: 246 B |
@ -0,0 +1,147 @@ |
||||
jQuery(document).ready(function ($) { |
||||
$(".comment-btn button").on("click", function () { |
||||
var postId = $(this).data("post-id"); |
||||
var $button = $(this); |
||||
|
||||
$.ajax({ |
||||
url: "/wp-admin/admin-ajax.php", |
||||
type: "POST", |
||||
data: { |
||||
action: "add_post_like", |
||||
post_id: postId, |
||||
}, |
||||
success: function (response) { |
||||
if (response.error) { |
||||
alert(response.error); |
||||
window.location.href = "/wp-login.php"; |
||||
return; |
||||
} |
||||
|
||||
$(".comment-btn span").text(response.count); |
||||
|
||||
if (response.is_liked) { |
||||
$button.addClass("active"); |
||||
|
||||
$button.find("svg path").attr({ |
||||
fill: "rgba(255, 0, 0, 0.7)", |
||||
stroke: "#ff0000", |
||||
}); |
||||
} else { |
||||
$button.removeClass("active"); |
||||
|
||||
$button.find("svg path").attr({ |
||||
fill: "rgb(18, 18, 18)", |
||||
stroke: "#666666", |
||||
}); |
||||
} |
||||
}, |
||||
error: function (error) { |
||||
if (error.responseJSON && error.responseJSON.data) { |
||||
alert(error.responseJSON.data); |
||||
window.location.href = "/wp-login.php"; |
||||
} |
||||
}, |
||||
}); |
||||
}); |
||||
|
||||
$(document).on("click", ".comment-like-btn", function () { |
||||
var commentId = $(this).data("comment-id"); |
||||
var $button = $(this); |
||||
|
||||
$.ajax({ |
||||
url: "/wp-admin/admin-ajax.php", |
||||
type: "POST", |
||||
data: { |
||||
action: "add_comment_like", |
||||
comment_id: commentId, |
||||
}, |
||||
success: function (response) { |
||||
if (response.error) { |
||||
alert(response.error); |
||||
window.location.href = "/wp-login.php"; |
||||
return; |
||||
} |
||||
|
||||
if (response.is_liked) { |
||||
$button |
||||
.empty() |
||||
.append( |
||||
$( |
||||
'<svg width="15" height="13" viewBox="0 0 15 13" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M10.7745 1C8.67239 1 7.7426 2.5355 7.54047 3.30325C7.39224 2.5355 6.49748 1 4.10427 1C1.11276 1 -0.221288 4.85199 2.40639 8.14801C4.50853 10.7848 6.705 11.8147 7.54047 12C8.47026 11.8279 10.8311 10.761 12.8363 7.87004C15.3427 4.25632 13.4022 1 10.7745 1Z" stroke="#ff0000" fill="rgba(255, 0, 0, 0.7)"></path></svg>' |
||||
) |
||||
) |
||||
.append(response.count); |
||||
$button.addClass("active"); |
||||
} else { |
||||
$button |
||||
.empty() |
||||
.append( |
||||
$( |
||||
'<svg width="15" height="13" viewBox="0 0 15 13" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M10.7745 1C8.67239 1 7.7426 2.5355 7.54047 3.30325C7.39224 2.5355 6.49748 1 4.10427 1C1.11276 1 -0.221288 4.85199 2.40639 8.14801C4.50853 10.7848 6.705 11.8147 7.54047 12C8.47026 11.8279 10.8311 10.761 12.8363 7.87004C15.3427 4.25632 13.4022 1 10.7745 1Z" stroke="#666666" fill="none"></path></svg>' |
||||
) |
||||
) |
||||
.append(response.count); |
||||
$button.removeClass("active"); |
||||
} |
||||
}, |
||||
error: function (error) { |
||||
if (error.responseJSON && error.responseJSON.data) { |
||||
alert(error.responseJSON.data); |
||||
window.location.href = "/wp-login.php"; |
||||
} |
||||
}, |
||||
}); |
||||
}); |
||||
|
||||
function checkLikedPosts() { |
||||
if (!document.body.classList.contains("logged-in")) { |
||||
return; |
||||
} |
||||
|
||||
$.ajax({ |
||||
url: "/wp-admin/admin-ajax.php", |
||||
type: "POST", |
||||
data: { |
||||
action: "check_user_likes", |
||||
}, |
||||
success: function (response) { |
||||
if (response.error) { |
||||
return; |
||||
} |
||||
|
||||
try { |
||||
var data = JSON.parse(response); |
||||
|
||||
if (data.posts && data.posts.length > 0) { |
||||
for (var i = 0; i < data.posts.length; i++) { |
||||
var $button = $('.comment-btn button[data-post-id="' + data.posts[i] + '"]'); |
||||
$button.addClass("active"); |
||||
$button.find("svg path").attr({ |
||||
fill: "rgba(255, 0, 0, 0.7)", |
||||
stroke: "#ff0000", |
||||
}); |
||||
} |
||||
} |
||||
|
||||
if (data.comments && data.comments.length > 0) { |
||||
for (var j = 0; j < data.comments.length; j++) { |
||||
var $commentButton = $('.comment-like-btn[data-comment-id="' + data.comments[j] + '"]'); |
||||
$commentButton.addClass("active"); |
||||
|
||||
$commentButton.find("svg path").attr({ |
||||
fill: "rgba(255, 0, 0, 0.7)", |
||||
stroke: "#ff0000", |
||||
}); |
||||
} |
||||
} |
||||
} catch (e) {} |
||||
}, |
||||
error: function (error) {}, |
||||
}); |
||||
} |
||||
|
||||
if (document.body.classList.contains("logged-in")) { |
||||
checkLikedPosts(); |
||||
} |
||||
}); |
||||
|
@ -0,0 +1,957 @@ |
||||
'use strict'; |
||||
|
||||
(function ($) { |
||||
const metaLocale = document.querySelector('meta[property="og:locale"]'); |
||||
const localeValue = metaLocale.getAttribute('content'); |
||||
function wc_cart_summary_upd(){ |
||||
let total = 0 |
||||
$('.cart_item').each(function(){ |
||||
total += Number($(this).data('cost')) |
||||
}) |
||||
return total |
||||
} |
||||
$('[data-pname]').on('click', function(){ |
||||
$('#sub_product_name').val($(this).data('pname')) |
||||
}) |
||||
|
||||
$(document).on('submit', '.product-item__form, .detail-block__form', function (e) { |
||||
e.preventDefault(); |
||||
var $form = $(this) |
||||
var product_qty = $form.find('input[name=quantity]').val() || 1 |
||||
var product_id = $form.find('input[name=product_id]').val() |
||||
var variation_id = $form.find('input[name=variation_id]').val() || 0; |
||||
var title = $(this).data('name') |
||||
var data = { |
||||
action: 'woocommerce_ajax_add_to_cart', |
||||
product_id: product_id, |
||||
product_sku: '', |
||||
quantity: product_qty, |
||||
variation_id: variation_id, |
||||
}; |
||||
dataLayer.push({ |
||||
"ecommerce": { |
||||
"currencyCode": "RUB", |
||||
"add": { |
||||
"products": [ |
||||
{ |
||||
"id": product_id, |
||||
"name": title, |
||||
"quantity": product_qty, |
||||
} |
||||
] |
||||
} |
||||
} |
||||
}); |
||||
// $(document.body).trigger('adding_to_cart', [$thisbutton, data]);
|
||||
|
||||
$.ajax({ |
||||
type: 'post', |
||||
url: woocommerce_params.ajax_url, |
||||
data: data, |
||||
beforeSend: function (response) { |
||||
$form.find('.detail-block-form__submit, .store-add-to-cart').addClass('loading').attr('disabled', true) |
||||
}, |
||||
complete: function (response) { |
||||
$form.find('.detail-block-form__submit, .store-add-to-cart').removeClass('loading').attr('disabled', false) |
||||
}, |
||||
success: function (response) { |
||||
$('.modal__item.modal__basket').html(response['cart']); |
||||
if(response['cart_count'] > 0){ |
||||
$('.mini-profile__button--counter').removeClass('disabled').html(response['cart_count']) |
||||
} |
||||
else{ |
||||
$('.mini-profile__button--counter').addClass('disabled').html(response['cart_count']) |
||||
} |
||||
initCounters(); |
||||
let modalF = document.querySelector('.modal'), |
||||
aside = document.querySelector('.modal__aside'), |
||||
device = window.screen.width; |
||||
|
||||
if(!$.cookie('gp-cosmopet-cartadd')){ |
||||
modalF.classList.add('active');
|
||||
$('.modal__basket').addClass('active'); |
||||
let thisContentElement = document.querySelector('.modal__basket'); |
||||
|
||||
let width = thisContentElement.clientWidth; |
||||
setTimeout(() => { |
||||
if (device <= 720) { |
||||
aside.style.width = `${device}px`; |
||||
thisContentElement.style.opacity = 1; |
||||
thisContentElement.style.filter = 'blur(0px)'; |
||||
}else{ |
||||
aside.style.width = `${width}px`; |
||||
thisContentElement.style.opacity = 1; |
||||
thisContentElement.style.filter = 'blur(0px)'; |
||||
} |
||||
}, 10); |
||||
|
||||
$.cookie('gp-cosmopet-cartadd', 'true', { expires: 2 }); |
||||
} |
||||
modalClose('.modal__close'); |
||||
}, |
||||
}); |
||||
|
||||
return false; |
||||
}); |
||||
|
||||
$(document).on('submit', '.modal__form-sub', function (e) { |
||||
e.preventDefault(); |
||||
var email = $(this).find('input[name="email"]').val() |
||||
var data = $(this).serialize() |
||||
$.ajax({ |
||||
type: 'post', |
||||
url: woocommerce_params.ajax_url, |
||||
data: data, |
||||
beforeSend: function (response) { |
||||
// $thisbutton.removeClass('added').addClass('loading');
|
||||
}, |
||||
complete: function (response) { |
||||
// $thisbutton.addClass('added').removeClass('loading');
|
||||
}, |
||||
success: function (response) { |
||||
$('.modal__to-know').removeClass('active') |
||||
$('#sub-result-email').html(email) |
||||
$('.modal__to-know-submit').addClass('active').css('filter', 'blur(0px)') |
||||
}, |
||||
}); |
||||
}); |
||||
|
||||
$(document).on('submit', '.form--contact', function (e) { |
||||
e.preventDefault(); |
||||
var form = this; |
||||
var data = $(this).serialize() |
||||
$.ajax({ |
||||
type: 'post', |
||||
url: woocommerce_params.ajax_url, |
||||
data: data, |
||||
beforeSend: function (response) { |
||||
// $thisbutton.removeClass('added').addClass('loading');
|
||||
}, |
||||
complete: function (response) { |
||||
// $thisbutton.addClass('added').removeClass('loading');
|
||||
}, |
||||
success: function (response) { |
||||
$(form).addClass('submited') |
||||
}, |
||||
}); |
||||
}); |
||||
|
||||
$('body').on('click', '.modal-basket__item .counter__button', function(){ |
||||
var input = $(this).closest('.counter').find('.counter__input').val() |
||||
var price = $(this).closest('.modal-basket-item__control').find('.modal-basket-item__price') |
||||
var productID = $(this).data('id') |
||||
var pr = $(this).closest('.modal-basket__item').find('.modal-basket__item-before').data('pr') |
||||
$(price).html(Number(input) * $(price).data('basecost')) |
||||
$(this).closest('.modal-basket__item').data('cost', Number(price.html())) |
||||
$('#cart_total').html(wc_cart_summary_upd()) |
||||
var title = $(this).closest('.cart_item').find('.modal-basket-item__title').html() |
||||
if ($(this).hasClass('minus')){ |
||||
$(this).attr('data-value', Number( $(this).attr('data-value')) - 1) |
||||
|
||||
if(Number($(this).attr('data-value')) == 0){ |
||||
$(this).closest('.modal-basket__item').find('.modal-basket__item-before').click() |
||||
} |
||||
dataLayer.push({ |
||||
"ecommerce": { |
||||
"currencyCode": "RUB", |
||||
"remove": { |
||||
"products": [ |
||||
{ |
||||
"id": pr, |
||||
"name": title, |
||||
"quantity": 1, |
||||
} |
||||
] |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
else{ |
||||
var min = $(this).closest('.counter--small').find('.minus') |
||||
$(min).attr('data-value', Number($(min).attr('data-value')) + 1) |
||||
dataLayer.push({ |
||||
"ecommerce": { |
||||
"currencyCode": "RUB", |
||||
"add": { |
||||
"products": [ |
||||
{ |
||||
"id": pr, |
||||
"name": title, |
||||
"quantity": 1, |
||||
} |
||||
] |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
// if ($(this).hasClass('minus') && Number(input) == 1){
|
||||
// $(this).closest('.modal-basket__item').find('.modal-basket__item-before').click()
|
||||
// }
|
||||
var data = { |
||||
action: 'get_cartprice', |
||||
quantity: input, |
||||
product: productID |
||||
}; |
||||
$.ajax({ |
||||
type: 'post', |
||||
url: '/wp-admin/admin-ajax.php', |
||||
data: data, |
||||
beforeSend: function (response) { |
||||
// $thisbutton.removeClass('added').addClass('loading');
|
||||
}, |
||||
complete: function (response) { |
||||
// $thisbutton.addClass('added').removeClass('loading');
|
||||
}, |
||||
success: function (response) { |
||||
if (response.error) { |
||||
|
||||
} else { |
||||
// $('#cart_total').html(response)
|
||||
initCounters() |
||||
if(response['cart_count'] > 0){ |
||||
$('.mini-profile__button--counter').removeClass('disabled').html(response['cart_count']) |
||||
} |
||||
else{ |
||||
$('.mini-profile__button--counter').addClass('disabled').html(response['cart_count']) |
||||
} |
||||
} |
||||
}, |
||||
}); |
||||
}) |
||||
|
||||
$('body').on('click', '.product-item-overlay__field .counter__button', function(){ |
||||
var input = $(this).closest('.counter').find('.counter__input').val() |
||||
var price = $(this).closest('.product-item__form').find('.product-item-overlay__price') |
||||
|
||||
|
||||
$(price).html(Number(input) * $(price).data('basecost')) |
||||
}) |
||||
|
||||
$('body').on('click', '.modal-basket__item-before', function(){ |
||||
var key = $(this).data('id') |
||||
var p_ID = $(this).data('pr'); |
||||
var var_ID = $(this).data('var'); |
||||
var quantity = $(this).closest('.modal-basket__item').find('.counter__input').val() |
||||
var layout = ` |
||||
<p class="modal-basket-item__title"> |
||||
Удаление товара из корзины: <span id="${key}_timer" class="timer_counter">5</span>с |
||||
</p> |
||||
|
||||
<button class="modal-basket-item__return" id="${key}_return" data-id="${p_ID}" data-var="${var_ID}" data-quantity="${quantity}"> |
||||
Восстановить |
||||
</button> |
||||
` |
||||
if(localeValue == 'en_US'){ |
||||
var layout = ` |
||||
<p class="modal-basket-item__title"> |
||||
Removing product from cart: <span id="${key}_timer" class="timer_counter">5</span>s |
||||
</p> |
||||
|
||||
<button class="modal-basket-item__return" id="${key}_return" data-id="${p_ID}" data-var="${var_ID}" data-quantity="${quantity}"> |
||||
Restore |
||||
</button> |
||||
` |
||||
} |
||||
|
||||
var old_html = $(this).closest('.modal-basket__item').html() |
||||
$(this).closest('.modal-basket__item').addClass('.modal-basket__item--return').html(layout) |
||||
var title = $(this).closest('.cart_item').find('.modal-basket-item__title').html() |
||||
|
||||
|
||||
var timerVal = 5; |
||||
|
||||
var interval = setInterval(function(){ |
||||
timerVal -= 1; |
||||
if (timerVal > 0){ |
||||
$(`#${key}_timer`).html(timerVal) |
||||
} |
||||
else{ |
||||
|
||||
dataLayer.push({ |
||||
"ecommerce": { |
||||
"currencyCode": "RUB", |
||||
"remove": { |
||||
"products": [ |
||||
{ |
||||
"id": p_ID, |
||||
"name": title, |
||||
"quantity": quantity, |
||||
} |
||||
] |
||||
} |
||||
} |
||||
}); |
||||
var input = 0; |
||||
var productID = key; |
||||
|
||||
var data = { |
||||
action: 'get_cartprice', |
||||
quantity: input, |
||||
product: productID |
||||
}; |
||||
$.ajax({ |
||||
type: 'post', |
||||
url: '/wp-admin/admin-ajax.php', |
||||
data: data, |
||||
beforeSend: function (response) { |
||||
// $thisbutton.removeClass('added').addClass('loading');
|
||||
}, |
||||
complete: function (response) { |
||||
// $thisbutton.addClass('added').removeClass('loading');
|
||||
}, |
||||
success: function (response) { |
||||
|
||||
if(response['cart_count'] > 0){ |
||||
$('.mini-profile__button--counter').removeClass('disabled').html(response['cart_count']) |
||||
} |
||||
else{ |
||||
$('.mini-profile__button--counter').addClass('disabled').html(response['cart_count']) |
||||
} |
||||
}, |
||||
}); |
||||
$(`#${key}_timer`).closest('.modal-basket__item').remove() |
||||
if (Number(wc_cart_summary_upd()) > 0){ |
||||
$('#cart_total').html(wc_cart_summary_upd()) |
||||
} |
||||
else{ |
||||
var tmpl = `<div class="modal__header --nb">
|
||||
<p class="modal__title">Корзина</p> |
||||
<p class="modal__text">Ваша корзина пуста</p> |
||||
</div> |
||||
|
||||
<div class="modal__footer"> |
||||
<div class="modal__block-button"> |
||||
<div class="modal__button"> |
||||
<a href="/shop/" class="button button--100-perc button--link button--white"> |
||||
Продолжить покупки |
||||
</a> |
||||
</div> |
||||
</div> |
||||
</div>` |
||||
|
||||
if(localeValue == 'en_US'){ |
||||
var tmpl = `<div class="modal__header --nb">
|
||||
<p class="modal__title">Cart</p> |
||||
<p class="modal__text">Your cart is empty</p> |
||||
</div> |
||||
|
||||
<div class="modal__footer"> |
||||
<div class="modal__block-button"> |
||||
<div class="modal__button"> |
||||
<a href="/en/shop-3/" class="button button--100-perc button--link button--white"> |
||||
Return to catalog |
||||
</a> |
||||
</div> |
||||
</div> |
||||
</div>` |
||||
} |
||||
$('.modal__basket').html(tmpl) |
||||
} |
||||
clearInterval(interval); |
||||
} |
||||
}, 1000) |
||||
|
||||
|
||||
|
||||
|
||||
$(`#${key}_return`).one('click', function(){ |
||||
$(this).closest('.modal-basket__item').removeClass('.modal-basket__item--return').html(old_html) |
||||
clearInterval(interval); |
||||
}) |
||||
}) |
||||
|
||||
$('body').on('click', '.state__button', function(){ |
||||
var s = $(this).closest('.select') |
||||
var id = $(this).data('id') |
||||
var bc = $(this).data('bc') |
||||
|
||||
var form = $(this).closest('.product-item__form') |
||||
|
||||
$(form).find('input[name="variation_id"]').val(id) |
||||
$(form).find('.counter__input').data('maxcount', $(this).data('stock')).attr('data-maxcount', $(this).data('stock')) |
||||
if (Number($(form).find('.counter__input').val()) > Number($(form).find('.counter__input').data('maxcount'))){ |
||||
$(form).find('.counter__input').val($(form).find('.counter__input').data('maxcount')) |
||||
} |
||||
var input = $(form).find('.counter__input').val() |
||||
$(form).find('.product-item-overlay__price').data('basecost', bc).html(Number(bc) * Number(input)) |
||||
}) |
||||
|
||||
$('body').on('click', '.btn-load-ajax', function(){ |
||||
var page = Number($(this).data('page')) + 1 |
||||
var maxpage = Number($(this).data('maxpage')) |
||||
var data = { |
||||
ajax_load: 'ajax',
|
||||
}; |
||||
var btn = this |
||||
var baseUrl = jQuery(location).attr('origin') + jQuery(location).attr('pathname') |
||||
baseUrl += 'page/' + page + '/' |
||||
var searchUrl = baseUrl |
||||
if (jQuery(location).attr('search')){ |
||||
searchUrl += jQuery(location).attr('search') + '&ajax_search=ajax' |
||||
} |
||||
else{ |
||||
searchUrl += '?ajax_search=ajax' |
||||
} |
||||
$.ajax({ |
||||
type: 'get', |
||||
url: searchUrl, |
||||
data: data, |
||||
beforeSend: function (response) { |
||||
$(btn).attr('disabled', true) |
||||
$(btn).attr('data-page', page) |
||||
$(btn).data('page', page) |
||||
}, |
||||
complete: function (response) { |
||||
if (page >= maxpage){ |
||||
$(btn).remove() |
||||
} |
||||
else{ |
||||
$(btn).attr('disabled', false) |
||||
} |
||||
}, |
||||
success: function (response) { |
||||
$('.products').append(response) |
||||
initCounters() |
||||
initOverlay() |
||||
initSelect() |
||||
modalOpen('.open-to-know', '.modal__to-know'); |
||||
|
||||
/// РЕШЕНИЕ ДЛЯ СТЕНДА AJAX ДЛЯ ПОДГРУЗКИ AJAX
|
||||
document.querySelectorAll('img').forEach(img => {
|
||||
var str = img.attributes['src'].value.replace('https://cosmopet.good-production.xyz/', 'https://cosmopet.shop/') |
||||
checkImage(str, function(){ img.attributes['src'].value = str }); |
||||
if (img.attributes['srcset']){ |
||||
img.attributes['srcset'].value = img.attributes['srcset'].value.replace('cosmopet.good-production.xyz', '<?=$main_host?>') |
||||
} |
||||
}) |
||||
//
|
||||
}, |
||||
}); |
||||
}) |
||||
|
||||
// $('body').on('click', '.singular-w-btn', function(){
|
||||
// var wg = $(this).data('wg')
|
||||
// var id = $(this).data('id')
|
||||
// $('#variation_id').val(id)
|
||||
// $('.detail__block-price').hide()
|
||||
// $('.detail__block-price[data-wg="' + wg + '"]').show()
|
||||
// if ($(this).data('available')){
|
||||
// $('.detail-block-form__item--tn').hide()
|
||||
// $('.detail-block-form__item--add').show()
|
||||
// }
|
||||
// else{
|
||||
// $('.detail-block-form__item--tn').show()
|
||||
// $('.detail-block-form__item--add').hide()
|
||||
// }
|
||||
|
||||
// })
|
||||
// асинхронный запрос при отправке формы
|
||||
$( '#ajaxform' ).on( 'submit',function( event ) { |
||||
event.preventDefault(); |
||||
|
||||
const form = $(this); |
||||
|
||||
$.ajax( { |
||||
type : 'POST', |
||||
url : woocommerce_params.ajax_url, |
||||
data : form.serialize(), |
||||
beforeSend : function( xhr ) { |
||||
$('.products').addClass('loading') |
||||
form.find('.button-submit').addClass('loading').attr('disabled', true) |
||||
}, |
||||
success : function( data ) { |
||||
$( '.products' ).html( data.products ); |
||||
$('.product__tag').html(data.tags); |
||||
$( '.btn-load-ajax' ).remove() |
||||
form.find('.button-submit').removeClass('loading').attr('disabled', false) |
||||
form.find('.modal__close').click() |
||||
$('.products').removeClass('loading') |
||||
if (data.err){ |
||||
$('.product__error-button').show() |
||||
} |
||||
else{ |
||||
$('.product__error-button').hide() |
||||
} |
||||
|
||||
initCounters() |
||||
initOverlay() |
||||
initSelect() |
||||
modalOpen('.open-to-know', '.modal__to-know'); |
||||
|
||||
document.querySelectorAll('img').forEach(img => {
|
||||
var str = img.attributes['src'].value.replace('https://cosmopet.good-production.xyz/', 'https://cosmopet.shop/') |
||||
checkImage(str, function(){ img.attributes['src'].value = str }); |
||||
if (img.attributes['srcset']){ |
||||
img.attributes['srcset'].value = img.attributes['srcset'].value.replace('cosmopet.good-production.xyz', '<?=$main_host?>') |
||||
} |
||||
}) |
||||
} |
||||
|
||||
} ); |
||||
|
||||
} ); |
||||
|
||||
|
||||
$('body').on('click', '.product-tag__item', function(){ |
||||
$('#tax_' + $(this).data('tag')).find('input').prop('checked', false) |
||||
$('#tax_' + $(this).data('tag')).removeClass('active'); |
||||
$(this).remove() |
||||
$('#ajaxform').submit() |
||||
}) |
||||
|
||||
|
||||
// Login
|
||||
$('.login_popup').on('click', function(e){ |
||||
e.preventDefault(); |
||||
$('.login_modal').addClass('active'); |
||||
}); |
||||
$('.login_close').on('click', function(){ |
||||
$('.login_modal').removeClass('active'); |
||||
}); |
||||
$('.login_back').on('click', function(){ |
||||
if($(this).is('.disabled')) { |
||||
return false; |
||||
} |
||||
$('.login_wrap .step').toggleClass('active'); |
||||
}); |
||||
$('.login_input input').on('input keyup', function(){ |
||||
$('.login_input').removeClass('error'); |
||||
}); |
||||
$('.js-get-code').on('click', function(){ |
||||
$('.login_input').removeClass('error'); |
||||
|
||||
var email = $('.js-input-email input').val(); |
||||
$('.sended_email').text(email); |
||||
|
||||
if(email === '') { |
||||
$('.js-input-email').addClass('error'); |
||||
$('.js-input-email .login_error').text(localeValue == 'en_US' ? 'Enter your email' : 'Укажите Email'); |
||||
return false; |
||||
} else { |
||||
// Проверка Email
|
||||
$.ajax({ |
||||
type: 'POST', |
||||
url: '/wp-admin/admin-ajax.php', |
||||
data: {action: 'email_validate', email:email}, |
||||
success: function(data){ |
||||
if(data['status'] === 'error') { |
||||
$('.js-input-email').addClass('error'); |
||||
$('.js-input-email .login_error').text(data['text']); |
||||
return false; |
||||
} else { |
||||
$('.login_wrap .step').toggleClass('active'); |
||||
send_code(); |
||||
} |
||||
} |
||||
}); |
||||
|
||||
} |
||||
|
||||
}); |
||||
$('.js-repeat-code').on('click', function(){ |
||||
$('.login_input').removeClass('error'); |
||||
send_code(); |
||||
}); |
||||
|
||||
function send_code(){ |
||||
$('.login_timer').show(); |
||||
$('.js-repeat-code').hide(); |
||||
$('.login_back').addClass('disabled'); |
||||
// Timer
|
||||
var seconds = 15; |
||||
var interval = setInterval(function() { |
||||
if (seconds > 0) { |
||||
seconds--; |
||||
$('.seconds').text(seconds); |
||||
} else { |
||||
clearInterval(interval); |
||||
$('.login_timer').hide(); |
||||
$('.js-repeat-code').show(); |
||||
$('.login_back').removeClass('disabled'); |
||||
$('.seconds').text(15); |
||||
} |
||||
}, 1000); |
||||
//Ajax отправка кода
|
||||
$.ajax({ |
||||
type: 'POST', |
||||
url: '/wp-admin/admin-ajax.php', |
||||
data: {action: 'send_code', email: $('.js-input-email input').val()} |
||||
}); |
||||
} |
||||
// Проверка кода и регистрация/авторизация
|
||||
$('.js-input-code input').on('input keydown keyup propertychange paste cut copy change', function(){ |
||||
var val = $(this).val(); |
||||
var email = $('.js-input-email input').val(); |
||||
if(val.length === 4) { |
||||
$.ajax({ |
||||
type: 'POST', |
||||
url: '/wp-admin/admin-ajax.php', |
||||
data: {action: 'check_code', code: val, email: email}, |
||||
success: function(data){ |
||||
console.log(data); |
||||
if(data['status'] == 'success_reg') { |
||||
$('.login_forms').addClass('hide'); |
||||
$('.login_success').removeClass('hide'); |
||||
if (typeof wc_checkout_params !== 'undefined') { |
||||
location.reload() |
||||
} |
||||
} |
||||
if(data['status'] == 'success_auth') { |
||||
$('.login_forms').addClass('hide'); |
||||
$('.login_auth').removeClass('hide'); |
||||
if (typeof wc_checkout_params !== 'undefined') { |
||||
location.reload() |
||||
} |
||||
} |
||||
if(data['status'] == 'error') { |
||||
$('.js-input-code').addClass('error'); |
||||
$('.js-input-code .login_error').text(data['text']); |
||||
} |
||||
} |
||||
}); |
||||
}
|
||||
}); |
||||
|
||||
$('.email_link_form').on('submit', function(e){ |
||||
e.preventDefault(); |
||||
$('.cabinet-card_linked-email .error').remove(); |
||||
var data = $(this).serializeArray(); |
||||
$.ajax({ |
||||
type: 'POST', |
||||
url: '/wp-admin/admin-ajax.php', |
||||
data: data, |
||||
success: function(data){ |
||||
if(data['error']) { |
||||
$('.cabinet-card_linked-email').append('<div class="cabinet-card__status cabinet-card__status--cancelled error">'+data['error']+'</div>'); |
||||
} else { |
||||
location.reload(); |
||||
} |
||||
|
||||
} |
||||
}); |
||||
}); |
||||
|
||||
|
||||
})(jQuery); |
||||
|
||||
function checkImage(imageSrc, good) { |
||||
var img = new Image(); |
||||
img.onload = good; |
||||
img.src = imageSrc; |
||||
} |
||||
// header
|
||||
toggleOpenX('.lang', '.lang__open', '.lang__list', '.lang__content', false); |
||||
toggleHeader('#pc-menu','.header__menu-block','.header__pc-menu', '.white', 'white'); |
||||
toggleHeader('#phone-menu','.header__menu-block','.header__phone-menu', '.white', 'white'); |
||||
// header
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function initOverlay(){ |
||||
|
||||
// overlay
|
||||
let products = document.querySelectorAll('.product__item'); |
||||
|
||||
products.forEach(productItem => { |
||||
let button = productItem.querySelector('.open-overlay'), |
||||
overlay = productItem.querySelector('.product-item__overlay'); |
||||
|
||||
|
||||
if (button) { |
||||
button.onclick = function (e) { |
||||
document.querySelectorAll('.product__item').forEach(e => { |
||||
if (e.classList.contains('active')) { |
||||
e.classList.remove('active'); |
||||
} |
||||
}); |
||||
document.querySelectorAll('.product-item__overlay').forEach(e => { |
||||
if (e.classList.contains('active')) { |
||||
e.classList.remove('active'); |
||||
} |
||||
}); |
||||
|
||||
productItem.classList.toggle('active');
|
||||
overlay.classList.toggle('active');
|
||||
} |
||||
} |
||||
|
||||
}) |
||||
// overlay
|
||||
} |
||||
|
||||
initOverlay() |
||||
|
||||
|
||||
function initSelect(){ |
||||
|
||||
|
||||
// select
|
||||
toggleOpenX('.select', '.select__state' , '.state__content', '.state__block', true); |
||||
|
||||
let selects = document.querySelectorAll('.select'); |
||||
|
||||
selects.forEach(select => { |
||||
let state = select.querySelector('.select__state'), |
||||
content = select.querySelector('.state__block'), |
||||
buttons = select.querySelectorAll('.state__button'); |
||||
|
||||
buttons.forEach(e => { |
||||
let button = e; |
||||
|
||||
e.onclick = function (event) { |
||||
event.preventDefault(); |
||||
|
||||
buttons.forEach(element => { |
||||
if (element.classList.contains('active')) { |
||||
element.classList.remove('active'); |
||||
} |
||||
})
|
||||
|
||||
let text = e.textContent.trim(); |
||||
state.value = text; |
||||
|
||||
button.classList.add('active'); |
||||
content.style.height = 0; |
||||
select.classList.remove('active'); |
||||
}
|
||||
}) |
||||
}) |
||||
|
||||
// select
|
||||
} |
||||
initSelect() |
||||
|
||||
// counter
|
||||
function initCounters(){ |
||||
let counters = document.querySelectorAll('.counter'); |
||||
counters.forEach(e => { |
||||
let minus = e.querySelector('.minus'), |
||||
plus = e.querySelector('.plus'), |
||||
input = e.querySelector('.counter__input'); |
||||
minus.onclick = function (e) { |
||||
e.preventDefault(); |
||||
|
||||
let number = input.value; |
||||
|
||||
if (number >= 2){ |
||||
input.value = Number(number) - 1; |
||||
input.setAttribute('value', input.value) |
||||
} |
||||
} |
||||
|
||||
plus.onclick = function (e) { |
||||
e.preventDefault(); |
||||
|
||||
let number = input.value; |
||||
let max = input.dataset.maxcount |
||||
if (number <= max - 1) { |
||||
input.value = Number(number) + 1; |
||||
input.setAttribute('value', input.value) |
||||
} |
||||
} |
||||
}) |
||||
} |
||||
|
||||
initCounters() |
||||
// counter
|
||||
|
||||
// checkbox
|
||||
let checkbox = document.querySelectorAll('.checkbox'); |
||||
|
||||
checkbox.forEach(e => { |
||||
e.onclick = function (event) { |
||||
let input = e.querySelector('.checkbox__input'); |
||||
|
||||
if (!e.classList.contains('active')) { |
||||
input.checked = 1; |
||||
}else{ |
||||
input.checked = 0; |
||||
} |
||||
e.classList.toggle('active'); |
||||
} |
||||
}) |
||||
// checkbox
|
||||
|
||||
|
||||
// function
|
||||
function modalOpen(buttonElement, contentElement){ |
||||
let modal = document.querySelector('.modal'), |
||||
aside = document.querySelector('.modal__aside'), |
||||
elements = document.querySelectorAll(buttonElement), |
||||
device = window.screen.width; |
||||
|
||||
elements.forEach(e => { |
||||
let thisContentElement = document.querySelector(contentElement); |
||||
|
||||
e.onclick = function () { |
||||
modal.classList.add('active'); |
||||
thisContentElement.classList.add('active'); |
||||
|
||||
let width = thisContentElement.clientWidth; |
||||
|
||||
setTimeout(() => { |
||||
if (device <= 720) { |
||||
aside.style.width = `${device}px`; |
||||
thisContentElement.style.opacity = 1; |
||||
thisContentElement.style.filter = 'blur(0px)'; |
||||
}else{ |
||||
aside.style.width = `${width}px`; |
||||
thisContentElement.style.opacity = 1; |
||||
thisContentElement.style.filter = 'blur(0px)'; |
||||
} |
||||
}, 10); |
||||
} |
||||
}) |
||||
} |
||||
|
||||
function modalClose(buttonElement) { |
||||
let modal = document.querySelector('.modal'), |
||||
aside = document.querySelector('.modal__aside'), |
||||
asideItems = document.querySelectorAll('.modal__item'), |
||||
elements = document.querySelectorAll(buttonElement); |
||||
|
||||
elements.forEach(e => { |
||||
e.onclick = function () {
|
||||
aside.style.width = '0px'; |
||||
|
||||
asideItems.forEach(e => { |
||||
if (e.classList.contains('active')) { |
||||
e.style.filter = 'blur(10px)'; |
||||
} |
||||
}); |
||||
|
||||
setTimeout(() => { |
||||
asideItems.forEach(e => { |
||||
if (e.classList.contains('active')) { |
||||
e.classList.remove('active'); |
||||
} |
||||
}); |
||||
|
||||
modal.classList.remove('active'); |
||||
}, 300); |
||||
} |
||||
}) |
||||
} |
||||
|
||||
function toggleOpenX(mainElement, buttonElement ,heightElement, contentElement, close) { |
||||
let elements = document.querySelectorAll(mainElement); |
||||
|
||||
elements.forEach(e => { |
||||
let thisMainElement = e, |
||||
thisButtonElement = e.querySelector(buttonElement), |
||||
thisHeightElement = e.querySelector(heightElement), |
||||
thisContentElement = e.querySelector(contentElement);
|
||||
|
||||
thisButtonElement.onclick = function (e) { |
||||
let height = thisHeightElement.clientHeight; |
||||
|
||||
if (close == true && !thisMainElement.classList.contains('active')) { |
||||
elements.forEach(e => { |
||||
if (e.classList.contains('active')) { |
||||
e.classList.remove('active'); |
||||
e.querySelector(contentElement).style.height = null |
||||
}
|
||||
}) |
||||
} |
||||
|
||||
if (!thisMainElement.classList.contains('active')) { |
||||
thisContentElement.style.height = `${height}px`; |
||||
thisMainElement.classList.add('active'); |
||||
}else{ |
||||
thisContentElement.style.height = null; |
||||
thisMainElement.classList.remove('active'); |
||||
} |
||||
} |
||||
|
||||
}); |
||||
} |
||||
var menu_opened = false; |
||||
function toggleHeader(button, content, blockheight, removeBlock, removeClass) { |
||||
let thisButton = document.querySelector(button),
|
||||
thisContent = document.querySelector(content), |
||||
thisRemoveBlock = document.querySelector(removeBlock) || '', |
||||
thisBlockheight = document.querySelector(blockheight); |
||||
|
||||
thisButton.onclick = function () { |
||||
let height = thisBlockheight.clientHeight; |
||||
|
||||
if (!thisContent.classList.contains('open')) { |
||||
thisContent.style.height = `${height}px`; |
||||
thisContent.classList .add('open'); |
||||
|
||||
if (removeBlock) { |
||||
thisRemoveBlock.classList.remove(removeClass); |
||||
} |
||||
}else{ |
||||
thisContent.style.height = null; |
||||
thisContent.classList.remove('open'); |
||||
|
||||
if (removeBlock) { |
||||
if (window.Y <= 25) { |
||||
thisRemoveBlock.classList.add(removeClass); |
||||
} |
||||
} |
||||
} |
||||
menu_opened = !menu_opened; |
||||
} |
||||
} |
||||
|
||||
|
||||
// resize
|
||||
window.addEventListener('resize', (e) => { |
||||
let width = window.screen.width; |
||||
|
||||
// media
|
||||
modalOpen('.button--filter', '.modal__filter'); |
||||
modalOpen('.basket-open', '.modal__basket'); |
||||
modalOpen('.login-open', '.modal__login'); |
||||
modalOpen('.open-to-know', '.modal__to-know'); |
||||
modalClose('.modal__close'); |
||||
modalClose('.modal-form-sub__close'); |
||||
|
||||
let modalItem = document.querySelectorAll('.modal__item'); |
||||
|
||||
// if (width <= 720) {
|
||||
modalItem.forEach(modal => { |
||||
if (modal.classList.contains('active')) { |
||||
let aside = document.querySelector('.modal__aside'); |
||||
|
||||
if (width <= 720) { |
||||
aside.style.width = `${width}px` |
||||
}else{ |
||||
let openAside = document.querySelector('.modal__item.active'), |
||||
newWidth = openAside.clientWidth; |
||||
|
||||
aside.style.width = `${newWidth}px` |
||||
} |
||||
} |
||||
}) |
||||
// }
|
||||
}); |
||||
// resize
|
||||
|
||||
//
|
||||
|
||||
|
||||
if (document.querySelector('.header').classList.contains('white')) { |
||||
window.addEventListener("scroll", function (e) { |
||||
let header = document.querySelector('.header'); |
||||
let scroll = window.scrollY; |
||||
if(!menu_opened){ |
||||
if (scroll >= 25) { |
||||
header.classList.remove('white') |
||||
}else{ |
||||
|
||||
header.classList.add('white') |
||||
|
||||
} |
||||
} |
||||
|
||||
}); |
||||
} |
||||
// scroll
|
||||
|
||||
|
||||
|
@ -1,151 +0,0 @@ |
||||
'use strict'; |
||||
|
||||
// function
|
||||
function modalOpen(buttonElement, contentElement){ |
||||
let modal = document.querySelector('.modal'), |
||||
aside = document.querySelector('.modal__aside'), |
||||
elements = document.querySelectorAll(buttonElement), |
||||
device = window.screen.width; |
||||
|
||||
elements.forEach(e => { |
||||
let thisContentElement = document.querySelector(contentElement); |
||||
|
||||
e.onclick = function () { |
||||
modal.classList.add('active'); |
||||
thisContentElement.classList.add('active'); |
||||
|
||||
let width = thisContentElement.clientWidth; |
||||
|
||||
setTimeout(() => { |
||||
if (device <= 720) { |
||||
aside.style.width = `${device}px`; |
||||
thisContentElement.style.opacity = 1; |
||||
thisContentElement.style.filter = 'blur(0px)'; |
||||
}else{ |
||||
aside.style.width = `${width}px`; |
||||
thisContentElement.style.opacity = 1; |
||||
thisContentElement.style.filter = 'blur(0px)'; |
||||
} |
||||
}, 10); |
||||
} |
||||
}) |
||||
} |
||||
|
||||
function modalClose(buttonElement) { |
||||
let modal = document.querySelector('.modal'), |
||||
aside = document.querySelector('.modal__aside'), |
||||
asideItems = document.querySelectorAll('.modal__item'), |
||||
elements = document.querySelectorAll(buttonElement); |
||||
|
||||
elements.forEach(e => { |
||||
e.onclick = function () {
|
||||
aside.style.width = '0px'; |
||||
|
||||
asideItems.forEach(e => { |
||||
if (e.classList.contains('active')) { |
||||
e.style.filter = 'blur(10px)'; |
||||
} |
||||
}); |
||||
|
||||
setTimeout(() => { |
||||
asideItems.forEach(e => { |
||||
if (e.classList.contains('active')) { |
||||
e.classList.remove('active'); |
||||
} |
||||
}); |
||||
|
||||
modal.classList.remove('active'); |
||||
}, 300); |
||||
} |
||||
}) |
||||
} |
||||
|
||||
function toggleOpenX(mainElement, buttonElement ,heightElement, contentElement, close) { |
||||
let elements = document.querySelectorAll(mainElement); |
||||
|
||||
elements.forEach(e => { |
||||
let thisMainElement = e, |
||||
thisButtonElement = e.querySelector(buttonElement), |
||||
thisHeightElement = e.querySelector(heightElement), |
||||
thisContentElement = e.querySelector(contentElement);
|
||||
|
||||
thisButtonElement.onclick = function (e) { |
||||
let height = thisHeightElement.clientHeight; |
||||
|
||||
if (close == true && !thisMainElement.classList.contains('active')) { |
||||
elements.forEach(e => { |
||||
if (e.classList.contains('active')) { |
||||
e.classList.remove('active'); |
||||
e.querySelector(contentElement).style.height = null |
||||
}
|
||||
}) |
||||
} |
||||
|
||||
if (!thisMainElement.classList.contains('active')) { |
||||
thisContentElement.style.height = `${height}px`; |
||||
thisMainElement.classList.add('active'); |
||||
}else{ |
||||
thisContentElement.style.height = null; |
||||
thisMainElement.classList.remove('active'); |
||||
} |
||||
} |
||||
|
||||
}); |
||||
} |
||||
var menu_opened = false; |
||||
function toggleHeader(button, content, blockheight, removeBlock, removeClass) { |
||||
let thisButton = document.querySelector(button),
|
||||
thisContent = document.querySelector(content), |
||||
thisRemoveBlock = document.querySelector(removeBlock) || '', |
||||
thisBlockheight = document.querySelector(blockheight); |
||||
|
||||
thisButton.onclick = function () { |
||||
let height = thisBlockheight.clientHeight; |
||||
|
||||
if (!thisContent.classList.contains('open')) { |
||||
thisContent.style.height = `${height}px`; |
||||
thisContent.classList .add('open'); |
||||
|
||||
if (removeBlock) { |
||||
thisRemoveBlock.classList.remove(removeClass); |
||||
} |
||||
}else{ |
||||
thisContent.style.height = null; |
||||
thisContent.classList.remove('open'); |
||||
|
||||
if (removeBlock) { |
||||
if (window.Y <= 25) { |
||||
thisRemoveBlock.classList.add(removeClass); |
||||
} |
||||
} |
||||
} |
||||
menu_opened = !menu_opened; |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
if (document.querySelector('.header').classList.contains('white')) { |
||||
window.addEventListener("scroll", function (e) { |
||||
let header = document.querySelector('.header'); |
||||
let scroll = window.scrollY; |
||||
if(!menu_opened){ |
||||
if (scroll >= 25) { |
||||
header.classList.remove('white') |
||||
}else{ |
||||
|
||||
header.classList.add('white') |
||||
|
||||
} |
||||
} |
||||
|
||||
}); |
||||
} |
||||
|
||||
toggleOpenX('.lang', '.lang__open', '.lang__list', '.lang__content', false); |
||||
toggleHeader('#pc-menu','.header__menu-block','.header__pc-menu', '.white', 'white'); |
||||
toggleHeader('#phone-menu','.header__menu-block','.header__phone-menu', '.white', 'white'); |
||||
// scroll
|
||||
|
||||
|
||||
|