Skip to content

Commit

Permalink
Merge pull request #5568 from redCOMPONENT-COM/LAC-211
Browse files Browse the repository at this point in the history
LAC-211: move js onestep checkout
  • Loading branch information
Lu Nguyen Nhat authored Jul 4, 2022
2 parents ace27f9 + f1986d6 commit 3692e9a
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 46 deletions.
45 changes: 0 additions & 45 deletions component/site/views/checkout/tmpl/onestepcheckout.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,48 +35,3 @@
)
);

?>
<script type="text/javascript">
(function ($) {
$(document).ready(function () {
$("input[name='togglerchecker']").each(function (idx, el) {
if ($(el).is(':checked')) {
getBillingTemplate($(el));
}
});

if ($('#createaccount') && $('#createaccount').is(':checked')) {
$('#onestep-createaccount-wrapper').css('display', 'block');
}

var settings = $('#adminForm').validate().settings;

// Modify validation settings
$.extend(true, settings, {
rules: {
payment_method_id: {
required: function () {
if ($("#adminForm [name='payment_method_id']") && !$("#adminForm [name='payment_method_id']").is(':checked')) {
return true;
} else {
return false;
}
}
}
},
messages: {
payment_method_id: "<?php echo JText::_('COM_REDSHOP_SELECT_PAYMENT_METHOD') ?>"
},
errorPlacement: function (error, element) {
if ((element.is(":radio") && element.attr('name') == "payment_method_id")) {
error.appendTo(element.parents('#paymentblock'));
} else if (element.is(":checkbox") && element.attr('name') == "termscondition") {
error.appendTo(element.closest('.checkbox'));
} else { // This is the default behavior
error.insertAfter(element);
}
}
});
});
})(jQuery);
</script>
39 changes: 39 additions & 0 deletions media/com_redshop/js/redshop.onestep.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@
(function($){
$(document).ready(function(){
$("input[name='togglerchecker']").each(function (idx, el) {
if ($(el).is(':checked')) {
getBillingTemplate($(el));
}
});

if ($('#createaccount') && $('#createaccount').is(':checked')) {
$('#onestep-createaccount-wrapper').css('display', 'block');
}

var settings = $('#adminForm').validate().settings;

// Modify validation settings
$.extend(true, settings, {
rules: {
payment_method_id: {
required: function () {
if ($("#adminForm [name='payment_method_id']") && !$("#adminForm [name='payment_method_id']").is(':checked')) {
return true;
} else {
return false;
}
}
}
},
messages: {
payment_method_id: "<?php echo JText::_('COM_REDSHOP_SELECT_PAYMENT_METHOD') ?>"
},
errorPlacement: function (error, element) {
if ((element.is(":radio") && element.attr('name') == "payment_method_id")) {
error.appendTo(element.parents('#divPaymentMethod'));
} else if (element.is(":checkbox") && element.attr('name') == "termscondition") {
error.appendTo(element.closest('.checkbox'));
} else { // This is the default behavior
error.insertAfter(element);
}
}
});

$(".onestep-createaccount-toggle").change(function(evt){
evt.preventDefault();
$("#onestep-createaccount-wrapper").slideToggle('medium');
Expand Down
2 changes: 1 addition & 1 deletion media/com_redshop/js/redshop.onestep.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions src/assets/com_redshop/js/redshop.onestep.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@
(function($){
$(document).ready(function(){
$("input[name='togglerchecker']").each(function (idx, el) {
if ($(el).is(':checked')) {
getBillingTemplate($(el));
}
});

if ($('#createaccount') && $('#createaccount').is(':checked')) {
$('#onestep-createaccount-wrapper').css('display', 'block');
}

var settings = $('#adminForm').validate().settings;

// Modify validation settings
$.extend(true, settings, {
rules: {
payment_method_id: {
required: function () {
if ($("#adminForm [name='payment_method_id']") && !$("#adminForm [name='payment_method_id']").is(':checked')) {
return true;
} else {
return false;
}
}
}
},
messages: {
payment_method_id: "<?php echo JText::_('COM_REDSHOP_SELECT_PAYMENT_METHOD') ?>"
},
errorPlacement: function (error, element) {
if ((element.is(":radio") && element.attr('name') == "payment_method_id")) {
error.appendTo(element.parents('#divPaymentMethod'));
} else if (element.is(":checkbox") && element.attr('name') == "termscondition") {
error.appendTo(element.closest('.checkbox'));
} else { // This is the default behavior
error.insertAfter(element);
}
}
});

$(".onestep-createaccount-toggle").change(function(evt){
evt.preventDefault();
$("#onestep-createaccount-wrapper").slideToggle('medium');
Expand Down

0 comments on commit 3692e9a

Please sign in to comment.