Add loader during ajax call

This commit is contained in:
Abhishek Kumar
2023-09-13 19:08:57 +05:30
parent 79c541fc7c
commit 106303a401
6 changed files with 244 additions and 145 deletions

View File

@@ -1,147 +1,190 @@
/**
* 2010-2023 Webkul.
*
* NOTICE OF LICENSE
*
* All right is reserved,
* Please go through LICENSE.txt file inside our module
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please refer to CustomizationPolicy.txt file inside our module for more information.
*
* @author Webkul IN
* @copyright 2010-2023 Webkul IN
* @license LICENSE.txt
*/
/* Block newsletter */
#columns #newsletter_block_left .form-group {
margin-bottom: 0; }
#columns #newsletter_block_left .form-group .form-control {
max-width: 222px;
display: inline-block;
margin-right: 6px; }
@media (min-width: 768px) and (max-width: 1199px) {
#columns #newsletter_block_left .form-group .form-control {
margin-bottom: 10px;
margin-right: 0; } }
#columns #newsletter_block_left .success_inline, #columns #newsletter_block_left .warning_inline {
text-align: left;
padding: 1px 0 0 0;
margin-bottom: -19px; }
#columns #newsletter_block_left .success_inline {
color: #418B19; }
#columns #newsletter_block_left .warning_inline {
color: #f13340; }
/* Block newsletter footer */
#footer #newsletter_block_left {
overflow: hidden;
/*width: 50%;*//*by webkul*/
float: left;
padding: 13px 15px 7px 15px;
height: 70px;/*by webkul*/
margin-bottom: 0; }
@media (max-width: 992px) {
#footer #newsletter_block_left {
height: 100px; }
#newsletter_block_left .block_content
{
width: 350px;
margin: 10px auto 0px;
}}
@media (max-width: 400px) {
#newsletter_block_left .block_content
{
width: 273px;
}}
@media (max-width: 767px) {
#footer #newsletter_block_left {
/*width: 100%;*/
height: auto; } }
#footer #newsletter_block_left h4 {
background: none;
float: left;
padding: 7px 16px 5px 0;
text-transform: none;
font-size: 21px;
line-height: 25px;
border: none; }
#footer #newsletter_block_left h4:after {
display: none; }
#footer #newsletter_block_left .block_content {
overflow: hidden; }
#footer #newsletter_block_left .form-group {
margin-bottom: 0; }
#footer #newsletter_block_left .form-group .form-control {
height: 45px;
max-width: 267px;
background: #3c3c3c;
border-color: #515151;
color: #fff;
padding: 10px 43px 10px 12px;
display: inline-block;
float: left; }
@media (max-width: 400px) {
#footer #newsletter_block_left .form-group .form-control{
padding: 7px 43px 7px 6px;
height: 37px;
}
}
#footer #newsletter_block_left .form-group .form-control:focus {
-moz-box-shadow: black 0px 0px 0px;
-webkit-box-shadow: black 0px 0px 0px;
box-shadow: black 0px 0px 0px; }
#footer #newsletter_block_left .form-group .button-small {
margin-left: -43px;
border: none;
background: none;
text-align: center;
color: #908f8f;
padding: 8px; }
#footer #newsletter_block_left .form-group .button-small:before {
content: "\f138";
font-family: "FontAwesome";
font-size: 28px;
line-height: 28px; }
#footer #newsletter_block_left .form-group .button-small:hover {
color: #fff !important; }
#footer #newsletter_block_left .form-group .button-small span {
display: none; }
#footer #newsletter_block_left .warning_inline {
display: block;
color: #f13340;
font-size: 13px;
line-height: 26px;
clear: both; }
@media (min-width: 1200px) {
#footer #newsletter_block_left .warning_inline {
display: inline-block;
position: relative;
top: -35px;
margin-bottom: -35px;
left: 15px;
clear: none; } }
#footer #newsletter_block_left .newsletter-input {
max-width: 230px !important; }/*by webkul original 300px*/
@media (max-width: 400px) {
#footer #newsletter_block_left .newsletter-input {
max-width: 190px !important;
}
}
#newsletter-input::-webkit-input-placeholder {
color: #bfbfbf;
}
#newsletter-input:-moz-placeholder { /* Firefox 18- */
color: #bfbfbf;
}
#newsletter-input::-moz-placeholder { /* Firefox 19+ */
color: #bfbfbf;
}
#newsletter-input:-ms-input-placeholder {
color: #bfbfbf;
}
/*# sourceMappingURL=blocknewsletter.css.map */
.button.button-medium.newsletter-btn {
position: relative;
padding: 0px 20px;
}
#newsletter-input
{
background-color: #3a3a3a;
border: 1px solid #868686;
color: #bfbfbf;
font-size: 13px;
height: 42px;
margin-bottom: 10px;
}
margin-bottom: 0; }
#columns #newsletter_block_left .form-group .form-control {
max-width: 222px;
display: inline-block;
margin-right: 6px; }
@media (min-width: 768px) and (max-width: 1199px) {
#columns #newsletter_block_left .form-group .form-control {
margin-bottom: 10px;
margin-right: 0; } }
#columns #newsletter_block_left .success_inline, #columns #newsletter_block_left .warning_inline {
text-align: left;
padding: 1px 0 0 0;
margin-bottom: -19px; }
#columns #newsletter_block_left .success_inline {
color: #418B19; }
#columns #newsletter_block_left .warning_inline {
color: #f13340; }
/* Block newsletter footer */
#footer #newsletter_block_left {
overflow: hidden;
/*width: 50%;*//*by webkul*/
float: left;
padding: 13px 15px 7px 15px;
height: 70px;/*by webkul*/
margin-bottom: 0; }
@media (max-width: 992px) {
#footer #newsletter_block_left {
height: 100px; }
#newsletter_block_left .block_content
{
width: 350px;
margin: 10px auto 0px;
}}
@media (max-width: 400px) {
#newsletter_block_left .block_content
{
width: 273px;
}}
@media (max-width: 767px) {
#footer #newsletter_block_left {
/*width: 100%;*/
height: auto; } }
#footer #newsletter_block_left h4 {
background: none;
float: left;
padding: 7px 16px 5px 0;
text-transform: none;
font-size: 21px;
line-height: 25px;
border: none; }
#footer #newsletter_block_left h4:after {
display: none; }
#footer #newsletter_block_left .block_content {
overflow: hidden; }
#footer #newsletter_block_left .form-group {
margin-bottom: 0; }
#footer #newsletter_block_left .form-group .form-control {
height: 45px;
max-width: 267px;
background: #3c3c3c;
border-color: #515151;
color: #fff;
padding: 10px 43px 10px 12px;
display: inline-block;
float: left; }
@media (max-width: 400px) {
#footer #newsletter_block_left .form-group .form-control{
padding: 7px 43px 7px 6px;
height: 37px;
}
}
#footer #newsletter_block_left .form-group .form-control:focus {
-moz-box-shadow: black 0px 0px 0px;
-webkit-box-shadow: black 0px 0px 0px;
box-shadow: black 0px 0px 0px; }
#footer #newsletter_block_left .form-group .button-small {
margin-left: -43px;
border: none;
background: none;
text-align: center;
color: #908f8f;
padding: 8px; }
#footer #newsletter_block_left .form-group .button-small:before {
content: "\f138";
font-family: "FontAwesome";
font-size: 28px;
line-height: 28px; }
#footer #newsletter_block_left .form-group .button-small:hover {
color: #fff !important; }
#footer #newsletter_block_left .form-group .button-small span {
display: none; }
#footer #newsletter_block_left .warning_inline {
display: block;
color: #f13340;
font-size: 13px;
line-height: 26px;
clear: both; }
@media (min-width: 1200px) {
#footer #newsletter_block_left .warning_inline {
display: inline-block;
position: relative;
top: -35px;
margin-bottom: -35px;
left: 15px;
clear: none; } }
#footer #newsletter_block_left .newsletter-input {
max-width: 230px !important; }/*by webkul original 300px*/
@media (max-width: 400px) {
#footer #newsletter_block_left .newsletter-input {
max-width: 190px !important;
}
}
#newsletter-input::-webkit-input-placeholder {
color: #bfbfbf;
}
#newsletter-input:-moz-placeholder { /* Firefox 18- */
color: #bfbfbf;
}
#newsletter-input::-moz-placeholder { /* Firefox 19+ */
color: #bfbfbf;
}
#newsletter-input:-ms-input-placeholder {
color: #bfbfbf;
}
#blocknewsletter .loader {
margin-left: 10px;
position: relative;
top: 10px;
}
#blocknewsletter .loader.loading {
display: inline-flex;
justify-content: center;
}
#blocknewsletter .loader.loading::after {
content: '';
width: 30px;
height: 30px;
border: 4px solid #dddddd;
border-top-color: transparent;
border-radius: 50%;
animation: loading 0.5s linear infinite;
}
@-webkit-keyframes loading { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@-moz-keyframes loading { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes loading { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
/*# sourceMappingURL=blocknewsletter.css.map */
.button.button-medium.newsletter-btn {
position: relative;
padding: 0px 20px;
}
#newsletter-input
{
background-color: #3a3a3a;
border: 1px solid #868686;
color: #bfbfbf;
font-size: 13px;
height: 42px;
margin-bottom: 10px;
}

View File

@@ -35,6 +35,8 @@ $(document).on('click', '#blocknewsletter .newsletter-btn', function (e) {
beforeSend: function () {
let messageBlock = $('#blocknewsletter .message-block');
$(messageBlock).fadeOut('fast');
$('#blocknewsletter .loader').show();
},
success: function (response) {
let messageBlock = $('#blocknewsletter .message-block');
@@ -44,6 +46,9 @@ $(document).on('click', '#blocknewsletter .newsletter-btn', function (e) {
if (jqXHR.readyState == 0) {
showErrorMessage(no_internet_txt);
}
},
complete: function () {
$('#blocknewsletter .loader').hide();
}
});
});

View File

@@ -46,6 +46,7 @@
<button type="submit" name="submitNewsletter" class="btn button button-medium newsletter-btn">
<span>{l s='Subscribe' mod='blocknewsletter'}</span>
</button>
<span class="loader loading" style="display: none;"></span>
</div>
</form>
</div>

View File

@@ -1,3 +1,22 @@
/**
* 2010-2023 Webkul.
*
* NOTICE OF LICENSE
*
* All right is reserved,
* Please go through LICENSE.txt file inside our module
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please refer to CustomizationPolicy.txt file inside our module for more information.
*
* @author Webkul IN
* @copyright 2010-2023 Webkul IN
* @license LICENSE.txt
*/
/* Block newsletter */
#columns #newsletter_block_left .form-group {
margin-bottom: 0; }
@@ -130,6 +149,31 @@
color: #bfbfbf;
}
#blocknewsletter .loader {
margin-left: 10px;
position: relative;
top: 10px;
}
#blocknewsletter .loader.loading {
display: inline-flex;
justify-content: center;
}
#blocknewsletter .loader.loading::after {
content: '';
width: 30px;
height: 30px;
border: 4px solid #dddddd;
border-top-color: transparent;
border-radius: 50%;
animation: loading 0.5s linear infinite;
}
@-webkit-keyframes loading { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@-moz-keyframes loading { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes loading { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
/*# sourceMappingURL=blocknewsletter.css.map */
.button.button-medium.newsletter-btn {
position: relative;

View File

@@ -35,6 +35,8 @@ $(document).on('click', '#blocknewsletter .newsletter-btn', function (e) {
beforeSend: function () {
let messageBlock = $('#blocknewsletter .message-block');
$(messageBlock).fadeOut('fast');
$('#blocknewsletter .loader').show();
},
success: function (response) {
let messageBlock = $('#blocknewsletter .message-block');
@@ -44,6 +46,9 @@ $(document).on('click', '#blocknewsletter .newsletter-btn', function (e) {
if (jqXHR.readyState == 0) {
showErrorMessage(no_internet_txt);
}
},
complete: function () {
$('#blocknewsletter .loader').hide();
}
});
});

View File

@@ -46,6 +46,7 @@
<button type="submit" name="submitNewsletter" class="btn button button-medium newsletter-btn">
<span>{l s='Subscribe' mod='blocknewsletter'}</span>
</button>
<span class="loader loading" style="display: none;"></span>
</div>
</form>
</div>