From 28238bc90242a280eda05bc459c93e35abef7582 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 19 Feb 2021 15:23:55 +0300 Subject: [PATCH] Fix signature dialog --- apps/common/main/lib/view/SignDialog.js | 43 +++++++++++++++++++ .../main/lib/view/SignSettingsDialog.js | 11 +++-- 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/apps/common/main/lib/view/SignDialog.js b/apps/common/main/lib/view/SignDialog.js index 867201207..261496c9c 100644 --- a/apps/common/main/lib/view/SignDialog.js +++ b/apps/common/main/lib/view/SignDialog.js @@ -74,6 +74,8 @@ define([ bold: false, italic: false }; + var filter = Common.localStorage.getKeysFilter(); + this.appPrefix = (filter && filter.length) ? filter.split(',')[0] : ''; this.template = [ '
', @@ -145,6 +147,7 @@ define([ menuStyle : 'min-width: 234px;max-height: 270px;', store : new Common.Collections.Fonts(), recent : 0, + takeFocusOnClose: true, hint : me.tipFontName }).on('selected', function(combo, record) { if (me.signObject) { @@ -160,6 +163,7 @@ define([ menuCls : 'scrollable-menu', menuStyle: 'min-width: 55px;max-height: 270px;', hint: this.tipFontSize, + takeFocusOnClose: true, data: [ { value: 8, displayValue: "8" }, { value: 9, displayValue: "9" }, @@ -186,6 +190,8 @@ define([ me.font.size = record.value; }); this.cmbFontSize.setValue(this.font.size); + this.cmbFontSize.on('changed:before', _.bind(this.onFontSizeChanged, this, true)); + this.cmbFontSize.on('changed:after', _.bind(this.onFontSizeChanged, this, false)); me.btnBold = new Common.UI.Button({ parentEl: $('#id-dlg-sign-bold'), @@ -241,6 +247,10 @@ define([ me.afterRender(); }, + getFocusedComponents: function() { + return [this.inputPurpose, this.inputName, this.cmbFonts, this.cmbFontSize]; + }, + show: function() { Common.UI.Window.prototype.show.apply(this, arguments); @@ -340,6 +350,39 @@ define([ this.signObject.setText(value, this.font.name, this.font.size, this.font.italic, this.font.bold); }, + onFontSizeChanged: function(before, combo, record, e) { + var value, + me = this; + + if (before) { + var item = combo.store.findWhere({ + displayValue: record.value + }); + + if (!item) { + value = /^\+?(\d*(\.|,)?\d+)$|^\+?(\d+(\.|,)?\d*)$/.exec(record.value); + + if (!value) { + value = combo.getValue(); + combo.setRawValue(value); + e.preventDefault(); + return false; + } + } + } else { + var maxvalue = (this.appPrefix=='sse-') ? 409 : 300; + value = Common.Utils.String.parseFloat(record.value); + value = value > maxvalue ? maxvalue : + value < 1 ? 1 : Math.floor((value+0.4)*2)/2; + + combo.setRawValue(value); + if (this.signObject) { + this.signObject.setText(this.inputName.getValue(), this.font.name, value, this.font.italic, this.font.bold); + } + this.font.size = value; + } + }, + textTitle: 'Sign Document', textPurpose: 'Purpose for signing this document', textCertificate: 'Certificate', diff --git a/apps/common/main/lib/view/SignSettingsDialog.js b/apps/common/main/lib/view/SignSettingsDialog.js index 397cb2a73..74d649b94 100644 --- a/apps/common/main/lib/view/SignSettingsDialog.js +++ b/apps/common/main/lib/view/SignSettingsDialog.js @@ -142,13 +142,12 @@ define([ $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); }, - show: function() { - Common.UI.Window.prototype.show.apply(this, arguments); + getFocusedComponents: function() { + return [this.inputName, this.inputTitle, this.inputEmail, this.textareaInstructions]; + }, - var me = this; - _.delay(function(){ - me.inputName.cmpEl.find('input').focus(); - },500); + getDefaultFocusableComponent: function () { + return this.inputName; }, setSettings: function (props) {