Website Summary Files Commits Branches @commit @diff @stats
path: root / wp-content / themes
diff options
context:
space:
mode:
Commit1c86fe831289eee3d3c2c963885fd553f40f81d2 (patch)
Author
 Victor Gorchilov <victor@gorchilov.com>
2020-07-15 20:43:05 +0300
Committer
 Victor Gorchilov <victor@gorchilov.com>
2020-07-15 20:43:05 +0300
Files1dc3d183affddf9c040eba8b9ec1e60c9e002d90 /wp-content/themes
tues-interns-2020-feature/offers-grid.tar
tues-interns-2020-feature/offers-grid.tar.gz
tues-interns-2020-feature/offers-grid.zip
Parent333668c49e98cdfc84cf0702f289bd149fc5fd25 (diff)
[fix] bring changes from master feature/offers-grid
diff --git a/wp-content/themes/carmag/assets/src/sass/components/_card.scss b/wp-content/themes/carmag/assets/src/sass/components/_card.scss
index e3535e0..00ac903 100644
--- a/wp-content/themes/carmag/assets/src/sass/components/_card.scss
+++ b/wp-content/themes/carmag/assets/src/sass/components/_card.scss
@@ -5,6 +5,7 @@
width: 350px;
height: 280px;
position: relative;
+ margin: 1rem;
.card-info {
position: absolute;
@@ -13,6 +14,7 @@
background-color: rgba(0, 0, 0, 0.6);
color: white;
padding: 20px 25px 0;
+ transition: 0.2s;
* {
margin: 0;
@@ -54,4 +56,12 @@
}
}
}
+
+ &:hover {
+ .card-info {
+ .info-readmore {
+ margin-top: calc(100% - 130px);
+ }
+ }
+ }
}
diff --git a/wp-content/themes/carmag/assets/src/sass/layout/_login-register.scss b/wp-content/themes/carmag/assets/src/sass/layout/_login-register.scss
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/wp-content/themes/carmag/assets/src/sass/layout/_login-register.scss
diff --git a/wp-content/themes/carmag/assets/src/scripts/scripts.js b/wp-content/themes/carmag/assets/src/scripts/scripts.js
index 93438c7..6d6347c 100644
--- a/wp-content/themes/carmag/assets/src/scripts/scripts.js
+++ b/wp-content/themes/carmag/assets/src/scripts/scripts.js
@@ -22,7 +22,7 @@ jQuery(document).ready(function ($) {
const toggleDrawer = () => {
const drawerClassList = event.target.classList;
- const navClassList = document.querySelectorAll(".menu-primary-container")[0]
+ const navClassList = document.querySelectorAll(".menu-container")[0]
.classList;
drawerClassList.toggle("opened");
navClassList.toggle("opened");
@@ -31,9 +31,13 @@ const toggleDrawer = () => {
const separator = document.createElement("span");
separator.className = "separator";
const loginLink = document.querySelectorAll(".login")[0];
+const profileDropdown = document.querySelectorAll(".profile")[0];
if (loginLink) {
loginLink.before(separator);
}
+if (profileDropdown) {
+ profileDropdown.before(separator);
+}
const faqFields = document.querySelectorAll(".faq-field");
faqFields.forEach((field) => {
@@ -42,3 +46,104 @@ faqFields.forEach((field) => {
field.querySelector(".field-content").classList.toggle("opened");
});
});
+
+let selectedBrand = document.getElementById("brands");
+let modelsNames = Object.keys(carModels);
+modelsNames.forEach((model) => {
+ let option = document.createElement("option");
+ option.value = model;
+ option.innerHTML = model;
+ selectedBrand.appendChild(option);
+});
+const handleModels = () => {
+ const brand = event.target.value;
+ const modelsSelect = document.getElementById("models");
+ const defaultOption = modelsSelect.firstElementChild;
+ modelsSelect.innerHTML = "";
+ modelsSelect.append(defaultOption);
+ let models;
+ if (selectedType.value === "car") {
+ models = carModels;
+ } else if (selectedType.value === "truck") {
+ models = truckModels;
+ } else if (selectedType.value === "motorcycle") {
+ models = motorcycleModels;
+ } else if (selectedType.value === "tractor") {
+ models = agriculturalBrands;
+ } else if (selectedType.value === "bus") {
+ models = busModels;
+ }
+ if (brand) {
+ models[brand].forEach((model) => {
+ let option = document.createElement("option");
+ option.value = model;
+ option.innerHTML = model;
+ modelsSelect.appendChild(option);
+ });
+ } else {
+ let option = document.createElement("option");
+ option.value = "";
+ option.innerHTML = "Model";
+ modelsSelect.appendChild(option);
+ }
+};
+let selectedType = document.getElementById("category");
+let types = document.querySelectorAll(".type");
+types.forEach((type) => {
+ type.addEventListener("click", () => {
+ event.stopPropagation();
+ types.forEach((type) => {
+ type.classList.remove("selected");
+ });
+ event.target.classList.add("selected");
+ selectedType.value = event.target.id;
+ let models;
+ if (selectedType.value === "car") {
+ models = carModels;
+ } else if (selectedType.value === "truck") {
+ models = truckModels;
+ } else if (selectedType.value === "motorcycle") {
+ models = motorcycleModels;
+ } else if (selectedType.value === "tractor") {
+ models = agriculturalBrands;
+ } else if (selectedType.value === "bus") {
+ models = busModels;
+ }
+ modelsNames = Object.keys(models);
+ const defaultOption = selectedBrand.firstElementChild;
+ selectedBrand.innerHTML = "";
+ selectedBrand.append(defaultOption);
+ modelsNames.forEach((model) => {
+ let option = document.createElement("option");
+ option.value = model;
+ option.innerHTML = model;
+ selectedBrand.appendChild(option);
+ });
+ });
+});
+
+const switcher = document.querySelectorAll(".switcher")[0];
+if (switcher) {
+ switcher.addEventListener("click", () => {
+ event.stopPropagation();
+ const firstPrice = document.querySelectorAll(".price-first")[0];
+ const secondPrice = document.querySelectorAll(".price-second")[0];
+ [firstPrice.value, secondPrice.value] = [
+ secondPrice.value,
+ firstPrice.value,
+ ];
+ });
+}
+var password = document.getElementById("password"),
+ confirm_password = document.getElementById("confirm_password");
+
+function validatePassword() {
+ if (password.value != confirm_password.value) {
+ confirm_password.setCustomValidity("Passwords don't match");
+ } else {
+ confirm_password.setCustomValidity("");
+ }
+}
+
+password.onchange = validatePassword;
+confirm_password.onkeyup = validatePassword;
diff --git a/wp-content/themes/carmag/template-parts/content-card.php b/wp-content/themes/carmag/template-parts/content-card.php
index e3d969e..e16d358 100644
--- a/wp-content/themes/carmag/template-parts/content-card.php
+++ b/wp-content/themes/carmag/template-parts/content-card.php
@@ -9,13 +9,19 @@
?>
-<div class="card">
- <div class="card-info">
- <p class="info-title">McLaren P1</p>
- <p class="info-price">$75,000</p>
- <button class="button info-readmore">
- <span>Read more</span>
- <i class="fas fa-long-arrow-alt-right"></i>
- </button>
- </div>
+<?php
+$name = get_query_var('name');
+$price = get_query_var('price');
+$url = get_query_var('url');
+$image = get_query_var('image');
+?>
+<div class="card" style="background-image: url('<?php echo $image ?>')">
+ <div class="card-info">
+ <p class="info-title"><?php echo $name ?></p>
+ <p class="info-price">$<?php echo $price ?></p>
+ <a href="<?php echo $url ?>" class="button info-readmore">
+ <span>Read more</span>
+ <i class="fas fa-long-arrow-alt-right"></i>
+ </a>
+ </div>
</div>
diff --git a/wp-content/themes/carmag/templates/homepage.php b/wp-content/themes/carmag/templates/homepage.php
index 96f4f11..7f0a94b 100644
--- a/wp-content/themes/carmag/templates/homepage.php
+++ b/wp-content/themes/carmag/templates/homepage.php
@@ -1,32 +1,136 @@
-<?php
+<?php
/**
* Template Name: Homepage
*
* Custom homepage template for the theme
- *
+ *
* @since v1.0.0
* @package CarMag
*/
+get_header();
+?>
+
+<section class="section-fullwidth section-search">
+ <div class="row">
+ <div class="column small-12 medium-12">
+ <div id="primary" class="content-area">
+ <main id="main" class="site-main">
+ <div class="simple-search">
+ <h2>Find your dream car</h2>
-get_header(); ?>
+ <form id="search-form" class="search-form" action="/" method="GET">
+ <input type="hidden" name="search" value="vehicles">
+ <div class="form-content">
+ <select id="brands" name="brand" class="form-field brands" onChange="handleModels()">
+ <option selected="" value="">Brand</option>
+ </select>
+
+ <select name="model" id="models" class="form-field models">
+ <option selected="" value="">Model</option>
+ </select>
+
+ <select name="condition" class="form-field condition">
+ <option selected="" value="">Condition</option>
+ <option value="new">Factory new</option>
+ <option value="used">Used</option>
+ <option value="for_parts">For parts</option>
+ </select>
+
+ <select name="location" class="form-field location">
+ <option selected="" value="">Location</option>
+ <option value="blagoevgrad">Благоевград</option>
+ <option value="burgas">Бургас</option>
+ <option value="varna">Варна</option>
+ <option value="velikoturnovo">Велико Търново</option>
+ <option value="vidin">Видин</option>
+ <option value="vratsa">Враца</option>
+ <option value="gabrovo">Габрово</option>
+ <option value="dobrich">Добрич</option>
+ <option value="dupnitsa">Дупница</option>
+ <option value="kurdjali">Кърджали</option>
+ <option value="kustendil">Кюстендил</option>
+ <option value="lovech">Ловеч</option>
+ <option value="montana">Монтана</option>
+ <option value="pazardjik">Пазарджик</option>
+ <option value="pernik">Перник</option>
+ <option value="pleven">Плевен</option>
+ <option value="plovdiv">Пловдив</option>
+ <option value="razgrad">Разград</option>
+ <option value="ruse">Русе</option>
+ <option value="silistra">Силистра</option>
+ <option value="sliven">Сливен</option>
+ <option value="smolqn">Смолян</option>
+ <option value="sofia">София</option>
+ <option value="starazagora">Стара Загора</option>
+ <option value="turgovishte">Търговище</option>
+ <option value="haskovo">Хасково</option>
+ <option value="shumen">Шумен</option>
+ <option value="qmbol">Ямбол</option>
+ </select>
+
+
+
+ <div class="wrapper-price">
+ <div class="price"><input type="number" class="form-field price-first" name="start_price" value="2000"></div>
+ <div class="switcher"><i class="fas fa-exchange-alt"></i> </div>
+ <div class="price"><input type="number" class="form-field price-second" name="end_price" value="16000"></div>
+ </div>
+ </div>
+
+ <div class="form-actions">
+ <div class="actions-vehicle-type">
+ <span id="car" class="selected type"><i class="fas fa-car"></i></span>
+ <span id="truck" class="type"><i class="fas fa-truck"></i></span>
+ <span id="motorcycle" class="type"><i class="fas fa-motorcycle"></i></span>
+ <span id="tractor" class="type"><i class="fas fa-tractor"></i></span>
+ <span id="bus" class="type"><i class="fas fa-bus"></i></span>
+ <input type="hidden" name="category" id="category" value="car">
+ </div>
+
+ <div class="actions-buttons">
+ <a href="<?php echo home_url( '/advanced-search/' ); ?>" class="advanced-button button secondary">Advanced Search</a>
+ <button type="submit" class="search-button button secondary" form="search-form">Search now</button>
+ </div>
+ </div>
+ </form>
+ </div>
+ </main><!-- #main -->
+ </div><!-- #primary -->
+ </div><!-- .column -->
+ </div><!-- .row -->
+</section><!-- .section-fullwidth section-main -->
<section class="section-fullwidth section-latestoffers">
- <div class="row">
- <div class="columns small-12 medium-8">
- <div id="primary" class="content-area">
- <main id="latestoffers" class="site-latestoffers">
- <div class="latestoffers" >
- <?php
- for($i = 0; $i < 5; $i++) :
- get_template_part( 'template-parts/content', 'card' );
- endfor;
- ?>
- </div>
- </main><!-- #main -->
- </div><!-- #primary -->
- </div><!-- .columns medium-8 -->
- </div><!-- .row -->
- </section><!-- .section-fullwidth section-main -->
+ <div class="row latestoffers-text">
+ Check our latest deals
+ </div><!-- .row -->
+ <div class="view latestoffers-grid">
+ <?php
+ $new_loop = new WP_Query( array(
+ 'post_type' => 'vehicles',
+ 'posts_per_page' => 6
+ ) );
+ ?>
+
+ <?php if ( $new_loop->have_posts() ) : ?>
+ <?php while ( $new_loop->have_posts() ) : $new_loop->the_post(); ?>
+ <?php
+ $images = ( array )json_decode( get_post_meta( get_the_ID(), __( 'vehicle-images' ), true ) );
+ set_query_var('name', sanitize_text_field( get_the_title() ));
+ set_query_var('price', sanitize_text_field( get_post_meta( get_the_ID(), __( 'vehicle-price' ), true ) ) );
+ set_query_var('url', sanitize_text_field( get_post_permalink( get_the_ID() ) ) );
+ set_query_var('image', sanitize_text_field( array_pop( $images ) ));
+ ?>
+ <?php get_template_part( 'template-parts/content', 'card' ); ?>
+ <?php endwhile;?>
+ <?php else: ?>
+ <?php endif; ?>
+ <?php wp_reset_query(); ?>
+
+ </div>
+</section><!-- .section-fullwidth section-main -->
-<?php get_footer(); ?>
+<?php
+get_footer();
+?>
diff --git a/wp-content/themes/carmag/templates/register.php b/wp-content/themes/carmag/templates/register.php
new file mode 100644
index 0000000..e61f9cc
--- /dev/null
+++ b/wp-content/themes/carmag/templates/register.php
@@ -0,0 +1,37 @@
+<?php
+/**
+ * Template Name: Register
+ *
+ * Custom register template for the theme
+ *
+ * @since v1.0.0
+ * @package CarMag
+ */
+
+
+get_header(); ?>
+
+<section class="section-fullwidth section-register">
+ <div class="row">
+ <div class="column small-12 medium-8">
+ <div id="primary" class="content-area">
+ <main id="main" class="site-main">
+ <form method="POST" action="<?php echo admin_url('admin-post.php') ?>" class="register-form">
+ <input type="hidden" name="action" value="process_register">
+ <h1>Create Account</h1>
+
+ <input class="form-input" type="email" name="email" id="email" placeholder="Email" required autofocus>
+ <input class="form-input" type="text" name="name" id="name" placeholder="Name" required>
+ <input class="form-input" type="password" name="password" id="password" placeholder="Password" required>
+ <input class="form-input" type="password" name="confirm_password" id="confirm_password" placeholder="Confirm password" required>
+ <button type="submit" class="form-submit">Register</button>
+
+ <p class="form-suggestion">Already have an account? <a href="/login/">Login</a></p>
+ </form>
+ </main><!-- #main -->
+ </div><!-- #primary -->
+ </div><!-- .column -->
+ </div><!-- .row -->
+</section><!-- .section-fullwidth -->
+
+<?php get_footer(); ?>