PageSourceSearch

https://erp.infinityitsuccess.com/web/static/src/libs/jSignatureCustom.js

js infinityitsuccess.com collected 2026-09-26 08:08:34 UTC 2,095 bytes, 49 lines download raw bytes

1function _renderImageOnCanvas( data, formattype, rerendercallable ) {
2    'use strict'
3    // #1. Do NOT rely on this. No worky on IE 
4    //   (url max len + lack of base64 decoder + possibly other issues)
5    // #2. This does NOT affect what is captured as "signature" as far as vector data is 
6    // concerned. This is treated same as "signature line" - i.e. completely ignored
7    // the only time you see imported image data exported is if you export as image.
8
9    // we do NOT call rerendercallable here (unlike in other import plugins)
10    // because importing image does absolutely nothing to the underlying vector data storage
11    // This could be a way to "import" old signatures stored as images
12    // This could also be a way to import extra decor into signature area.
13
14    // Odoo override: 
15    // If a signature is saved in mobile resolution, when the user tries to sign a document in desktop, the size that is shown is the mobile size, which is strange for the user.
16    // This modifies the library method that adds the image to the canvas, resizing the image to the canvas size, keeping the image ratio and showing it centered.
17    
18    var img = new Image()
19    // this = Canvas DOM elem. Not jQuery object. Not Canvas's parent div.
20    , c = this;
21
22    img.onload = function () {
23        var ctx = c.getContext("2d");
24        var oldShadowColor = ctx.shadowColor;
25        ctx.shadowColor = "transparent";
26
27        var ratio = ((img.width / img.height) > (c.width / c.height)) ? c.width / img.width : c.height / img.height;
28
29        ctx.drawImage( 
30            img,
31            (c.width / 2) - (img.width * ratio / 2),
32            (c.height / 2) - (img.height * ratio / 2)
33            , img.width * ratio
34            , img.height * ratio
35        );
36        ctx.shadowColor = oldShadowColor;
37    };
38
39    img.src = 'data:' + formattype + ',' + data;
40}
41
42// Override
43// Supported image types
44[
45    'image',
46    'image/png;base64',
47    'image/jpeg;base64',
48    'image/jpg;base64',
49].forEach(imageType => $.fn.jSignature("addPlugin", "import", imageType, _renderImageOnCanvas));

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.