diff --git a/apps/documenteditor/main/app/controller/LeftMenu.js b/apps/documenteditor/main/app/controller/LeftMenu.js index 4beebba3c..00d106cfe 100644 --- a/apps/documenteditor/main/app/controller/LeftMenu.js +++ b/apps/documenteditor/main/app/controller/LeftMenu.js @@ -682,14 +682,13 @@ define([ if (result == 'ok') { me.api.asc_AddSignatureLine2(dlg.getSettings()); } - Common.NotificationCenter.trigger('edit:complete'); + Common.NotificationCenter.trigger('edit:complete', me); } }); win.show(); menu.hide(); - this.leftMenu.btnFile.toggle(false, true); }, addInvisibleSign: function(menu) { @@ -702,14 +701,13 @@ define([ var props = dlg.getSettings(); me.api.asc_Sign(props.certificateId); } - Common.NotificationCenter.trigger('edit:complete'); + Common.NotificationCenter.trigger('edit:complete', me); } }); win.show(); menu.hide(); - this.leftMenu.btnFile.toggle(false, true); }, textNoTextFound : 'Text not found', diff --git a/apps/documenteditor/main/app/view/FileMenu.js b/apps/documenteditor/main/app/view/FileMenu.js index 7c58c7ade..702764ed2 100644 --- a/apps/documenteditor/main/app/view/FileMenu.js +++ b/apps/documenteditor/main/app/view/FileMenu.js @@ -240,7 +240,6 @@ define([ applyMode: function() { this.miPrint[this.mode.canPrint?'show':'hide'](); this.miRename[(this.mode.canRename && !this.mode.isDesktopApp) ?'show':'hide'](); - this.miRename.$el.find('+.devider')[!this.mode.isDisconnected?'show':'hide'](); this.items[7][(this.mode.isDesktopApp) ?'show':'hide'](); this.items[7].$el.find('+.devider')[!this.mode.isDisconnected?'show':'hide'](); this.miRecent[this.mode.canOpenRecent?'show':'hide'](); diff --git a/apps/documenteditor/main/app/view/SignatureSettings.js b/apps/documenteditor/main/app/view/SignatureSettings.js index 16942f7bd..d05122ec3 100644 --- a/apps/documenteditor/main/app/view/SignatureSettings.js +++ b/apps/documenteditor/main/app/view/SignatureSettings.js @@ -268,7 +268,7 @@ define([ win.show(); }, - onViewSignature: function(guid) { + onViewSignature: function(event) { var target = $(event.currentTarget); if (target.hasClass('disabled')) return; diff --git a/apps/presentationeditor/main/app/controller/LeftMenu.js b/apps/presentationeditor/main/app/controller/LeftMenu.js index d41162cdd..c21a70bc4 100644 --- a/apps/presentationeditor/main/app/controller/LeftMenu.js +++ b/apps/presentationeditor/main/app/controller/LeftMenu.js @@ -43,6 +43,7 @@ define([ 'core', 'common/main/lib/util/Shortcuts', + 'common/main/lib/view/SignDialog', 'presentationeditor/main/app/view/LeftMenu', 'presentationeditor/main/app/view/FileMenu' ], function () { @@ -83,7 +84,8 @@ define([ 'saveas:format': _.bind(this.clickSaveAsFormat, this), 'settings:apply': _.bind(this.applySettings, this), 'create:new': _.bind(this.onCreateNew, this), - 'recent:open': _.bind(this.onOpenRecent, this) + 'recent:open': _.bind(this.onOpenRecent, this), + 'signature:invisible': _.bind(this.addInvisibleSign, this) }, 'Toolbar': { 'file:settings': _.bind(this.clickToolbarSettings,this), @@ -528,18 +530,37 @@ define([ }, onPluginOpen: function(panel, type, action) { - if ( type == 'onboard' ) { - if ( action == 'open' ) { + if (type == 'onboard') { + if (action == 'open') { this.leftMenu.close(); this.leftMenu.btnThumbs.toggle(false, false); this.leftMenu.panelPlugins.show(); - this.leftMenu.onBtnMenuClick({pressed:true, options: {action: 'plugins'}}); + this.leftMenu.onBtnMenuClick({pressed: true, options: {action: 'plugins'}}); } else { this.leftMenu.close(); } } }, + addInvisibleSign: function(menu) { + var me = this, + win = new Common.Views.SignDialog({ + api: me.api, + signType: 'invisible', + handler: function(dlg, result) { + if (result == 'ok') { + var props = dlg.getSettings(); + me.api.asc_Sign(props.certificateId); + } + Common.NotificationCenter.trigger('edit:complete', me); + } + }); + + win.show(); + + menu.hide(); + }, + textNoTextFound : 'Text not found', newDocumentTitle : 'Unnamed document', requestEditRightsText : 'Requesting editing rights...' diff --git a/apps/presentationeditor/main/app/controller/RightMenu.js b/apps/presentationeditor/main/app/controller/RightMenu.js index a625e3887..b9aa0bf20 100644 --- a/apps/presentationeditor/main/app/controller/RightMenu.js +++ b/apps/presentationeditor/main/app/controller/RightMenu.js @@ -79,6 +79,7 @@ define([ this._settings[Common.Utils.documentSettingsType.Shape] = {panelId: "id-shape-settings", panel: rightMenu.shapeSettings, btn: rightMenu.btnShape, hidden: 1, locked: false}; this._settings[Common.Utils.documentSettingsType.TextArt] = {panelId: "id-textart-settings", panel: rightMenu.textartSettings, btn: rightMenu.btnTextArt, hidden: 1, locked: false}; this._settings[Common.Utils.documentSettingsType.Chart] = {panelId: "id-chart-settings", panel: rightMenu.chartSettings, btn: rightMenu.btnChart, hidden: 1, locked: false}; + this._settings[Common.Utils.documentSettingsType.Signature] = {panelId: "id-signature-settings", panel: rightMenu.signatureSettings, btn: rightMenu.btnSignature, hidden: (rightMenu.signatureSettings) ? 0 : 1, props: {}, locked: false}; }, setApi: function(api) { @@ -97,7 +98,7 @@ define([ var panel = this._settings[type].panel; var props = this._settings[type].props; if (props && panel) - panel.ChangeSettings.call(panel, props); + panel.ChangeSettings.call(panel, (type==Common.Utils.documentSettingsType.Signature) ? undefined : props); } Common.NotificationCenter.trigger('layout:changed', 'rightmenu'); this.rightmenu.fireEvent('editcomplete', this.rightmenu); @@ -109,12 +110,14 @@ define([ var needhide = true; for (var i=0; i0) ? 0 : 1; + this._settings[Common.Utils.documentSettingsType.Signature].locked = false; for (i=0; i
  • +
  • @@ -29,4 +30,5 @@
    +
    \ No newline at end of file diff --git a/apps/presentationeditor/main/app/template/RightMenu.template b/apps/presentationeditor/main/app/template/RightMenu.template index baba70c3e..f4cfb2d7b 100644 --- a/apps/presentationeditor/main/app/template/RightMenu.template +++ b/apps/presentationeditor/main/app/template/RightMenu.template @@ -14,6 +14,8 @@
    +
    +
    @@ -24,5 +26,6 @@ +
    \ No newline at end of file diff --git a/apps/presentationeditor/main/app/template/SignatureSettings.template b/apps/presentationeditor/main/app/template/SignatureSettings.template new file mode 100644 index 000000000..b5b986dc7 --- /dev/null +++ b/apps/presentationeditor/main/app/template/SignatureSettings.template @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + +
    + +
    + +
    \ No newline at end of file diff --git a/apps/presentationeditor/main/app/view/DocumentHolder.js b/apps/presentationeditor/main/app/view/DocumentHolder.js index 207903d55..490511223 100644 --- a/apps/presentationeditor/main/app/view/DocumentHolder.js +++ b/apps/presentationeditor/main/app/view/DocumentHolder.js @@ -38,6 +38,7 @@ define([ 'common/main/lib/util/utils', 'common/main/lib/component/Menu', 'common/main/lib/view/CopyWarningDialog', + 'common/main/lib/view/SignDialog', 'presentationeditor/main/app/view/HyperlinkSettingsDialog', // 'common/main/lib/view/InsertTableDialog', 'presentationeditor/main/app/view/ParagraphSettingsAdvanced', @@ -677,6 +678,36 @@ define([ } }; + var onSignatureClick = function(guid, width, height) { + if (_.isUndefined(me.fontStore)) { + me.fontStore = new Common.Collections.Fonts(); + var fonts = PE.getController('Toolbar').getView('Toolbar').cmbFontName.store.toJSON(); + var arr = []; + _.each(fonts, function(font, index){ + if (!font.cloneid) { + arr.push(_.clone(font)); + } + }); + me.fontStore.add(arr); + } + + var win = new Common.Views.SignDialog({ + api: me.api, + signType: 'visible', + fontStore: me.fontStore, + signSize: {width: width, height: height}, + handler: function(dlg, result) { + if (result == 'ok') { + var props = dlg.getSettings(); + me.api.asc_Sign(props.certificateId, guid, props.images[0], props.images[1]); + } + me.fireEvent('editcomplete', me); + } + }); + + win.show(); + }; + var onTextLanguage = function(langid) { me._currLang.id = langid; }; @@ -1517,6 +1548,7 @@ define([ me.api.asc_registerCallback('asc_onUpdateThemeIndex', _.bind(onApiUpdateThemeIndex, me)); me.api.asc_registerCallback('asc_onLockDocumentTheme', _.bind(onApiLockDocumentTheme, me)); me.api.asc_registerCallback('asc_onUnLockDocumentTheme', _.bind(onApiUnLockDocumentTheme, me)); + me.api.asc_registerCallback('asc_onSignatureClick', _.bind(onSignatureClick, me)); } return me; diff --git a/apps/presentationeditor/main/app/view/FileMenu.js b/apps/presentationeditor/main/app/view/FileMenu.js index e6d79d23d..c77d30402 100644 --- a/apps/presentationeditor/main/app/view/FileMenu.js +++ b/apps/presentationeditor/main/app/view/FileMenu.js @@ -164,6 +164,12 @@ define([ this.miSaveAs, this.miPrint, this.miRename, + new Common.UI.MenuItem({ + el : $('#fm-btn-protect',this.el), + action : 'protect', + caption : this.btnProtectCaption, + canFocused: false + }), this.miRecent, this.miNew, new Common.UI.MenuItem({ @@ -228,7 +234,8 @@ define([ applyMode: function() { this.miPrint[this.mode.canPrint?'show':'hide'](); this.miRename[(this.mode.canRename && !this.mode.isDesktopApp) ?'show':'hide'](); - this.miRename.$el.find('+.devider')[!this.mode.isDisconnected?'show':'hide'](); + this.items[7][(this.mode.isDesktopApp) ?'show':'hide'](); + this.items[7].$el.find('+.devider')[!this.mode.isDisconnected?'show':'hide'](); this.miRecent[this.mode.canOpenRecent?'show':'hide'](); this.miNew[this.mode.canCreateNew?'show':'hide'](); this.miNew.$el.find('+.devider')[this.mode.canCreateNew?'show':'hide'](); @@ -264,8 +271,10 @@ define([ } } - if (this.mode.targetApp == 'desktop') { + if (this.mode.isDesktopApp) { this.$el.find('#fm-btn-create, #fm-btn-back, #fm-btn-create+.devider').hide(); + this.panels['protect'] = (new PE.Views.FileMenuPanels.ProtectDoc({menu:this})).render(); + this.panels['protect'].setMode(this.mode); } this.panels['help'].setLangConfig(this.mode.lang); @@ -288,6 +297,7 @@ define([ setApi: function(api) { this.api = api; + if (this.panels['protect']) this.panels['protect'].setApi(api); this.api.asc_registerCallback('asc_onDocumentName', _.bind(this.onDocumentName, this)); }, @@ -354,6 +364,7 @@ define([ btnSettingsCaption : 'Advanced Settings...', btnSaveAsCaption : 'Save as', btnRenameCaption : 'Rename...', - btnCloseMenuCaption : 'Close Menu' + btnCloseMenuCaption : 'Close Menu', + btnProtectCaption: 'Protect\\Sign' }, PE.Views.FileMenu || {})); }); diff --git a/apps/presentationeditor/main/app/view/FileMenuPanels.js b/apps/presentationeditor/main/app/view/FileMenuPanels.js index 75547a46d..0d2867e6f 100644 --- a/apps/presentationeditor/main/app/view/FileMenuPanels.js +++ b/apps/presentationeditor/main/app/view/FileMenuPanels.js @@ -852,4 +852,102 @@ define([ } } }); + + PE.Views.FileMenuPanels.ProtectDoc = Common.UI.BaseView.extend(_.extend({ + el: '#panel-protect', + menu: undefined, + + template: _.template([ + '', + '', + '
    ', + '
    ' + ].join('')), + + initialize: function(options) { + Common.UI.BaseView.prototype.initialize.call(this,arguments); + + this.menu = options.menu; + + this.templateValid = _.template([ + '', + '', + '<% _.each(signatures, function(item) { %>', + '', + '', + '', + '', + '<% }); %>', + '
    <%= Common.Utils.String.htmlEncode(item.name) %><%= Common.Utils.String.htmlEncode(item.date) %>
    ' + ].join('')); + }, + + render: function() { + $(this.el).html(this.template({scope: this})); + + this.btnAddInvisibleSign = new Common.UI.Button({ + el: '#fms-btn-invisible-sign' + }); + this.btnAddInvisibleSign.on('click', _.bind(this.addInvisibleSign, this)); + + this.lblSignHeader = $('#id-fms-lbl-sign-header', this.$el); + + this.cntValidSign = $('#id-fms-valid-sign'); + this.cntInvalidSign = $('#id-fms-invalid-sign'); + + if (_.isUndefined(this.scroller)) { + this.scroller = new Common.UI.Scroller({ + el: $(this.el), + suppressScrollX: true + }); + } + + return this; + }, + + show: function() { + Common.UI.BaseView.prototype.show.call(this,arguments); + this.updateSignatures(); + }, + + setMode: function(mode) { + this.mode = mode; + if (!this.mode.isEdit) { + this.btnAddInvisibleSign.setVisible(false); + this.lblSignHeader.html(this.strSignature); + } + }, + + setApi: function(o) { + this.api = o; + return this; + }, + + addInvisibleSign: function() { + if (this.menu) + this.menu.fireEvent('signature:invisible', [this.menu]); + }, + + updateSignatures: function(){ + var valid = this.api.asc_getSignatures(), + valid_arr = [], invalid_arr = []; + + _.each(valid, function(item, index){ + var sign = {name: item.asc_getSigner1(), date: '18/05/2017'}; + (item.asc_getValid()==0) ? valid_arr.push(sign) : invalid_arr.push(sign); + }); + this.cntValidSign.html(this.templateValid({signatures: valid_arr, header: this.strValid})); + this.cntInvalidSign.html(this.templateValid({signatures: invalid_arr, header: this.strInvalid})); + // this.cntValidSign.html(this.templateValid({signatures: [{name: 'Hammish Mitchell', date: '18/05/2017'}, {name: 'Someone Somewhere', date: '18/05/2017'}], header: this.strValid})); + // this.cntInvalidSign.html(this.templateValid({signatures: [{name: 'Mary White', date: '18/05/2017'}, {name: 'John Black', date: '18/05/2017'}], header: this.strInvalid})); + }, + + strProtect: 'Protect Document', + strInvisibleSign: 'Add invisible digital signature', + strValid: 'Valid signatures', + strInvalid: 'Invalid signatures', + strSignature: 'Signature' + + }, PE.Views.FileMenuPanels.ProtectDoc || {})); + }); diff --git a/apps/presentationeditor/main/app/view/RightMenu.js b/apps/presentationeditor/main/app/view/RightMenu.js index fe1d4583a..3d4cb5700 100644 --- a/apps/presentationeditor/main/app/view/RightMenu.js +++ b/apps/presentationeditor/main/app/view/RightMenu.js @@ -56,6 +56,7 @@ define([ 'presentationeditor/main/app/view/ShapeSettings', 'presentationeditor/main/app/view/SlideSettings', 'presentationeditor/main/app/view/TextArtSettings', + 'presentationeditor/main/app/view/SignatureSettings', 'common/main/lib/component/Scroller' ], function (menuTemplate, $, _, Backbone) { 'use strict'; @@ -143,7 +144,7 @@ define([ return this; }, - render: function () { + render: function (mode) { var el = $(this.el); this.trigger('render:before', this); @@ -178,6 +179,21 @@ define([ this.shapeSettings = new PE.Views.ShapeSettings(); this.textartSettings = new PE.Views.TextArtSettings(); + if (mode && mode.isDesktopApp) { + this.btnSignature = new Common.UI.Button({ + hint: this.txtSignatureSettings, + asctype: Common.Utils.documentSettingsType.Signature, + enableToggle: true, + disabled: true, + toggleGroup: 'tabpanelbtnsGroup' + }); + this._settings[Common.Utils.documentSettingsType.Signature] = {panel: "id-signature-settings", btn: this.btnSignature}; + + this.btnSignature.el = $('#id-right-menu-signature'); this.btnSignature.render().setVisible(true); + this.btnSignature.on('click', _.bind(this.onBtnMenuClick, this)); + this.signatureSettings = new PE.Views.SignatureSettings(); + } + if (_.isUndefined(this.scroller)) { this.scroller = new Common.UI.Scroller({ el: $(this.el).find('.right-panel'), @@ -206,6 +222,7 @@ define([ this.tableSettings.setApi(api).on('editcomplete', _.bind( fire, this)); this.shapeSettings.setApi(api).on('editcomplete', _.bind( fire, this)); this.textartSettings.setApi(api).on('editcomplete', _.bind( fire, this)); + if (this.signatureSettings) this.signatureSettings.setApi(api).on('editcomplete', _.bind( fire, this)); }, setMode: function(mode) { @@ -299,6 +316,7 @@ define([ txtShapeSettings: 'Shape Settings', txtTextArtSettings: 'Text Art Settings', txtSlideSettings: 'Slide Settings', - txtChartSettings: 'Chart Settings' + txtChartSettings: 'Chart Settings', + txtSignatureSettings: 'Signature Settings' }, PE.Views.RightMenu || {})); }); \ No newline at end of file diff --git a/apps/presentationeditor/main/app/view/SignatureSettings.js b/apps/presentationeditor/main/app/view/SignatureSettings.js new file mode 100644 index 000000000..7a9a52228 --- /dev/null +++ b/apps/presentationeditor/main/app/view/SignatureSettings.js @@ -0,0 +1,207 @@ +/* + * + * (c) Copyright Ascensio System Limited 2010-2017 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, + * EU, LV-1021. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * +*/ +/** + * SignatureSettings.js + * + * Created by Julia Radzhabova on 5/24/17 + * Copyright (c) 2017 Ascensio System SIA. All rights reserved. + * + */ + +define([ + 'text!presentationeditor/main/app/template/SignatureSettings.template', + 'jquery', + 'underscore', + 'backbone', + 'common/main/lib/component/Button', + 'common/main/lib/view/SignDialog' +], function (menuTemplate, $, _, Backbone) { + 'use strict'; + + PE.Views.SignatureSettings = Backbone.View.extend(_.extend({ + el: '#id-signature-settings', + + // Compile our stats template + template: _.template(menuTemplate), + + // Delegated events for creating new items, and clearing completed ones. + events: { + }, + + options: { + alias: 'SignatureSettings' + }, + + initialize: function () { + var me = this; + + this._initSettings = true; + + this._state = { + DisabledControls: false, + validSignatures: undefined, + invalidSignatures: undefined + }; + this._locked = false; + this.lockedControls = []; + + this._noApply = false; + this._originalProps = null; + + this.templateValid = _.template([ + '', + '', + '', + '<% _.each(signatures, function(item) { %>', + '', + '', + '', + '', + '', + '<% }); %>', + '
    <%= Common.Utils.String.htmlEncode(item.name) %>
    <%= Common.Utils.String.htmlEncode(item.date) %>
    ', + '' + ].join('')); + + this.render(); + }, + + render: function () { + this.$el.html(this.template({ + scope: this + })); + + this.btnAddInvisibleSign = new Common.UI.Button({ + el: this.$el.find('#signature-invisible-sign') + }); + this.btnAddInvisibleSign.on('click', _.bind(this.addInvisibleSign, this)); + this.lockedControls.push(this.btnAddInvisibleSign); + + this.cntValidSign = $('#signature-valid-sign'); + this.cntInvalidSign = $('#signature-invalid-sign'); + }, + + setApi: function(api) { + this.api = api; + if (this.api) { + this.api.asc_registerCallback('asc_onUpdateSignatures', _.bind(this.onUpdateSignatures, this)); + } + return this; + }, + + createDelayedControls: function() { + this._initSettings = false; + }, + + ChangeSettings: function(props) { + if (this._initSettings) + this.createDelayedControls(); + + if (!this._state.validSignatures || !this._state.invalidSignatures) { + this.onUpdateSignatures(this.api.asc_getSignatures()); + } + + this.disableControls(this._locked); + }, + + setLocked: function (locked) { + this._locked = locked; + }, + + disableControls: function(disable) { + if (this._initSettings) return; + + if (this._state.DisabledControls!==disable) { + this._state.DisabledControls = disable; + _.each(this.lockedControls, function(item) { + item.setDisabled(disable); + }); + this.$linksSign.toggleClass('disabled', disable); + this.$linksView.toggleClass('disabled', disable); + } + }, + + setMode: function(mode) { + this.mode = mode; + }, + + onUpdateSignatures: function(valid){ + var me = this; + me._state.validSignatures = []; + me._state.invalidSignatures = []; + + _.each(valid, function(item, index){ + var sign = {name: item.asc_getSigner1(), guid: item.asc_getId(), date: '18/05/2017'}; + (item.asc_getValid()==0) ? me._state.validSignatures.push(sign) : me._state.invalidSignatures.push(sign); + }); + this.cntValidSign.html(this.templateValid({signatures: me._state.validSignatures, header: this.strValid})); + this.cntInvalidSign.html(this.templateValid({signatures: me._state.invalidSignatures, header: this.strInvalid})); + // this.cntValidSign.html(this.templateValid({signatures: [{name: 'Hammish Mitchell', guid: '123', date: '18/05/2017'}, {name: 'Someone Somewhere', guid: '345', date: '18/05/2017'}], header: this.strValid})); + // this.cntInvalidSign.html(this.templateValid({signatures: [{name: 'Mary White', guid: '111', date: '18/05/2017'}, {name: 'John Black', guid: '456', date: '18/05/2017'}], header: this.strInvalid})); + + this.$linksView = $('.signature-view-link', this.$el); + this.$el.on('click', '.signature-view-link', _.bind(this.onViewSignature, this)); + }, + + addInvisibleSign: function(btn) { + var me = this, + win = new Common.Views.SignDialog({ + api: me.api, + signType: 'invisible', + handler: function(dlg, result) { + if (result == 'ok') { + var props = dlg.getSettings(); + me.api.asc_Sign(props.certificateId); + } + me.fireEvent('editcomplete', me); + } + }); + + win.show(); + }, + + onViewSignature: function(event) { + var target = $(event.currentTarget); + if (target.hasClass('disabled')) return; + + this.api.asc_ViewCertificate(target.attr('data-value')); + }, + + strSignature: 'Signature', + strInvisibleSign: 'Add invisible digital signature', + strValid: 'Valid signatures', + strInvalid: 'Invalid signatures', + strView: 'View' + + }, PE.Views.SignatureSettings || {})); +}); \ No newline at end of file diff --git a/apps/presentationeditor/main/app/view/Viewport.js b/apps/presentationeditor/main/app/view/Viewport.js index e7da2ea5f..e1be9b2d2 100644 --- a/apps/presentationeditor/main/app/view/Viewport.js +++ b/apps/presentationeditor/main/app/view/Viewport.js @@ -123,7 +123,7 @@ define([ }, applyEditorMode: function() { - PE.getController('RightMenu').getView('RightMenu').render(); + PE.getController('RightMenu').getView('RightMenu').render(this.mode); if ( Common.localStorage.getBool('pe-hidden-status') ) PE.getController('Statusbar').getView('Statusbar').setVisible(false); diff --git a/apps/presentationeditor/main/resources/less/leftmenu.less b/apps/presentationeditor/main/resources/less/leftmenu.less index 5300f2365..433dd2f24 100644 --- a/apps/presentationeditor/main/resources/less/leftmenu.less +++ b/apps/presentationeditor/main/resources/less/leftmenu.less @@ -468,4 +468,32 @@ -webkit-transform: rotate(180deg); -o-transform: rotate(180deg); transform: rotate(180deg); +} + +#panel-protect { + #file-menu-panel & { + padding: 30px 30px; + } + + + button { + display: block; + width: auto; + margin-top: 20px; + } + + label { + font: 12px tahoma, arial, verdana, sans-serif; + } + + .header { + font-weight: bold; + margin: 30px 0 10px; + } + + table { + td { + padding: 5px 5px; + } + } } \ No newline at end of file diff --git a/apps/presentationeditor/main/resources/less/rightmenu.less b/apps/presentationeditor/main/resources/less/rightmenu.less index c2955f812..1d932b104 100644 --- a/apps/presentationeditor/main/resources/less/rightmenu.less +++ b/apps/presentationeditor/main/resources/less/rightmenu.less @@ -26,6 +26,9 @@ /*menuTextArt*/ .toolbar-btn-icon(btn-menu-textart, 57, @toolbar-icon-size); + + /**menuSignature*/ + .toolbar-btn-icon(btn-menu-signature, 57, @toolbar-icon-size); } } diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index 6026afb7b..ca56fd173 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -44,6 +44,7 @@ define([ 'core', 'common/main/lib/util/utils', 'common/main/lib/view/CopyWarningDialog', + 'common/main/lib/view/SignDialog', 'spreadsheeteditor/main/app/view/DocumentHolder', 'spreadsheeteditor/main/app/view/HyperlinkSettingsDialog', 'spreadsheeteditor/main/app/view/ParagraphSettingsAdvanced', @@ -266,6 +267,7 @@ define([ this.api.asc_registerCallback('asc_onShowSpecialPasteOptions', _.bind(this.onShowSpecialPasteOptions, this)); this.api.asc_registerCallback('asc_onHideSpecialPasteOptions', _.bind(this.onHideSpecialPasteOptions, this)); } + this.api.asc_registerCallback('asc_onSignatureClick', _.bind(this.onSignatureClick, this)); return this; }, @@ -2432,6 +2434,37 @@ define([ _conf && view.paraBulletsPicker.selectRecord(_conf.rec, true); }, + onSignatureClick: function(guid, width, height) { + var me = this; + if (_.isUndefined(me.fontStore)) { + me.fontStore = new Common.Collections.Fonts(); + var fonts = SSE.getController('Toolbar').getView('Toolbar').cmbFontName.store.toJSON(); + var arr = []; + _.each(fonts, function(font, index){ + if (!font.cloneid) { + arr.push(_.clone(font)); + } + }); + me.fontStore.add(arr); + } + + var win = new Common.Views.SignDialog({ + api: me.api, + signType: 'visible', + fontStore: me.fontStore, + signSize: {width: width, height: height}, + handler: function(dlg, result) { + if (result == 'ok') { + var props = dlg.getSettings(); + me.api.asc_Sign(props.certificateId, guid, props.images[0], props.images[1]); + } + Common.NotificationCenter.trigger('edit:complete', me.documentHolder); + } + }); + + win.show(); + }, + guestText : 'Guest', textCtrlClick : 'Press CTRL and click link', txtHeight : 'Height', diff --git a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js index 94cfd26db..9ccd36207 100644 --- a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js +++ b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js @@ -33,6 +33,8 @@ define([ 'core', 'common/main/lib/util/Shortcuts', + 'common/main/lib/view/SignSettingsDialog', + 'common/main/lib/view/SignDialog', 'spreadsheeteditor/main/app/view/LeftMenu', 'spreadsheeteditor/main/app/view/FileMenu' ], function () { @@ -73,7 +75,9 @@ define([ 'saveas:format': _.bind(this.clickSaveAsFormat, this), 'settings:apply': _.bind(this.applySettings, this), 'create:new': _.bind(this.onCreateNew, this), - 'recent:open': _.bind(this.onOpenRecent, this) + 'recent:open': _.bind(this.onOpenRecent, this), + 'signature:visible': _.bind(this.addVisibleSign, this), + 'signature:invisible': _.bind(this.addInvisibleSign, this) }, 'Toolbar': { 'file:settings': _.bind(this.clickToolbarSettings,this), @@ -746,11 +750,11 @@ define([ }, onPluginOpen: function(panel, type, action) { - if ( type == 'onboard' ) { - if ( action == 'open' ) { + if (type == 'onboard') { + if (action == 'open') { this.leftMenu.close(); this.leftMenu.panelPlugins.show(); - this.leftMenu.onBtnMenuClick({pressed:true, options: {action: 'plugins'}}); + this.leftMenu.onBtnMenuClick({pressed: true, options: {action: 'plugins'}}); this.leftMenu._state.pluginIsRunning = true; } else { this.leftMenu._state.pluginIsRunning = false; @@ -759,6 +763,41 @@ define([ } }, + addVisibleSign: function(menu) { + var me = this, + win = new Common.Views.SignSettingsDialog({ + handler: function(dlg, result) { + if (result == 'ok') { + me.api.asc_AddSignatureLine2(dlg.getSettings()); + } + Common.NotificationCenter.trigger('edit:complete', me); + } + }); + + win.show(); + + menu.hide(); + }, + + addInvisibleSign: function(menu) { + var me = this, + win = new Common.Views.SignDialog({ + api: me.api, + signType: 'invisible', + handler: function(dlg, result) { + if (result == 'ok') { + var props = dlg.getSettings(); + me.api.asc_Sign(props.certificateId); + } + Common.NotificationCenter.trigger('edit:complete', me); + } + }); + + win.show(); + + menu.hide(); + }, + textNoTextFound : 'Text not found', newDocumentTitle : 'Unnamed document', textItemEntireCell : 'Entire cell contents', diff --git a/apps/spreadsheeteditor/main/app/controller/RightMenu.js b/apps/spreadsheeteditor/main/app/controller/RightMenu.js index 85af0e8a4..9a5c5acf2 100644 --- a/apps/spreadsheeteditor/main/app/controller/RightMenu.js +++ b/apps/spreadsheeteditor/main/app/controller/RightMenu.js @@ -85,6 +85,7 @@ define([ this._settings[Common.Utils.documentSettingsType.TextArt] = {panelId: "id-textart-settings", panel: rightMenu.textartSettings, btn: rightMenu.btnTextArt, hidden: 1, locked: false}; this._settings[Common.Utils.documentSettingsType.Chart] = {panelId: "id-chart-settings", panel: rightMenu.chartSettings, btn: rightMenu.btnChart, hidden: 1, locked: false}; this._settings[Common.Utils.documentSettingsType.Table] = {panelId: "id-table-settings", panel: rightMenu.tableSettings, btn: rightMenu.btnTable, hidden: 1, locked: false}; + this._settings[Common.Utils.documentSettingsType.Signature] = {panelId: "id-signature-settings", panel: rightMenu.signatureSettings, btn: rightMenu.btnSignature, hidden: (rightMenu.signatureSettings) ? 0 : 1, props: {}, locked: false}; }, setApi: function(api) { @@ -103,7 +104,7 @@ define([ var panel = this._settings[type].panel; var props = this._settings[type].props; if (props && panel) - panel.ChangeSettings.call(panel, props); + panel.ChangeSettings.call(panel, (type==Common.Utils.documentSettingsType.Signature) ? undefined : props); } Common.NotificationCenter.trigger('layout:changed', 'rightmenu'); }, @@ -138,11 +139,13 @@ define([ return; for (var i=0; i
  • +
  • @@ -29,4 +30,5 @@
    +
    \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/template/RightMenu.template b/apps/spreadsheeteditor/main/app/template/RightMenu.template index 1f7d9abf6..24c8de9ca 100644 --- a/apps/spreadsheeteditor/main/app/template/RightMenu.template +++ b/apps/spreadsheeteditor/main/app/template/RightMenu.template @@ -12,6 +12,8 @@
    +
    +
    @@ -21,5 +23,6 @@ +
    \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/template/SignatureSettings.template b/apps/spreadsheeteditor/main/app/template/SignatureSettings.template new file mode 100644 index 000000000..5a4fa0157 --- /dev/null +++ b/apps/spreadsheeteditor/main/app/template/SignatureSettings.template @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + +
    + +
    + +
    + +
    \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/view/FileMenu.js b/apps/spreadsheeteditor/main/app/view/FileMenu.js index f1067ae56..0a7712085 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenu.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenu.js @@ -158,6 +158,12 @@ define([ this.miSaveAs, this.miPrint, this.miRename, + new Common.UI.MenuItem({ + el : $('#fm-btn-protect',this.el), + action : 'protect', + caption : this.btnProtectCaption, + canFocused: false + }), this.miRecent, this.miNew, new Common.UI.MenuItem({ @@ -217,7 +223,8 @@ define([ applyMode: function() { this.miPrint[this.mode.canPrint?'show':'hide'](); this.miRename[(this.mode.canRename && !this.mode.isDesktopApp) ?'show':'hide'](); - this.miRename.$el.find('+.devider')[!this.mode.isDisconnected?'show':'hide'](); + this.items[7][(this.mode.isDesktopApp) ?'show':'hide'](); + this.items[7].$el.find('+.devider')[!this.mode.isDisconnected?'show':'hide'](); this.miRecent[this.mode.canOpenRecent?'show':'hide'](); this.miNew[this.mode.canCreateNew?'show':'hide'](); this.miNew.$el.find('+.devider')[this.mode.canCreateNew?'show':'hide'](); @@ -255,6 +262,11 @@ define([ } } + if (this.mode.isDesktopApp) { + this.panels['protect'] = (new SSE.Views.FileMenuPanels.ProtectDoc({menu:this})).render(); + this.panels['protect'].setMode(this.mode); + } + this.panels['help'].setLangConfig(this.mode.lang); }, @@ -276,6 +288,7 @@ define([ setApi: function(api) { this.api = api; if (this.panels['opts']) this.panels['opts'].setApi(api); + if (this.panels['protect']) this.panels['protect'].setApi(api); this.api.asc_registerCallback('asc_onDocumentName', _.bind(this.onDocumentName, this)); }, @@ -333,6 +346,7 @@ define([ btnSettingsCaption : 'Advanced Settings...', btnSaveAsCaption : 'Save as', btnRenameCaption : 'Rename...', - btnCloseMenuCaption : 'Close Menu' + btnCloseMenuCaption : 'Close Menu', + btnProtectCaption: 'Protect\\Sign' }, SSE.Views.FileMenu || {})); }); diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index b5143d50e..9dbe00ff5 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -1318,4 +1318,136 @@ define([ } } }); + + SSE.Views.FileMenuPanels.ProtectDoc = Common.UI.BaseView.extend(_.extend({ + el: '#panel-protect', + menu: undefined, + + template: _.template([ + '', + '', + '', + '
    ', + '
    ', + '
    ' + ].join('')), + + initialize: function(options) { + Common.UI.BaseView.prototype.initialize.call(this,arguments); + + this.menu = options.menu; + + this.templateRequested = _.template([ + '', + '', + '<% _.each(signatures, function(item) { %>', + '', + '', + '', + '<% }); %>', + '
    <%= Common.Utils.String.htmlEncode(item) %>
    ' + ].join('')); + + this.templateValid = _.template([ + '', + '', + '<% _.each(signatures, function(item) { %>', + '', + '', + '', + '', + '<% }); %>', + '
    <%= Common.Utils.String.htmlEncode(item.name) %><%= Common.Utils.String.htmlEncode(item.date) %>
    ' + ].join('')); + }, + + render: function() { + $(this.el).html(this.template({scope: this})); + + this.btnAddInvisibleSign = new Common.UI.Button({ + el: '#fms-btn-invisible-sign' + }); + this.btnAddInvisibleSign.on('click', _.bind(this.addInvisibleSign, this)); + + this.btnAddVisibleSign = new Common.UI.Button({ + el: '#fms-btn-visible-sign' + }); + this.btnAddVisibleSign.on('click', _.bind(this.addVisibleSign, this)); + + this.lblSignHeader = $('#id-fms-lbl-sign-header', this.$el); + + this.cntRequestedSign = $('#id-fms-requested-sign'); + this.cntValidSign = $('#id-fms-valid-sign'); + this.cntInvalidSign = $('#id-fms-invalid-sign'); + + if (_.isUndefined(this.scroller)) { + this.scroller = new Common.UI.Scroller({ + el: $(this.el), + suppressScrollX: true + }); + } + + return this; + }, + + show: function() { + Common.UI.BaseView.prototype.show.call(this,arguments); + this.updateSignatures(); + }, + + setMode: function(mode) { + this.mode = mode; + if (!this.mode.isEdit) { + this.btnAddInvisibleSign.setVisible(false); + this.btnAddVisibleSign.setVisible(false); + this.lblSignHeader.html(this.strSignature); + } + }, + + setApi: function(o) { + this.api = o; + return this; + }, + + addInvisibleSign: function() { + if (this.menu) + this.menu.fireEvent('signature:invisible', [this.menu]); + }, + + addVisibleSign: function() { + if (this.menu) + this.menu.fireEvent('signature:visible', [this.menu]); + }, + + updateSignatures: function(){ + var requested = this.api.asc_getRequestSignatures(), + requested_arr = [], + valid = this.api.asc_getSignatures(), + valid_arr = [], invalid_arr = []; + + _.each(requested, function(item, index){ + requested_arr.push(item.asc_getSigner1()); + }); + _.each(valid, function(item, index){ + var sign = {name: item.asc_getSigner1(), date: '18/05/2017'}; + (item.asc_getValid()==0) ? valid_arr.push(sign) : invalid_arr.push(sign); + }); + this.cntRequestedSign.html(this.templateRequested({signatures: requested_arr, header: this.strRequested})); + this.cntValidSign.html(this.templateValid({signatures: valid_arr, header: this.strValid})); + this.cntInvalidSign.html(this.templateValid({signatures: invalid_arr, header: this.strInvalid})); + // this.cntRequestedSign.html(this.templateRequested({signatures: ['Hammish Mitchell', 'Someone Somewhere', 'Mary White', 'John Black'], header: this.strRequested})); + // this.cntValidSign.html(this.templateValid({signatures: [{name: 'Hammish Mitchell', date: '18/05/2017'}, {name: 'Someone Somewhere', date: '18/05/2017'}], header: this.strValid})); + // this.cntInvalidSign.html(this.templateValid({signatures: [{name: 'Mary White', date: '18/05/2017'}, {name: 'John Black', date: '18/05/2017'}], header: this.strInvalid})); + }, + + strProtect: 'Protect Document', + strInvisibleSign: 'Add invisible digital signature', + strVisibleSign: 'Add visible signature', + strRequested: 'Requested signatures', + strValid: 'Valid signatures', + strInvalid: 'Invalid signatures', + strSignature: 'Signature' + + }, SSE.Views.FileMenuPanels.ProtectDoc || {})); + }); diff --git a/apps/spreadsheeteditor/main/app/view/RightMenu.js b/apps/spreadsheeteditor/main/app/view/RightMenu.js index c685e418a..ce1106e19 100644 --- a/apps/spreadsheeteditor/main/app/view/RightMenu.js +++ b/apps/spreadsheeteditor/main/app/view/RightMenu.js @@ -55,6 +55,7 @@ define([ 'spreadsheeteditor/main/app/view/ShapeSettings', 'spreadsheeteditor/main/app/view/TextArtSettings', 'spreadsheeteditor/main/app/view/TableSettings', + 'spreadsheeteditor/main/app/view/SignatureSettings', 'common/main/lib/component/Scroller' ], function (menuTemplate, $, _, Backbone) { 'use strict'; @@ -134,7 +135,7 @@ define([ return this; }, - render: function () { + render: function (mode) { var el = $(this.el); this.trigger('render:before', this); @@ -166,6 +167,21 @@ define([ this.textartSettings = new SSE.Views.TextArtSettings(); this.tableSettings = new SSE.Views.TableSettings(); + if (mode && mode.isDesktopApp) { + this.btnSignature = new Common.UI.Button({ + hint: this.txtSignatureSettings, + asctype: Common.Utils.documentSettingsType.Signature, + enableToggle: true, + disabled: true, + toggleGroup: 'tabpanelbtnsGroup' + }); + this._settings[Common.Utils.documentSettingsType.Signature] = {panel: "id-signature-settings", btn: this.btnSignature}; + + this.btnSignature.el = $('#id-right-menu-signature'); this.btnSignature.render().setVisible(true); + this.btnSignature.on('click', _.bind(this.onBtnMenuClick, this)); + this.signatureSettings = new SSE.Views.SignatureSettings(); + } + if (_.isUndefined(this.scroller)) { this.scroller = new Common.UI.Scroller({ el: $(this.el).find('.right-panel'), @@ -187,7 +203,7 @@ define([ this.shapeSettings.setApi(api); this.textartSettings.setApi(api); this.tableSettings.setApi(api); - + if (this.signatureSettings) this.signatureSettings.setApi(api); return this; }, @@ -264,6 +280,7 @@ define([ txtTextArtSettings: 'Text Art Settings', txtChartSettings: 'Chart Settings', txtSparklineSettings: 'Sparkline Settings', - txtTableSettings: 'Table Settings' + txtTableSettings: 'Table Settings', + txtSignatureSettings: 'Signature Settings' }, SSE.Views.RightMenu || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/view/SignatureSettings.js b/apps/spreadsheeteditor/main/app/view/SignatureSettings.js new file mode 100644 index 000000000..32241a8c5 --- /dev/null +++ b/apps/spreadsheeteditor/main/app/view/SignatureSettings.js @@ -0,0 +1,288 @@ +/* + * + * (c) Copyright Ascensio System Limited 2010-2017 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, + * EU, LV-1021. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * +*/ +/** + * SignatureSettings.js + * + * Created by Julia Radzhabova on 5/24/17 + * Copyright (c) 2017 Ascensio System SIA. All rights reserved. + * + */ + +define([ + 'text!spreadsheeteditor/main/app/template/SignatureSettings.template', + 'jquery', + 'underscore', + 'backbone', + 'common/main/lib/component/Button', + 'common/main/lib/view/SignDialog', + 'common/main/lib/view/SignSettingsDialog' +], function (menuTemplate, $, _, Backbone) { + 'use strict'; + + SSE.Views.SignatureSettings = Backbone.View.extend(_.extend({ + el: '#id-signature-settings', + + // Compile our stats template + template: _.template(menuTemplate), + + // Delegated events for creating new items, and clearing completed ones. + events: { + }, + + options: { + alias: 'SignatureSettings' + }, + + initialize: function () { + var me = this; + + this._initSettings = true; + + this._state = { + DisabledControls: false, + requestedSignatures: undefined, + validSignatures: undefined, + invalidSignatures: undefined + }; + this._locked = false; + this.lockedControls = []; + + this._noApply = false; + this._originalProps = null; + + this.templateRequested = _.template([ + '', + '', + '', + '<% _.each(signatures, function(item) { %>', + '', + '', + '', + '', + '<% }); %>', + '
    ', + '' + ].join('')); + + this.templateValid = _.template([ + '', + '', + '', + '<% _.each(signatures, function(item) { %>', + '', + '', + '', + '', + '', + '<% }); %>', + '
    <%= Common.Utils.String.htmlEncode(item.name) %>
    <%= Common.Utils.String.htmlEncode(item.date) %>
    ', + '' + ].join('')); + + this.render(); + }, + + render: function () { + this.$el.html(this.template({ + scope: this + })); + + this.btnAddInvisibleSign = new Common.UI.Button({ + el: this.$el.find('#signature-invisible-sign') + }); + this.btnAddInvisibleSign.on('click', _.bind(this.addInvisibleSign, this)); + this.lockedControls.push(this.btnAddInvisibleSign); + + this.btnAddVisibleSign = new Common.UI.Button({ + el: this.$el.find('#signature-visible-sign') + }); + this.btnAddVisibleSign.on('click', _.bind(this.addVisibleSign, this)); + this.lockedControls.push(this.btnAddVisibleSign); + + this.cntRequestedSign = $('#signature-requested-sign'); + this.cntValidSign = $('#signature-valid-sign'); + this.cntInvalidSign = $('#signature-invalid-sign'); + }, + + setApi: function(api) { + this.api = api; + if (this.api) { + this.api.asc_registerCallback('asc_onUpdateSignatures', _.bind(this.onUpdateSignatures, this)); + } + return this; + }, + + createDelayedControls: function() { + this._initSettings = false; + }, + + ChangeSettings: function(props) { + if (this._initSettings) + this.createDelayedControls(); + + if (!this._state.requestedSignatures || !this._state.validSignatures || !this._state.invalidSignatures) { + this.onUpdateSignatures(this.api.asc_getSignatures(), this.api.asc_getRequestSignatures()); + } + + this.disableControls(this._locked); + }, + + setLocked: function (locked) { + this._locked = locked; + }, + + disableControls: function(disable) { + if (this._initSettings) return; + + if (this._state.DisabledControls!==disable) { + this._state.DisabledControls = disable; + _.each(this.lockedControls, function(item) { + item.setDisabled(disable); + }); + this.$linksSign.toggleClass('disabled', disable); + this.$linksView.toggleClass('disabled', disable); + } + }, + + setMode: function(mode) { + this.mode = mode; + }, + + onUpdateSignatures: function(valid, requested){ + var me = this; + me._state.requestedSignatures = []; + me._state.validSignatures = []; + me._state.invalidSignatures = []; + + _.each(requested, function(item, index){ + me._state.requestedSignatures.push({name: item.asc_getSigner1(), guid: item.asc_getGuid()}); + }); + _.each(valid, function(item, index){ + var sign = {name: item.asc_getSigner1(), guid: item.asc_getId(), date: '18/05/2017'}; + (item.asc_getValid()==0) ? me._state.validSignatures.push(sign) : me._state.invalidSignatures.push(sign); + }); + this.cntRequestedSign.html(this.templateRequested({signatures: me._state.requestedSignatures, header: this.strRequested})); + this.cntValidSign.html(this.templateValid({signatures: me._state.validSignatures, header: this.strValid})); + this.cntInvalidSign.html(this.templateValid({signatures: me._state.invalidSignatures, header: this.strInvalid})); + // this.cntRequestedSign.html(this.templateRequested({signatures: [{name: 'Hammish Mitchell', guid: '123'}, {name: 'Someone Somewhere', guid: '123'}, {name: 'Mary White', guid: '123'}, {name: 'John Black', guid: '123'}], header: this.strRequested})); + // this.cntValidSign.html(this.templateValid({signatures: [{name: 'Hammish Mitchell', guid: '123', date: '18/05/2017'}, {name: 'Someone Somewhere', guid: '345', date: '18/05/2017'}], header: this.strValid})); + // this.cntInvalidSign.html(this.templateValid({signatures: [{name: 'Mary White', guid: '111', date: '18/05/2017'}, {name: 'John Black', guid: '456', date: '18/05/2017'}], header: this.strInvalid})); + + this.$linksSign = $('.signature-sign-link', this.$el); + this.$linksView = $('.signature-view-link', this.$el); + this.$el.on('click', '.signature-sign-link', _.bind(this.onSign, this)); + this.$el.on('click', '.signature-view-link', _.bind(this.onViewSignature, this)); + }, + + addVisibleSign: function(btn) { + var me = this, + win = new Common.Views.SignSettingsDialog({ + handler: function(dlg, result) { + if (result == 'ok') { + me.api.asc_AddSignatureLine2(dlg.getSettings()); + } + me.fireEvent('editcomplete', me); + } + }); + + win.show(); + }, + + addInvisibleSign: function(btn) { + var me = this, + win = new Common.Views.SignDialog({ + api: me.api, + signType: 'invisible', + handler: function(dlg, result) { + if (result == 'ok') { + var props = dlg.getSettings(); + me.api.asc_Sign(props.certificateId); + } + me.fireEvent('editcomplete', me); + } + }); + + win.show(); + }, + + onSign: function(event) { + var me = this, + target = $(event.currentTarget); + + if (target.hasClass('disabled')) return; + + if (_.isUndefined(me.fontStore)) { + me.fontStore = new Common.Collections.Fonts(); + var fonts = SSE.getController('Toolbar').getView('Toolbar').cmbFontName.store.toJSON(); + var arr = []; + _.each(fonts, function(font, index){ + if (!font.cloneid) { + arr.push(_.clone(font)); + } + }); + me.fontStore.add(arr); + } + + var win = new Common.Views.SignDialog({ + api: me.api, + signType: 'visible', + fontStore: me.fontStore, + handler: function(dlg, result) { + if (result == 'ok') { + var props = dlg.getSettings(); + me.api.asc_Sign(props.certificateId, target.attr('data-value'), props.images[0], props.images[1]); + } + me.fireEvent('editcomplete', me); + } + }); + win.show(); + }, + + onViewSignature: function(event) { + var target = $(event.currentTarget); + if (target.hasClass('disabled')) return; + + this.api.asc_ViewCertificate(target.attr('data-value')); + }, + + strSignature: 'Signature', + strInvisibleSign: 'Add invisible digital signature', + strVisibleSign: 'Add visible signature', + strRequested: 'Requested signatures', + strValid: 'Valid signatures', + strInvalid: 'Invalid signatures', + strSign: 'Sign', + strView: 'View' + + }, SSE.Views.SignatureSettings || {})); +}); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/view/Viewport.js b/apps/spreadsheeteditor/main/app/view/Viewport.js index 341b4a1e1..86c059741 100644 --- a/apps/spreadsheeteditor/main/app/view/Viewport.js +++ b/apps/spreadsheeteditor/main/app/view/Viewport.js @@ -147,7 +147,7 @@ define([ var me = this, rightMenuView = SSE.getController('RightMenu').getView('RightMenu'); - me._rightMenu = rightMenuView.render(); + me._rightMenu = rightMenuView.render(this.mode); }, setMode: function(mode, delay) { diff --git a/apps/spreadsheeteditor/main/resources/less/leftmenu.less b/apps/spreadsheeteditor/main/resources/less/leftmenu.less index 9ee72cb35..29020bf74 100644 --- a/apps/spreadsheeteditor/main/resources/less/leftmenu.less +++ b/apps/spreadsheeteditor/main/resources/less/leftmenu.less @@ -537,4 +537,32 @@ -webkit-transform: rotate(180deg); -o-transform: rotate(180deg); transform: rotate(180deg); +} + +#panel-protect { + #file-menu-panel & { + padding: 30px 30px; + } + + + button { + display: block; + width: auto; + margin-top: 20px; + } + + label { + font: 12px tahoma, arial, verdana, sans-serif; + } + + .header { + font-weight: bold; + margin: 30px 0 10px; + } + + table { + td { + padding: 5px 5px; + } + } } \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/resources/less/rightmenu.less b/apps/spreadsheeteditor/main/resources/less/rightmenu.less index d50c9bf07..89b5e8a1e 100644 --- a/apps/spreadsheeteditor/main/resources/less/rightmenu.less +++ b/apps/spreadsheeteditor/main/resources/less/rightmenu.less @@ -23,6 +23,9 @@ /*menuTable*/ .toolbar-btn-icon(btn-menu-table, 80, @toolbar-icon-size); + + /**menuSignature*/ + .toolbar-btn-icon(btn-menu-signature, 66, @toolbar-icon-size); } }