From dd760764879eae2b1a99a465f22ebcc66906bd66 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 11 Mar 2025 13:27:53 +0300 Subject: [PATCH] [PDF] Add autofit option --- .../main/app/template/FormSettings.template | 19 ++++- apps/pdfeditor/main/app/view/FormSettings.js | 73 +++++++++++++------ apps/pdfeditor/main/locale/en.json | 2 +- 3 files changed, 70 insertions(+), 24 deletions(-) diff --git a/apps/pdfeditor/main/app/template/FormSettings.template b/apps/pdfeditor/main/app/template/FormSettings.template index f5af01bc77..3322ea2704 100644 --- a/apps/pdfeditor/main/app/template/FormSettings.template +++ b/apps/pdfeditor/main/app/template/FormSettings.template @@ -37,16 +37,31 @@ - +
- +
+ + + + + + + + + + +
+
+
+
+
diff --git a/apps/pdfeditor/main/app/view/FormSettings.js b/apps/pdfeditor/main/app/view/FormSettings.js index 19a707a751..7770bdbfb2 100644 --- a/apps/pdfeditor/main/app/view/FormSettings.js +++ b/apps/pdfeditor/main/app/view/FormSettings.js @@ -86,6 +86,9 @@ define([ })); this.PlaceholderSettings = el.find('.form-placeholder'); this.ListOnlySettings = el.find('.form-list'); + this.AutofitSettings = el.find('.form-autofit'); + this.TextSettings = el.find('.form-text'); + this.ComboSettings = el.find('.form-combo'); }, createDelayedElements: function() { @@ -127,25 +130,6 @@ define([ this.chRequired.on('change', this.onChRequired.bind(this)); this.lockedControls.push(this.chRequired); - //Spec props - this.txtPlaceholder = new Common.UI.InputField({ - el : $markup.findById('#form-txt-pholder'), - allowBlank : true, - validateOnChange: false, - validateOnBlur: false, - style : 'width: 100%;', - value : '', - dataHint : '1', - dataHintDirection: 'left', - dataHintOffset: 'small' - }); - this.lockedControls.push(this.txtPlaceholder); - this.txtPlaceholder.on('changed:after', this.onPlaceholderChanged.bind(this)); - this.txtPlaceholder.on('inputleave', function(){ me.fireEvent('editcomplete', me);}); - this.txtPlaceholder.cmpEl.on('focus', 'input.form-control', function() { - setTimeout(function(){me.txtPlaceholder._input && me.txtPlaceholder._input.select();}, 1); - }); - this.cmbLineWidth = new Common.UI.ComboBox({ el: $markup.findById('#form-combo-line-width'), cls: 'input-group-nr', @@ -184,6 +168,35 @@ define([ this.cmbLineStyle.on('selected', this.onLineStyleChanged.bind(this)); this.lockedControls.push(this.cmbLineStyle); + //Spec props + // combobox & text field + this.txtPlaceholder = new Common.UI.InputField({ + el : $markup.findById('#form-txt-pholder'), + allowBlank : true, + validateOnChange: false, + validateOnBlur: false, + style : 'width: 100%;', + value : '', + dataHint : '1', + dataHintDirection: 'left', + dataHintOffset: 'small' + }); + this.lockedControls.push(this.txtPlaceholder); + this.txtPlaceholder.on('changed:after', this.onPlaceholderChanged.bind(this)); + this.txtPlaceholder.on('inputleave', function(){ me.fireEvent('editcomplete', me);}); + this.txtPlaceholder.cmpEl.on('focus', 'input.form-control', function() { + setTimeout(function(){me.txtPlaceholder._input && me.txtPlaceholder._input.select();}, 1); + }); + + this.chAutofit = new Common.UI.CheckBox({ + el: $markup.findById('#form-chb-autofit'), + labelText: this.textAutofit, + dataHint: '1', + dataHintDirection: 'left', + dataHintOffset: 'small' + }); + this.chAutofit.on('change', this.onChAutofit.bind(this)); + // combobox & dropdown list this.txtNewValue = new Common.UI.InputField({ el : $markup.findById('#form-txt-new-value'), @@ -422,6 +435,13 @@ define([ this.btnListDown.setDisabled(idx<0 || idx>this.list.store.length-2 || this._state.DisabledControls); }, + onChAutofit: function(field, newValue, oldValue, eOpts){ + if (this.api && !this._noApply) { + this.api.SetFieldAutoFit(field.getValue()=='checked'); + this.fireEvent('editcomplete', this); + } + }, + ChangeSettings: function(props, isShape) { if (this._initSettings) this.createDelayedElements(); @@ -448,7 +468,7 @@ define([ this._state.Name = undefined; } - val = props.asc_getName(); + var val = props.asc_getName(); if (this._state.Name!==val) { this.cmbName.setValue(val ? val : ''); this._state.Name=val; @@ -522,11 +542,18 @@ define([ if (type===AscPDF.FIELD_TYPES.text || type == AscPDF.FIELD_TYPES.combobox) { if (specProps) { - var val = specProps.asc_getPlaceholder(); + val = specProps.asc_getPlaceholder(); if (this._state.placeholder !== val) { this.txtPlaceholder.setValue(val ? val : ''); this._state.placeholder = val; } + + val = specProps.asc_getAutoFit(); + if ( this._state.AutoFit!==val ) { + this.chAutofit.setValue(!!val, true); + this._state.AutoFit=val; + } + this.chAutofit.setDisabled(this._state.Comb || this._state.DisabledControls); } } //for list controls @@ -663,6 +690,7 @@ define([ }); } this.btnListAdd.setDisabled(this.txtNewValue.length<1 || this._state.DisabledControls); + this.chAutofit.setDisabled(this._state.Comb || this._state.DisabledControls); }, showHideControls: function(type, specProps) { @@ -670,7 +698,10 @@ define([ isText = type === AscPDF.FIELD_TYPES.text, isListbox = type === AscPDF.FIELD_TYPES.listbox; this.PlaceholderSettings.toggleClass('hidden', !(isCombobox || isText)); + this.AutofitSettings.toggleClass('hidden', !(isCombobox || isText)); this.ListOnlySettings.toggleClass('hidden', !(isCombobox || isListbox)); + this.TextSettings.toggleClass('hidden', !isText); + this.ComboSettings.toggleClass('hidden', !isCombobox); } }, PDFE.Views.FormSettings || {})); diff --git a/apps/pdfeditor/main/locale/en.json b/apps/pdfeditor/main/locale/en.json index 3aca8138b1..5aa18ab9b1 100644 --- a/apps/pdfeditor/main/locale/en.json +++ b/apps/pdfeditor/main/locale/en.json @@ -1401,7 +1401,7 @@ "PDFE.Views.FormSettings.textTipDelete": "Delete value", "PDFE.Views.FormSettings.textTipDown": "Move down", "PDFE.Views.FormSettings.textTipUp": "Move up", - + "PDFE.Views.FormSettings.textAutofit": "AutoFit", "PDFE.Views.FormsTab.capBtnCheckBox": "Checkbox", "PDFE.Views.FormsTab.capBtnComboBox": "Combo Box", "PDFE.Views.FormsTab.capBtnDownloadForm": "Download As PDF",