mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
ADD the possibility to specify signature size
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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');
|
||||
@@ -241,4 +243,4 @@ $.widget('kbw.signature', $.ui.mouse, signatureOverrides);
|
||||
// Make some things more accessible
|
||||
$.kbw.signature.options = $.kbw.signature.prototype.options;
|
||||
|
||||
})(jQuery);
|
||||
})(jQuery);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -15,4 +15,4 @@
|
||||
t-att-height="widget.node.attrs.img_height || widget.node.attrs.height"
|
||||
/>
|
||||
</t>
|
||||
</templates>
|
||||
</templates>
|
||||
|
||||
Reference in New Issue
Block a user