[DE] Sign visible signature.

This commit is contained in:
Julia Radzhabova 2017-05-23 17:01:51 +03:00
parent 4ab7e47406
commit 8477d8b7dd
3 changed files with 22 additions and 12 deletions

View file

@ -714,7 +714,7 @@ define([
handler: function(dlg, result) { handler: function(dlg, result) {
if (result == 'ok') { if (result == 'ok') {
var props = dlg.getSettings(); var props = dlg.getSettings();
me.api.asc_Sign(props.certificateId); me.api.asc_Sign(props.certificateId, 'guid', props.images[0], props.images[1]);
} }
Common.NotificationCenter.trigger('edit:complete'); Common.NotificationCenter.trigger('edit:complete');
} }

View file

@ -746,7 +746,7 @@ define([
handler: function(dlg, result) { handler: function(dlg, result) {
if (result == 'ok') { if (result == 'ok') {
var props = dlg.getSettings(); var props = dlg.getSettings();
me.api.asc_Sign(props.certificateId, guid, props.image); me.api.asc_Sign(props.certificateId, guid, props.images[0], props.images[1]);
} }
Common.NotificationCenter.trigger('edit:complete'); Common.NotificationCenter.trigger('edit:complete');
} }

View file

@ -149,7 +149,7 @@ define([
hint : me.tipFontName hint : me.tipFontName
}).on('selected', function(combo, record) { }).on('selected', function(combo, record) {
if (me.signObject) { if (me.signObject) {
me.signObject.put_FontFamily(record.name); me.signObject.setText(me.inputName.getValue(), record.name, me.font.size, me.font.italic, me.font.bold);
} }
me.font.name = record.name; me.font.name = record.name;
}); });
@ -181,7 +181,7 @@ define([
] ]
}).on('selected', function(combo, record) { }).on('selected', function(combo, record) {
if (me.signObject) { if (me.signObject) {
me.signObject.put_FontSize(record.value); me.signObject.setText(me.inputName.getValue(), me.font.name, record.value, me.font.italic, me.font.bold);
} }
me.font.size = record.value; me.font.size = record.value;
}); });
@ -196,7 +196,7 @@ define([
me.btnBold.render($('#id-dlg-sign-bold')) ; me.btnBold.render($('#id-dlg-sign-bold')) ;
me.btnBold.on('click', function(btn, e) { me.btnBold.on('click', function(btn, e) {
if (me.signObject) { if (me.signObject) {
me.signObject.put_Bold(btn.pressed); me.signObject.setText(me.inputName.getValue(), me.font.name, me.font.size, me.font.italic, btn.pressed);
} }
me.font.bold = btn.pressed; me.font.bold = btn.pressed;
}); });
@ -210,7 +210,7 @@ define([
me.btnItalic.render($('#id-dlg-sign-italic')) ; me.btnItalic.render($('#id-dlg-sign-italic')) ;
me.btnItalic.on('click', function(btn, e) { me.btnItalic.on('click', function(btn, e) {
if (me.signObject) { if (me.signObject) {
me.signObject.put_Italic(btn.pressed); me.signObject.setText(me.inputName.getValue(), me.font.name, me.font.size, btn.pressed, me.font.bold);
} }
me.font.italic = btn.pressed; me.font.italic = btn.pressed;
}); });
@ -246,6 +246,13 @@ define([
},500); },500);
}, },
hide: function() {
Common.UI.Window.prototype.hide.apply(this, arguments);
if (this.signObject)
this.signObject.destroy();
},
afterRender: function () { afterRender: function () {
if (this.api) { if (this.api) {
this.api.asc_unregisterCallback('on_signature_defaultcertificate_ret', _.bind(this.onCertificateChanged, this)); this.api.asc_unregisterCallback('on_signature_defaultcertificate_ret', _.bind(this.onCertificateChanged, this));
@ -258,7 +265,7 @@ define([
if (this.signType == 'visible') { if (this.signType == 'visible') {
this.cmbFonts.fillFonts(this.fontStore); this.cmbFonts.fillFonts(this.fontStore);
// this.signObject = new Asc.CSignature('signature-preview-img'); this.signObject = new AscCommon.CSignatureDrawer('signature-preview-img', this.api);
var rec = this.fontStore.findWhere({name: this.font.name}); var rec = this.fontStore.findWhere({name: this.font.name});
this.cmbFonts.setValue((rec) ? rec.get('name') : this.fontStore.at(0).get('name')); this.cmbFonts.setValue((rec) ? rec.get('name') : this.fontStore.at(0).get('name'));
@ -271,8 +278,7 @@ define([
if (this.signType == 'invisible') { if (this.signType == 'invisible') {
props.purpose = this.inputPurpose.getValue(); props.purpose = this.inputPurpose.getValue();
} else { } else {
if (this.signObject) props.images = this.signObject ? this.signObject.getImages() : [null, null];
props.url = this.signObject.getUrl();
} }
return props; return props;
@ -290,8 +296,12 @@ define([
}, },
_handleInput: function(state) { _handleInput: function(state) {
if (this.options.handler) if (this.options.handler) {
if (state == 'ok' && this.signObject && !this.signObject.isValid())
return;
this.options.handler.call(this, this, state); this.options.handler.call(this, this, state);
}
this.close(); this.close();
}, },
@ -308,13 +318,13 @@ define([
onSelectImage: function() { onSelectImage: function() {
if (!this.signObject) return; if (!this.signObject) return;
this.signObject.LoadImage(); this.signObject.selectImage();
this.inputName.setValue(''); this.inputName.setValue('');
}, },
onChangeName: function (input, value) { onChangeName: function (input, value) {
if (!this.signObject) return; if (!this.signObject) return;
this.signObject.SetName(value); this.signObject.setText(value, this.font.name, this.font.size, this.font.italic, this.font.bold);
}, },
textTitle: 'Sign Document', textTitle: 'Sign Document',