1function resizeAllSignaturePads() { 2 $('.ECCSignatureTool').each(function() { 3 var tool = $(this).data('eccSignatureTool'); 4 resizeOneSignaturePad(tool); 5 }); 6} 7 8function resizeOneSignaturePad(tool) { 9 var canvas = tool.padElement; 10 var signaturePad = tool.signaturePad; 11 var ratio = Math.max(window.devicePixelRatio || 1, 1); 12 canvas.width = canvas.offsetWidth * ratio; 13 canvas.height = canvas.offsetHeight * ratio; 14 canvas.getContext("2d").scale(ratio, ratio); 15 signaturePad.clear(); 16} 17 18$(document).ready(function() { 19 20 // Initialize all tools marked with the ECCSignatureTool class. See product.jsp. 21 $('.ECCSignatureTool').each(function() { 22 $(this).data('eccSignatureTool', new ECCSignatureTool($(this))); 23 }); 24 25 // Register with window once for all ECCSignatureTool's 26 window.onresize = resizeAllSignaturePads; 27}); 28 29ECCSignatureTool = function(element) { 30 var tool = this; 31 this.element = element; 32 this.padElement = this.element.find('.ECCSignatureTool-pad')[0]; 33 this.valueElement = this.element.find('.ECCSignatureTool-value')[0]; 34 this.formElement = this.valueElement.form; 35 this.clearElement = this.element.find('.ECCSignatureTool-clear')[0]; 36 this.signaturePad = new SignaturePad(this.padElement, { 37 backgroundColor: 'rgb(250,250,250)', 38 39 // Populate the input value with the encoded png representation of the signature 40 // onEnd = whenever a stroke ends, ie the user lifts a finger or the mouse button 41 // Don't listen to form.submit - doesn't play well with one page checkout 42 onEnd: function() { 43 $(tool.valueElement).val(tool.signaturePad.toDataURL()); 44 } 45 }); 46 this.init(); 47} 48 49ECCSignatureTool.prototype.init = function() { 50 var tool = this; 51 52 // Run resize function on it initially 53 resizeOneSignaturePad(tool); 54 55 // Clear the pad when button is clickeds 56 $(tool.clearElement).click(function(event) { 57 event.stopPropagation(); 58 tool.signaturePad.clear(); 59 $(tool.valueElement).val(''); 60 }); 61}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.