Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Do not merge] PoC of signing a form #174

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions resources/argon-design-system-pro/scss/custom/_styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -588,3 +588,28 @@ label.required {
.h-6 {
height: 2.5rem;
}

#userSignature {
& .modal-content .modal-body{
display: -webkit-box;
display: -ms-flexbox;
display: block;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
width: 100%;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
margin: 0;
padding: 32px 16px;

canvas{
border: dashed 2px black;
}
}
}
93 changes: 80 additions & 13 deletions resources/views/frontend/host/terms-and-conditions.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,88 @@

<section class="bg-h4h-form py-5">
<div class="container">
<form method="POST" action="{{ route('store-hosts-terms-agreed') }}" id="sendGetInvolved">
@csrf
<div class="card shadow mb-4">
<div class="card-header bg-primary">
<h6 class="mb-0 text-white font-weight-600">
1. {{ __('Terms and conditions') }}
</h6>
</div>
<div class="card-body py-5">
{!! $termsAndConditionsForHosts !!}

{!! NoCaptcha::displaySubmit('sendGetInvolved', '' . __('I agree') . " <i class=\"fa fa-arrow-right\"></i>", ['type' => 'submit', 'id' => 'submit-button-2', 'class' => 'btn btn-secondary btn-h4h-offer-help-submit pull-right btn-lg px-6']) !!}
</div>
<div class="card shadow mb-4">
<div class="card-header bg-primary">
<h6 class="mb-0 text-white font-weight-600">
1. {{ __('Terms and conditions') }}
</h6>
</div>
</form>
<div class="card-body py-5">
{!! $termsAndConditionsForHosts !!}
<button class="btn btn-secondary" data-target="#userSignature" data-toggle="modal"> semneaza
</button>
</div>
</div>
</div>
</section>

<div class="modal fade" id="userSignature" data-backdrop="static" data-keyboard="false" tabindex="-1"
aria-labelledby="staticBackdropLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="staticBackdropLabel">{{__('Signature') }}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div id="signature-pad" class="signature-pad">
<div class="signature-pad--body">
<div class="invalid-feedback"></div>
<canvas></canvas>
</div>
</div>
<form method="POST" action="{{ route('store-hosts-terms-agreed') }}" id="sendGetInvolved">
@csrf
{{ Form::hidden('invisible', 'secret',array('id' => 'hidden-signature')) }}
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-warning clear">{{ __('Clear') }}</button>
{!! NoCaptcha::displaySubmit('', '' . __('I agree') . " <i class=\"fa fa-arrow-right\"></i>", ['type' => 'submit', 'id' => 'submit-button-2', 'class' => 'btn btn-secondary btn-h4h-offer-help-submit pull-right btn-lg px-6', 'onClick'=>'onAgreeOnTermsAndConditions()']) !!}
</div>
</div>
</div>
</div>
@endsection

@section('scripts')
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/signature_pad.umd.min.js"></script>
<script>
/**
* Customer Signature
* */
let signaturePad;
$('#userSignature').on('shown.bs.modal', function(e) {
let canvas = $("#signature-pad canvas");
let parentWidth = $(canvas).parent().outerWidth();
let parentHeight = $(canvas).parent().outerHeight();
canvas.attr("width", parentWidth + 'px')
.attr("height", parentHeight + 'px');
signaturePad = new SignaturePad(canvas[0], {
backgroundColor: 'rgb(255, 255, 255)'
});
})
$('#userSignature').on('hidden.bs.modal', function(e) {
signaturePad.clear();
});
$(document).on('click', '#userSignature .clear', function() {
signaturePad.clear();
});

function onAgreeOnTermsAndConditions() {
if (signaturePad.isEmpty()) {
alert("Please provide a signature first.");
} else {
let dataURL = signaturePad.toDataURL();
$('.signature').attr('src', dataURL);
$('#hidden-signature').val(dataURL);
$('#userSignature').modal('hide');

document.getElementById("sendGetInvolved").submit();
}
}
</script>
@endsection