Files
tmhr/venv/lib/python3.10/site-packages/jsignature/static/js/django_jsignature.js
2024-02-23 10:30:02 +00:00

23 lines
824 B
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
(function($) {
$(document).ready(function() {
$(".jsign-container").each(function(){
var config = $(this).data('config');
var value = $(this).data('initial-value');
$(this).jSignature(config);
$(this).jSignature("setData", value, "native");
});
/* Each time user is done drawing a stroke, update value of hidden input */
$(".jsign-container").on("change", function(e) {
var jSignature_data = $(this).jSignature('getData', 'native');
var django_field_name = $(this).attr('id').split(/_(.+)/)[1];
$('#id_' + django_field_name).val(JSON.stringify(jSignature_data));
});
/* Bind clear button */
$(".jsign-wrapper input").on("click", function(e) {
$(this).siblings('.jsign-container').jSignature('reset');
});
});
})(jQuery || django.jQuery)