From f066d6cc82082c90517e90d27f1e24dfcab2fdd4 Mon Sep 17 00:00:00 2001 From: eLBati Date: Thu, 26 Nov 2015 15:24:21 +0100 Subject: [PATCH] ADD the possibility to specify signature size --- web_widget_digital_signature/__openerp__.py | 1 + .../static/lib/jquery.signature.js | 10 ++++++---- .../static/src/js/digital_sign.js | 11 +++++++++-- .../static/src/xml/digital_sign.xml | 2 +- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/web_widget_digital_signature/__openerp__.py b/web_widget_digital_signature/__openerp__.py index ed44aac8..22af46d8 100644 --- a/web_widget_digital_signature/__openerp__.py +++ b/web_widget_digital_signature/__openerp__.py @@ -5,6 +5,7 @@ # Copyright (C) 2004-2010 OpenERP SA () # Copyright (C) 2011-2015 Serpent Consulting Services Pvt. Ltd. # (). +# Copyright 2015 Lorenzo Battistini - Agile Business Group # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as diff --git a/web_widget_digital_signature/static/lib/jquery.signature.js b/web_widget_digital_signature/static/lib/jquery.signature.js index 14731c7d..8fa8ad29 100644 --- a/web_widget_digital_signature/static/lib/jquery.signature.js +++ b/web_widget_digital_signature/static/lib/jquery.signature.js @@ -14,7 +14,9 @@ var signatureOverrides = { guidelineIndent: 10, // Guide line indent from the edges notAvailable: 'Your browser doesn\'t support signing', // Error message when no canvas syncField: null, // Selector for synchronised text field - change: null // Callback when signature changed + change: null, // Callback when signature changed + width: 170, + height: 50 }, /* Initialise a new signature area. */ @@ -23,8 +25,8 @@ var signatureOverrides = { this.element.addClass(this.widgetFullName || this.widgetBaseClass); try { - this.canvas = $('' + '' + '')[0]; + this.canvas = $('' + '' + '')[0]; this.element.prepend(this.canvas); this.element.find('img').remove(); this.ctx = this.canvas.getContext('2d'); @@ -241,4 +243,4 @@ $.widget('kbw.signature', $.ui.mouse, signatureOverrides); // Make some things more accessible $.kbw.signature.options = $.kbw.signature.prototype.options; -})(jQuery); \ No newline at end of file +})(jQuery); diff --git a/web_widget_digital_signature/static/src/js/digital_sign.js b/web_widget_digital_signature/static/src/js/digital_sign.js index 42c0f235..a73bde02 100644 --- a/web_widget_digital_signature/static/src/js/digital_sign.js +++ b/web_widget_digital_signature/static/src/js/digital_sign.js @@ -39,6 +39,13 @@ openerp.web_widget_digital_signature = function(instance) { } var $img = $(QWeb.render("FieldBinaryImage-img", { widget: this, url: url })); this.$el.find('img').remove(); + var sign_options = {} + if ('width' in self.node.attrs){ + sign_options.width = self.node.attrs.width; + } + if ('height' in self.node.attrs){ + sign_options.height = self.node.attrs.height; + } if(this.view.get("actual_mode") !== 'edit' && this.view.get("actual_mode") !== 'create'){ this.$el.prepend($img); }else if(this.view.get("actual_mode") == 'edit' ){ @@ -46,7 +53,7 @@ openerp.web_widget_digital_signature = function(instance) { this.$el.find('> canvas').remove(); if(! this.get('value')){ this.$el.find('> img').remove(); - $(this.$el[0]).find(".signature").signature(); + $(this.$el[0]).find(".signature").signature(sign_options); }else if(this.get('value')){ this.$el.prepend($img); } @@ -56,7 +63,7 @@ openerp.web_widget_digital_signature = function(instance) { this.$el.find('> canvas').remove(); if(! this.get('value')){ this.$el.find('> img').remove(); - $(this.$el[0]).find(".signature").signature(); + $(this.$el[0]).find(".signature").signature(sign_options); }else if(this.get('value')){ this.$el.prepend($img); } diff --git a/web_widget_digital_signature/static/src/xml/digital_sign.xml b/web_widget_digital_signature/static/src/xml/digital_sign.xml index 68cf2d64..1d035be0 100644 --- a/web_widget_digital_signature/static/src/xml/digital_sign.xml +++ b/web_widget_digital_signature/static/src/xml/digital_sign.xml @@ -15,4 +15,4 @@ t-att-height="widget.node.attrs.img_height || widget.node.attrs.height" /> - \ No newline at end of file +