[SSE] Signature refactoring (show tip when signature is signed).
This commit is contained in:
parent
4811d3e6cf
commit
539c66ed47
|
@ -71,7 +71,9 @@ define([
|
||||||
DisabledInsertControls: false,
|
DisabledInsertControls: false,
|
||||||
requestedSignatures: undefined,
|
requestedSignatures: undefined,
|
||||||
validSignatures: undefined,
|
validSignatures: undefined,
|
||||||
invalidSignatures: undefined
|
invalidSignatures: undefined,
|
||||||
|
DisabledEditing: false,
|
||||||
|
ready: false
|
||||||
};
|
};
|
||||||
this._locked = false;
|
this._locked = false;
|
||||||
this.lockedControls = [];
|
this.lockedControls = [];
|
||||||
|
@ -139,16 +141,15 @@ define([
|
||||||
setApi: function(api) {
|
setApi: function(api) {
|
||||||
this.api = api;
|
this.api = api;
|
||||||
if (this.api) {
|
if (this.api) {
|
||||||
this.api.asc_registerCallback('asc_onUpdateSignatures', _.bind(this.onUpdateSignatures, this));
|
this.api.asc_registerCallback('asc_onUpdateSignatures', _.bind(this.onApiUpdateSignatures, this));
|
||||||
}
|
}
|
||||||
Common.NotificationCenter.on('document:ready', _.bind(this.onDocumentReady, this));
|
Common.NotificationCenter.on('document:ready', _.bind(this.onDocumentReady, this));
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
ChangeSettings: function(props) {
|
ChangeSettings: function(props) {
|
||||||
if (!this._state.requestedSignatures || !this._state.validSignatures || !this._state.invalidSignatures) {
|
if (!this._state.requestedSignatures || !this._state.validSignatures || !this._state.invalidSignatures)
|
||||||
this.onUpdateSignatures(this.api.asc_getSignatures(), this.api.asc_getRequestSignatures());
|
this.updateSignatures(this.api.asc_getSignatures(), this.api.asc_getRequestSignatures());
|
||||||
}
|
|
||||||
|
|
||||||
this.disableControls(this._locked);
|
this.disableControls(this._locked);
|
||||||
},
|
},
|
||||||
|
@ -179,7 +180,14 @@ define([
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
},
|
},
|
||||||
|
|
||||||
onUpdateSignatures: function(valid, requested){
|
onApiUpdateSignatures: function(valid, requested){
|
||||||
|
if (!this._state.ready) return;
|
||||||
|
|
||||||
|
this.updateSignatures(valid, requested);
|
||||||
|
this.showSignatureTooltip(this._state.validSignatures.length>0 || this._state.invalidSignatures.length>0);
|
||||||
|
},
|
||||||
|
|
||||||
|
updateSignatures: function(valid, requested){
|
||||||
var me = this;
|
var me = this;
|
||||||
me._state.requestedSignatures = [];
|
me._state.requestedSignatures = [];
|
||||||
me._state.validSignatures = [];
|
me._state.validSignatures = [];
|
||||||
|
@ -209,6 +217,8 @@ define([
|
||||||
width = this.$linksView.width();
|
width = this.$linksView.width();
|
||||||
$('.signature-sign-name', this.cntValidSign).css('max-width', 170-width);
|
$('.signature-sign-name', this.cntValidSign).css('max-width', 170-width);
|
||||||
$('.signature-sign-name', this.cntInvalidSign).css('max-width', 170-width);
|
$('.signature-sign-name', this.cntInvalidSign).css('max-width', 170-width);
|
||||||
|
|
||||||
|
me.disableEditing(me._state.validSignatures.length>0 || me._state.invalidSignatures.length>0);
|
||||||
},
|
},
|
||||||
|
|
||||||
addVisibleSign: function(btn) {
|
addVisibleSign: function(btn) {
|
||||||
|
@ -283,37 +293,40 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
onDocumentReady: function() {
|
onDocumentReady: function() {
|
||||||
this.ChangeSettings();
|
this._state.ready = true;
|
||||||
|
|
||||||
|
this.updateSignatures(this.api.asc_getSignatures(), this.api.asc_getRequestSignatures());
|
||||||
|
this.showSignatureTooltip(this._state.validSignatures.length>0 || this._state.invalidSignatures.length>0, this._state.requestedSignatures.length>0);
|
||||||
|
},
|
||||||
|
|
||||||
|
showSignatureTooltip: function(hasSigned, hasRequested) {
|
||||||
|
if (!hasSigned && !hasRequested) return;
|
||||||
|
|
||||||
var me = this,
|
var me = this,
|
||||||
hasSigned = (me._state.validSignatures.length>0 || me._state.invalidSignatures.length>0),
|
tip = new Common.UI.SynchronizeTip({
|
||||||
hasRequested = (me._state.requestedSignatures.length>0);
|
|
||||||
|
|
||||||
hasSigned && this.disableEditing(hasSigned);
|
|
||||||
|
|
||||||
if (!this._state.tip && (hasSigned || hasRequested)) {
|
|
||||||
this._state.tip = new Common.UI.SynchronizeTip({
|
|
||||||
target : SSE.getController('RightMenu').getView('RightMenu').btnSignature.btnEl,
|
target : SSE.getController('RightMenu').getView('RightMenu').btnSignature.btnEl,
|
||||||
text : (hasSigned) ? this.txtSignedDocument : this.txtRequestedSignatures,
|
text : (hasSigned) ? this.txtSignedDocument : this.txtRequestedSignatures,
|
||||||
showLink: hasSigned,
|
showLink: hasSigned,
|
||||||
textLink: this.txtContinueEditing,
|
textLink: this.txtContinueEditing,
|
||||||
placement: 'left'
|
placement: 'left'
|
||||||
});
|
});
|
||||||
this._state.tip.on({
|
tip.on({
|
||||||
'dontshowclick': function() {
|
'dontshowclick': function() {
|
||||||
me._state.tip.hide();
|
tip.close();
|
||||||
// me.api.editSingedDoc();
|
// me.api.editSingedDoc();
|
||||||
me.disableEditing(false);
|
me.disableEditing(false);
|
||||||
},
|
},
|
||||||
'closeclick': function() {
|
'closeclick': function() {
|
||||||
me._state.tip.hide();
|
tip.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this._state.tip.show();
|
tip.show();
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
disableEditing: function(disable) {
|
disableEditing: function(disable) {
|
||||||
|
if (this._state.DisabledEditing != disable) {
|
||||||
|
this._state.DisabledEditing = disable;
|
||||||
|
|
||||||
disable && SSE.getController('RightMenu').getView('RightMenu').clearSelection();
|
disable && SSE.getController('RightMenu').getView('RightMenu').clearSelection();
|
||||||
SSE.getController('Toolbar').DisableToolbar(disable, disable);
|
SSE.getController('Toolbar').DisableToolbar(disable, disable);
|
||||||
SSE.getController('RightMenu').SetDisabled(disable, true);
|
SSE.getController('RightMenu').SetDisabled(disable, true);
|
||||||
|
@ -328,6 +341,7 @@ define([
|
||||||
comments.setPreviewMode(disable);
|
comments.setPreviewMode(disable);
|
||||||
|
|
||||||
this.disableInsertControls(disable);
|
this.disableInsertControls(disable);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
strSignature: 'Signature',
|
strSignature: 'Signature',
|
||||||
|
|
Loading…
Reference in a new issue