Browse Source

ADD the possibility to specify signature size

pull/267/head
eLBati 9 years ago
parent
commit
f066d6cc82
  1. 1
      web_widget_digital_signature/__openerp__.py
  2. 8
      web_widget_digital_signature/static/lib/jquery.signature.js
  3. 11
      web_widget_digital_signature/static/src/js/digital_sign.js

1
web_widget_digital_signature/__openerp__.py

@ -5,6 +5,7 @@
# Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
# Copyright (C) 2011-2015 Serpent Consulting Services Pvt. Ltd.
# (<http://www.serpentcs.com>).
# 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

8
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 = $('<canvas width="' + 170 + '" height="' +
50 + '">' + '' + '</canvas>')[0];
this.canvas = $('<canvas width="' + this.options.width + '" height="' +
this.options.height + '">' + '' + '</canvas>')[0];
this.element.prepend(this.canvas);
this.element.find('img').remove();
this.ctx = this.canvas.getContext('2d');

11
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);
}

Loading…
Cancel
Save