From 21fe777282a4b59ba4b672c85e8586f2a313533e Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 10 Nov 2017 16:38:48 +0300 Subject: [PATCH] [PE] Signature refactoring (show tip when signature is signed). --- .../main/app/controller/RightMenu.js | 32 ++++++- .../main/app/view/RightMenu.js | 23 ----- .../main/app/view/SignatureSettings.js | 89 +++++++++++-------- 3 files changed, 81 insertions(+), 63 deletions(-) diff --git a/apps/presentationeditor/main/app/controller/RightMenu.js b/apps/presentationeditor/main/app/controller/RightMenu.js index 46a9cd588..1a9a0b599 100644 --- a/apps/presentationeditor/main/app/controller/RightMenu.js +++ b/apps/presentationeditor/main/app/controller/RightMenu.js @@ -206,14 +206,40 @@ define([ }, onCoAuthoringDisconnect: function() { - if (this.rightmenu) - this.rightmenu.SetDisabled('', true, true); + this.SetDisabled(true); this.setMode({isEdit: false}); }, SetDisabled: function(disabled, allowSignature) { this.setMode({isEdit: !disabled}); - this.rightmenu.SetDisabled('', disabled, true, allowSignature); + if (this.rightmenu) { + this.rightmenu.slideSettings.SetSlideDisabled(disabled, disabled, disabled); + this.rightmenu.paragraphSettings.disableControls(disabled); + this.rightmenu.shapeSettings.disableControls(disabled); + this.rightmenu.textartSettings.disableControls(disabled); + this.rightmenu.tableSettings.disableControls(disabled); + this.rightmenu.imageSettings.disableControls(disabled); + this.rightmenu.chartSettings.disableControls(disabled); + + if (!allowSignature && this.rightmenu.signatureSettings) { + this.rightmenu.signatureSettings.disableControls(disabled); + this.rightmenu.btnSignature.setDisabled(disabled); + } + + if (disabled) { + this.rightmenu.btnSlide.setDisabled(disabled); + this.rightmenu.btnText.setDisabled(disabled); + this.rightmenu.btnTable.setDisabled(disabled); + this.rightmenu.btnImage.setDisabled(disabled); + this.rightmenu.btnShape.setDisabled(disabled); + this.rightmenu.btnTextArt.setDisabled(disabled); + this.rightmenu.btnChart.setDisabled(disabled); + } else { + var selectedElements = this.api.getSelectedElements(); + if (selectedElements.length > 0) + this.onFocusObject(selectedElements); + } + } }, onInsertTable: function() { diff --git a/apps/presentationeditor/main/app/view/RightMenu.js b/apps/presentationeditor/main/app/view/RightMenu.js index 28dfdf324..0551372cf 100644 --- a/apps/presentationeditor/main/app/view/RightMenu.js +++ b/apps/presentationeditor/main/app/view/RightMenu.js @@ -280,29 +280,6 @@ define([ return (this.minimizedMode) ? null : this.$el.find(".settings-panel.active")[0].id; }, - SetDisabled: function(id, disabled, all, allowSignature) { - if (all) { - this.slideSettings.SetSlideDisabled(disabled, disabled, disabled); - this.paragraphSettings.disableControls(disabled); - this.shapeSettings.disableControls(disabled); - this.tableSettings.disableControls(disabled); - this.imageSettings.disableControls(disabled); - this.chartSettings.disableControls(disabled); - - if (!allowSignature && this.signatureSettings) { - this.signatureSettings.disableControls(disabled); - this.btnSignature.setDisabled(disabled); - } - - } else { - var cmp = $("#" + id); - if (disabled !== cmp.hasClass('disabled')) { - cmp.toggleClass('disabled', disabled); - (disabled) ? cmp.attr({disabled: disabled}) : cmp.removeAttr('disabled'); - } - } - }, - clearSelection: function() { var target_pane = $(".right-panel"); target_pane.find('> .active').removeClass('active'); diff --git a/apps/presentationeditor/main/app/view/SignatureSettings.js b/apps/presentationeditor/main/app/view/SignatureSettings.js index 80bac26ee..5f3f943c3 100644 --- a/apps/presentationeditor/main/app/view/SignatureSettings.js +++ b/apps/presentationeditor/main/app/view/SignatureSettings.js @@ -69,7 +69,9 @@ define([ DisabledControls: false, DisabledInsertControls: false, validSignatures: undefined, - invalidSignatures: undefined + invalidSignatures: undefined, + DisabledEditing: false, + ready: false }; this._locked = false; this.lockedControls = []; @@ -115,16 +117,15 @@ define([ setApi: function(api) { this.api = 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)); return this; }, ChangeSettings: function(props) { - if (!this._state.validSignatures || !this._state.invalidSignatures) { - this.onUpdateSignatures(this.api.asc_getSignatures()); - } + if (!this._state.validSignatures || !this._state.invalidSignatures) + this.updateSignatures(this.api.asc_getSignatures()); this.disableControls(this._locked); }, @@ -154,7 +155,14 @@ define([ this.mode = mode; }, - onUpdateSignatures: function(valid){ + onApiUpdateSignatures: function(valid){ + if (!this._state.ready) return; + + this.updateSignatures(valid); + this.showSignatureTooltip(this._state.validSignatures.length>0 || this._state.invalidSignatures.length>0); + }, + + updateSignatures: function(valid){ var me = this; me._state.validSignatures = []; me._state.invalidSignatures = []; @@ -174,6 +182,8 @@ define([ var width = this.$linksView.width(); $('.signature-sign-name', this.cntValidSign).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); }, addInvisibleSign: function(btn) { @@ -201,50 +211,55 @@ define([ }, onDocumentReady: function() { - this.ChangeSettings(); + this._state.ready = true; + + this.updateSignatures(this.api.asc_getSignatures()); + this.showSignatureTooltip(this._state.validSignatures.length>0 || this._state.invalidSignatures.length>0); + }, + + showSignatureTooltip: function(hasSigned) { + if (!hasSigned) return; var me = this, - hasSigned = (me._state.validSignatures.length>0 || me._state.invalidSignatures.length>0); - - hasSigned && this.disableEditing(hasSigned); - - if (!this._state.tip && hasSigned) { - this._state.tip = new Common.UI.SynchronizeTip({ + tip = new Common.UI.SynchronizeTip({ target : PE.getController('RightMenu').getView('RightMenu').btnSignature.btnEl, text : this.txtSignedDocument, showLink: hasSigned, textLink: this.txtContinueEditing, placement: 'left' }); - this._state.tip.on({ - 'dontshowclick': function() { - me._state.tip.hide(); - // me.api.editSingedDoc(); - me.disableEditing(false); - }, - 'closeclick': function() { - me._state.tip.hide(); - } - }); - this._state.tip.show(); - } + tip.on({ + 'dontshowclick': function() { + tip.close(); + // me.api.editSingedDoc(); + me.disableEditing(false); + }, + 'closeclick': function() { + tip.close(); + } + }); + tip.show(); }, disableEditing: function(disable) { - disable && PE.getController('RightMenu').getView('RightMenu').clearSelection(); - PE.getController('RightMenu').SetDisabled(disable, true); - PE.getController('Toolbar').DisableToolbar(disable, disable); - PE.getController('Statusbar').getView('Statusbar').SetDisabled(disable); - PE.getController('Common.Controllers.ReviewChanges').SetDisabled(disable); - PE.getController('DocumentHolder').getView('DocumentHolder').SetDisabled(disable); + if (this._state.DisabledEditing != disable) { + this._state.DisabledEditing = disable; - var leftMenu = PE.getController('LeftMenu').leftMenu; - leftMenu.btnComments.setDisabled(disable); - var comments = PE.getController('Common.Controllers.Comments'); - if (comments) - comments.setPreviewMode(disable); + disable && PE.getController('RightMenu').getView('RightMenu').clearSelection(); + PE.getController('RightMenu').SetDisabled(disable, true); + PE.getController('Toolbar').DisableToolbar(disable, disable); + PE.getController('Statusbar').getView('Statusbar').SetDisabled(disable); + PE.getController('Common.Controllers.ReviewChanges').SetDisabled(disable); + PE.getController('DocumentHolder').getView('DocumentHolder').SetDisabled(disable); - this.disableInsertControls(disable); + var leftMenu = PE.getController('LeftMenu').leftMenu; + leftMenu.btnComments.setDisabled(disable); + var comments = PE.getController('Common.Controllers.Comments'); + if (comments) + comments.setPreviewMode(disable); + + this.disableInsertControls(disable); + } }, strSignature: 'Signature',