init
This commit is contained in:
@@ -0,0 +1,286 @@
|
||||
.esun-contact-popup-modal .modal-inner-wrap {
|
||||
width: min(660px, calc(100% - 40px));
|
||||
max-width: 660px;
|
||||
overflow: hidden;
|
||||
border: 0;
|
||||
border-radius: 20px;
|
||||
background: #fff;
|
||||
box-shadow: 0 18px 60px rgba(19, 63, 42, 0.2);
|
||||
}
|
||||
|
||||
.esun-contact-popup-modal .modal-header {
|
||||
padding: 24px 36px;
|
||||
background: #1e9e5a;
|
||||
}
|
||||
|
||||
.esun-contact-popup-modal .modal-title {
|
||||
padding: 0;
|
||||
border: 0;
|
||||
color: #fff;
|
||||
font-size: 28px;
|
||||
font-weight: 700;
|
||||
line-height: 1.25;
|
||||
}
|
||||
|
||||
.esun-contact-popup-modal .action-close {
|
||||
top: 18px;
|
||||
right: 24px;
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
padding: 0;
|
||||
border: 1px solid rgba(255, 255, 255, 0.65);
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
color: #fff;
|
||||
transition: background-color 0.2s ease;
|
||||
}
|
||||
|
||||
.esun-contact-popup-modal .action-close:before {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.esun-contact-popup-modal .action-close:hover,
|
||||
.esun-contact-popup-modal .action-close:focus {
|
||||
border-color: #fff;
|
||||
background: rgba(255, 255, 255, 0.25);
|
||||
}
|
||||
|
||||
.esun-contact-popup-modal .modal-content {
|
||||
padding: 34px 36px 38px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.esun-contact-popup__grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 20px 18px;
|
||||
}
|
||||
|
||||
.esun-contact-popup__field {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.esun-contact-popup__grid .esun-contact-popup__field {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.esun-contact-popup__label {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.esun-contact-popup input.input-text,
|
||||
.esun-contact-popup select,
|
||||
.esun-contact-popup textarea {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #d9dde1;
|
||||
background: #fff;
|
||||
color: #1a1a1a;
|
||||
font-family: inherit;
|
||||
font-size: 15px;
|
||||
box-shadow: none;
|
||||
transition:
|
||||
border-color 0.2s ease,
|
||||
box-shadow 0.2s ease;
|
||||
}
|
||||
.esun-contact-popup select {
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
appearance: none;
|
||||
padding-right: 54px;
|
||||
background-color: #fff;
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='8' viewBox='0 0 14 8'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%23a3a3a3' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
|
||||
background-repeat: no-repeat;
|
||||
background-position: right 22px center;
|
||||
background-size: 10px 8px;
|
||||
}
|
||||
.esun-contact-popup input.input-text,
|
||||
.esun-contact-popup select {
|
||||
height: 48px;
|
||||
padding: 0 20px;
|
||||
border-radius: 24px;
|
||||
}
|
||||
|
||||
.esun-contact-popup textarea {
|
||||
min-height: 140px;
|
||||
padding: 16px 20px;
|
||||
border-radius: 18px;
|
||||
line-height: 1.5;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
.esun-contact-popup input.input-text::placeholder,
|
||||
.esun-contact-popup textarea::placeholder,
|
||||
.esun-contact-popup select:invalid {
|
||||
color: #a3a3a3;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.esun-contact-popup input.input-text:focus,
|
||||
.esun-contact-popup select:focus,
|
||||
.esun-contact-popup textarea:focus {
|
||||
outline: none;
|
||||
border-color: #1e9e5a;
|
||||
box-shadow: 0 0 0 3px rgba(30, 158, 90, 0.12);
|
||||
}
|
||||
|
||||
.esun-contact-popup__field--full:first-of-type {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.esun-contact-popup__grid + .esun-contact-popup__field--full {
|
||||
margin-top: 24px;
|
||||
}
|
||||
|
||||
.esun-contact-popup .mage-error {
|
||||
margin-top: 6px;
|
||||
color: #e02b27;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.esun-contact-popup__status {
|
||||
display: none;
|
||||
margin-bottom: 20px;
|
||||
padding: 12px 18px;
|
||||
border-radius: 12px;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.esun-contact-popup__status.success,
|
||||
.esun-contact-popup__status.error {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.esun-contact-popup__status.success {
|
||||
background: #edf8f2;
|
||||
color: #167746;
|
||||
}
|
||||
|
||||
.esun-contact-popup__status.error {
|
||||
background: #fff1f0;
|
||||
color: #c62828;
|
||||
}
|
||||
|
||||
.esun-contact-popup-modal
|
||||
.esun-contact-popup
|
||||
button.action.primary.esun-contact-popup__submit {
|
||||
width: 100%;
|
||||
min-height: 48px;
|
||||
border: 0;
|
||||
border-radius: 24px;
|
||||
background: #1e9e5a;
|
||||
color: #fff;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.4px;
|
||||
box-shadow: none;
|
||||
transition:
|
||||
background-color 0.2s ease,
|
||||
transform 0.2s ease;
|
||||
}
|
||||
|
||||
.esun-contact-popup-modal
|
||||
.esun-contact-popup
|
||||
button.action.primary.esun-contact-popup__submit:hover,
|
||||
.esun-contact-popup-modal
|
||||
.esun-contact-popup
|
||||
button.action.primary.esun-contact-popup__submit:focus {
|
||||
background: #178049;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.esun-contact-popup-modal
|
||||
.esun-contact-popup
|
||||
button.action.primary.esun-contact-popup__submit:active {
|
||||
transform: translateY(1px);
|
||||
}
|
||||
|
||||
.esun-contact-popup-modal
|
||||
.esun-contact-popup
|
||||
button.action.primary.esun-contact-popup__submit.disabled {
|
||||
opacity: 0.65;
|
||||
}
|
||||
|
||||
.esun-contact-inline {
|
||||
box-sizing: border-box;
|
||||
margin: 30px auto;
|
||||
max-width: 660px;
|
||||
padding: 34px 36px 38px;
|
||||
border-radius: 20px;
|
||||
background: #fff;
|
||||
box-shadow: 0 10px 38px rgba(19, 63, 42, 0.12);
|
||||
}
|
||||
|
||||
.esun-contact-inline button.action.primary.esun-contact-popup__submit {
|
||||
width: 100%;
|
||||
min-height: 48px;
|
||||
border: 0;
|
||||
border-radius: 24px;
|
||||
background: #1e9e5a;
|
||||
color: #fff;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.4px;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.esun-contact-inline button.action.primary.esun-contact-popup__submit:hover,
|
||||
.esun-contact-inline button.action.primary.esun-contact-popup__submit:focus {
|
||||
background: #178049;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.esun-contact-inline button.action.primary.esun-contact-popup__submit.disabled {
|
||||
opacity: 0.65;
|
||||
}
|
||||
|
||||
.esun-contact-popup__trap {
|
||||
position: absolute !important;
|
||||
left: -10000px !important;
|
||||
width: 1px !important;
|
||||
height: 1px !important;
|
||||
opacity: 0 !important;
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.esun-contact-popup-modal .modal-inner-wrap {
|
||||
width: calc(100% - 24px);
|
||||
border-radius: 16px;
|
||||
min-height: auto !important;
|
||||
}
|
||||
.modal-popup.esun-contact-popup-modal.modal-slide {
|
||||
left: 5%;
|
||||
right: 5%;
|
||||
}
|
||||
.esun-contact-popup-modal .modal-header {
|
||||
padding: 20px 24px;
|
||||
}
|
||||
|
||||
.esun-contact-popup-modal .modal-title {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.esun-contact-popup-modal .modal-content {
|
||||
padding: 26px 20px 30px;
|
||||
}
|
||||
|
||||
.esun-contact-popup__grid {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 18px;
|
||||
}
|
||||
|
||||
.esun-contact-popup__field {
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
.esun-contact-inline {
|
||||
margin: 20px auto;
|
||||
padding: 26px 20px 30px;
|
||||
border-radius: 16px;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
define([
|
||||
'jquery',
|
||||
'mage/validation'
|
||||
], function ($) {
|
||||
'use strict';
|
||||
|
||||
return function (config, element) {
|
||||
var $form = $(element);
|
||||
var $status = $form.find('[data-role="contact-status"]');
|
||||
var $submit = $form.find('[type="submit"]');
|
||||
|
||||
$form.validation();
|
||||
|
||||
$form.on('submit.esunContactInline', function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
if (!$form.validation('isValid')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$submit.prop('disabled', true).addClass('disabled');
|
||||
$status.removeClass('success error').empty();
|
||||
|
||||
$.ajax({
|
||||
url: $form.attr('action'),
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: $form.serialize()
|
||||
}).done(function (response) {
|
||||
if (response.success) {
|
||||
$(document).trigger('esun:generateLead', {leadType: 'contact_popup'});
|
||||
$form[0].reset();
|
||||
$status.addClass('success').text(response.message);
|
||||
} else {
|
||||
$status.addClass('error').text(response.message);
|
||||
}
|
||||
}).fail(function (xhr) {
|
||||
var response = xhr.responseJSON || {};
|
||||
|
||||
$status.addClass('error').text(
|
||||
response.message || $.mage.__('Unable to send your message. Please try again.')
|
||||
);
|
||||
}).always(function () {
|
||||
$submit.prop('disabled', false).removeClass('disabled');
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,87 @@
|
||||
define([
|
||||
'jquery',
|
||||
'Magento_Ui/js/modal/modal',
|
||||
'mage/validation'
|
||||
], function ($, modal) {
|
||||
'use strict';
|
||||
|
||||
return function (config, element) {
|
||||
var $popup = $(element);
|
||||
var $form = $popup.find('form');
|
||||
var $status = $popup.find('.esun-contact-popup__status');
|
||||
var $submit = $form.find('[type="submit"]');
|
||||
|
||||
modal({
|
||||
type: 'popup',
|
||||
responsive: true,
|
||||
innerScroll: true,
|
||||
modalClass: 'esun-contact-popup-modal',
|
||||
title: $.mage.__('Leave Message'),
|
||||
buttons: []
|
||||
}, $popup);
|
||||
|
||||
$(document).on('click.esunContactPopup', config.triggerSelector, function (event) {
|
||||
event.preventDefault();
|
||||
$status.removeClass('success error').empty();
|
||||
$popup.modal('openModal');
|
||||
});
|
||||
|
||||
// Keep product-page delegated button handlers from receiving this click.
|
||||
$submit.on('click.esunContactPopup', function (event) {
|
||||
event.stopPropagation();
|
||||
});
|
||||
|
||||
$form.on('submit.esunContactPopup', function (event) {
|
||||
var scrollPosition = window.pageYOffset || document.documentElement.scrollTop;
|
||||
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
|
||||
if (!$form.validation('isValid')) {
|
||||
window.scrollTo(0, scrollPosition);
|
||||
window.requestAnimationFrame(function () {
|
||||
window.scrollTo(0, scrollPosition);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
$submit.prop('disabled', true).addClass('disabled');
|
||||
$status.removeClass('success error').empty();
|
||||
|
||||
$.ajax({
|
||||
url: $form.attr('action'),
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: $form.serialize()
|
||||
}).done(function (response) {
|
||||
if (response.success) {
|
||||
$(document).trigger('esun:generateLead', {leadType: 'contact_popup'});
|
||||
$form[0].reset();
|
||||
$status.addClass('success').text(response.message);
|
||||
} else {
|
||||
$status.addClass('error').text(response.message);
|
||||
}
|
||||
}).fail(function (xhr) {
|
||||
var response = xhr.responseJSON || {};
|
||||
|
||||
$status.addClass('error').text(
|
||||
response.message || $.mage.__('Unable to send your message. Please try again.')
|
||||
);
|
||||
}).always(function () {
|
||||
$submit.prop('disabled', false).removeClass('disabled');
|
||||
window.scrollTo(0, scrollPosition);
|
||||
window.requestAnimationFrame(function () {
|
||||
window.scrollTo(0, scrollPosition);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Register Magento validation after our isolated submit handler.
|
||||
$form.validation();
|
||||
$form.off('invalid-form.validate');
|
||||
|
||||
if ($form.data('validator')) {
|
||||
$form.data('validator').settings.focusInvalid = false;
|
||||
}
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user