[PE][SSE] Adding signatures.

This commit is contained in:
Julia Radzhabova 2017-09-13 11:57:30 +03:00
parent 1cbc937e05
commit 4ff60d7f56
29 changed files with 1079 additions and 34 deletions

View file

@ -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',

View file

@ -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']();

View file

@ -268,7 +268,7 @@ define([
win.show();
},
onViewSignature: function(guid) {
onViewSignature: function(event) {
var target = $(event.currentTarget);
if (target.hasClass('disabled')) return;

View file

@ -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...'

View file

@ -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; i<this._settings.length; i++) {
if (i==Common.Utils.documentSettingsType.Signature) continue;
if (this._settings[i]) {
this._settings[i].hidden = 1;
this._settings[i].locked = undefined;
}
}
this._settings[Common.Utils.documentSettingsType.Slide].hidden = (SelectedObjects.length>0) ? 0 : 1;
this._settings[Common.Utils.documentSettingsType.Signature].locked = false;
for (i=0; i<SelectedObjects.length; i++)
{
@ -152,7 +155,7 @@ define([
activePane = this.rightmenu.GetActivePane();
for (i=0; i<this._settings.length; i++) {
var pnl = this._settings[i];
if (pnl===undefined) continue;
if (pnl===undefined || pnl.btn===undefined || pnl.panel===undefined) continue;
if ( pnl.hidden ) {
if (!pnl.btn.isDisabled()) pnl.btn.setDisabled(true);
@ -160,7 +163,7 @@ define([
currentactive = -1;
} else {
if (pnl.btn.isDisabled()) pnl.btn.setDisabled(false);
if ( i!=Common.Utils.documentSettingsType.Slide )
if ( i!=Common.Utils.documentSettingsType.Slide && i!=Common.Utils.documentSettingsType.Signature)
lastactive = i;
if ( pnl.needShow ) {
pnl.needShow = false;
@ -190,7 +193,10 @@ define([
if (active !== undefined) {
this.rightmenu.SetActivePane(active, open);
this._settings[active].panel.ChangeSettings.call(this._settings[active].panel, this._settings[active].props);
if (active!=Common.Utils.documentSettingsType.Signature)
this._settings[active].panel.ChangeSettings.call(this._settings[active].panel, this._settings[active].props);
else
this._settings[active].panel.ChangeSettings.call(this._settings[active].panel);
}
}

View file

@ -8,6 +8,7 @@
<li id="fm-btn-save-desktop" class="fm-btn" />
<li id="fm-btn-print" class="fm-btn" />
<li id="fm-btn-rename" class="fm-btn" />
<li id="fm-btn-protect" class="fm-btn" />
<li class="devider" />
<li id="fm-btn-recent" class="fm-btn" />
<li id="fm-btn-create" class="fm-btn" />
@ -29,4 +30,5 @@
<div id="panel-rights" class="content-box" />
<div id="panel-settings" class="content-box" />
<div id="panel-help" class="content-box" />
<div id="panel-protect" class="content-box" />
</div>

View file

@ -14,6 +14,8 @@
</div>
<div id="id-textart-settings" class="settings-panel">
</div>
<div id="id-signature-settings" class="settings-panel">
</div>
</div>
<div class="tool-menu-btns">
<div class="ct-btn-category arrow-left" />
@ -24,5 +26,6 @@
<button id="id-right-menu-table" class="btn btn-category arrow-left" content-target="id-table-settings"><i class="icon img-toolbarmenu btn-menu-table">&nbsp;</i></button>
<button id="id-right-menu-chart" class="btn btn-category arrow-left" content-target="id-chart-settings"><i class="icon img-toolbarmenu btn-menu-chart">&nbsp;</i></button>
<button id="id-right-menu-textart" class="btn btn-category arrow-left" content-target="id-textart-settings"><i class="icon img-toolbarmenu btn-menu-textart">&nbsp;</i></button>
<button id="id-right-menu-signature" class="btn btn-category arrow-left hidden" content-target="id-signature-settings"><i class="icon img-toolbarmenu btn-menu-signature">&nbsp;</i></button>
</div>
</div>

View file

@ -0,0 +1,19 @@
<table cols="2">
<tr>
<td class="padding-large">
<label style="font-size: 18px;"><%= scope.strSignature %></label>
</td>
</tr>
<tr>
<td class="padding-large">
<button id="signature-invisible-sign" class="btn btn-text-default" style="width:100%;"><%= scope.strInvisibleSign %></button>
</td>
</tr>
<tr id="signature-valid-sign">
<td></td>
</tr>
<tr id="signature-invalid-sign">
<td></td>
</tr>
<tr class="finish-cell"></tr>
</table>

View file

@ -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;

View file

@ -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 || {}));
});

View file

@ -852,4 +852,102 @@ define([
}
}
});
PE.Views.FileMenuPanels.ProtectDoc = Common.UI.BaseView.extend(_.extend({
el: '#panel-protect',
menu: undefined,
template: _.template([
'<label id="id-fms-lbl-sign-header" style="font-size: 18px;"><%= scope.strProtect %></label>',
'<button id="fms-btn-invisible-sign" class="btn btn-text-default" style="min-width:190px;"><%= scope.strInvisibleSign %></button>',
'<div id="id-fms-valid-sign"></div>',
'<div id="id-fms-invalid-sign"></div>'
].join('')),
initialize: function(options) {
Common.UI.BaseView.prototype.initialize.call(this,arguments);
this.menu = options.menu;
this.templateValid = _.template([
'<label class="header <% if (signatures.length<1) { %>hidden<% } %>"><%= header %></label>',
'<table>',
'<% _.each(signatures, function(item) { %>',
'<tr>',
'<td><%= Common.Utils.String.htmlEncode(item.name) %></td>',
'<td><%= Common.Utils.String.htmlEncode(item.date) %></td>',
'</tr>',
'<% }); %>',
'</table>'
].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 || {}));
});

View file

@ -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 || {}));
});

View file

@ -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([
'<td class="padding-large <% if (signatures.length<1) { %>hidden<% } %>"">',
'<table class="<% if (signatures.length<1) { %>hidden<% } %>" style="width:100%">',
'<tr><td colspan="2" class="padding-large"><label class="header"><%= header %></label></td></tr>',
'<% _.each(signatures, function(item) { %>',
'<tr>',
'<td><div style="overflow: hidden; max-height: 15px;"><%= Common.Utils.String.htmlEncode(item.name) %></div></td>',
'<td rowspan="2" style="padding: 0 5px; vertical-align: top; text-align: right;"><label class="link-solid signature-view-link" data-value="<%= item.guid %>">' + this.strView + '</label></td>',
'</tr>',
'<tr><td style="padding-bottom: 3px;"><%= Common.Utils.String.htmlEncode(item.date) %></td></tr>',
'<% }); %>',
'</table>',
'</td>'
].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 || {}));
});

View file

@ -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);

View file

@ -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;
}
}
}

View file

@ -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);
}
}

View file

@ -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',

View file

@ -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',

View file

@ -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<this._settings.length; ++i) {
if (i==Common.Utils.documentSettingsType.Signature) continue;
if (this._settings[i]) {
this._settings[i].hidden = 1;
this._settings[i].locked = false;
}
}
this._settings[Common.Utils.documentSettingsType.Signature].locked = false;
for (i=0; i<SelectedObjects.length; ++i)
{
@ -169,6 +172,9 @@ define([
this._settings[settingsType].props = value;
this._settings[settingsType].hidden = 0;
this._settings[settingsType].locked = value.asc_getLocked();
if (!this._settings[Common.Utils.documentSettingsType.Signature].locked) // lock Signature, если хотя бы один объект locked
this._settings[Common.Utils.documentSettingsType.Signature].locked = value.asc_getLocked();
}
if (formatTableInfo) {
@ -190,7 +196,7 @@ define([
activePane = this.rightmenu.GetActivePane();
for (i=0; i<this._settings.length; ++i) {
var pnl = this._settings[i];
if (pnl===undefined) continue;
if (pnl===undefined || pnl.btn===undefined || pnl.panel===undefined) continue;
if ( pnl.hidden ) {
if ( !pnl.btn.isDisabled() )
@ -200,7 +206,7 @@ define([
} else {
if ( pnl.btn.isDisabled() )
pnl.btn.setDisabled(false);
lastactive = i;
if (i!=Common.Utils.documentSettingsType.Signature) lastactive = i;
if ( pnl.needShow ) {
pnl.needShow = false;
priorityactive = i;
@ -222,7 +228,10 @@ define([
if (active !== undefined) {
this.rightmenu.SetActivePane(active, this._openRightMenu);
this._settings[active].panel.ChangeSettings.call(this._settings[active].panel, this._settings[active].props);
if (active!=Common.Utils.documentSettingsType.Signature)
this._settings[active].panel.ChangeSettings.call(this._settings[active].panel, this._settings[active].props);
else
this._settings[active].panel.ChangeSettings.call(this._settings[active].panel);
this._openRightMenu = false;
}
}
@ -322,6 +331,11 @@ define([
this.rightmenu.chartSettings.disableControls(disabled);
this.rightmenu.tableSettings.disableControls(disabled);
if (this.rightmenu.signatureSettings) {
this.rightmenu.signatureSettings.disableControls(disabled);
this.rightmenu.btnSignature.setDisabled(disabled);
}
if (disabled) {
this.rightmenu.btnText.setDisabled(disabled);
this.rightmenu.btnTable.setDisabled(disabled);

View file

@ -8,6 +8,7 @@
<li id="fm-btn-save-desktop" class="fm-btn" />
<li id="fm-btn-print" class="fm-btn" />
<li id="fm-btn-rename" class="fm-btn" />
<li id="fm-btn-protect" class="fm-btn" />
<li class="devider" />
<li id="fm-btn-recent" class="fm-btn" />
<li id="fm-btn-create" class="fm-btn" />
@ -29,4 +30,5 @@
<div id="panel-rights" class="content-box" />
<div id="panel-settings" class="content-box" />
<div id="panel-help" class="content-box" />
<div id="panel-protect" class="content-box" />
</div>

View file

@ -12,6 +12,8 @@
</div>
<div id="id-textart-settings" class="settings-panel">
</div>
<div id="id-signature-settings" class="settings-panel">
</div>
</div>
<div class="tool-menu-btns">
<div class="ct-btn-category arrow-left" />
@ -21,5 +23,6 @@
<button id="id-right-menu-chart" class="btn btn-category arrow-left" content-target="id-chart-settings"><i class="icon img-toolbarmenu btn-menu-chart">&nbsp;</i></button>
<button id="id-right-menu-text" class="btn btn-category arrow-left" content-target="id-paragraph-settings"><i class="icon img-toolbarmenu btn-menu-text">&nbsp;</i></button>
<button id="id-right-menu-textart" class="btn btn-category arrow-left" content-target="id-textart-settings"><i class="icon img-toolbarmenu btn-menu-textart">&nbsp;</i></button>
<button id="id-right-menu-signature" class="btn btn-category arrow-left hidden" content-target="id-signature-settings"><i class="icon img-toolbarmenu btn-menu-signature">&nbsp;</i></button>
</div>
</div>

View file

@ -0,0 +1,27 @@
<table cols="2">
<tr>
<td class="padding-large">
<label style="font-size: 18px;"><%= scope.strSignature %></label>
</td>
</tr>
<tr>
<td class="padding-small">
<button id="signature-invisible-sign" class="btn btn-text-default" style="width:100%;"><%= scope.strInvisibleSign %></button>
</td>
</tr>
<tr>
<td class="padding-large">
<button id="signature-visible-sign" class="btn btn-text-default" style="width:100%;"><%= scope.strVisibleSign %></button>
</td>
</tr>
<tr id="signature-requested-sign">
<td></td>
</tr>
<tr id="signature-valid-sign">
<td></td>
</tr>
<tr id="signature-invalid-sign">
<td></td>
</tr>
<tr class="finish-cell"></tr>
</table>

View file

@ -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 || {}));
});

View file

@ -1318,4 +1318,136 @@ define([
}
}
});
SSE.Views.FileMenuPanels.ProtectDoc = Common.UI.BaseView.extend(_.extend({
el: '#panel-protect',
menu: undefined,
template: _.template([
'<label id="id-fms-lbl-sign-header" style="font-size: 18px;"><%= scope.strProtect %></label>',
'<button id="fms-btn-invisible-sign" class="btn btn-text-default" style="min-width:190px;"><%= scope.strInvisibleSign %></button>',
'<button id="fms-btn-visible-sign" class="btn btn-text-default" style="min-width:190px;"><%= scope.strVisibleSign %></button>',
'<div id="id-fms-requested-sign"></div>',
'<div id="id-fms-valid-sign"></div>',
'<div id="id-fms-invalid-sign"></div>'
].join('')),
initialize: function(options) {
Common.UI.BaseView.prototype.initialize.call(this,arguments);
this.menu = options.menu;
this.templateRequested = _.template([
'<label class="header <% if (signatures.length<1) { %>hidden<% } %>"><%= header %></label>',
'<table>',
'<% _.each(signatures, function(item) { %>',
'<tr>',
'<td><%= Common.Utils.String.htmlEncode(item) %></td>',
'</tr>',
'<% }); %>',
'</table>'
].join(''));
this.templateValid = _.template([
'<label class="header <% if (signatures.length<1) { %>hidden<% } %>"><%= header %></label>',
'<table>',
'<% _.each(signatures, function(item) { %>',
'<tr>',
'<td><%= Common.Utils.String.htmlEncode(item.name) %></td>',
'<td><%= Common.Utils.String.htmlEncode(item.date) %></td>',
'</tr>',
'<% }); %>',
'</table>'
].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 || {}));
});

View file

@ -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 || {}));
});

View file

@ -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([
'<td class="padding-large <% if (signatures.length<1) { %>hidden<% } %>">',
'<table class="<% if (signatures.length<1) { %>hidden<% } %>" style="width:100%">',
'<tr><td colspan="2" class="padding-large"><label class="header"><%= header %></label></td></tr>',
'<% _.each(signatures, function(item) { %>',
'<tr>',
'<td style="padding-bottom: 3px;"><label style="overflow: hidden; max-height: 15px;"><%= Common.Utils.String.htmlEncode(item.name) %></label></td>',
'<td style="padding: 0 5px; vertical-align: top; text-align: right;"><label class="link-solid signature-sign-link" data-value="<%= item.guid %>">' + this.strSign + '</label></td>',
'</tr>',
'<% }); %>',
'</table>',
'</td>'
].join(''));
this.templateValid = _.template([
'<td class="padding-large <% if (signatures.length<1) { %>hidden<% } %>"">',
'<table class="<% if (signatures.length<1) { %>hidden<% } %>" style="width:100%">',
'<tr><td colspan="2" class="padding-large"><label class="header"><%= header %></label></td></tr>',
'<% _.each(signatures, function(item) { %>',
'<tr>',
'<td><div style="overflow: hidden; max-height: 15px;"><%= Common.Utils.String.htmlEncode(item.name) %></div></td>',
'<td rowspan="2" style="padding: 0 5px; vertical-align: top; text-align: right;"><label class="link-solid signature-view-link" data-value="<%= item.guid %>">' + this.strView + '</label></td>',
'</tr>',
'<tr><td style="padding-bottom: 3px;"><%= Common.Utils.String.htmlEncode(item.date) %></td></tr>',
'<% }); %>',
'</table>',
'</td>'
].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 || {}));
});

View file

@ -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) {

View file

@ -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;
}
}
}

View file

@ -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);
}
}