2020-09-28 16:06:12 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* (c) Copyright Ascensio System SIA 2010-2020
|
|
|
|
*
|
|
|
|
* 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 20A-12 Ernesta Birznieka-Upisha
|
|
|
|
* street, Riga, Latvia, EU, LV-1050.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* FormSettings.js
|
|
|
|
*
|
|
|
|
* Created by Julia Radzhabova on 28/09/20
|
|
|
|
* Copyright (c) 2020 Ascensio System SIA. All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
define([
|
|
|
|
'text!documenteditor/main/app/template/FormSettings.template',
|
|
|
|
'jquery',
|
|
|
|
'underscore',
|
|
|
|
'backbone',
|
|
|
|
'common/main/lib/component/ComboBox',
|
|
|
|
'common/main/lib/component/MetricSpinner',
|
2020-09-30 07:33:38 +00:00
|
|
|
'common/main/lib/component/TextareaField',
|
2020-10-06 17:52:17 +00:00
|
|
|
'common/main/lib/component/CheckBox',
|
|
|
|
'common/main/lib/view/ImageFromUrlDialog'
|
2020-09-28 16:06:12 +00:00
|
|
|
], function (menuTemplate, $, _, Backbone) {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
DE.Views.FormSettings = Backbone.View.extend(_.extend({
|
|
|
|
el: '#id-form-settings',
|
|
|
|
|
|
|
|
// Compile our stats template
|
|
|
|
template: _.template(menuTemplate),
|
|
|
|
|
|
|
|
// Delegated events for creating new items, and clearing completed ones.
|
|
|
|
events: {
|
|
|
|
},
|
|
|
|
|
|
|
|
options: {
|
|
|
|
alias: 'FormSettings'
|
|
|
|
},
|
|
|
|
|
|
|
|
initialize: function () {
|
|
|
|
this._initSettings = true;
|
|
|
|
|
|
|
|
this._state = {
|
2020-10-06 16:25:49 +00:00
|
|
|
DisabledControls: undefined,
|
|
|
|
LockDelete: undefined
|
2020-09-28 16:06:12 +00:00
|
|
|
};
|
|
|
|
this.spinners = [];
|
|
|
|
this.lockedControls = [];
|
2020-09-30 07:33:38 +00:00
|
|
|
this.internalId = null;
|
2020-09-28 16:06:12 +00:00
|
|
|
this._locked = true;
|
2020-09-30 07:33:38 +00:00
|
|
|
this._originalTextFormProps = null;
|
|
|
|
this._originalFormProps = null;
|
|
|
|
this._originalProps = null;
|
2020-09-28 16:06:12 +00:00
|
|
|
|
|
|
|
this.render();
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function () {
|
|
|
|
var el = this.$el || $(this.el);
|
|
|
|
el.html(this.template({
|
|
|
|
scope: this
|
|
|
|
}));
|
|
|
|
|
2020-09-30 10:25:18 +00:00
|
|
|
this.TextOnlySettings = el.find('.form-textfield');
|
|
|
|
this.PlaceholderSettings = el.find('.form-placeholder');
|
2020-09-30 12:46:19 +00:00
|
|
|
this.KeySettings = el.find('.form-keyfield');
|
2020-11-10 18:46:20 +00:00
|
|
|
this.KeySettingsTd = this.KeySettings.find('td');
|
2020-09-30 10:25:18 +00:00
|
|
|
this.CheckOnlySettings = el.find('.form-checkbox');
|
|
|
|
this.RadioOnlySettings = el.find('.form-radiobox');
|
|
|
|
this.ListOnlySettings = el.find('.form-list');
|
|
|
|
this.ImageOnlySettings = el.find('.form-image');
|
2020-11-10 18:46:20 +00:00
|
|
|
this.ConnectedSettings = el.find('.form-connected');
|
2021-06-17 16:42:52 +00:00
|
|
|
this.NotImageSettings = el.find('.form-not-image');
|
2020-09-28 16:06:12 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
createDelayedElements: function() {
|
2020-09-30 07:33:38 +00:00
|
|
|
this._initSettings = false;
|
|
|
|
|
2020-09-28 16:06:12 +00:00
|
|
|
var $markup = this.$el || $(this.el);
|
|
|
|
|
|
|
|
var me = this;
|
|
|
|
|
|
|
|
this.labelFormName = $markup.findById('#form-settings-name');
|
2020-11-10 18:46:20 +00:00
|
|
|
this.labelConnectedFields = $markup.findById('#form-settings-connected');
|
|
|
|
$markup.findById('#form-settings-disconnect').on('click', _.bind(this.onDisconnect, this));
|
2020-09-28 16:06:12 +00:00
|
|
|
|
2020-09-30 10:25:18 +00:00
|
|
|
// Common props
|
2020-09-28 16:06:12 +00:00
|
|
|
this.cmbKey = new Common.UI.ComboBox({
|
|
|
|
el: $markup.findById('#form-combo-key'),
|
|
|
|
cls: 'input-group-nr',
|
2020-09-30 07:33:38 +00:00
|
|
|
menuStyle: 'min-width: 100%;',
|
2020-09-28 16:06:12 +00:00
|
|
|
editable: true,
|
2021-07-08 17:16:39 +00:00
|
|
|
data: [],
|
|
|
|
dataHint: '1',
|
|
|
|
dataHintDirection: 'bottom',
|
|
|
|
dataHintOffset: 'big'
|
2020-09-28 16:06:12 +00:00
|
|
|
});
|
|
|
|
this.cmbKey.setValue('');
|
|
|
|
this.lockedControls.push(this.cmbKey);
|
2020-09-30 07:33:38 +00:00
|
|
|
this.cmbKey.on('selected', this.onKeyChanged.bind(this));
|
2020-09-28 16:06:12 +00:00
|
|
|
this.cmbKey.on('changed:after', this.onKeyChanged.bind(this));
|
|
|
|
this.cmbKey.on('hide:after', this.onHideMenus.bind(this));
|
|
|
|
|
|
|
|
this.txtPlaceholder = new Common.UI.InputField({
|
|
|
|
el : $markup.findById('#form-txt-pholder'),
|
|
|
|
allowBlank : true,
|
|
|
|
validateOnChange: false,
|
|
|
|
validateOnBlur: false,
|
|
|
|
style : 'width: 100%;',
|
2021-07-08 17:16:39 +00:00
|
|
|
value : '',
|
|
|
|
dataHint : '1',
|
|
|
|
dataHintDirection: 'left',
|
|
|
|
dataHintOffset: 'small'
|
2020-09-28 16:06:12 +00:00
|
|
|
});
|
|
|
|
this.lockedControls.push(this.txtPlaceholder);
|
|
|
|
this.txtPlaceholder.on('changed:after', this.onPlaceholderChanged.bind(this));
|
2020-09-30 07:33:38 +00:00
|
|
|
this.txtPlaceholder.on('inputleave', function(){ me.fireEvent('editcomplete', me);});
|
2021-07-22 20:39:06 +00:00
|
|
|
this.txtPlaceholder.cmpEl.on('focus', 'input.form-control', function() {
|
|
|
|
setTimeout(function(){me.txtPlaceholder._input && me.txtPlaceholder._input.select();}, 1);
|
|
|
|
});
|
2020-09-28 16:06:12 +00:00
|
|
|
|
2020-09-30 07:33:38 +00:00
|
|
|
this.textareaHelp = new Common.UI.TextareaField({
|
|
|
|
el : $markup.findById('#form-txt-help'),
|
2020-09-30 10:25:18 +00:00
|
|
|
style : 'width: 100%; height: 60px;',
|
2021-07-08 17:16:39 +00:00
|
|
|
value : '',
|
|
|
|
dataHint : '1',
|
|
|
|
dataHintDirection: 'left',
|
|
|
|
dataHintOffset: 'small'
|
2020-09-28 16:06:12 +00:00
|
|
|
});
|
2020-09-30 07:33:38 +00:00
|
|
|
this.lockedControls.push(this.textareaHelp);
|
|
|
|
this.textareaHelp.on('changed:after', this.onHelpChanged.bind(this));
|
|
|
|
this.textareaHelp.on('inputleave', function(){ me.fireEvent('editcomplete', me);});
|
2020-09-28 16:06:12 +00:00
|
|
|
|
2020-09-30 10:25:18 +00:00
|
|
|
// Text props
|
2020-09-28 16:06:12 +00:00
|
|
|
this.chMaxChars = new Common.UI.CheckBox({
|
|
|
|
el: $markup.findById('#form-chb-max-chars'),
|
2021-07-08 17:16:39 +00:00
|
|
|
labelText: this.textMaxChars,
|
|
|
|
dataHint: '1',
|
|
|
|
dataHintDirection: 'left',
|
|
|
|
dataHintOffset: 'small'
|
2020-09-28 16:06:12 +00:00
|
|
|
});
|
|
|
|
this.chMaxChars.on('change', this.onChMaxCharsChanged.bind(this));
|
|
|
|
this.lockedControls.push(this.chMaxChars);
|
|
|
|
|
|
|
|
this.spnMaxChars = new Common.UI.MetricSpinner({
|
|
|
|
el: $markup.findById('#form-spin-max-chars'),
|
|
|
|
step: 1,
|
2020-10-20 16:26:31 +00:00
|
|
|
width: 45,
|
2020-09-28 16:06:12 +00:00
|
|
|
defaultUnit : "",
|
|
|
|
value: '10',
|
|
|
|
maxValue: 1000000,
|
2021-07-08 17:16:39 +00:00
|
|
|
minValue: 1,
|
|
|
|
dataHint: '1',
|
|
|
|
dataHintDirection: 'bottom',
|
|
|
|
dataHintOffset: 'big'
|
2020-09-28 16:06:12 +00:00
|
|
|
});
|
|
|
|
this.lockedControls.push(this.spnMaxChars);
|
|
|
|
this.spnMaxChars.on('change', this.onMaxCharsChange.bind(this));
|
|
|
|
this.spnMaxChars.on('inputleave', function(){ me.fireEvent('editcomplete', me);});
|
|
|
|
|
|
|
|
this.chComb = new Common.UI.CheckBox({
|
|
|
|
el: $markup.findById('#form-chb-comb'),
|
2021-07-08 17:16:39 +00:00
|
|
|
labelText: this.textComb,
|
|
|
|
dataHint: '1',
|
|
|
|
dataHintDirection: 'left',
|
|
|
|
dataHintOffset: 'small'
|
2020-09-28 16:06:12 +00:00
|
|
|
});
|
|
|
|
this.chComb.on('change', this.onChCombChanged.bind(this));
|
|
|
|
this.lockedControls.push(this.chComb);
|
|
|
|
|
|
|
|
this.spnWidth = new Common.UI.MetricSpinner({
|
|
|
|
el: $markup.findById('#form-spin-width'),
|
|
|
|
step: .1,
|
2020-09-30 07:33:38 +00:00
|
|
|
width: 64,
|
2020-09-28 16:06:12 +00:00
|
|
|
defaultUnit : "cm",
|
2020-09-30 07:33:38 +00:00
|
|
|
value: 'Auto',
|
|
|
|
allowAuto: true,
|
2020-09-28 16:06:12 +00:00
|
|
|
maxValue: 55.88,
|
2021-07-08 17:16:39 +00:00
|
|
|
minValue: 0.1,
|
|
|
|
dataHint: '1',
|
|
|
|
dataHintDirection: 'bottom',
|
|
|
|
dataHintOffset: 'big'
|
2020-09-28 16:06:12 +00:00
|
|
|
});
|
|
|
|
this.lockedControls.push(this.spnWidth);
|
2021-01-11 15:06:12 +00:00
|
|
|
this.spinners.push(this.spnWidth);
|
2020-09-28 16:06:12 +00:00
|
|
|
this.spnWidth.on('change', this.onWidthChange.bind(this));
|
|
|
|
this.spnWidth.on('inputleave', function(){ me.fireEvent('editcomplete', me);});
|
|
|
|
|
2021-06-17 16:42:52 +00:00
|
|
|
this.chAutofit = new Common.UI.CheckBox({
|
|
|
|
el: $markup.findById('#form-chb-autofit'),
|
|
|
|
labelText: this.textAutofit
|
|
|
|
});
|
|
|
|
this.chAutofit.on('change', this.onChAutofit.bind(this));
|
|
|
|
this.lockedControls.push(this.chAutofit);
|
|
|
|
|
|
|
|
this.chMulti = new Common.UI.CheckBox({
|
|
|
|
el: $markup.findById('#form-chb-multiline'),
|
|
|
|
labelText: this.textMulti
|
|
|
|
});
|
|
|
|
this.chMulti.on('change', this.onChMulti.bind(this));
|
|
|
|
this.lockedControls.push(this.chMulti);
|
|
|
|
|
2021-05-19 21:38:09 +00:00
|
|
|
this.chRequired = new Common.UI.CheckBox({
|
|
|
|
el: $markup.findById('#form-chb-required'),
|
2021-07-08 17:16:39 +00:00
|
|
|
labelText: this.textRequired,
|
|
|
|
dataHint: '1',
|
|
|
|
dataHintDirection: 'left',
|
|
|
|
dataHintOffset: 'small'
|
2021-05-19 21:38:09 +00:00
|
|
|
});
|
|
|
|
this.chRequired.on('change', this.onChRequired.bind(this));
|
|
|
|
this.lockedControls.push(this.chRequired);
|
|
|
|
|
|
|
|
this.chFixed = new Common.UI.CheckBox({
|
|
|
|
el: $markup.findById('#form-chb-fixed'),
|
2021-07-08 17:16:39 +00:00
|
|
|
labelText: this.textFixed,
|
|
|
|
dataHint: '1',
|
|
|
|
dataHintDirection: 'left',
|
|
|
|
dataHintOffset: 'small'
|
2021-05-19 21:38:09 +00:00
|
|
|
});
|
|
|
|
this.chFixed.on('change', this.onChFixed.bind(this));
|
|
|
|
this.lockedControls.push(this.chFixed);
|
|
|
|
|
2020-09-30 10:25:18 +00:00
|
|
|
// Radio props
|
|
|
|
this.cmbGroupKey = new Common.UI.ComboBox({
|
|
|
|
el: $markup.findById('#form-combo-group-key'),
|
|
|
|
cls: 'input-group-nr',
|
|
|
|
menuStyle: 'min-width: 100%;',
|
|
|
|
editable: true,
|
2021-07-08 17:16:39 +00:00
|
|
|
data: [],
|
|
|
|
dataHint: '1',
|
|
|
|
dataHintDirection: 'bottom',
|
|
|
|
dataHintOffset: 'big'
|
2020-09-30 10:25:18 +00:00
|
|
|
});
|
|
|
|
this.cmbGroupKey.setValue('');
|
|
|
|
this.lockedControls.push(this.cmbGroupKey);
|
|
|
|
this.cmbGroupKey.on('selected', this.onGroupKeyChanged.bind(this));
|
|
|
|
this.cmbGroupKey.on('changed:after', this.onGroupKeyChanged.bind(this));
|
|
|
|
this.cmbGroupKey.on('hide:after', this.onHideMenus.bind(this));
|
|
|
|
|
2020-09-30 12:46:19 +00:00
|
|
|
// combobox & dropdown list
|
|
|
|
this.txtNewValue = new Common.UI.InputField({
|
|
|
|
el : $markup.findById('#form-txt-new-value'),
|
|
|
|
allowBlank : true,
|
|
|
|
validateOnChange: false,
|
|
|
|
validateOnBlur: false,
|
|
|
|
style : 'width: 100%;',
|
2021-07-08 17:16:39 +00:00
|
|
|
value : '',
|
|
|
|
dataHint : '1',
|
|
|
|
dataHintDirection: 'left',
|
|
|
|
dataHintOffset: 'small'
|
2020-09-30 12:46:19 +00:00
|
|
|
});
|
|
|
|
this.lockedControls.push(this.txtNewValue);
|
2020-11-03 11:05:39 +00:00
|
|
|
this.txtNewValue.on('inputleave', function(){ me.fireEvent('editcomplete', me);});
|
2020-12-24 13:25:49 +00:00
|
|
|
this.txtNewValue._input.on('keydown', _.bind(this.onNewValueKeydown, this));
|
2020-09-30 12:46:19 +00:00
|
|
|
|
|
|
|
this.list = new Common.UI.ListView({
|
|
|
|
el: $markup.findById('#form-list-list'),
|
|
|
|
store: new Common.UI.DataViewStore(),
|
|
|
|
emptyText: '',
|
|
|
|
template: _.template(['<div class="listview inner" style=""></div>'].join('')),
|
|
|
|
itemTemplate: _.template([
|
|
|
|
'<div id="<%= id %>" class="list-item" style="width: 100%;display:inline-block;">',
|
|
|
|
// '<div style="width:65px;display: inline-block;vertical-align: middle; overflow: hidden; text-overflow: ellipsis;white-space: pre;margin-right: 5px;"><%= name %></div>',
|
2021-04-26 11:54:55 +00:00
|
|
|
'<div style="width:145px;display: inline-block;vertical-align: middle; overflow: hidden; text-overflow: ellipsis;white-space: pre;"><%= Common.Utils.String.htmlEncode(name) %></div>',
|
2020-09-30 12:46:19 +00:00
|
|
|
'</div>'
|
|
|
|
].join(''))
|
|
|
|
});
|
|
|
|
this.list.on('item:select', _.bind(this.onSelectItem, this));
|
2020-10-06 16:25:49 +00:00
|
|
|
this.lockedControls.push(this.list);
|
2020-09-30 12:46:19 +00:00
|
|
|
|
|
|
|
this.btnListAdd = new Common.UI.Button({
|
|
|
|
parentEl: $markup.findById('#form-list-add'),
|
|
|
|
cls: 'btn-toolbar',
|
2020-10-07 16:13:24 +00:00
|
|
|
iconCls: 'toolbar__icon btn-zoomup',
|
2021-07-08 17:16:39 +00:00
|
|
|
hint: this.textTipAdd,
|
|
|
|
dataHint: '1',
|
|
|
|
dataHintDirection: 'left',
|
|
|
|
dataHintOffset: 'big'
|
2020-09-30 12:46:19 +00:00
|
|
|
});
|
|
|
|
this.btnListAdd.on('click', _.bind(this.onAddItem, this));
|
2020-10-06 16:25:49 +00:00
|
|
|
this.lockedControls.push(this.btnListAdd);
|
2020-09-30 12:46:19 +00:00
|
|
|
|
|
|
|
this.btnListDelete = new Common.UI.Button({
|
|
|
|
parentEl: $markup.findById('#form-list-delete'),
|
|
|
|
cls: 'btn-toolbar',
|
|
|
|
iconCls: 'toolbar__icon cc-remove',
|
2021-07-08 17:16:39 +00:00
|
|
|
hint: this.textTipDelete,
|
|
|
|
dataHint: '1',
|
|
|
|
dataHintDirection: 'left',
|
|
|
|
dataHintOffset: 'big'
|
2020-09-30 12:46:19 +00:00
|
|
|
});
|
|
|
|
this.btnListDelete.on('click', _.bind(this.onDeleteItem, this));
|
2020-10-06 16:25:49 +00:00
|
|
|
this.lockedControls.push(this.btnListDelete);
|
2020-09-30 12:46:19 +00:00
|
|
|
|
|
|
|
this.btnListUp = new Common.UI.Button({
|
|
|
|
parentEl: $markup.findById('#form-list-up'),
|
|
|
|
cls: 'btn-toolbar',
|
2020-10-13 12:27:32 +00:00
|
|
|
iconCls: 'toolbar__icon btn-arrow-up',
|
2021-07-08 17:16:39 +00:00
|
|
|
hint: this.textTipUp,
|
|
|
|
dataHint: '1',
|
|
|
|
dataHintDirection: 'left',
|
|
|
|
dataHintOffset: 'big'
|
2020-09-30 12:46:19 +00:00
|
|
|
});
|
|
|
|
this.btnListUp.on('click', _.bind(this.onMoveItem, this, true));
|
2020-10-06 16:25:49 +00:00
|
|
|
this.lockedControls.push(this.btnListUp);
|
2020-09-30 12:46:19 +00:00
|
|
|
|
|
|
|
this.btnListDown = new Common.UI.Button({
|
|
|
|
parentEl: $markup.findById('#form-list-down'),
|
|
|
|
cls: 'btn-toolbar',
|
2020-10-13 12:27:32 +00:00
|
|
|
iconCls: 'toolbar__icon btn-arrow-down',
|
2021-07-08 17:16:39 +00:00
|
|
|
hint: this.textTipDown,
|
|
|
|
dataHint: '1',
|
|
|
|
dataHintDirection: 'left',
|
|
|
|
dataHintOffset: 'big'
|
2020-09-30 12:46:19 +00:00
|
|
|
});
|
|
|
|
this.btnListDown.on('click', _.bind(this.onMoveItem, this, false));
|
2020-10-06 16:25:49 +00:00
|
|
|
this.lockedControls.push(this.btnListDown);
|
2020-09-30 12:46:19 +00:00
|
|
|
|
2020-10-06 17:52:17 +00:00
|
|
|
// image props
|
|
|
|
this.btnSelectImage = new Common.UI.Button({
|
|
|
|
parentEl: $('#form-button-replace'),
|
|
|
|
cls: 'btn-text-menu-default',
|
|
|
|
caption: this.textSelectImage,
|
|
|
|
style: "width:100%;",
|
|
|
|
menu: new Common.UI.Menu({
|
|
|
|
style: 'min-width: 194px;',
|
|
|
|
maxHeight: 200,
|
|
|
|
items: [
|
|
|
|
{caption: this.textFromFile, value: 0},
|
|
|
|
{caption: this.textFromUrl, value: 1},
|
|
|
|
{caption: this.textFromStorage, value: 2}
|
|
|
|
]
|
2021-07-08 17:16:39 +00:00
|
|
|
}),
|
|
|
|
dataHint: '1',
|
|
|
|
dataHintDirection: 'bottom',
|
|
|
|
dataHintOffset: 'big'
|
2020-10-06 17:52:17 +00:00
|
|
|
});
|
|
|
|
this.lockedControls.push(this.btnSelectImage);
|
|
|
|
this.btnSelectImage.menu.on('item:click', _.bind(this.onImageSelect, this));
|
|
|
|
this.btnSelectImage.menu.items[2].setVisible(this.mode.canRequestInsertImage || this.mode.fileChoiceUrl && this.mode.fileChoiceUrl.indexOf("{documentType}")>-1);
|
|
|
|
|
2020-09-28 16:52:48 +00:00
|
|
|
this.btnRemForm = new Common.UI.Button({
|
|
|
|
parentEl: $markup.findById('#form-btn-delete'),
|
|
|
|
cls : 'btn-toolbar',
|
2020-09-30 12:46:19 +00:00
|
|
|
iconCls : 'toolbar__icon cc-remove',
|
2020-09-28 16:52:48 +00:00
|
|
|
caption : this.textDelete,
|
2021-07-08 17:16:39 +00:00
|
|
|
style : 'text-align: left;',
|
|
|
|
dataHint : '1',
|
|
|
|
dataHintDirection: 'left',
|
|
|
|
dataHintOffset: 'small'
|
2020-09-28 16:52:48 +00:00
|
|
|
});
|
|
|
|
this.btnRemForm.on('click', _.bind(function(btn){
|
2020-12-14 09:25:12 +00:00
|
|
|
this.api.asc_RemoveContentControl(this._state.id);
|
2020-09-28 16:52:48 +00:00
|
|
|
}, this));
|
|
|
|
this.lockedControls.push(this.btnRemForm);
|
|
|
|
|
|
|
|
this.btnLockForm = new Common.UI.Button({
|
|
|
|
parentEl: $markup.findById('#form-btn-lock'),
|
|
|
|
cls : 'btn-toolbar',
|
2020-10-07 12:44:36 +00:00
|
|
|
iconCls : 'toolbar__icon btn-lock',
|
2020-09-28 16:52:48 +00:00
|
|
|
caption : this.textLock,
|
2021-07-08 17:16:39 +00:00
|
|
|
style : 'text-align: left;',
|
|
|
|
dataHint : '1',
|
|
|
|
dataHintDirection: 'left',
|
|
|
|
dataHintOffset: 'small'
|
2020-09-28 16:52:48 +00:00
|
|
|
});
|
|
|
|
this.btnLockForm.on('click', _.bind(function(btn){
|
2020-09-30 07:33:38 +00:00
|
|
|
if (this.api && !this._noApply) {
|
|
|
|
var props = this._originalProps || new AscCommon.CContentControlPr();
|
2020-10-06 16:25:49 +00:00
|
|
|
props.put_Lock(!this._state.LockDelete ? Asc.c_oAscSdtLockType.SdtLocked : Asc.c_oAscSdtLockType.Unlocked);
|
2020-09-30 07:33:38 +00:00
|
|
|
this.api.asc_SetContentControlProperties(props, this.internalId);
|
|
|
|
}
|
2020-09-28 16:52:48 +00:00
|
|
|
}, this));
|
|
|
|
|
2021-07-02 15:46:09 +00:00
|
|
|
this.chAspect = new Common.UI.CheckBox({
|
|
|
|
el: $markup.findById('#form-chb-aspect'),
|
|
|
|
labelText: this.textAspect
|
|
|
|
});
|
|
|
|
this.chAspect.on('change', this.onChAspect.bind(this));
|
|
|
|
this.lockedControls.push(this.chAspect);
|
|
|
|
|
|
|
|
this.cmbScale = new Common.UI.ComboBox({
|
|
|
|
el: $markup.findById('#form-combo-scale'),
|
|
|
|
cls: 'input-group-nr',
|
|
|
|
menuStyle: 'min-width: 100%;',
|
|
|
|
editable: false,
|
|
|
|
data: [{ displayValue: this.textAlways, value: Asc.c_oAscPictureFormScaleFlag.Always },
|
|
|
|
{ displayValue: this.textNever, value: Asc.c_oAscPictureFormScaleFlag.Never },
|
|
|
|
{ displayValue: this.textTooBig, value: Asc.c_oAscPictureFormScaleFlag.Bigger },
|
|
|
|
{ displayValue: this.textTooSmall, value: Asc.c_oAscPictureFormScaleFlag.Smaller }]
|
|
|
|
});
|
|
|
|
this.cmbScale.setValue(Asc.c_oAscPictureFormScaleFlag.Always);
|
|
|
|
this.lockedControls.push(this.cmbScale);
|
|
|
|
this.cmbScale.on('selected', this.onScaleChanged.bind(this));
|
|
|
|
this.cmbScale.on('changed:after', this.onScaleChanged.bind(this));
|
|
|
|
this.cmbScale.on('hide:after', this.onHideMenus.bind(this));
|
|
|
|
|
2021-08-04 22:27:55 +00:00
|
|
|
this.imagePositionPreview = $markup.findById('#form-img-example');
|
|
|
|
this.imagePositionLabel = $markup.findById('#form-img-slider-value');
|
|
|
|
|
2021-08-03 17:00:23 +00:00
|
|
|
this.sldrPreviewPositionX = new Common.UI.SingleSlider({
|
|
|
|
el: $('#form-img-slider-position-x'),
|
|
|
|
width: 116,
|
|
|
|
minValue: 0,
|
|
|
|
maxValue: 100,
|
|
|
|
value: 50
|
|
|
|
});
|
2021-08-04 22:27:55 +00:00
|
|
|
this.sldrPreviewPositionX.on('change', _.bind(this.onImagePositionChange, this, 'x'));
|
|
|
|
this.sldrPreviewPositionX.on('changecomplete', _.bind(this.onImagePositionChangeComplete, this, 'x'));
|
|
|
|
this.lockedControls.push(this.sldrPreviewPositionX);
|
2021-08-03 17:00:23 +00:00
|
|
|
|
|
|
|
this.sldrPreviewPositionY = new Common.UI.SingleSlider({
|
|
|
|
el: $('#form-img-slider-position-y'),
|
|
|
|
width: 116,
|
|
|
|
minValue: 0,
|
|
|
|
maxValue: 100,
|
|
|
|
value: 50,
|
|
|
|
direction: 'vertical'
|
|
|
|
});
|
2021-08-04 22:27:55 +00:00
|
|
|
this.sldrPreviewPositionY.on('change', _.bind(this.onImagePositionChange, this, 'y'));
|
|
|
|
this.sldrPreviewPositionY.on('changecomplete', _.bind(this.onImagePositionChangeComplete, this, 'y'));
|
|
|
|
this.lockedControls.push(this.sldrPreviewPositionY);
|
|
|
|
|
|
|
|
var xValue = this.sldrPreviewPositionX.getValue(),
|
|
|
|
yValue = this.sldrPreviewPositionY.getValue();
|
|
|
|
this.imagePositionLabel.text(xValue + ',' + yValue);
|
2021-08-03 17:00:23 +00:00
|
|
|
|
2020-09-28 16:06:12 +00:00
|
|
|
this.updateMetricUnit();
|
2020-10-20 16:26:31 +00:00
|
|
|
this.UpdateThemeColors();
|
2020-09-28 16:06:12 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
setApi: function(api) {
|
|
|
|
this.api = api;
|
|
|
|
if (this.api) {
|
|
|
|
// this.api.asc_registerCallback('asc_onParaSpacingLine', _.bind(this._onLineSpacing, this));
|
|
|
|
}
|
2021-04-30 09:24:42 +00:00
|
|
|
Common.NotificationCenter.on('storage:image-insert', _.bind(this.insertImageFromStorage, this));
|
2020-09-28 16:06:12 +00:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2020-10-06 17:52:17 +00:00
|
|
|
setMode: function(mode) {
|
|
|
|
this.mode = mode;
|
|
|
|
},
|
|
|
|
|
2020-09-28 16:06:12 +00:00
|
|
|
onKeyChanged: function(combo, record) {
|
2020-09-30 07:33:38 +00:00
|
|
|
if (this.api && !this._noApply) {
|
|
|
|
var props = this._originalProps || new AscCommon.CContentControlPr();
|
|
|
|
var formPr = this._originalFormProps || new AscCommon.CSdtFormPr();
|
|
|
|
formPr.put_Key(record.value);
|
|
|
|
props.put_FormPr(formPr);
|
|
|
|
this.api.asc_SetContentControlProperties(props, this.internalId);
|
|
|
|
this.fireEvent('editcomplete', this);
|
2020-09-28 16:06:12 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onPlaceholderChanged: function(input, newValue, oldValue, e) {
|
2020-12-24 13:17:30 +00:00
|
|
|
if (this.api && !this._noApply && (newValue!==oldValue)) {
|
2020-09-30 07:33:38 +00:00
|
|
|
var props = this._originalProps || new AscCommon.CContentControlPr();
|
2020-10-30 19:38:52 +00:00
|
|
|
props.put_PlaceholderText(newValue || ' ');
|
2020-09-30 07:33:38 +00:00
|
|
|
this.api.asc_SetContentControlProperties(props, this.internalId);
|
2020-12-24 13:17:30 +00:00
|
|
|
if (!e.relatedTarget || (e.relatedTarget.localName != 'input' && e.relatedTarget.localName != 'textarea') || !/form-control/.test(e.relatedTarget.className))
|
|
|
|
this.fireEvent('editcomplete', this);
|
2020-09-30 07:33:38 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onHelpChanged: function(input, newValue, oldValue, e) {
|
2020-12-24 13:17:30 +00:00
|
|
|
if (this.api && !this._noApply && (newValue!==oldValue)) {
|
2020-09-30 07:33:38 +00:00
|
|
|
var props = this._originalProps || new AscCommon.CContentControlPr();
|
|
|
|
var formPr = this._originalFormProps || new AscCommon.CSdtFormPr();
|
|
|
|
formPr.put_HelpText(newValue);
|
|
|
|
props.put_FormPr(formPr);
|
|
|
|
this.api.asc_SetContentControlProperties(props, this.internalId);
|
2020-12-24 13:17:30 +00:00
|
|
|
if (!e.relatedTarget || (e.relatedTarget.localName != 'input' && e.relatedTarget.localName != 'textarea') || !/form-control/.test(e.relatedTarget.className))
|
|
|
|
this.fireEvent('editcomplete', this);
|
2020-09-28 16:06:12 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onChMaxCharsChanged: function(field, newValue, oldValue, eOpts){
|
2020-10-30 19:19:10 +00:00
|
|
|
var checked = (field.getValue()=='checked');
|
|
|
|
this.spnMaxChars.setDisabled(!checked);
|
|
|
|
if (!checked) {
|
|
|
|
this.chComb.setValue(false, true);
|
|
|
|
this.spnWidth.setDisabled(true);
|
|
|
|
}
|
2020-09-30 07:33:38 +00:00
|
|
|
if (this.api && !this._noApply) {
|
|
|
|
var props = this._originalProps || new AscCommon.CContentControlPr();
|
|
|
|
var formTextPr = this._originalTextFormProps || new AscCommon.CSdtTextFormPr();
|
2020-10-30 19:19:10 +00:00
|
|
|
(!checked) && formTextPr.put_Comb(checked);
|
2020-09-30 07:33:38 +00:00
|
|
|
formTextPr.put_MaxCharacters(checked ? (this.spnMaxChars.getNumberValue() || 10) : checked);
|
|
|
|
props.put_TextFormPr(formTextPr);
|
|
|
|
this.api.asc_SetContentControlProperties(props, this.internalId);
|
|
|
|
this.fireEvent('editcomplete', this);
|
|
|
|
}
|
2020-09-28 16:06:12 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onMaxCharsChange: function(field, newValue, oldValue, eOpts){
|
2020-09-30 07:33:38 +00:00
|
|
|
if (this.api && !this._noApply) {
|
|
|
|
var props = this._originalProps || new AscCommon.CContentControlPr();
|
|
|
|
var formTextPr = this._originalTextFormProps || new AscCommon.CSdtTextFormPr();
|
|
|
|
var checked = (this.chMaxChars.getValue()=='checked' || this.chComb.getValue()=='checked');
|
|
|
|
formTextPr.put_MaxCharacters(checked ? (field.getNumberValue() || 10) : checked);
|
|
|
|
props.put_TextFormPr(formTextPr);
|
|
|
|
this.api.asc_SetContentControlProperties(props, this.internalId);
|
|
|
|
}
|
2020-09-28 16:06:12 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onChCombChanged: function(field, newValue, oldValue, eOpts){
|
|
|
|
var checked = (field.getValue()=='checked');
|
|
|
|
if (checked) {
|
2020-09-30 07:33:38 +00:00
|
|
|
this.chMaxChars.setValue(true, true);
|
|
|
|
this.spnMaxChars.setDisabled(false);
|
2020-09-28 16:06:12 +00:00
|
|
|
}
|
|
|
|
this.spnWidth.setDisabled(!checked);
|
2020-09-30 07:33:38 +00:00
|
|
|
if (this.api && !this._noApply) {
|
|
|
|
var props = this._originalProps || new AscCommon.CContentControlPr();
|
|
|
|
var formTextPr = this._originalTextFormProps || new AscCommon.CSdtTextFormPr();
|
|
|
|
formTextPr.put_Comb(checked);
|
|
|
|
if (checked) {
|
|
|
|
formTextPr.put_MaxCharacters(this.spnMaxChars.getNumberValue() || 10);
|
|
|
|
if (this.spnWidth.getValue()) {
|
|
|
|
var value = this.spnWidth.getNumberValue();
|
2021-04-22 12:17:43 +00:00
|
|
|
formTextPr.put_Width(value<=0 ? 0 : parseInt(Common.Utils.Metric.fnRecalcToMM(value) * 72 * 20 / 25.4 + 0.5));
|
2020-09-30 07:33:38 +00:00
|
|
|
} else
|
|
|
|
formTextPr.put_Width(0);
|
|
|
|
}
|
|
|
|
props.put_TextFormPr(formTextPr);
|
|
|
|
this.api.asc_SetContentControlProperties(props, this.internalId);
|
|
|
|
this.fireEvent('editcomplete', this);
|
2020-09-28 16:06:12 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-09-30 07:33:38 +00:00
|
|
|
onWidthChange: function(field, newValue, oldValue, eOpts){
|
|
|
|
if (this.api && !this._noApply) {
|
|
|
|
var props = this._originalProps || new AscCommon.CContentControlPr();
|
|
|
|
var formTextPr = this._originalTextFormProps || new AscCommon.CSdtTextFormPr();
|
|
|
|
if (this.spnWidth.getValue()) {
|
|
|
|
var value = this.spnWidth.getNumberValue();
|
2021-04-22 12:17:43 +00:00
|
|
|
formTextPr.put_Width(value<=0 ? 0 : parseInt(Common.Utils.Metric.fnRecalcToMM(value) * 72 * 20 / 25.4 + 0.5));
|
2020-09-30 07:33:38 +00:00
|
|
|
} else
|
|
|
|
formTextPr.put_Width(0);
|
|
|
|
|
|
|
|
props.put_TextFormPr(formTextPr);
|
|
|
|
this.api.asc_SetContentControlProperties(props, this.internalId);
|
2020-09-28 16:06:12 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-05-19 21:38:09 +00:00
|
|
|
onChRequired: function(field, newValue, oldValue, eOpts){
|
|
|
|
var checked = (field.getValue()=='checked');
|
|
|
|
if (this.api && !this._noApply) {
|
|
|
|
var props = this._originalProps || new AscCommon.CContentControlPr();
|
|
|
|
var formPr = this._originalFormProps || new AscCommon.CSdtFormPr();
|
|
|
|
formPr.put_Required(checked);
|
|
|
|
props.put_FormPr(formPr);
|
|
|
|
this.api.asc_SetContentControlProperties(props, this.internalId);
|
|
|
|
this.fireEvent('editcomplete', this);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-06-17 16:42:52 +00:00
|
|
|
onChAutofit: function(field, newValue, oldValue, eOpts){
|
2021-05-19 21:38:09 +00:00
|
|
|
var checked = (field.getValue()=='checked');
|
|
|
|
if (this.api && !this._noApply) {
|
|
|
|
var props = this._originalProps || new AscCommon.CContentControlPr();
|
|
|
|
var formTextPr = this._originalTextFormProps || new AscCommon.CSdtTextFormPr();
|
2021-06-17 16:42:52 +00:00
|
|
|
formTextPr.put_AutoFit(checked);
|
2021-05-19 21:38:09 +00:00
|
|
|
props.put_TextFormPr(formTextPr);
|
|
|
|
this.api.asc_SetContentControlProperties(props, this.internalId);
|
|
|
|
this.fireEvent('editcomplete', this);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-06-17 16:42:52 +00:00
|
|
|
onChMulti: function(field, newValue, oldValue, eOpts){
|
2021-05-19 21:38:09 +00:00
|
|
|
var checked = (field.getValue()=='checked');
|
|
|
|
if (this.api && !this._noApply) {
|
|
|
|
var props = this._originalProps || new AscCommon.CContentControlPr();
|
|
|
|
var formTextPr = this._originalTextFormProps || new AscCommon.CSdtTextFormPr();
|
2021-06-17 16:42:52 +00:00
|
|
|
formTextPr.put_MultiLine(checked);
|
2021-05-19 21:38:09 +00:00
|
|
|
props.put_TextFormPr(formTextPr);
|
|
|
|
this.api.asc_SetContentControlProperties(props, this.internalId);
|
|
|
|
this.fireEvent('editcomplete', this);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-06-17 16:42:52 +00:00
|
|
|
onChFixed: function(field, newValue, oldValue, eOpts){
|
|
|
|
if (this.api && !this._noApply) {
|
|
|
|
this.api.asc_SetFixedForm(this.internalId, field.getValue()=='checked');
|
|
|
|
this.fireEvent('editcomplete', this);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-07-02 15:46:09 +00:00
|
|
|
onChAspect: function(field, newValue, oldValue, eOpts){
|
|
|
|
if (this.api && !this._noApply) {
|
|
|
|
var props = this._originalProps || new AscCommon.CContentControlPr();
|
|
|
|
var pictPr = this._originalPictProps || new AscCommon.CSdtPictureFormPr();
|
|
|
|
pictPr.put_ConstantProportions(field.getValue()=='checked');
|
|
|
|
props.put_PictureFormPr(pictPr);
|
|
|
|
this.api.asc_SetContentControlProperties(props, this.internalId);
|
|
|
|
this.fireEvent('editcomplete', this);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onScaleChanged: function(combo, record) {
|
|
|
|
if (this.api && !this._noApply) {
|
|
|
|
var props = this._originalProps || new AscCommon.CContentControlPr();
|
|
|
|
var pictPr = this._originalPictProps || new AscCommon.CSdtPictureFormPr();
|
|
|
|
pictPr.put_ScaleFlag(record.value);
|
|
|
|
props.put_PictureFormPr(pictPr);
|
|
|
|
this.api.asc_SetContentControlProperties(props, this.internalId);
|
|
|
|
this.fireEvent('editcomplete', this);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-09-30 10:25:18 +00:00
|
|
|
onGroupKeyChanged: function(combo, record) {
|
|
|
|
if (this.api && !this._noApply) {
|
|
|
|
var props = this._originalProps || new AscCommon.CContentControlPr();
|
|
|
|
var specProps = this._originalCheckProps || new AscCommon.CSdtCheckBoxPr();
|
|
|
|
specProps.put_GroupKey(record.value);
|
|
|
|
props.put_CheckBoxPr(specProps);
|
|
|
|
this.api.asc_SetContentControlProperties(props, this.internalId);
|
|
|
|
this.fireEvent('editcomplete', this);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-09-30 12:46:19 +00:00
|
|
|
fillListProps: function() {
|
|
|
|
if (this.api && !this._noApply) {
|
|
|
|
var props = this._originalProps || new AscCommon.CContentControlPr();
|
|
|
|
var specProps = this._originalListProps || new AscCommon.CSdtComboBoxPr();
|
|
|
|
specProps.clear();
|
|
|
|
this.list.store.each(function (item, index) {
|
|
|
|
specProps.add_Item(item.get('name'), item.get('value'));
|
|
|
|
});
|
|
|
|
(this.type == Asc.c_oAscContentControlSpecificType.ComboBox) ? props.put_ComboBoxPr(specProps) : props.put_DropDownListPr(specProps);
|
|
|
|
this.api.asc_SetContentControlProperties(props, this.internalId);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-12-24 13:25:49 +00:00
|
|
|
onNewValueKeydown: function(event) {
|
|
|
|
if (this.api && !this._noApply && event.keyCode == Common.UI.Keys.RETURN) {
|
|
|
|
this.onAddItem();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-09-30 12:46:19 +00:00
|
|
|
onAddItem: function() {
|
|
|
|
var store = this.list.store,
|
|
|
|
value = this.txtNewValue.getValue();
|
|
|
|
if (value!=='') {
|
|
|
|
var rec = store.findWhere({value: value});
|
|
|
|
if (!rec) {
|
|
|
|
store.add({value: value, name: value});
|
2020-11-10 14:42:47 +00:00
|
|
|
this._state.listValue = value;
|
|
|
|
this._state.listIndex = undefined;
|
2020-09-30 12:46:19 +00:00
|
|
|
this.fillListProps();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.fireEvent('editcomplete', this);
|
|
|
|
},
|
|
|
|
|
|
|
|
onDeleteItem: function(btn, eOpts){
|
|
|
|
var rec = this.list.getSelectedRec();
|
|
|
|
if (rec) {
|
|
|
|
var store = this.list.store;
|
2020-11-10 14:42:47 +00:00
|
|
|
this._state.listIndex = store.indexOf(rec);
|
|
|
|
this._state.listValue = undefined;
|
2020-09-30 12:46:19 +00:00
|
|
|
store.remove(rec);
|
|
|
|
this.fillListProps();
|
|
|
|
}
|
|
|
|
this.fireEvent('editcomplete', this);
|
|
|
|
},
|
|
|
|
|
|
|
|
onMoveItem: function(up) {
|
|
|
|
var store = this.list.store,
|
|
|
|
length = store.length,
|
|
|
|
rec = this.list.getSelectedRec();
|
|
|
|
if (rec) {
|
|
|
|
var index = store.indexOf(rec);
|
|
|
|
store.add(store.remove(rec), {at: up ? Math.max(0, index-1) : Math.min(length-1, index+1)});
|
|
|
|
this.fillListProps();
|
|
|
|
}
|
|
|
|
this.fireEvent('editcomplete', this);
|
|
|
|
},
|
|
|
|
|
2020-10-06 17:52:17 +00:00
|
|
|
setImageUrl: function(url, token) {
|
2020-10-15 09:17:34 +00:00
|
|
|
this.api.asc_SetContentControlPictureUrl(url, this.internalId, token);
|
2020-10-06 17:52:17 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
insertImageFromStorage: function(data) {
|
2021-08-27 11:07:50 +00:00
|
|
|
if (data && data._urls && data.c=='control') {
|
|
|
|
this.setImageUrl(data._urls[0], data.token);
|
2020-10-06 17:52:17 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onImageSelect: function(menu, item) {
|
|
|
|
if (item.value==1) {
|
|
|
|
var me = this;
|
|
|
|
(new Common.Views.ImageFromUrlDialog({
|
|
|
|
handler: function(result, value) {
|
|
|
|
if (result == 'ok') {
|
|
|
|
if (me.api) {
|
|
|
|
var checkUrl = value.replace(/ /g, '');
|
|
|
|
if (!_.isEmpty(checkUrl)) {
|
|
|
|
me.setImageUrl(checkUrl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
me.fireEvent('editcomplete', me);
|
|
|
|
}
|
|
|
|
})).show();
|
|
|
|
} else if (item.value==2) {
|
|
|
|
Common.NotificationCenter.trigger('storage:image-load', 'control');
|
|
|
|
} else {
|
|
|
|
if (this._isFromFile) return;
|
|
|
|
this._isFromFile = true;
|
|
|
|
if (this.api) this.api.asc_addImage(this._originalProps);
|
|
|
|
this.fireEvent('editcomplete', this);
|
|
|
|
this._isFromFile = false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-08-12 17:06:16 +00:00
|
|
|
onColorBGSelect: function(btn, color) {
|
|
|
|
this.BackgroundColor = color;
|
|
|
|
this._state.BackgroundColor = undefined;
|
|
|
|
|
|
|
|
var props = this._originalProps || new AscCommon.CContentControlPr();
|
|
|
|
var formPr = this._originalFormProps || new AscCommon.CSdtFormPr();
|
|
|
|
|
|
|
|
if (this.api) {
|
|
|
|
if (color === 'transparent') {
|
|
|
|
formPr.put_Shd(false);
|
|
|
|
} else {
|
|
|
|
formPr.put_Shd(true, Common.Utils.ThemeColor.getRgbColor(color));
|
|
|
|
}
|
|
|
|
props.put_FormPr(formPr);
|
|
|
|
this.api.asc_SetContentControlProperties(props, this.internalId);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.fireEvent('editcomplete', this);
|
|
|
|
},
|
|
|
|
|
2020-10-20 16:26:31 +00:00
|
|
|
onColorPickerSelect: function(btn, color) {
|
|
|
|
this.BorderColor = color;
|
2020-12-24 08:50:09 +00:00
|
|
|
this._state.BorderColor = undefined;
|
2020-10-20 16:26:31 +00:00
|
|
|
|
|
|
|
if (this.api && !this._noApply) {
|
|
|
|
var props = this._originalProps || new AscCommon.CContentControlPr();
|
2021-07-29 15:01:28 +00:00
|
|
|
var formPr = this._originalFormProps || new AscCommon.CSdtFormPr();
|
2020-10-20 16:26:31 +00:00
|
|
|
if (color == 'transparent') {
|
2021-07-29 15:01:28 +00:00
|
|
|
formPr.put_Border();
|
2020-10-20 16:26:31 +00:00
|
|
|
} else {
|
2021-07-29 15:01:28 +00:00
|
|
|
var brd = formPr.get_Border();
|
2020-10-20 16:26:31 +00:00
|
|
|
if (!brd)
|
|
|
|
brd = new Asc.asc_CTextBorder();
|
|
|
|
brd.put_Value(1);
|
|
|
|
brd.put_Color(Common.Utils.ThemeColor.getRgbColor(color));
|
2021-07-29 15:01:28 +00:00
|
|
|
formPr.put_Border(brd);
|
2020-10-20 16:26:31 +00:00
|
|
|
}
|
2021-07-29 15:01:28 +00:00
|
|
|
props.put_FormPr(formPr);
|
2020-10-20 16:26:31 +00:00
|
|
|
this.api.asc_SetContentControlProperties(props, this.internalId);
|
|
|
|
this.fireEvent('editcomplete', this);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-12-24 08:50:09 +00:00
|
|
|
onNoBorderClick: function(item) {
|
|
|
|
this.BorderColor = 'transparent';
|
|
|
|
this._state.BorderColor = undefined;
|
|
|
|
|
|
|
|
if (this.api && !this._noApply) {
|
|
|
|
var props = this._originalProps || new AscCommon.CContentControlPr();
|
2021-07-29 15:01:28 +00:00
|
|
|
var formPr = this._originalFormProps || new AscCommon.CSdtFormPr();
|
|
|
|
formPr.put_Border();
|
|
|
|
props.put_FormPr(formPr);
|
2020-12-24 08:50:09 +00:00
|
|
|
this.api.asc_SetContentControlProperties(props, this.internalId);
|
|
|
|
this.fireEvent('editcomplete', this);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-09-28 16:06:12 +00:00
|
|
|
ChangeSettings: function(props) {
|
|
|
|
if (this._initSettings)
|
|
|
|
this.createDelayedElements();
|
|
|
|
|
|
|
|
if (props) {
|
2020-09-30 07:33:38 +00:00
|
|
|
this._originalProps = props;
|
|
|
|
|
|
|
|
this._noApply = true;
|
|
|
|
|
|
|
|
this.internalId = props.get_InternalId();
|
|
|
|
|
2020-09-28 16:06:12 +00:00
|
|
|
var val = props.get_PlaceholderText();
|
2021-01-23 16:20:51 +00:00
|
|
|
if (this._state.placeholder !== val) {
|
2020-09-30 07:33:38 +00:00
|
|
|
this.txtPlaceholder.setValue(val ? val : '');
|
|
|
|
this._state.placeholder = val;
|
|
|
|
}
|
2020-09-28 16:06:12 +00:00
|
|
|
|
|
|
|
val = props.get_Lock();
|
|
|
|
(val===undefined) && (val = Asc.c_oAscSdtLockType.Unlocked);
|
2020-10-06 16:25:49 +00:00
|
|
|
if (this._state.LockDelete !== (val==Asc.c_oAscSdtLockType.SdtContentLocked || val==Asc.c_oAscSdtLockType.SdtLocked)) {
|
|
|
|
this._state.LockDelete = (val==Asc.c_oAscSdtLockType.SdtContentLocked || val==Asc.c_oAscSdtLockType.SdtLocked);
|
|
|
|
this.btnLockForm.setCaption(this._state.LockDelete ? this.textUnlock : this.textLock);
|
2020-09-30 07:33:38 +00:00
|
|
|
}
|
2020-10-06 16:25:49 +00:00
|
|
|
this.disableControls(this._locked);
|
2020-09-28 16:06:12 +00:00
|
|
|
|
2020-11-10 18:46:20 +00:00
|
|
|
var type = props.get_SpecificType(),
|
|
|
|
connected = false;
|
2020-09-28 16:06:12 +00:00
|
|
|
var specProps;
|
|
|
|
//for list controls
|
|
|
|
if (type == Asc.c_oAscContentControlSpecificType.ComboBox || type == Asc.c_oAscContentControlSpecificType.DropDownList) {
|
|
|
|
this.labelFormName.text(type == Asc.c_oAscContentControlSpecificType.ComboBox ? this.textCombobox : this.textDropDown);
|
|
|
|
specProps = (type == Asc.c_oAscContentControlSpecificType.ComboBox) ? props.get_ComboBoxPr() : props.get_DropDownListPr();
|
|
|
|
if (specProps) {
|
2020-09-30 07:33:38 +00:00
|
|
|
this._originalListProps = specProps;
|
2020-09-28 16:06:12 +00:00
|
|
|
var count = specProps.get_ItemsCount();
|
|
|
|
var arr = [];
|
|
|
|
for (var i=0; i<count; i++) {
|
2020-10-31 15:31:41 +00:00
|
|
|
(specProps.get_ItemValue(i)!=='') && arr.push({
|
2020-09-28 16:06:12 +00:00
|
|
|
value: specProps.get_ItemValue(i),
|
|
|
|
name: specProps.get_ItemDisplayText(i)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
this.list.store.reset(arr);
|
2020-11-10 14:42:47 +00:00
|
|
|
var rec = null;
|
|
|
|
if (arr.length>0 && this._state.internalId === this.internalId && (this._state.listValue!==undefined || this._state.listIndex!==undefined)) {
|
|
|
|
if (this._state.listIndex!==undefined) {
|
|
|
|
(this._state.listIndex>=this.list.store.length) && (this._state.listIndex = this.list.store.length-1);
|
|
|
|
}
|
|
|
|
rec = (this._state.listValue!==undefined) ? this.list.store.findWhere({value: this._state.listValue}) : this.list.store.at(this._state.listIndex);
|
|
|
|
}
|
|
|
|
if (rec) {
|
2021-08-17 19:12:29 +00:00
|
|
|
this.list.selectRecord(rec, this.txtNewValue._input.is(':focus'));
|
2020-11-10 14:42:47 +00:00
|
|
|
this.list.scrollToRecord(rec);
|
2021-08-12 11:54:06 +00:00
|
|
|
} else if (!this.txtNewValue._input.is(':focus')) {
|
2020-11-10 14:42:47 +00:00
|
|
|
this.txtNewValue.setValue('');
|
|
|
|
this._state.listValue = this._state.listIndex = undefined;
|
|
|
|
}
|
2020-09-28 16:06:12 +00:00
|
|
|
}
|
|
|
|
this.disableListButtons();
|
2020-09-30 07:33:38 +00:00
|
|
|
} else if (type == Asc.c_oAscContentControlSpecificType.CheckBox) {
|
2020-09-28 16:06:12 +00:00
|
|
|
specProps = props.get_CheckBoxPr();
|
2020-09-30 07:33:38 +00:00
|
|
|
this._originalCheckProps = specProps;
|
2020-09-28 16:06:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// form settings
|
|
|
|
var formPr = props.get_FormPr();
|
|
|
|
if (formPr) {
|
2020-09-30 07:33:38 +00:00
|
|
|
this._originalFormProps = formPr;
|
|
|
|
|
2020-09-30 14:26:06 +00:00
|
|
|
var data = [];
|
|
|
|
if (type == Asc.c_oAscContentControlSpecificType.CheckBox)
|
|
|
|
data = this.api.asc_GetCheckBoxFormKeys();
|
2020-10-07 07:43:12 +00:00
|
|
|
else if (type == Asc.c_oAscContentControlSpecificType.Picture) {
|
2020-09-30 14:26:06 +00:00
|
|
|
data = this.api.asc_GetPictureFormKeys();
|
2020-10-07 07:43:12 +00:00
|
|
|
this.labelFormName.text(this.textImage);
|
|
|
|
} else
|
2020-09-30 14:26:06 +00:00
|
|
|
data = this.api.asc_GetTextFormKeys();
|
2021-01-23 16:20:51 +00:00
|
|
|
if (!this._state.arrKey || this._state.arrKey.length!==data.length || _.difference(this._state.arrKey, data).length>0) {
|
2020-12-24 13:26:20 +00:00
|
|
|
var arr = [];
|
|
|
|
data.forEach(function(item) {
|
|
|
|
arr.push({ displayValue: item, value: item });
|
|
|
|
});
|
|
|
|
this.cmbKey.setData(arr);
|
|
|
|
this._state.arrKey=data;
|
|
|
|
}
|
2020-09-30 14:26:06 +00:00
|
|
|
|
2020-09-28 16:06:12 +00:00
|
|
|
val = formPr.get_Key();
|
2021-01-23 16:20:51 +00:00
|
|
|
if (this._state.Key!==val) {
|
2020-12-24 13:26:20 +00:00
|
|
|
this.cmbKey.setValue(val ? val : '');
|
|
|
|
this._state.Key=val;
|
|
|
|
}
|
2020-09-28 16:06:12 +00:00
|
|
|
|
2020-11-11 12:56:14 +00:00
|
|
|
if (val) {
|
|
|
|
val = this.api.asc_GetFormsCountByKey(val);
|
|
|
|
connected = (val>1);
|
|
|
|
}
|
2020-11-10 18:46:20 +00:00
|
|
|
connected && this.labelConnectedFields.text(this.textConnected + ': ' + val);
|
|
|
|
|
2020-09-28 16:06:12 +00:00
|
|
|
val = formPr.get_HelpText();
|
2021-01-23 16:20:51 +00:00
|
|
|
if (this._state.help!==val) {
|
2020-09-30 07:33:38 +00:00
|
|
|
this.textareaHelp.setValue(val ? val : '');
|
|
|
|
this._state.help=val;
|
|
|
|
}
|
2020-09-28 16:06:12 +00:00
|
|
|
|
2021-05-19 21:38:09 +00:00
|
|
|
val = formPr.get_Required();
|
|
|
|
if ( this._state.Required!==val ) {
|
|
|
|
this.chRequired.setValue(!!val, true);
|
|
|
|
this._state.Required=val;
|
|
|
|
}
|
|
|
|
|
2020-09-28 16:06:12 +00:00
|
|
|
if (type == Asc.c_oAscContentControlSpecificType.CheckBox && specProps) {
|
|
|
|
val = specProps.get_GroupKey();
|
2020-09-30 14:26:06 +00:00
|
|
|
var ischeckbox = (typeof val !== 'string');
|
|
|
|
if (!ischeckbox) {
|
2020-12-24 13:26:20 +00:00
|
|
|
data = this.api.asc_GetRadioButtonGroupKeys();
|
2021-01-23 16:20:51 +00:00
|
|
|
if (!this._state.arrGroupKey || this._state.arrGroupKey.length!==data.length || _.difference(this._state.arrGroupKey, data).length>0) {
|
2020-12-24 13:26:20 +00:00
|
|
|
var arr = [];
|
|
|
|
data.forEach(function(item) {
|
|
|
|
arr.push({ displayValue: item, value: item });
|
|
|
|
});
|
|
|
|
this.cmbGroupKey.setData(arr);
|
|
|
|
this._state.arrGroupKey=data;
|
|
|
|
}
|
|
|
|
|
2021-01-23 16:20:51 +00:00
|
|
|
if (this._state.groupKey!==val) {
|
2020-12-24 13:26:20 +00:00
|
|
|
this.cmbGroupKey.setValue(val ? val : '');
|
|
|
|
this._state.groupKey=val;
|
|
|
|
}
|
2020-09-30 07:33:38 +00:00
|
|
|
}
|
2020-09-30 14:26:06 +00:00
|
|
|
|
|
|
|
this.labelFormName.text(ischeckbox ? this.textCheckbox : this.textRadiobox);
|
2020-09-28 16:06:12 +00:00
|
|
|
}
|
2021-06-17 16:42:52 +00:00
|
|
|
|
|
|
|
if (type !== Asc.c_oAscContentControlSpecificType.Picture) {
|
|
|
|
val = formPr.get_Fixed();
|
|
|
|
if ( this._state.Fixed!==val ) {
|
|
|
|
this.chFixed.setValue(!!val, true);
|
|
|
|
this._state.Fixed=val;
|
|
|
|
}
|
|
|
|
}
|
2021-07-29 15:01:28 +00:00
|
|
|
|
|
|
|
var brd = formPr.get_Border();
|
|
|
|
if (brd) {
|
|
|
|
var color = brd.get_Color();
|
|
|
|
if (color) {
|
|
|
|
if (color.get_type() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) {
|
|
|
|
this.BorderColor = {color: Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()), effectValue: color.get_value() };
|
|
|
|
} else {
|
|
|
|
this.BorderColor = Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b());
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
this.BorderColor = 'transparent';
|
|
|
|
} else
|
|
|
|
this.BorderColor = 'transparent';
|
|
|
|
|
|
|
|
var type1 = typeof(this.BorderColor),
|
|
|
|
type2 = typeof(this._state.BorderColor);
|
|
|
|
if ( (type1 !== type2) || (type1=='object' &&
|
|
|
|
(this.BorderColor.effectValue!==this._state.BorderColor.effectValue || this._state.BorderColor.color.indexOf(this.BorderColor.color)<0)) ||
|
|
|
|
(type1!='object' && this._state.BorderColor.indexOf(this.BorderColor)<0 )) {
|
|
|
|
|
|
|
|
this.btnColor.setColor(this.BorderColor);
|
|
|
|
this.mnuColorPicker.clearSelection();
|
|
|
|
this.mnuNoBorder.setChecked(this.BorderColor == 'transparent', true);
|
|
|
|
(this.BorderColor != 'transparent') && this.mnuColorPicker.selectByRGB(typeof(this.BorderColor) == 'object' ? this.BorderColor.color : this.BorderColor,true);
|
|
|
|
this._state.BorderColor = this.BorderColor;
|
|
|
|
}
|
2021-08-12 17:06:16 +00:00
|
|
|
|
|
|
|
var shd = formPr.get_Shd();
|
|
|
|
if (shd) {
|
|
|
|
var bgColor = shd.get_Color();
|
|
|
|
if (bgColor) {
|
|
|
|
if (bgColor.get_type() === Asc.c_oAscColor.COLOR_TYPE_SCHEME) {
|
|
|
|
this.BackgroundColor = {color: Common.Utils.ThemeColor.getHexColor(bgColor.get_r(), bgColor.get_g(), bgColor.get_b()), effectValue: bgColor.get_value() };
|
|
|
|
} else {
|
|
|
|
this.BackgroundColor = Common.Utils.ThemeColor.getHexColor(bgColor.get_r(), bgColor.get_g(), bgColor.get_b());
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
this.BackgroundColor = 'transparent';
|
|
|
|
} else {
|
|
|
|
this.BackgroundColor = 'transparent';
|
|
|
|
}
|
|
|
|
|
|
|
|
type1 = typeof(this.BackgroundColor);
|
|
|
|
type2 = typeof(this._state.BackgroundColor);
|
|
|
|
if ( (type1 !== type2) || (type1 === 'object' &&
|
|
|
|
(this.BackgroundColor.effectValue!==this._state.BackgroundColor.effectValue || this._state.BackgroundColor.color.indexOf(this.BackgroundColor.color)<0)) ||
|
|
|
|
(type1 !== 'object' && this._state.BackgroundColor.indexOf(this.BackgroundColor)<0 )) {
|
|
|
|
|
|
|
|
this.btnBGColor.setColor(this.BackgroundColor);
|
|
|
|
if ( typeof(this.BackgroundColor) == 'object' ) {
|
|
|
|
var isselected = false;
|
|
|
|
for (i=0; i<10; i++) {
|
|
|
|
if ( Common.Utils.ThemeColor.ThemeValues[i] === this.BackgroundColor.effectValue ) {
|
|
|
|
this.mnuBGColorPicker.select(this.BackgroundColor, true);
|
|
|
|
isselected = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!isselected) this.mnuBGColorPicker.clearSelection();
|
|
|
|
} else
|
|
|
|
this.mnuBGColorPicker.select(this.BackgroundColor,true);
|
|
|
|
|
|
|
|
this._state.BackgroundColor = this.BackgroundColor;
|
|
|
|
}
|
|
|
|
|
2020-09-28 16:06:12 +00:00
|
|
|
}
|
|
|
|
|
2021-07-02 15:46:09 +00:00
|
|
|
var pictPr = props.get_PictureFormPr();
|
|
|
|
if (pictPr) {
|
|
|
|
this._originalPictProps = pictPr;
|
|
|
|
val = pictPr.get_ConstantProportions();
|
|
|
|
if ( this._state.Aspect!==val ) {
|
|
|
|
this.chAspect.setValue(!!val, true);
|
|
|
|
this._state.Aspect=val;
|
|
|
|
}
|
|
|
|
|
|
|
|
val = pictPr.get_ScaleFlag();
|
|
|
|
if (this._state.scaleFlag!==val) {
|
|
|
|
this.cmbScale.setValue(val);
|
|
|
|
this._state.scaleFlag=val;
|
|
|
|
}
|
2021-08-04 22:27:55 +00:00
|
|
|
|
|
|
|
val = pictPr.get_ShiftX() * 100;
|
|
|
|
if (this._state.imgPositionX !== val) {
|
|
|
|
this.sldrPreviewPositionX.setValue(val);
|
|
|
|
this._state.imgPositionX = val;
|
|
|
|
}
|
2021-08-09 16:11:22 +00:00
|
|
|
val = pictPr.get_ShiftY() * 100;
|
2021-08-04 22:27:55 +00:00
|
|
|
if (this._state.imgPositionY !== val) {
|
|
|
|
this.sldrPreviewPositionY.setValue(val);
|
|
|
|
this._state.imgPositionY = val;
|
|
|
|
}
|
|
|
|
this.imagePositionLabel.text(Math.round(this._state.imgPositionX) + ',' + Math.round(this._state.imgPositionY));
|
|
|
|
val = ((130 - 80) * this._state.imgPositionX) / 100 - 1;
|
|
|
|
this.imagePositionPreview.css({'left': val + 'px'});
|
2021-08-09 16:11:22 +00:00
|
|
|
val = ((130 - 80) * this._state.imgPositionY) / 100 - 1;
|
2021-08-04 22:27:55 +00:00
|
|
|
this.imagePositionPreview.css({'top': val + 'px'});
|
2021-08-09 16:11:22 +00:00
|
|
|
|
|
|
|
this.chAspect.setDisabled(this._state.scaleFlag === Asc.c_oAscPictureFormScaleFlag.Never);
|
|
|
|
var disableSliders = this._state.scaleFlag === Asc.c_oAscPictureFormScaleFlag.Always && !this._state.Aspect;
|
|
|
|
this.sldrPreviewPositionX.setDisabled(disableSliders);
|
|
|
|
this.sldrPreviewPositionY.setDisabled(disableSliders);
|
2020-09-28 16:06:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var formTextPr = props.get_TextFormPr();
|
|
|
|
if (formTextPr) {
|
2020-09-30 07:33:38 +00:00
|
|
|
this._originalTextFormProps = formTextPr;
|
|
|
|
|
2020-09-28 16:06:12 +00:00
|
|
|
this.labelFormName.text(this.textField);
|
|
|
|
val = formTextPr.get_Comb();
|
|
|
|
if ( this._state.Comb!==val ) {
|
|
|
|
this.chComb.setValue(!!val, true);
|
|
|
|
this._state.Comb=val;
|
|
|
|
}
|
|
|
|
|
2021-06-17 16:42:52 +00:00
|
|
|
val = formTextPr.get_MultiLine();
|
|
|
|
if ( this._state.Multi!==val ) {
|
|
|
|
this.chMulti.setValue(!!val, true);
|
|
|
|
this._state.Multi=val;
|
|
|
|
}
|
2021-07-12 15:08:02 +00:00
|
|
|
this.chMulti.setDisabled(!this._state.Fixed || this._state.Comb);
|
2021-06-17 16:42:52 +00:00
|
|
|
|
|
|
|
val = formTextPr.get_AutoFit();
|
|
|
|
if ( this._state.AutoFit!==val ) {
|
|
|
|
this.chAutofit.setValue(!!val, true);
|
|
|
|
this._state.AutoFit=val;
|
|
|
|
}
|
2021-07-12 15:08:02 +00:00
|
|
|
this.chAutofit.setDisabled(!this._state.Fixed || this._state.Comb);
|
2020-09-28 16:06:12 +00:00
|
|
|
|
2021-07-02 12:51:33 +00:00
|
|
|
this.spnWidth.setDisabled(!this._state.Comb);
|
2020-09-28 16:06:12 +00:00
|
|
|
val = formTextPr.get_Width();
|
2021-01-23 16:20:51 +00:00
|
|
|
if ( (val===undefined || this._state.Width===undefined)&&(this._state.Width!==val) || Math.abs(this._state.Width-val)>0.1) {
|
2020-09-30 07:33:38 +00:00
|
|
|
this.spnWidth.setValue(val!==0 && val!==undefined ? Common.Utils.Metric.fnRecalcFromMM(val * 25.4 / 20 / 72.0) : -1, true);
|
2020-09-28 16:06:12 +00:00
|
|
|
this._state.Width=val;
|
|
|
|
}
|
|
|
|
|
2020-10-30 18:55:58 +00:00
|
|
|
val = this.api.asc_GetTextFormAutoWidth();
|
|
|
|
if ( (this._state.WidthPlaceholder!==val) || Math.abs(this._state.WidthPlaceholder-val)>0.01) {
|
2021-04-22 12:17:43 +00:00
|
|
|
this.spnWidth.setDefaultValue(val!==undefined && val!==null ? Common.Utils.Metric.fnRecalcFromMM((val+1) * 25.4 / 20 / 72.0) : this.spnWidth.options.minValue);
|
2020-10-30 18:55:58 +00:00
|
|
|
this._state.WidthPlaceholder=val;
|
|
|
|
}
|
|
|
|
|
2020-09-28 16:06:12 +00:00
|
|
|
val = formTextPr.get_MaxCharacters();
|
2020-09-30 07:33:38 +00:00
|
|
|
this.chMaxChars.setValue(val && val>=0);
|
|
|
|
this.spnMaxChars.setDisabled(!val || val<0);
|
2021-01-23 16:20:51 +00:00
|
|
|
if ( (val===undefined || this._state.MaxChars===undefined)&&(this._state.MaxChars!==val) || Math.abs(this._state.MaxChars-val)>0.1) {
|
2020-12-24 13:26:20 +00:00
|
|
|
this.spnMaxChars.setValue(val && val>=0 ? val : 10, true);
|
|
|
|
this._state.MaxChars=val;
|
|
|
|
}
|
2020-09-28 16:06:12 +00:00
|
|
|
}
|
2020-10-20 16:26:31 +00:00
|
|
|
|
2020-09-30 07:33:38 +00:00
|
|
|
this._noApply = false;
|
2020-09-30 10:25:18 +00:00
|
|
|
|
2020-11-10 18:46:20 +00:00
|
|
|
this.KeySettingsTd.toggleClass('padding-small', !connected);
|
|
|
|
this.ConnectedSettings.toggleClass('hidden', !connected);
|
2020-09-30 12:46:19 +00:00
|
|
|
if (this.type !== type || type == Asc.c_oAscContentControlSpecificType.CheckBox)
|
|
|
|
this.showHideControls(type, formTextPr, specProps);
|
|
|
|
this.type = type;
|
2020-11-10 14:42:47 +00:00
|
|
|
|
|
|
|
this._state.internalId = this.internalId;
|
2020-09-28 16:06:12 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
updateMetricUnit: function() {
|
|
|
|
if (this.spinners) {
|
|
|
|
for (var i=0; i<this.spinners.length; i++) {
|
|
|
|
var spinner = this.spinners[i];
|
|
|
|
spinner.setDefaultUnit(Common.Utils.Metric.getCurrentMetricName());
|
2021-01-11 15:06:12 +00:00
|
|
|
spinner.setStep(Common.Utils.Metric.getCurrentMetric()==Common.Utils.Metric.c_MetricUnits.pt ? 1 : 0.1);
|
2020-09-28 16:06:12 +00:00
|
|
|
}
|
2021-01-11 15:06:12 +00:00
|
|
|
var val = this._state.Width;
|
|
|
|
this.spnWidth && this.spnWidth.setMinValue(Common.Utils.Metric.fnRecalcFromMM(1));
|
|
|
|
this.spnWidth && this.spnWidth.setValue(val!==0 && val!==undefined ? Common.Utils.Metric.fnRecalcFromMM(val * 25.4 / 20 / 72.0) : -1, true);
|
2020-09-28 16:06:12 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-10-20 16:26:31 +00:00
|
|
|
UpdateThemeColors: function() {
|
|
|
|
if (this._initSettings) return;
|
|
|
|
|
|
|
|
if (!this.btnColor) {
|
|
|
|
this.btnColor = new Common.UI.ColorButton({
|
|
|
|
parentEl: (this.$el || $(this.el)).findById('#form-color-btn'),
|
2020-12-24 08:50:09 +00:00
|
|
|
additionalItems: [
|
|
|
|
this.mnuNoBorder = new Common.UI.MenuItem({
|
|
|
|
style: 'padding-left:20px;',
|
|
|
|
caption: this.textNoBorder,
|
|
|
|
toggleGroup: 'form-settings-no-border',
|
|
|
|
checkable: true
|
|
|
|
}), {caption: '--'}],
|
|
|
|
menu : true,
|
|
|
|
colors: ['000000', '993300', '333300', '003300', '003366', '000080', '333399', '333333', '800000', 'FF6600',
|
|
|
|
'808000', '00FF00', '008080', '0000FF', '666699', '808080', 'FF0000', 'FF9900', '99CC00', '339966',
|
|
|
|
'33CCCC', '3366FF', '800080', '999999', 'FF00FF', 'FFCC00', 'FFFF00', '00FF00', '00FFFF', '00CCFF',
|
2021-01-29 17:28:04 +00:00
|
|
|
'993366', 'C0C0C0', 'FF99CC', 'FFCC99', 'FFFF99', 'CCFFCC', 'CCFFFF', 'C9C8FF', 'CC99FF', 'FFFFFF'
|
2020-12-24 08:50:09 +00:00
|
|
|
],
|
2021-07-08 17:16:39 +00:00
|
|
|
paletteHeight: 94,
|
|
|
|
dataHint: '1',
|
|
|
|
dataHintDirection: 'bottom',
|
|
|
|
dataHintOffset: 'big'
|
2020-10-20 16:26:31 +00:00
|
|
|
});
|
|
|
|
this.lockedControls.push(this.btnColor);
|
2020-12-24 08:50:09 +00:00
|
|
|
this.mnuNoBorder.on('click', _.bind(this.onNoBorderClick, this));
|
2020-10-20 16:26:31 +00:00
|
|
|
this.btnColor.on('color:select', this.onColorPickerSelect.bind(this));
|
|
|
|
this.btnColor.setMenu();
|
|
|
|
this.mnuColorPicker = this.btnColor.getPicker();
|
|
|
|
}
|
2021-08-12 17:06:16 +00:00
|
|
|
if (!this.btnBGColor) {
|
|
|
|
this.btnBGColor = new Common.UI.ColorButton({
|
|
|
|
parentEl: $('#form-background-color-btn'),
|
|
|
|
transparent: true,
|
|
|
|
menu: true
|
|
|
|
});
|
|
|
|
this.lockedControls.push(this.btnBGColor);
|
|
|
|
this.btnBGColor.on('color:select', _.bind(this.onColorBGSelect, this));
|
|
|
|
this.btnBGColor.setMenu();
|
|
|
|
this.mnuBGColorPicker = this.btnBGColor.getPicker();
|
|
|
|
}
|
|
|
|
this.mnuBGColorPicker.updateColors(Common.Utils.ThemeColor.getEffectColors(), Common.Utils.ThemeColor.getStandartColors());
|
2020-10-20 16:26:31 +00:00
|
|
|
},
|
|
|
|
|
2020-09-28 16:06:12 +00:00
|
|
|
onHideMenus: function(menu, e, isFromInputControl){
|
|
|
|
if (!isFromInputControl) this.fireEvent('editcomplete', this);
|
|
|
|
},
|
|
|
|
|
|
|
|
setLocked: function (locked) {
|
|
|
|
this._locked = locked;
|
|
|
|
},
|
|
|
|
|
|
|
|
disableControls: function(disable) {
|
2020-10-07 11:20:14 +00:00
|
|
|
if (this._initSettings) return;
|
2020-10-07 12:44:36 +00:00
|
|
|
|
2020-10-06 16:25:49 +00:00
|
|
|
var me = this;
|
|
|
|
if (this._state.DisabledControls!==(this._state.LockDelete || disable)) {
|
|
|
|
this._state.DisabledControls = this._state.LockDelete || disable;
|
2020-09-28 16:06:12 +00:00
|
|
|
_.each(this.lockedControls, function(item) {
|
2020-10-06 16:25:49 +00:00
|
|
|
item.setDisabled(me._state.DisabledControls);
|
2020-09-28 16:06:12 +00:00
|
|
|
});
|
|
|
|
}
|
2020-10-06 16:25:49 +00:00
|
|
|
this.btnLockForm.setDisabled(disable);
|
2020-09-28 16:06:12 +00:00
|
|
|
},
|
|
|
|
|
2020-09-30 12:46:19 +00:00
|
|
|
showHideControls: function(type, textProps, specProps) {
|
2020-09-30 10:25:18 +00:00
|
|
|
var textOnly = false,
|
|
|
|
checkboxOnly = false,
|
|
|
|
radioboxOnly = false,
|
|
|
|
listOnly = false,
|
|
|
|
imageOnly = false;
|
2020-09-30 12:46:19 +00:00
|
|
|
if (type == Asc.c_oAscContentControlSpecificType.ComboBox || type == Asc.c_oAscContentControlSpecificType.DropDownList) {
|
2020-09-30 10:25:18 +00:00
|
|
|
listOnly = !!specProps;
|
2020-09-30 12:46:19 +00:00
|
|
|
} else if (type == Asc.c_oAscContentControlSpecificType.CheckBox) {
|
2020-09-30 10:25:18 +00:00
|
|
|
if (specProps) {
|
|
|
|
checkboxOnly = (typeof specProps.get_GroupKey() !== 'string');
|
|
|
|
radioboxOnly = !checkboxOnly;
|
|
|
|
}
|
2020-09-30 12:46:19 +00:00
|
|
|
} else if (type == Asc.c_oAscContentControlSpecificType.Picture) {
|
2020-09-30 10:25:18 +00:00
|
|
|
imageOnly = true;
|
2020-09-30 12:46:19 +00:00
|
|
|
} else if (type == Asc.c_oAscContentControlSpecificType.None) {
|
2020-09-30 10:25:18 +00:00
|
|
|
textOnly = !!textProps;
|
|
|
|
}
|
2020-09-30 12:46:19 +00:00
|
|
|
this.TextOnlySettings.toggleClass('hidden', !textOnly);
|
|
|
|
this.ListOnlySettings.toggleClass('hidden', !listOnly);
|
|
|
|
this.ImageOnlySettings.toggleClass('hidden', !imageOnly);
|
|
|
|
this.RadioOnlySettings.toggleClass('hidden', !radioboxOnly);
|
|
|
|
this.KeySettings.toggleClass('hidden', radioboxOnly);
|
|
|
|
var value = (checkboxOnly || radioboxOnly);
|
|
|
|
this.PlaceholderSettings.toggleClass('hidden', value);
|
|
|
|
this.CheckOnlySettings.toggleClass('hidden', !value);
|
2021-06-17 16:42:52 +00:00
|
|
|
this.NotImageSettings.toggleClass('hidden', imageOnly);
|
2020-09-30 12:46:19 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onSelectItem: function(listView, itemView, record) {
|
2021-07-23 16:38:42 +00:00
|
|
|
if (!record) return;
|
2020-11-03 11:05:39 +00:00
|
|
|
this.txtNewValue.setValue(record.get('name'));
|
2020-11-10 14:42:47 +00:00
|
|
|
this._state.listValue = record.get('name');
|
|
|
|
this._state.listIndex = undefined;
|
2020-09-30 12:46:19 +00:00
|
|
|
this.disableListButtons(false);
|
|
|
|
},
|
|
|
|
|
2020-11-10 18:46:20 +00:00
|
|
|
onDisconnect: function() {
|
|
|
|
this.onKeyChanged(this.cmbKey, {value: ""});
|
|
|
|
},
|
|
|
|
|
2020-09-30 12:46:19 +00:00
|
|
|
disableListButtons: function(disabled) {
|
|
|
|
if (disabled===undefined)
|
|
|
|
disabled = !this.list.getSelectedRec();
|
2020-10-06 16:25:49 +00:00
|
|
|
this.btnListDelete.setDisabled(disabled || this._state.DisabledControls);
|
|
|
|
this.btnListUp.setDisabled(disabled || this._state.DisabledControls);
|
|
|
|
this.btnListDown.setDisabled(disabled || this._state.DisabledControls);
|
2020-09-28 16:06:12 +00:00
|
|
|
},
|
|
|
|
|
2021-08-04 22:27:55 +00:00
|
|
|
onImagePositionChange: function (type, field, newValue, oldValue) {
|
2021-08-09 16:11:22 +00:00
|
|
|
var value = ((130 - 80) * newValue) / 100 - 1;
|
2021-08-04 22:27:55 +00:00
|
|
|
if (type === 'x') {
|
|
|
|
this.imagePositionPreview.css({'left': value + 'px'});
|
|
|
|
this._state.imgPositionX = newValue;
|
|
|
|
} else {
|
|
|
|
this.imagePositionPreview.css({'top': value + 'px'});
|
|
|
|
this._state.imgPositionY = newValue;
|
|
|
|
}
|
|
|
|
if (_.isUndefined(this._state.imgPositionX)) {
|
|
|
|
this._state.imgPositionX = 50;
|
|
|
|
} else if (_.isUndefined(this._state.imgPositionY)) {
|
|
|
|
this._state.imgPositionY = 50;
|
|
|
|
}
|
|
|
|
this.imagePositionLabel.text(Math.round(this._state.imgPositionX) + ',' + Math.round(this._state.imgPositionY));
|
|
|
|
|
|
|
|
if (this._sendUndoPoint) {
|
|
|
|
this.api.setStartPointHistory();
|
|
|
|
this._sendUndoPoint = false;
|
|
|
|
this.updateslider = setInterval(_.bind(this.imgPositionApplyFunc, this, type), 100);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onImagePositionChangeComplete: function (type, field, newValue, oldValue) {
|
|
|
|
clearInterval(this.updateslider);
|
|
|
|
if (type === 'x') {
|
|
|
|
this._state.imgPositionX = newValue;
|
|
|
|
} else {
|
|
|
|
this._state.imgPositionY = newValue;
|
|
|
|
}
|
|
|
|
if (!this._sendUndoPoint) { // start point was added
|
|
|
|
this.api.setEndPointHistory();
|
|
|
|
this.imgPositionApplyFunc(type);
|
|
|
|
}
|
|
|
|
this._sendUndoPoint = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
imgPositionApplyFunc: function (type) {
|
|
|
|
if (this.api && !this._noApply) {
|
|
|
|
var props = this._originalProps || new AscCommon.CContentControlPr();
|
|
|
|
var pictPr = this._originalPictProps || new AscCommon.CSdtPictureFormPr();
|
|
|
|
var val;
|
|
|
|
if (type === 'x') {
|
|
|
|
val = this._state.imgPositionX / 100;
|
|
|
|
pictPr.put_ShiftX(val);
|
|
|
|
} else {
|
2021-08-09 16:11:22 +00:00
|
|
|
val = this._state.imgPositionY / 100;
|
2021-08-04 22:27:55 +00:00
|
|
|
pictPr.put_ShiftY(val);
|
|
|
|
}
|
|
|
|
props.put_PictureFormPr(pictPr);
|
|
|
|
this.api.asc_SetContentControlProperties(props, this.internalId);
|
|
|
|
this.fireEvent('editcomplete', this);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-10-07 16:13:24 +00:00
|
|
|
textField: 'Text Field',
|
2020-09-28 16:06:12 +00:00
|
|
|
textKey: 'Key',
|
|
|
|
textPlaceholder: 'Placeholder',
|
|
|
|
textTip: 'Tip',
|
|
|
|
textMaxChars: 'Characters limit',
|
|
|
|
textComb: 'Comb of characters',
|
2020-10-30 19:00:22 +00:00
|
|
|
textWidth: 'Cell width',
|
2020-09-28 16:06:12 +00:00
|
|
|
textDelete: 'Delete',
|
2020-09-30 07:33:38 +00:00
|
|
|
textLock: 'Lock',
|
|
|
|
textUnlock: 'Unlock',
|
2020-10-07 16:13:24 +00:00
|
|
|
textRadiobox: 'Radio Button',
|
2020-09-30 07:33:38 +00:00
|
|
|
textCheckbox: 'Checkbox',
|
2020-10-07 16:13:24 +00:00
|
|
|
textCombobox: 'Combo Box',
|
2020-09-30 07:33:38 +00:00
|
|
|
textDropDown: 'Dropdown',
|
2020-09-30 10:25:18 +00:00
|
|
|
textImage: 'Image',
|
2020-09-30 12:46:19 +00:00
|
|
|
textGroupKey: 'Group key',
|
|
|
|
textTipAdd: 'Add new value',
|
|
|
|
textTipDelete: 'Delete value',
|
|
|
|
textTipUp: 'Move up',
|
|
|
|
textTipDown: 'Move down',
|
2020-10-06 17:52:17 +00:00
|
|
|
textValue: 'Value Options',
|
|
|
|
textSelectImage: 'Select Image',
|
|
|
|
textFromUrl: 'From URL',
|
|
|
|
textFromFile: 'From File',
|
2020-10-20 16:26:31 +00:00
|
|
|
textFromStorage: 'From Storage',
|
2020-11-10 18:46:20 +00:00
|
|
|
textColor: 'Border color',
|
|
|
|
textConnected: 'Fields connected',
|
2020-12-24 08:50:09 +00:00
|
|
|
textDisconnect: 'Disconnect',
|
2021-05-19 21:38:09 +00:00
|
|
|
textNoBorder: 'No border',
|
|
|
|
textFixed: 'Fixed size field',
|
2021-06-17 16:42:52 +00:00
|
|
|
textRequired: 'Required',
|
|
|
|
textAutofit: 'AutoFit',
|
2021-07-02 15:46:09 +00:00
|
|
|
textMulti: 'Multiline field',
|
|
|
|
textAspect: 'Lock aspect ratio',
|
|
|
|
textAlways: 'Always',
|
|
|
|
textNever: 'Never',
|
|
|
|
textTooBig: 'Image is Too Big',
|
|
|
|
textTooSmall: 'Image is Too Small',
|
2021-08-12 17:06:16 +00:00
|
|
|
textScale: 'When to scale',
|
|
|
|
textBackgroundColor: 'Background Color'
|
2020-09-28 16:06:12 +00:00
|
|
|
|
|
|
|
}, DE.Views.FormSettings || {}));
|
|
|
|
});
|