Merge branch 'feature/de-new-controls' into develop

This commit is contained in:
Julia Radzhabova 2020-10-31 19:11:19 +03:00
commit 460ff7e6f3
44 changed files with 1911 additions and 86 deletions

View file

@ -246,6 +246,10 @@ define([
if (e.keyCode === Common.UI.Keys.RETURN)
this._doChange(e);
if (e.keyCode == Common.UI.Keys.ESC)
this.setValue(this.value);
if (e.keyCode==Common.UI.Keys.RETURN || e.keyCode==Common.UI.Keys.ESC)
this.trigger('inputleave', this);
},
onKeyUp: function(e) {

View file

@ -234,10 +234,7 @@ define([
},
getNumberValue: function(){
if (this.options.allowAuto && this.value==this.options.autoText)
return -1;
else
return parseFloat(this.value);
return this.checkAutoText(this.value) ? -1 : parseFloat(this.value);
},
getUnitValue: function(){
@ -262,7 +259,7 @@ define([
this.lastValue = this.value;
if ( typeof value === 'undefined' || value === ''){
this.value = '';
} else if (this.options.allowAuto && (Math.abs(Common.Utils.String.parseFloat(value)+1.)<0.0001 || value==this.options.autoText)) {
} else if (this.options.allowAuto && (Math.abs(Common.Utils.String.parseFloat(value)+1.)<0.0001 || this.checkAutoText(value))) {
this.value = this.options.autoText;
} else {
var number = this._add(Common.Utils.String.parseFloat(value), 0, (this.options.allowDecimal) ? 3 : 0);
@ -450,8 +447,8 @@ define([
val = this.getRawValue();
val = _.isEmpty(val) ? me.oldValue : Common.Utils.String.parseFloat(val);
} else if(me.getValue() !== '') {
if (me.options.allowAuto && me.getValue()==me.options.autoText) {
val = me.options.minValue-me.options.step;
if (me.checkAutoText(me.getValue())) {
val = me.options.defaultValue-me.options.step;
} else
val = Common.Utils.String.parseFloat(me.getValue());
if (isNaN(val))
@ -471,7 +468,7 @@ define([
val = this.getRawValue();
val = _.isEmpty(val) ? me.oldValue : Common.Utils.String.parseFloat(val);
} else if(me.getValue() !== '') {
if (me.options.allowAuto && me.getValue()==me.options.autoText) {
if (me.checkAutoText(me.getValue())) {
val = me.options.minValue;
} else
val = Common.Utils.String.parseFloat(me.getValue());
@ -541,6 +538,18 @@ define([
focus: function() {
if (this.$input) this.$input.focus();
},
setDefaultValue: function(value) {
this.options.defaultValue = value;
},
checkAutoText: function(value) {
if (this.options.allowAuto && typeof value == 'string') {
var val = value.toLowerCase();
return (val==this.options.autoText.toLowerCase() || val=='auto');
}
return false;
}
});

View file

@ -0,0 +1,201 @@
/*
*
* (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
*
*/
/**
* TextareaField.js
*
* Created by Julia Radzhabova on 29/09/20
* Copyright (c) 2020 Ascensio System SIA. All rights reserved.
*
*/
if (Common === undefined)
var Common = {};
define([
'common/main/lib/component/BaseView',
'common/main/lib/component/Tooltip'
], function () { 'use strict';
Common.UI.TextareaField = Common.UI.BaseView.extend((function() {
return {
options : {
id : null,
cls : '',
style : '',
value : '',
maxlength : undefined,
placeHolder : '',
spellcheck : false,
disabled: false
},
template: _.template([
'<div class="textarea-field" style="<%= style %>">',
'<textarea ',
'spellcheck="<%= spellcheck %>" ',
'class="form-control <%= cls %>" ',
'placeholder="<%= placeHolder %>" ',
'></textarea>',
'</div>'
].join('')),
initialize : function(options) {
Common.UI.BaseView.prototype.initialize.call(this, options);
var me = this;
this.id = me.options.id || Common.UI.getId();
this.cls = me.options.cls;
this.style = me.options.style;
this.value = me.options.value;
this.placeHolder = me.options.placeHolder;
this.template = me.options.template || me.template;
this.disabled = me.options.disabled;
this.spellcheck = me.options.spellcheck;
this.maxLength = me.options.maxLength;
me.rendered = me.options.rendered || false;
if (me.options.el) {
me.render();
}
},
render : function(parentEl) {
var me = this;
if (!me.rendered) {
this.cmpEl = $(this.template({
id : this.id,
cls : this.cls,
style : this.style,
placeHolder : this.placeHolder,
spellcheck : this.spellcheck,
scope : me
}));
if (parentEl) {
this.setElement(parentEl, false);
parentEl.html(this.cmpEl);
} else {
this.$el.html(this.cmpEl);
}
} else {
this.cmpEl = this.$el;
}
if (!me.rendered) {
var el = this.cmpEl;
this._input = this.cmpEl.find('textarea').addBack().filter('textarea');
this._input.on('blur', _.bind(this.onInputChanged, this));
this._input.on('keydown', _.bind(this.onKeyDown, this));
if (this.maxLength) this._input.attr('maxlength', this.maxLength);
if (this.disabled)
this.setDisabled(this.disabled);
}
me.rendered = true;
return this;
},
_doChange: function(e, extra) {
// skip processing for internally-generated synthetic event
// to avoid double processing
if (extra && extra.synthetic)
return;
var newValue = $(e.target).val(),
oldValue = this.value;
this.trigger('changed:before', this, newValue, oldValue, e);
if (e.isDefaultPrevented())
return;
this.value = newValue;
// trigger changed event
this.trigger('changed:after', this, newValue, oldValue, e);
},
onInputChanged: function(e, extra) {
this._doChange(e, extra);
},
onKeyDown: function(e) {
this.trigger('keydown:before', this, e);
if (e.isDefaultPrevented())
return;
if (e.keyCode === Common.UI.Keys.RETURN)
this._doChange(e);
if (e.keyCode == Common.UI.Keys.ESC)
this.setValue(this.value);
if (e.keyCode==Common.UI.Keys.RETURN || e.keyCode==Common.UI.Keys.ESC)
this.trigger('inputleave', this);
},
setDisabled: function(disabled) {
this.disabled = disabled;
$(this.el).toggleClass('disabled', disabled);
disabled
? this._input.attr('disabled', true)
: this._input.removeAttr('disabled');
},
isDisabled: function() {
return this.disabled;
},
setValue: function(value) {
this.value = value;
if (this.rendered){
this._input.val(value);
}
},
getValue: function() {
return this.value;
},
focus: function() {
this._input.focus();
}
}
})());
});

View file

@ -746,7 +746,7 @@ define([
leftMenu.setPreviewMode(disable);
if (this.view) {
this.view.$el.find('.no-group-mask').css('opacity', 1);
this.view.$el.find('.no-group-mask.review').css('opacity', 1);
this.view.btnsDocLang && this.view.btnsDocLang.forEach(function(button) {
if ( button ) {

View file

@ -106,7 +106,8 @@ Common.Utils = _.extend(new(function() {
Signature : 9,
Pivot : 10,
Cell : 11,
Slicer : 12
Slicer : 12,
Form : 13
},
importTextType = {
DRM: 0,

View file

@ -57,7 +57,7 @@ define([
Common.Views.ReviewChanges = Common.UI.BaseView.extend(_.extend((function(){
var template =
'<section id="review-changes-panel" class="panel" data-tab="review">' +
'<div class="group no-group-mask">' +
'<div class="group no-group-mask review">' +
'<span id="slot-btn-sharing" class="btn-slot text x-huge"></span>' +
'<span id="slot-btn-coauthmode" class="btn-slot text x-huge"></span>' +
'</div>' +
@ -70,7 +70,7 @@ define([
'<div class="group">' +
'<span id="btn-review-on" class="btn-slot text x-huge"></span>' +
'</div>' +
'<div class="group no-group-mask" style="padding-left: 0;">' +
'<div class="group no-group-mask review" style="padding-left: 0;">' +
'<span id="btn-review-view" class="btn-slot text x-huge"></span>' +
'</div>' +
'<div class="group move-changes" style="padding-left: 0;">' +
@ -84,11 +84,11 @@ define([
'<span id="btn-compare" class="btn-slot text x-huge"></span>' +
'</div>' +
'<div class="separator long compare"></div>' +
'<div class="group no-group-mask">' +
'<div class="group no-group-mask review form-view">' +
'<span id="slot-btn-chat" class="btn-slot text x-huge"></span>' +
'</div>' +
'<div class="separator long chat"></div>' +
'<div class="group no-group-mask">' +
'<div class="group no-group-mask review form-view">' +
'<span id="slot-btn-history" class="btn-slot text x-huge"></span>' +
'</div>' +
'</section>';
@ -647,7 +647,7 @@ define([
button.setDisabled(state);
}
}, this);
this.btnChat && this.btnChat.setDisabled(state);
// this.btnChat && this.btnChat.setDisabled(state);
this.btnCommentRemove && this.btnCommentRemove.setDisabled(state || !Common.Utils.InternalSettings.get(this.appPrefix + "settings-livecomment"));
},

Binary file not shown.

After

Width:  |  Height:  |  Size: 287 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

View file

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 414 B

View file

@ -151,6 +151,7 @@ require([
'Toolbar',
'Statusbar',
'Links',
'FormsTab',
'Navigation',
'RightMenu',
'LeftMenu',
@ -176,6 +177,7 @@ require([
'documenteditor/main/app/controller/DocumentHolder',
'documenteditor/main/app/controller/Toolbar',
'documenteditor/main/app/controller/Statusbar',
'documenteditor/main/app/controller/FormsTab',
'documenteditor/main/app/controller/Links',
'documenteditor/main/app/controller/Navigation',
'documenteditor/main/app/controller/RightMenu',

View file

@ -0,0 +1,290 @@
/*
*
* (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
*
*/
/**
* FormsTab.js
*
* Created by Julia Radzhabova on 06.10.2020
* Copyright (c) 2020 Ascensio System SIA. All rights reserved.
*
*/
define([
'core',
'documenteditor/main/app/view/FormsTab'
], function () {
'use strict';
DE.Controllers.FormsTab = Backbone.Controller.extend(_.extend({
models : [],
collections : [
],
views : [
'FormsTab'
],
sdkViewName : '#id_main',
initialize: function () {
},
onLaunch: function () {
this._state = {
prcontrolsdisable:undefined
};
},
setApi: function (api) {
if (api) {
this.api = api;
this.api.asc_registerCallback('asc_onFocusObject', this.onApiFocusObject.bind(this));
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this));
this.api.asc_registerCallback('asc_onChangeSpecialFormsGlobalSettings', _.bind(this.onChangeSpecialFormsGlobalSettings, this));
this.api.asc_registerCallback('asc_onSendThemeColors', _.bind(this.onSendThemeColors, this));
Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this));
// this.api.asc_registerCallback('asc_onShowContentControlsActions',_.bind(this.onShowContentControlsActions, this));
// this.api.asc_registerCallback('asc_onHideContentControlsActions',_.bind(this.onHideContentControlsActions, this));
}
return this;
},
setConfig: function(config) {
this.toolbar = config.toolbar;
this.view = this.createView('FormsTab', {
toolbar: this.toolbar.toolbar
});
this.addListeners({
'FormsTab': {
'forms:insert': this.onControlsSelect,
'forms:new-color': this.onNewControlsColor,
'forms:clear': this.onClearClick,
'forms:no-color': this.onNoControlsColor,
'forms:select-color': this.onSelectControlsColor,
'forms:open-color': this.onColorsShow,
'forms:mode': this.onModeClick
}
});
},
SetDisabled: function(state) {
this.view && this.view.SetDisabled(state);
},
getView: function(name) {
return !name && this.view ?
this.view : Backbone.Controller.prototype.getView.call(this, name);
},
onCoAuthoringDisconnect: function() {
this.SetDisabled(true);
},
onApiFocusObject: function(selectedObjects) {
if (!this.toolbar.editMode) return;
var pr, i = -1, type,
paragraph_locked = false,
header_locked = false;
while (++i < selectedObjects.length) {
type = selectedObjects[i].get_ObjectType();
pr = selectedObjects[i].get_ObjectValue();
if (type === Asc.c_oAscTypeSelectElement.Paragraph) {
paragraph_locked = pr.get_Locked();
} else if (type === Asc.c_oAscTypeSelectElement.Header) {
header_locked = pr.get_Locked();
}
}
var in_control = this.api.asc_IsContentControl();
var control_props = in_control ? this.api.asc_GetContentControlProperties() : null,
lock_type = (in_control&&control_props) ? control_props.get_Lock() : Asc.c_oAscSdtLockType.Unlocked,
control_plain = (in_control&&control_props) ? (control_props.get_ContentControlType()==Asc.c_oAscSdtLevelType.Inline) : false;
(lock_type===undefined) && (lock_type = Asc.c_oAscSdtLockType.Unlocked);
var content_locked = lock_type==Asc.c_oAscSdtLockType.SdtContentLocked || lock_type==Asc.c_oAscSdtLockType.ContentLocked;
var need_disable = (paragraph_locked || header_locked || control_plain || content_locked);
if (this._state.prcontrolsdisable !== need_disable) {
this.view.btnTextField.setDisabled(need_disable);
this.view.btnComboBox.setDisabled(need_disable);
this.view.btnDropDown.setDisabled(need_disable);
this.view.btnCheckBox.setDisabled(need_disable);
this.view.btnRadioBox.setDisabled(need_disable);
this.view.btnImageField.setDisabled(need_disable);
this.view.btnTextField.setDisabled(need_disable);
this._state.prcontrolsdisable = need_disable;
}
},
onSendThemeColors: function() {
this._needUpdateColors = true;
},
updateThemeColors: function() {
var updateColors = function(picker, defaultColorIndex) {
if (picker) {
var clr;
var effectcolors = Common.Utils.ThemeColor.getEffectColors();
for (var i = 0; i < effectcolors.length; i++) {
if (typeof(picker.currentColor) == 'object' &&
clr === undefined &&
picker.currentColor.effectId == effectcolors[i].effectId)
clr = effectcolors[i];
}
picker.updateColors(effectcolors, Common.Utils.ThemeColor.getStandartColors());
if (picker.currentColor === undefined) {
picker.currentColor = effectcolors[defaultColorIndex];
} else if ( clr!==undefined ) {
picker.currentColor = clr;
}
}
};
this.view && this.view.mnuFormsColorPicker && updateColors(this.view.mnuFormsColorPicker, 1);
this.onChangeSpecialFormsGlobalSettings();
},
onChangeSpecialFormsGlobalSettings: function() {
if (this.view && this.view.mnuFormsColorPicker) {
var clr = this.api.asc_GetSpecialFormsHighlightColor(),
show = !!clr;
this.view.mnuNoFormsColor.setChecked(!show, true);
this.view.mnuFormsColorPicker.clearSelection();
if (clr) {
clr = Common.Utils.ThemeColor.getHexColor(clr.get_r(), clr.get_g(), clr.get_b());
this.view.mnuFormsColorPicker.selectByRGB(clr, true);
}
this.view.btnHighlight.currentColor = clr;
$('.btn-color-value-line', this.view.btnHighlight.cmpEl).css('background-color', clr ? '#' + clr : 'transparent');
}
},
onColorsShow: function(menu) {
this._needUpdateColors && this.updateThemeColors();
this._needUpdateColors = false;
},
onControlsSelect: function(type) {
if (!(this.toolbar.mode && this.toolbar.mode.canFeatureContentControl)) return;
var oPr,
oFormPr = new AscCommon.CSdtFormPr();
this.toolbar.toolbar.fireEvent('insertcontrol', this.toolbar.toolbar);
if (type == 'picture')
this.api.asc_AddContentControlPicture(oFormPr);
else if (type == 'checkbox' || type == 'radiobox') {
oPr = new AscCommon.CSdtCheckBoxPr();
(type == 'radiobox') && oPr.put_GroupKey('Group 1');
this.api.asc_AddContentControlCheckBox(oPr, oFormPr);
} else if (type == 'combobox' || type == 'dropdown')
this.api.asc_AddContentControlList(type == 'combobox', oPr, oFormPr);
else if (type == 'text') {
oPr = new AscCommon.CSdtTextFormPr();
this.api.asc_AddContentControlTextForm(oPr, oFormPr);
}
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
},
onModeClick: function(state) {
if (this.api) {
this.disableEditing(state);
this.api.asc_setRestriction(state ? Asc.c_oAscRestrictionType.OnlyForms : Asc.c_oAscRestrictionType.None);
}
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
},
onClearClick: function() {
if (this.api) {
this.api.asc_ClearAllSpecialForms();
}
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
},
onNewControlsColor: function() {
this.view.mnuFormsColorPicker.addNewColor();
},
onNoControlsColor: function(item) {
if (!item.isChecked())
this.api.asc_SetSpecialFormsHighlightColor(255, 192, 0);
else
this.api.asc_SetSpecialFormsHighlightColor();
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
},
onSelectControlsColor: function(color) {
var clr = Common.Utils.ThemeColor.getRgbColor(color);
if (this.api) {
this.api.asc_SetSpecialFormsHighlightColor(clr.get_r(), clr.get_g(), clr.get_b());
}
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
},
disableEditing: function(disable) {
if (this._state.DisabledEditing != disable) {
this._state.DisabledEditing = disable;
var app = this.getApplication();
var rightMenuController = app.getController('RightMenu');
rightMenuController.getView('RightMenu').clearSelection();
rightMenuController.SetDisabled(disable);
app.getController('Toolbar').DisableToolbar(disable, false, false, true);
app.getController('Statusbar').getView('Statusbar').SetDisabled(disable);
app.getController('Common.Controllers.ReviewChanges').SetDisabled(disable);
app.getController('DocumentHolder').getView().SetDisabled(disable);
app.getController('Navigation') && app.getController('Navigation').SetDisabled(disable);
app.getController('LeftMenu').setPreviewMode(disable);
var comments = app.getController('Common.Controllers.Comments');
if (comments)
comments.setPreviewMode(disable);
if (this.view)
this.view.$el.find('.no-group-mask.form-view').css('opacity', 1);
}
},
onAppReady: function (config) {
var me = this;
(new Promise(function (accept, reject) {
accept();
})).then(function(){
if (config.canEditContentControl) {
var clr = me.api.asc_GetSpecialFormsHighlightColor();
clr && (clr = Common.Utils.ThemeColor.getHexColor(clr.get_r(), clr.get_g(), clr.get_b()));
me.view.btnHighlight.currentColor = clr;
}
});
}
}, DE.Controllers.FormsTab || {}));
});

View file

@ -1357,6 +1357,7 @@ define([
toolbarView.on('insertshape', _.bind(me.onInsertShape, me));
toolbarView.on('inserttextart', _.bind(me.onInsertTextArt, me));
toolbarView.on('insertchart', _.bind(me.onInsertChart, me));
toolbarView.on('insertcontrol', _.bind(me.onInsertControl, me));
}
var value = Common.localStorage.getItem('de-settings-unit');
@ -2033,6 +2034,10 @@ define([
this.getApplication().getController('RightMenu').onInsertTextArt();
},
onInsertControl: function() {
this.getApplication().getController('RightMenu').onInsertControl();
},
unitsChanged: function(m) {
var value = Common.localStorage.getItem("de-settings-unit");
value = (value!==null) ? parseInt(value) : Common.Utils.Metric.getDefaultMetric();

View file

@ -80,6 +80,7 @@ define([
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.MailMerge] = {panelId: "id-mail-merge-settings", panel: rightMenu.mergeSettings, btn: rightMenu.btnMailMerge, hidden: 1, props: {}, locked: false};
this._settings[Common.Utils.documentSettingsType.Signature] = {panelId: "id-signature-settings", panel: rightMenu.signatureSettings, btn: rightMenu.btnSignature, hidden: 1, props: {}, locked: false};
this._settings[Common.Utils.documentSettingsType.Form] = {panelId: "id-form-settings", panel: rightMenu.formSettings, btn: rightMenu.btnForm, hidden: 1, props: {}, locked: false};
},
setApi: function(api) {
@ -124,6 +125,8 @@ define([
this._settings[Common.Utils.documentSettingsType.Signature].locked = false;
var isChart = false;
var control_props = this.api.asc_IsContentControl() ? this.api.asc_GetContentControlProperties() : null,
control_lock = false;
for (i=0; i<SelectedObjects.length; i++)
{
var content_locked = false;
@ -137,8 +140,7 @@ define([
var value = SelectedObjects[i].get_ObjectValue();
if (settingsType == Common.Utils.documentSettingsType.Image) {
var control_props = this.api.asc_IsContentControl() ? this.api.asc_GetContentControlProperties() : null,
lock_type = (control_props) ? control_props.get_Lock() : Asc.c_oAscSdtLockType.Unlocked;
var lock_type = (control_props) ? control_props.get_Lock() : Asc.c_oAscSdtLockType.Unlocked;
content_locked = lock_type==Asc.c_oAscSdtLockType.SdtContentLocked || lock_type==Asc.c_oAscSdtLockType.ContentLocked;
if (value.get_ChartProperties() !== null) {
@ -153,9 +155,11 @@ define([
this._settings[Common.Utils.documentSettingsType.TextArt].locked = value.get_Locked() || content_locked;
}
}
control_lock = control_lock || value.get_Locked();
} else if (settingsType == Common.Utils.documentSettingsType.Paragraph) {
this._settings[settingsType].panel.isChart = isChart;
can_add_table = value.get_CanAddTable();
control_lock = control_lock || value.get_Locked();
}
this._settings[settingsType].props = value;
this._settings[settingsType].hidden = 0;
@ -166,6 +170,17 @@ define([
this._settings[Common.Utils.documentSettingsType.Signature].locked = value.get_Locked();
}
if (control_props && control_props.get_FormPr()) {
var spectype = control_props.get_SpecificType();
if (spectype==Asc.c_oAscContentControlSpecificType.CheckBox || spectype==Asc.c_oAscContentControlSpecificType.Picture ||
spectype==Asc.c_oAscContentControlSpecificType.ComboBox || spectype==Asc.c_oAscContentControlSpecificType.DropDownList || spectype==Asc.c_oAscContentControlSpecificType.None) {
settingsType = Common.Utils.documentSettingsType.Form;
this._settings[settingsType].props = control_props;
this._settings[settingsType].locked = control_lock;
this._settings[settingsType].hidden = 0;
}
}
if ( this._settings[Common.Utils.documentSettingsType.Header].locked ) { // если находимся в locked header/footer, то считаем, что все элементы в нем тоже недоступны
for (i=0; i<this._settings.length; i++) {
if (this._settings[i])
@ -249,11 +264,17 @@ define([
this._settings[Common.Utils.documentSettingsType.TextArt].needShow = true;
},
onInsertControl: function() {
if (this._settings[Common.Utils.documentSettingsType.Form])
this._settings[Common.Utils.documentSettingsType.Form].needShow = true;
},
UpdateThemeColors: function() {
this.rightmenu.paragraphSettings.UpdateThemeColors();
this.rightmenu.tableSettings.UpdateThemeColors();
this.rightmenu.shapeSettings.UpdateThemeColors();
this.rightmenu.textartSettings.UpdateThemeColors();
this.rightmenu.formSettings && this.rightmenu.formSettings.UpdateThemeColors();
},
updateMetricUnit: function() {
@ -262,6 +283,7 @@ define([
this.rightmenu.chartSettings.updateMetricUnit();
this.rightmenu.imageSettings.updateMetricUnit();
this.rightmenu.tableSettings.updateMetricUnit();
this.rightmenu.formSettings && this.rightmenu.formSettings.updateMetricUnit();
},
createDelayedElements: function() {
@ -347,6 +369,7 @@ define([
this.rightmenu.headerSettings.disableControls(disabled);
this.rightmenu.tableSettings.disableControls(disabled);
this.rightmenu.imageSettings.disableControls(disabled);
this.rightmenu.formSettings && this.rightmenu.formSettings.disableControls(disabled);
if (!allowMerge && this.rightmenu.mergeSettings) {
this.rightmenu.mergeSettings.disableControls(disabled);
disabled && this.rightmenu.btnMailMerge.setDisabled(disabled);
@ -365,6 +388,7 @@ define([
this.rightmenu.btnShape.setDisabled(disabled);
this.rightmenu.btnTextArt.setDisabled(disabled);
this.rightmenu.btnChart.setDisabled(disabled);
this.rightmenu.btnForm && this.rightmenu.btnForm.setDisabled(disabled);
} else {
var selectedElements = this.api.getSelectedElements();
if (selectedElements.length > 0)

View file

@ -790,11 +790,12 @@ define([
toolbar.btnContentControls.setDisabled(paragraph_locked || header_locked);
if (!(paragraph_locked || header_locked)) {
var control_disable = control_plain || content_locked;
for (var i=0; i<14; i++)
var control_disable = control_plain || content_locked,
if_form = control_props && control_props.get_FormPr();
for (var i=0; i<7; i++)
toolbar.btnContentControls.menu.items[i].setDisabled(control_disable);
toolbar.btnContentControls.menu.items[15].setDisabled(!in_control || lock_type==Asc.c_oAscSdtLockType.SdtContentLocked || lock_type==Asc.c_oAscSdtLockType.SdtLocked);
toolbar.btnContentControls.menu.items[17].setDisabled(!in_control);
toolbar.btnContentControls.menu.items[8].setDisabled(!in_control || lock_type==Asc.c_oAscSdtLockType.SdtContentLocked || lock_type==Asc.c_oAscSdtLockType.SdtLocked || if_form);
toolbar.btnContentControls.menu.items[10].setDisabled(!in_control || if_form);
}
var need_text_disable = paragraph_locked || header_locked || in_chart || rich_edit_lock || plain_edit_lock;
@ -1905,6 +1906,7 @@ define([
oPr, oFormPr;
if (isnew) {
oFormPr = new AscCommon.CSdtFormPr();
this.toolbar.fireEvent('insertcontrol', this.toolbar);
}
if (item.value == 'plain' || item.value == 'rich')
this.api.asc_AddContentControl((item.value=='plain') ? Asc.c_oAscSdtLevelType.Inline : Asc.c_oAscSdtLevelType.Block);
@ -2967,27 +2969,36 @@ define([
this.DisableToolbar(true, true);
},
DisableToolbar: function(disable, viewMode, reviewmode) {
DisableToolbar: function(disable, viewMode, reviewmode, fillformmode) {
if (viewMode!==undefined) this.editMode = !viewMode;
disable = disable || !this.editMode;
var toolbar_mask = $('.toolbar-mask'),
group_mask = $('.toolbar-group-mask'),
mask = reviewmode ? group_mask : toolbar_mask;
mask = (reviewmode || fillformmode) ? group_mask : toolbar_mask;
if (disable && mask.length>0 || !disable && mask.length==0) return;
var toolbar = this.toolbar;
if(disable) {
if (reviewmode) {
mask = $("<div class='toolbar-group-mask'>").appendTo(toolbar.$el.find('.toolbar section.panel .group:not(.no-mask):not(.no-group-mask)'));
mask = $("<div class='toolbar-group-mask'>").appendTo(toolbar.$el.find('.toolbar section.panel .group:not(.no-mask):not(.no-group-mask.review)'));
} else if (fillformmode) {
mask = $("<div class='toolbar-group-mask'>").appendTo(toolbar.$el.find('.toolbar section.panel .group:not(.no-mask):not(.no-group-mask.form-view)'));
} else
mask = $("<div class='toolbar-mask'>").appendTo(toolbar.$el.find('.toolbar'));
} else {
mask.remove();
}
$('.no-group-mask').css('opacity', (reviewmode || !disable) ? 1 : 0.4);
$('.no-group-mask').each(function(index, item){
var $el = $(item);
if ($el.find('.toolbar-group-mask').length>0)
$el.css('opacity', 0.4);
else {
$el.css('opacity', reviewmode || fillformmode || !disable ? 1 : 0.4);
}
});
disable = disable || (reviewmode ? toolbar_mask.length>0 : group_mask.length>0);
disable = disable || ((reviewmode || fillformmode) ? toolbar_mask.length>0 : group_mask.length>0);
toolbar.$el.find('.toolbar').toggleClass('masked', disable);
if ( toolbar.synchTooltip )
toolbar.synchTooltip.hide();
@ -3053,7 +3064,7 @@ define([
var tab = {action: 'review', caption: me.toolbar.textTabCollaboration};
var $panel = me.application.getController('Common.Controllers.ReviewChanges').createToolbarPanel();
if ( $panel )
me.toolbar.addTab(tab, $panel, 4);
me.toolbar.addTab(tab, $panel, 5);
if ( config.isEdit ) {
me.toolbar.setMode(config);
@ -3077,13 +3088,22 @@ define([
tab = {action: 'protect', caption: me.toolbar.textTabProtect};
$panel = me.getApplication().getController('Common.Controllers.Protection').createToolbarPanel();
if ($panel) me.toolbar.addTab(tab, $panel, 5);
if ($panel) me.toolbar.addTab(tab, $panel, 6);
}
}
var links = me.getApplication().getController('Links');
links.setApi(me.api).setConfig({toolbar: me});
Array.prototype.push.apply(me.toolbar.toolbarControls, links.getView('Links').getButtons());
if (config.canFeatureContentControl) {
tab = {caption: me.textTabForms, action: 'forms'};
var forms = me.getApplication().getController('FormsTab');
forms.setApi(me.api).setConfig({toolbar: me});
me.toolbar.addTab(tab, $panel, 4);
me.toolbar.setVisible('forms', true);
Array.prototype.push.apply(me.toolbar.toolbarControls, forms.getView('FormsTab').getButtons());
}
}
},
@ -3505,7 +3525,8 @@ define([
notcriticalErrorTitle: 'Warning',
txtMarginsW: 'Left and right margins are too high for a given page wight',
txtMarginsH: 'Top and bottom margins are too high for a given page height',
textInsert: 'Insert'
textInsert: 'Insert',
textTabForms: 'Forms'
}, DE.Controllers.Toolbar || {}));
});

View file

@ -0,0 +1,102 @@
<table cols="1">
<tr>
<td>
<label class="header padding-small" id="form-settings-name"><%= scope.textField %></label>
</td>
</tr>
<tr class="form-keyfield">
<td class="padding-small">
<label class="input-label"><%= scope.textKey %></label>
<div id="form-combo-key" style="width: 100%;"></div>
</td>
</tr>
<tr class="form-radiobox">
<td class="padding-small">
<label class="input-label"><%= scope.textGroupKey %></label>
<div id="form-combo-group-key" style="width: 100%;"></div>
</td>
</tr>
<tr class="form-placeholder">
<td class="padding-small">
<label class="input-label"><%= scope.textPlaceholder %></label>
<div id="form-txt-pholder"></div>
</td>
</tr>
<tr>
<td class="padding-large">
<label class="input-label"><%= scope.textTip %></label>
<div id="form-txt-help"></div>
</td>
</tr>
<tr class="form-textfield">
<td class="padding-small">
<div id="form-chb-max-chars" style="display: inline-block;margin-top: 4px;"></div>
<div id="form-spin-max-chars" style="display: inline-block;float: right;"></div>
</td>
</tr>
<tr class="form-textfield">
<td class="padding-small">
<div id="form-chb-comb"></div>
</td>
</tr>
<tr class="form-textfield">
<td class="padding-small">
<label class="input-label" style="margin-left: 22px;margin-top: 4px;"><%= scope.textWidth %></label>
<div id="form-spin-width" style="display: inline-block; float: right;"></div>
</td>
</tr>
<tr class="form-textfield">
<td class="padding-large">
<label class="input-label" style="margin-left: 22px;margin-top: 4px;"><%= scope.textColor %></label>
<div id="form-color-btn" style="display: inline-block; float: right;"></div>
</td>
</tr>
<tr class="form-image">
<td class="padding-large">
<div id="form-button-replace" style="width:100%;"></div>
</td>
</tr>
</table>
<table cols="2" class="form-list">
<tr>
<td colspan="2" class="padding-small">
<label class="input-label"><%= scope.textValue %></label>
</td>
</tr>
<tr style="vertical-align: top;">
<td class="padding-small">
<div id="form-txt-new-value" style="margin-right: 5px;"></div>
</td>
<td class="padding-small">
<div id="form-list-add" style="margin-left: 5px;"></div>
</td>
</tr>
<tr style="vertical-align: top;">
<td class="padding-large">
<div id="form-list-list" style="height: 95px;margin-right: 5px;background-color: #fff;"></div>
</td>
<td class="padding-large">
<div id="form-list-delete" style="margin-bottom: 5px;margin-left: 5px;"></div>
<div id="form-list-up" style="margin-bottom: 5px;margin-left: 5px;"></div>
<div id="form-list-down" style="margin-left: 5px;"></div>
</td>
</tr>
</table>
<table cols="1">
<tr>
<td class="padding-small">
<div class="separator horizontal"></div>
</td>
</tr>
<tr>
<td class="padding-small">
<div id="form-btn-delete"></div>
</td>
</tr>
<tr>
<td class="padding-small">
<div id="form-btn-lock"></div>
</td>
</tr>
<tr class="finish-cell"></tr>
</table>

View file

@ -18,6 +18,8 @@
</div>
<div id="id-signature-settings" class="settings-panel">
</div>
<div id="id-form-settings" class="settings-panel">
</div>
</div>
<div class="tool-menu-btns">
<div class="ct-btn-category arrow-left"></div>
@ -30,5 +32,6 @@
<button id="id-right-menu-textart" class="btn btn-category arrow-left" content-target="id-textart-settings"><i class="icon toolbar__icon btn-menu-textart">&nbsp;</i></button>
<button id="id-right-menu-mail-merge" class="btn btn-category arrow-left hidden" content-target="id-mail-merge-settings"><i class="icon toolbar__icon btn-mailmerge">&nbsp;</i></button>
<button id="id-right-menu-signature" class="btn btn-category arrow-left hidden" content-target="id-signature-settings"><i class="icon toolbar__icon btn-menu-signature">&nbsp;</i></button>
<button id="id-right-menu-form" class="btn btn-category arrow-left hidden" content-target="id-form-settings"><i class="icon toolbar__icon btn-field">&nbsp;</i></button>
</div>
</div>

View file

@ -173,6 +173,29 @@
</div>
</div>
</section>
<section class="panel" data-tab="forms">
<div class="group">
<span class="btn-slot text x-huge" id="slot-btn-form-field"></span>
<span class="btn-slot text x-huge" id="slot-btn-form-combobox"></span>
<span class="btn-slot text x-huge" id="slot-btn-form-dropdown"></span>
<span class="btn-slot text x-huge" id="slot-btn-form-checkbox"></span>
<span class="btn-slot text x-huge" id="slot-btn-form-radiobox"></span>
<span class="btn-slot text x-huge" id="slot-btn-form-image"></span>
</div>
<div class="separator long"></div>
<div class="group">
<div class="elset">
<span class="btn-slot text" id="slot-form-clear-fields"></span>
</div>
<div class="elset">
<span class="btn-slot text" id="slot-form-highlight"></span>
</div>
</div>
<div class="separator long"></div>
<div class="group no-group-mask form-view">
<span class="btn-slot text x-huge" id="slot-btn-form-view"></span>
</div>
</section>
</section>
</section>
</div>

View file

@ -313,7 +313,8 @@ define([ 'text!documenteditor/main/app/template/ControlSettingsDialog.template',
step: .1,
width: 80,
defaultUnit : "cm",
value: '3 cm',
value: 'Auto',
allowAuto: true,
maxValue: 55.88,
minValue: 0.1
});
@ -550,7 +551,7 @@ define([ 'text!documenteditor/main/app/template/ControlSettingsDialog.template',
this.spnMaxChars.setValue(val && val>=0 ? val : 10);
val = formTextPr.get_Width();
this.spnWidth.setValue(val ? val : '', true);
this.spnWidth.setValue(val!==0 && val!==undefined ? Common.Utils.Metric.fnRecalcFromMM(val * 25.4 / 20 / 72.0) : -1, true);
}
if ((type == Asc.c_oAscContentControlSpecificType.CheckBox || type == Asc.c_oAscContentControlSpecificType.Picture) && !formPr ) {// standart checkbox or picture
@ -563,7 +564,7 @@ define([ 'text!documenteditor/main/app/template/ControlSettingsDialog.template',
var props = new AscCommon.CContentControlPr();
props.put_Alias(this.txtName.getValue());
props.put_Tag(this.txtTag.getValue());
props.put_PlaceholderText(this.txtPlaceholder.getValue());
props.put_PlaceholderText(this.txtPlaceholder.getValue() || ' ');
props.put_Appearance(this.cmbShow.getValue());
if (this.isSystemColor) {
@ -639,8 +640,12 @@ define([ 'text!documenteditor/main/app/template/ControlSettingsDialog.template',
if (this.btnsCategory[5].isVisible()) {
var formTextPr = new AscCommon.CSdtTextFormPr();
if (this.spnWidth.getValue())
formTextPr.put_Width(this.spnWidth.getNumberValue());
if (this.spnWidth.getValue()) {
var value = this.spnWidth.getNumberValue();
formTextPr.put_Width(value<=0 ? 0 : parseInt(Common.Utils.Metric.fnRecalcToMM(value) * 72 * 20 / 25.4));
} else
formTextPr.put_Width(0);
if (this.placeholder && this.placeholder.changed) {
formTextPr.put_PlaceHolderSymbol(this.placeholder.code);
formTextPr.put_PlaceHolderFont(this.placeholder.font);
@ -650,7 +655,7 @@ define([ 'text!documenteditor/main/app/template/ControlSettingsDialog.template',
var checked = (this.chMaxChars.getValue()=='checked' || this.chComb.getValue()=='checked');
formTextPr.put_MaxCharacters(checked);
if (checked)
formTextPr.put_MaxCharacters(this.spnMaxChars.getNumberValue() || 12);
formTextPr.put_MaxCharacters(this.spnMaxChars.getNumberValue() || 10);
props.put_TextFormPr(formTextPr);
}

View file

@ -491,20 +491,24 @@ define([
var showPoint, ToolTip,
type = moveData.get_Type();
if (type==1 || type==3) { // 1 - hyperlink, 3 - footnote
if (type==Asc.c_oAscMouseMoveDataTypes.Hyperlink || type==Asc.c_oAscMouseMoveDataTypes.Footnote || type==Asc.c_oAscMouseMoveDataTypes.Form) { // 1 - hyperlink, 3 - footnote
if (isTooltipHiding) {
mouseMoveData = moveData;
return;
}
if (type==1) {
if (type==Asc.c_oAscMouseMoveDataTypes.Hyperlink) {
var hyperProps = moveData.get_Hyperlink();
if (!hyperProps) return;
ToolTip = (_.isEmpty(hyperProps.get_ToolTip())) ? hyperProps.get_Value() : hyperProps.get_ToolTip();
} else {
} else if (type == Asc.c_oAscMouseMoveDataTypes.Footnote) {
ToolTip = moveData.get_FootnoteText();
if (ToolTip.length>1000)
ToolTip = ToolTip.substr(0, 1000) + '...';
} else if (type==Asc.c_oAscMouseMoveDataTypes.Form) {
ToolTip = moveData.get_FormHelpText();
if (ToolTip.length>1000)
ToolTip = ToolTip.substr(0, 1000) + '...';
}
var recalc = false;
@ -513,7 +517,7 @@ define([
ToolTip = Common.Utils.String.htmlEncode(ToolTip);
if (screenTip.tipType !== type || screenTip.tipLength !== ToolTip.length || screenTip.strTip.indexOf(ToolTip)<0 ) {
screenTip.toolTip.setTitle((type==1) ? (ToolTip + '<br><b>' + me.txtPressLink + '</b>') : ToolTip);
screenTip.toolTip.setTitle((type==Asc.c_oAscMouseMoveDataTypes.Hyperlink) ? (ToolTip + '<br><b>' + me.txtPressLink + '</b>') : ToolTip);
screenTip.tipLength = ToolTip.length;
screenTip.strTip = ToolTip;
screenTip.tipType = type;
@ -547,7 +551,7 @@ define([
screenTip.toolTip.getBSTip().$tip.css({top: showPoint[1] + 'px', left: showPoint[0] + 'px'});
}
/** coauthoring begin **/
else if (moveData.get_Type()==2 && me.mode.isEdit) { // 2 - locked object
else if (moveData.get_Type()==Asc.c_oAscMouseMoveDataTypes.LockedObject && me.mode.isEdit) { // 2 - locked object
var src;
if (me.usertipcount >= me.usertips.length) {
src = $(document.createElement("div"));
@ -2793,13 +2797,14 @@ define([
});
var menuTableRemoveControl = new Common.UI.MenuItem({
iconCls: 'menu__icon cc-remove',
caption: me.textRemove,
value: 'remove'
}).on('click', _.bind(me.onControlsSelect, me));
var menuTableControlSettings = new Common.UI.MenuItem({
caption: me.textSettings,
value: 'settings'
caption: me.textSettings,
value: 'settings'
}).on('click', _.bind(me.onControlsSelect, me));
var menuTableControl = new Common.UI.MenuItem({
@ -3229,9 +3234,11 @@ define([
menuTableControl.setVisible(in_control);
if (in_control) {
var control_props = me.api.asc_GetContentControlProperties(),
lock_type = (control_props) ? control_props.get_Lock() : Asc.c_oAscSdtLockType.Unlocked;
lock_type = (control_props) ? control_props.get_Lock() : Asc.c_oAscSdtLockType.Unlocked,
is_form = control_props && control_props.get_FormPr();
menuTableRemoveControl.setDisabled(lock_type==Asc.c_oAscSdtLockType.SdtContentLocked || lock_type==Asc.c_oAscSdtLockType.SdtLocked);
menuTableControlSettings.setVisible(me.mode.canEditContentControl);
menuTableRemoveControl.setCaption(is_form ? me.getControlLabel(control_props) : me.textRemoveControl);
menuTableControlSettings.setVisible(me.mode.canEditContentControl && !is_form);
var spectype = control_props ? control_props.get_SpecificType() : Asc.c_oAscContentControlSpecificType.None;
control_lock = control_lock || spectype==Asc.c_oAscContentControlSpecificType.CheckBox || spectype==Asc.c_oAscContentControlSpecificType.Picture ||
@ -3676,6 +3683,7 @@ define([
});
var menuParaRemoveControl = new Common.UI.MenuItem({
iconCls: 'menu__icon cc-remove',
caption: me.textRemoveControl,
value: 'remove'
}).on('click', _.bind(me.onControlsSelect, me));
@ -3908,14 +3916,16 @@ define([
!value.paraProps.value.can_DeleteInlineContentControl() || !value.paraProps.value.can_EditInlineContentControl()) : false;
var in_toc = me.api.asc_GetTableOfContentsPr(true),
in_control = !in_toc && me.api.asc_IsContentControl() ;
in_control = !in_toc && me.api.asc_IsContentControl(),
control_props = in_control ? me.api.asc_GetContentControlProperties() : null,
is_form = control_props && control_props.get_FormPr();
menuParaRemoveControl.setVisible(in_control);
menuParaControlSettings.setVisible(in_control && me.mode.canEditContentControl);
menuParaControlSettings.setVisible(in_control && me.mode.canEditContentControl && !is_form);
menuParaControlSeparator.setVisible(in_control);
if (in_control) {
var control_props = me.api.asc_GetContentControlProperties(),
lock_type = (control_props) ? control_props.get_Lock() : Asc.c_oAscSdtLockType.Unlocked;
var lock_type = (control_props) ? control_props.get_Lock() : Asc.c_oAscSdtLockType.Unlocked;
menuParaRemoveControl.setDisabled(lock_type==Asc.c_oAscSdtLockType.SdtContentLocked || lock_type==Asc.c_oAscSdtLockType.SdtLocked);
menuParaRemoveControl.setCaption(is_form ? me.getControlLabel(control_props) : me.textRemoveControl);
var spectype = control_props ? control_props.get_SpecificType() : Asc.c_oAscContentControlSpecificType.None;
control_lock = control_lock || spectype==Asc.c_oAscContentControlSpecificType.CheckBox || spectype==Asc.c_oAscContentControlSpecificType.Picture ||
@ -4236,6 +4246,7 @@ define([
var type = obj.type,
props = obj.pr,
specProps = (type == Asc.c_oAscContentControlSpecificType.ComboBox) ? props.get_ComboBoxPr() : props.get_DropDownListPr(),
isForm = !!props.get_FormPr(),
menu = this.listControlMenu,
menuContainer = menu ? this.cmpEl.find(Common.Utils.String.format('#menu-container-{0}', menu.id)) : null,
me = this;
@ -4272,14 +4283,25 @@ define([
});
}
if (specProps) {
if (isForm){ // for dropdown and combobox form control always add placeholder item
menu.addItem(new Common.UI.MenuItem({
caption : props.get_PlaceholderText(),
value : '',
template : _.template([
'<a id="<%= id %>" tabindex="-1" type="menuitem" style="<% if (options.value=="") { %> opacity: 0.6 <% } %>">',
'<%= caption %>',
'</a>'
].join(''))
}));
}
var count = specProps.get_ItemsCount();
for (var i=0; i<count; i++) {
menu.addItem(new Common.UI.MenuItem({
(specProps.get_ItemValue(i)!=='' || !isForm) && menu.addItem(new Common.UI.MenuItem({
caption : specProps.get_ItemDisplayText(i),
value : specProps.get_ItemValue(i)
}));
}
if (count<1) {
if (!isForm && menu.items.length<1) {
menu.addItem(new Common.UI.MenuItem({
caption : this.txtEmpty,
value : -1
@ -4327,6 +4349,23 @@ define([
this._state.lock_doc = false;
},
getControlLabel: function(props) {
var type = props ? props.get_SpecificType() : Asc.c_oAscContentControlSpecificType.None;
switch (type) {
case Asc.c_oAscContentControlSpecificType.CheckBox:
var specProps = props.get_CheckBoxPr();
return (typeof specProps.get_GroupKey() !== 'string') ? this.textRemCheckBox : this.textRemRadioBox;
case Asc.c_oAscContentControlSpecificType.ComboBox:
return this.textRemComboBox;
case Asc.c_oAscContentControlSpecificType.DropDownList:
return this.textRemDropdown;
case Asc.c_oAscContentControlSpecificType.Picture:
return this.textRemPicture;
default:
return this.textRemField;
}
},
focus: function() {
var me = this;
_.defer(function(){ me.cmpEl.focus(); }, 50);
@ -4557,7 +4596,12 @@ define([
textTitleCellsRemove: 'Delete Cells',
textLeft: 'Shift cells left',
textRow: 'Delete entire row',
textCol: 'Delete entire column'
}, DE.Views.DocumentHolder || {}));
textCol: 'Delete entire column',
textRemCheckBox: 'Remove Checkbox',
textRemRadioBox: 'Remove Radio Button',
textRemComboBox: 'Remove Combo Box',
textRemDropdown: 'Remove Dropdown',
textRemPicture: 'Remove Image',
textRemField: 'Remove Text Field'
}, DE.Views.DocumentHolder || {}));
});

View file

@ -0,0 +1,826 @@
/*
*
* (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',
'common/main/lib/component/TextareaField',
'common/main/lib/component/CheckBox',
'common/main/lib/view/ImageFromUrlDialog'
], 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 = {
DisabledControls: undefined,
LockDelete: undefined
};
this.spinners = [];
this.lockedControls = [];
this.internalId = null;
this._locked = true;
this._originalTextFormProps = null;
this._originalFormProps = null;
this._originalProps = null;
this.render();
},
render: function () {
var el = this.$el || $(this.el);
el.html(this.template({
scope: this
}));
this.TextOnlySettings = el.find('.form-textfield');
this.PlaceholderSettings = el.find('.form-placeholder');
this.KeySettings = el.find('.form-keyfield');
this.CheckOnlySettings = el.find('.form-checkbox');
this.RadioOnlySettings = el.find('.form-radiobox');
this.ListOnlySettings = el.find('.form-list');
this.ImageOnlySettings = el.find('.form-image');
},
createDelayedElements: function() {
this._initSettings = false;
var $markup = this.$el || $(this.el);
var me = this;
this.labelFormName = $markup.findById('#form-settings-name');
// Common props
this.cmbKey = new Common.UI.ComboBox({
el: $markup.findById('#form-combo-key'),
cls: 'input-group-nr',
menuStyle: 'min-width: 100%;',
editable: true,
data: []
});
this.cmbKey.setValue('');
this.lockedControls.push(this.cmbKey);
this.cmbKey.on('selected', this.onKeyChanged.bind(this));
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%;',
value : ''
});
this.lockedControls.push(this.txtPlaceholder);
this.txtPlaceholder.on('changed:after', this.onPlaceholderChanged.bind(this));
this.txtPlaceholder.on('inputleave', function(){ me.fireEvent('editcomplete', me);});
this.textareaHelp = new Common.UI.TextareaField({
el : $markup.findById('#form-txt-help'),
style : 'width: 100%; height: 60px;',
value : ''
});
this.lockedControls.push(this.textareaHelp);
this.textareaHelp.on('changed:after', this.onHelpChanged.bind(this));
this.textareaHelp.on('inputleave', function(){ me.fireEvent('editcomplete', me);});
// Text props
this.chMaxChars = new Common.UI.CheckBox({
el: $markup.findById('#form-chb-max-chars'),
labelText: this.textMaxChars
});
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,
width: 45,
defaultUnit : "",
value: '10',
maxValue: 1000000,
minValue: 1
});
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'),
labelText: this.textComb
});
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,
width: 64,
defaultUnit : "cm",
value: 'Auto',
allowAuto: true,
maxValue: 55.88,
minValue: 0.1
});
this.lockedControls.push(this.spnWidth);
this.spnWidth.on('change', this.onWidthChange.bind(this));
this.spnWidth.on('inputleave', function(){ me.fireEvent('editcomplete', me);});
// 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,
data: []
});
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));
// 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%;',
value : ''
});
this.lockedControls.push(this.txtNewValue);
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>',
'<div style="width:65px;display: inline-block;vertical-align: middle; overflow: hidden; text-overflow: ellipsis;white-space: pre;"><%= name %></div>',
'</div>'
].join(''))
});
this.list.on('item:select', _.bind(this.onSelectItem, this));
this.lockedControls.push(this.list);
this.btnListAdd = new Common.UI.Button({
parentEl: $markup.findById('#form-list-add'),
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-zoomup',
hint: this.textTipAdd
});
this.btnListAdd.on('click', _.bind(this.onAddItem, this));
this.lockedControls.push(this.btnListAdd);
this.btnListDelete = new Common.UI.Button({
parentEl: $markup.findById('#form-list-delete'),
cls: 'btn-toolbar',
iconCls: 'toolbar__icon cc-remove',
hint: this.textTipDelete
});
this.btnListDelete.on('click', _.bind(this.onDeleteItem, this));
this.lockedControls.push(this.btnListDelete);
this.btnListUp = new Common.UI.Button({
parentEl: $markup.findById('#form-list-up'),
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-arrow-up',
hint: this.textTipUp
});
this.btnListUp.on('click', _.bind(this.onMoveItem, this, true));
this.lockedControls.push(this.btnListUp);
this.btnListDown = new Common.UI.Button({
parentEl: $markup.findById('#form-list-down'),
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-arrow-down',
hint: this.textTipDown
});
this.btnListDown.on('click', _.bind(this.onMoveItem, this, false));
this.lockedControls.push(this.btnListDown);
// 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}
]
})
});
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);
this.btnRemForm = new Common.UI.Button({
parentEl: $markup.findById('#form-btn-delete'),
cls : 'btn-toolbar',
iconCls : 'toolbar__icon cc-remove',
caption : this.textDelete,
style : 'text-align: left;'
});
this.btnRemForm.on('click', _.bind(function(btn){
this.api.asc_RemoveContentControlWrapper(this._state.id);
}, this));
this.lockedControls.push(this.btnRemForm);
this.btnLockForm = new Common.UI.Button({
parentEl: $markup.findById('#form-btn-lock'),
cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-lock',
caption : this.textLock,
style : 'text-align: left;'
});
this.btnLockForm.on('click', _.bind(function(btn){
if (this.api && !this._noApply) {
var props = this._originalProps || new AscCommon.CContentControlPr();
props.put_Lock(!this._state.LockDelete ? Asc.c_oAscSdtLockType.SdtLocked : Asc.c_oAscSdtLockType.Unlocked);
this.api.asc_SetContentControlProperties(props, this.internalId);
}
}, this));
this.updateMetricUnit();
this.UpdateThemeColors();
},
setApi: function(api) {
this.api = api;
if (this.api) {
// this.api.asc_registerCallback('asc_onParaSpacingLine', _.bind(this._onLineSpacing, this));
}
return this;
},
setMode: function(mode) {
this.mode = mode;
},
onKeyChanged: function(combo, record) {
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);
}
},
onPlaceholderChanged: function(input, newValue, oldValue, e) {
if (this.api && !this._noApply) {
var props = this._originalProps || new AscCommon.CContentControlPr();
props.put_PlaceholderText(newValue || ' ');
this.api.asc_SetContentControlProperties(props, this.internalId);
this.fireEvent('editcomplete', this);
}
},
onHelpChanged: function(input, newValue, oldValue, e) {
if (this.api && !this._noApply) {
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);
this.fireEvent('editcomplete', this);
}
},
onChMaxCharsChanged: function(field, newValue, oldValue, eOpts){
var checked = (field.getValue()=='checked');
this.spnMaxChars.setDisabled(!checked);
if (!checked) {
this.chComb.setValue(false, true);
this.spnWidth.setDisabled(true);
}
if (this.api && !this._noApply) {
var props = this._originalProps || new AscCommon.CContentControlPr();
var formTextPr = this._originalTextFormProps || new AscCommon.CSdtTextFormPr();
(!checked) && formTextPr.put_Comb(checked);
formTextPr.put_MaxCharacters(checked ? (this.spnMaxChars.getNumberValue() || 10) : checked);
props.put_TextFormPr(formTextPr);
this.api.asc_SetContentControlProperties(props, this.internalId);
this.fireEvent('editcomplete', this);
}
},
onMaxCharsChange: function(field, newValue, oldValue, eOpts){
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);
this.fireEvent('editcomplete', this);
}
},
onChCombChanged: function(field, newValue, oldValue, eOpts){
var checked = (field.getValue()=='checked');
if (checked) {
this.chMaxChars.setValue(true, true);
this.spnMaxChars.setDisabled(false);
}
this.spnWidth.setDisabled(!checked);
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();
formTextPr.put_Width(value<=0 ? 0 : parseInt(Common.Utils.Metric.fnRecalcToMM(value) * 72 * 20 / 25.4));
} else
formTextPr.put_Width(0);
}
props.put_TextFormPr(formTextPr);
this.api.asc_SetContentControlProperties(props, this.internalId);
this.fireEvent('editcomplete', this);
}
},
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();
formTextPr.put_Width(value<=0 ? 0 : parseInt(Common.Utils.Metric.fnRecalcToMM(value) * 72 * 20 / 25.4));
} else
formTextPr.put_Width(0);
props.put_TextFormPr(formTextPr);
this.api.asc_SetContentControlProperties(props, this.internalId);
this.fireEvent('editcomplete', this);
}
},
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);
}
},
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);
}
},
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});
this.fillListProps();
}
}
this.fireEvent('editcomplete', this);
},
onDeleteItem: function(btn, eOpts){
var rec = this.list.getSelectedRec();
if (rec) {
var store = this.list.store;
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);
},
setImageUrl: function(url, token) {
this.api.asc_SetContentControlPictureUrl(url, this.internalId, token);
},
insertImageFromStorage: function(data) {
if (data && data.url && data.c=='control') {
this.setImageUrl(data.url, data.token);
}
},
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;
}
},
onColorPickerSelect: function(btn, color) {
this.BorderColor = color;
this._state.BorderColor = this.BorderColor;
if (this.api && !this._noApply) {
var props = this._originalProps || new AscCommon.CContentControlPr();
var formTextPr = this._originalTextFormProps || new AscCommon.CSdtTextFormPr();
if (color == 'transparent') {
formTextPr.put_CombBorder();
} else {
var brd = formTextPr.get_CombBorder();
if (!brd)
brd = new Asc.asc_CTextBorder();
brd.put_Value(1);
brd.put_Color(Common.Utils.ThemeColor.getRgbColor(color));
formTextPr.put_CombBorder(brd);
}
props.put_TextFormPr(formTextPr);
this.api.asc_SetContentControlProperties(props, this.internalId);
this.fireEvent('editcomplete', this);
}
},
ChangeSettings: function(props) {
if (this._initSettings)
this.createDelayedElements();
if (props) {
this._originalProps = props;
this._noApply = true;
this.internalId = props.get_InternalId();
var val = props.get_PlaceholderText();
if (this._state.placeholder !== val) {
this.txtPlaceholder.setValue(val ? val : '');
this._state.placeholder = val;
}
val = props.get_Lock();
(val===undefined) && (val = Asc.c_oAscSdtLockType.Unlocked);
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);
}
this.disableControls(this._locked);
var type = props.get_SpecificType();
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) {
this._originalListProps = specProps;
var count = specProps.get_ItemsCount();
var arr = [];
for (var i=0; i<count; i++) {
(specProps.get_ItemValue(i)!=='') && arr.push({
value: specProps.get_ItemValue(i),
name: specProps.get_ItemDisplayText(i)
});
}
this.list.store.reset(arr);
this.txtNewValue.setValue('');
}
this.disableListButtons();
} else if (type == Asc.c_oAscContentControlSpecificType.CheckBox) {
specProps = props.get_CheckBoxPr();
this._originalCheckProps = specProps;
}
// form settings
var formPr = props.get_FormPr();
if (formPr) {
this._originalFormProps = formPr;
var data = [];
if (type == Asc.c_oAscContentControlSpecificType.CheckBox)
data = this.api.asc_GetCheckBoxFormKeys();
else if (type == Asc.c_oAscContentControlSpecificType.Picture) {
data = this.api.asc_GetPictureFormKeys();
this.labelFormName.text(this.textImage);
} else
data = this.api.asc_GetTextFormKeys();
var arr = [];
data.forEach(function(item) {
arr.push({ displayValue: item, value: item });
});
this.cmbKey.setData(arr);
val = formPr.get_Key();
this.cmbKey.setValue(val ? val : '');
val = formPr.get_HelpText();
if (this._state.help!==val) {
this.textareaHelp.setValue(val ? val : '');
this._state.help=val;
}
if (type == Asc.c_oAscContentControlSpecificType.CheckBox && specProps) {
val = specProps.get_GroupKey();
var ischeckbox = (typeof val !== 'string');
if (!ischeckbox) {
var arr = [];
this.api.asc_GetRadioButtonGroupKeys().forEach(function(item) {
arr.push({ displayValue: item, value: item });
});
this.cmbGroupKey.setData(arr);
this.cmbGroupKey.setValue(val ? val : '');
}
this.labelFormName.text(ischeckbox ? this.textCheckbox : this.textRadiobox);
}
}
var formTextPr = props.get_TextFormPr();
if (formTextPr) {
this._originalTextFormProps = formTextPr;
this.labelFormName.text(this.textField);
val = formTextPr.get_Comb();
if ( this._state.Comb!==val ) {
this.chComb.setValue(!!val, true);
this._state.Comb=val;
}
this.btnColor.setDisabled(!val);
this.spnWidth.setDisabled(!val);
val = formTextPr.get_Width();
if ( (val===undefined || this._state.Width===undefined)&&(this._state.Width!==val) || Math.abs(this._state.Width-val)>0.1) {
this.spnWidth.setValue(val!==0 && val!==undefined ? Common.Utils.Metric.fnRecalcFromMM(val * 25.4 / 20 / 72.0) : -1, true);
this._state.Width=val;
}
val = this.api.asc_GetTextFormAutoWidth();
if ( (this._state.WidthPlaceholder!==val) || Math.abs(this._state.WidthPlaceholder-val)>0.01) {
this.spnWidth.setDefaultValue(val!==undefined && val!==null ? Common.Utils.Metric.fnRecalcFromMM(val) : this.spnWidth.options.minValue);
this._state.WidthPlaceholder=val;
}
val = formTextPr.get_MaxCharacters();
this.chMaxChars.setValue(val && val>=0);
this.spnMaxChars.setDisabled(!val || val<0);
this.spnMaxChars.setValue(val && val>=0 ? val : 10);
var brd = formTextPr.get_CombBorder();
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.mnuColorPicker.selectByRGB(typeof(this.BorderColor) == 'object' ? this.BorderColor.color : this.BorderColor,true);
this._state.BorderColor = this.BorderColor;
}
}
this._noApply = false;
if (this.type !== type || type == Asc.c_oAscContentControlSpecificType.CheckBox)
this.showHideControls(type, formTextPr, specProps);
this.type = type;
}
},
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());
spinner.setStep(Common.Utils.Metric.getCurrentMetric()==Common.Utils.Metric.c_MetricUnits.pt ? 1 : 0.01);
}
}
},
UpdateThemeColors: function() {
if (this._initSettings) return;
if (!this.btnColor) {
this.btnColor = new Common.UI.ColorButton({
parentEl: (this.$el || $(this.el)).findById('#form-color-btn'),
transparent: true,
menu : true
});
this.lockedControls.push(this.btnColor);
this.btnColor.on('color:select', this.onColorPickerSelect.bind(this));
this.btnColor.setMenu();
this.mnuColorPicker = this.btnColor.getPicker();
}
this.mnuColorPicker.updateColors(Common.Utils.ThemeColor.getEffectColors(), Common.Utils.ThemeColor.getStandartColors());
this.mnuColorPicker.clearSelection();
this.BorderColor && this.mnuColorPicker.selectByRGB(typeof(this.BorderColor) == 'object' ? this.BorderColor.color : this.BorderColor,true);
},
onHideMenus: function(menu, e, isFromInputControl){
if (!isFromInputControl) this.fireEvent('editcomplete', this);
},
setLocked: function (locked) {
this._locked = locked;
},
disableControls: function(disable) {
if (this._initSettings) return;
var me = this;
if (this._state.DisabledControls!==(this._state.LockDelete || disable)) {
this._state.DisabledControls = this._state.LockDelete || disable;
_.each(this.lockedControls, function(item) {
item.setDisabled(me._state.DisabledControls);
});
}
this.btnLockForm.setDisabled(disable);
},
showHideControls: function(type, textProps, specProps) {
var textOnly = false,
checkboxOnly = false,
radioboxOnly = false,
listOnly = false,
imageOnly = false;
if (type == Asc.c_oAscContentControlSpecificType.ComboBox || type == Asc.c_oAscContentControlSpecificType.DropDownList) {
listOnly = !!specProps;
} else if (type == Asc.c_oAscContentControlSpecificType.CheckBox) {
if (specProps) {
checkboxOnly = (typeof specProps.get_GroupKey() !== 'string');
radioboxOnly = !checkboxOnly;
}
} else if (type == Asc.c_oAscContentControlSpecificType.Picture) {
imageOnly = true;
} else if (type == Asc.c_oAscContentControlSpecificType.None) {
textOnly = !!textProps;
}
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);
},
onSelectItem: function(listView, itemView, record) {
this.disableListButtons(false);
},
disableListButtons: function(disabled) {
if (disabled===undefined)
disabled = !this.list.getSelectedRec();
this.btnListDelete.setDisabled(disabled || this._state.DisabledControls);
this.btnListUp.setDisabled(disabled || this._state.DisabledControls);
this.btnListDown.setDisabled(disabled || this._state.DisabledControls);
},
textField: 'Text Field',
textKey: 'Key',
textPlaceholder: 'Placeholder',
textTip: 'Tip',
textMaxChars: 'Characters limit',
textComb: 'Comb of characters',
textWidth: 'Cell width',
textDelete: 'Delete',
textLock: 'Lock',
textUnlock: 'Unlock',
textRadiobox: 'Radio Button',
textCheckbox: 'Checkbox',
textCombobox: 'Combo Box',
textDropDown: 'Dropdown',
textImage: 'Image',
textGroupKey: 'Group key',
textTipAdd: 'Add new value',
textTipDelete: 'Delete value',
textTipUp: 'Move up',
textTipDown: 'Move down',
textValue: 'Value Options',
textSelectImage: 'Select Image',
textFromUrl: 'From URL',
textFromFile: 'From File',
textFromStorage: 'From Storage',
textColor: 'Border color'
}, DE.Views.FormSettings || {}));
});

View file

@ -0,0 +1,274 @@
/*
*
* (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
*
*/
/**
* FormsTab.js
*
* Created by Julia Radzhabova on 06.10.2020
* Copyright (c) 2020 Ascensio System SIA. All rights reserved.
*
*/
define([
'common/main/lib/util/utils',
'common/main/lib/component/BaseView',
'common/main/lib/component/Layout'
], function () {
'use strict';
DE.Views.FormsTab = Common.UI.BaseView.extend(_.extend((function(){
function setEvents() {
var me = this;
this.btnTextField.on('click', function (b, e) {
me.fireEvent('forms:insert', ['text']);
});
this.btnComboBox.on('click', function (b, e) {
me.fireEvent('forms:insert', ['combobox']);
});
this.btnDropDown.on('click', function (b, e) {
me.fireEvent('forms:insert', ['dropdown']);
});
this.btnCheckBox.on('click', function (b, e) {
me.fireEvent('forms:insert', ['checkbox']);
});
this.btnRadioBox.on('click', function (b, e) {
me.fireEvent('forms:insert', ['radiobox']);
});
this.btnImageField.on('click', function (b, e) {
me.fireEvent('forms:insert', ['picture']);
});
this.btnViewForm.on('click', function (b, e) {
me.fireEvent('forms:mode', [b.pressed]);
});
if (this.mnuFormsColorPicker) {
this.btnClearFields.on('click', function (b, e) {
me.fireEvent('forms:clear');
});
$('#id-toolbar-menu-new-form-color').on('click', function (b, e) {
me.fireEvent('forms:new-color');
});
this.mnuNoFormsColor.on('click', function (item) {
me.fireEvent('forms:no-color', [item]);
});
this.mnuFormsColorPicker.on('select', function(picker, color) {
me.fireEvent('forms:select-color', [color]);
});
this.btnHighlight.menu.on('show:after', function(picker, color) {
me.fireEvent('forms:open-color', [color]);
});
}
}
return {
options: {},
initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this);
this.toolbar = options.toolbar;
this.paragraphControls = [];
var me = this,
$host = me.toolbar.$el;
this.btnTextField = new Common.UI.Button({
parentEl: $host.find('#slot-btn-form-field'),
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-text-field',
caption: this.capBtnText,
disabled: true
});
this.paragraphControls.push(this.btnTextField);
this.btnComboBox = new Common.UI.Button({
parentEl: $host.find('#slot-btn-form-combobox'),
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-combo-box',
caption: this.capBtnComboBox,
disabled: true
});
this.paragraphControls.push(this.btnComboBox);
this.btnDropDown = new Common.UI.Button({
parentEl: $host.find('#slot-btn-form-dropdown'),
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-dropdown',
caption: this.capBtnDropDown,
disabled: true
});
this.paragraphControls.push(this.btnDropDown);
this.btnCheckBox = new Common.UI.Button({
parentEl: $host.find('#slot-btn-form-checkbox'),
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-checkbox',
caption: this.capBtnCheckBox,
disabled: true
});
this.paragraphControls.push(this.btnCheckBox);
this.btnRadioBox = new Common.UI.Button({
parentEl: $host.find('#slot-btn-form-radiobox'),
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-radio-button',
caption: this.capBtnRadioBox,
disabled: true
});
this.paragraphControls.push(this.btnRadioBox);
this.btnImageField = new Common.UI.Button({
parentEl: $host.find('#slot-btn-form-image'),
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-insertimage',
caption: this.capBtnImage,
disabled: true
});
this.paragraphControls.push(this.btnImageField);
this.btnViewForm = new Common.UI.Button({
parentEl: $host.find('#slot-btn-form-view'),
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-sheet-view',
caption: this.capBtnView,
enableToggle: true,
disabled: true
});
this.paragraphControls.push(this.btnViewForm);
this.btnClearFields = new Common.UI.Button({
parentEl : $host.find('#slot-form-clear-fields'),
cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-clearstyle',
caption : this.textClearFields,
disabled: true
});
this.paragraphControls.push(this.btnClearFields);
this.btnHighlight = new Common.UI.Button({
parentEl : $host.find('#slot-form-highlight'),
cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-highlight',
caption : this.textHighlight,
menu : true,
disabled: true
});
this.paragraphControls.push(this.btnHighlight);
this._state = {disabled: false};
Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this));
},
render: function (el) {
return this;
},
onAppReady: function (config) {
var me = this;
(new Promise(function (accept, reject) {
accept();
})).then(function(){
if (config.canEditContentControl) {
me.btnHighlight.setMenu(new Common.UI.Menu({
items: [
me.mnuNoFormsColor = new Common.UI.MenuItem({
id: 'id-toolbar-menu-no-highlight-form',
caption: me.textNoHighlight,
checkable: true
}),
{caption: '--'},
{template: _.template('<div id="id-toolbar-menu-form-color" style="width: 169px; height: 220px; margin: 10px;"></div>')},
{template: _.template('<a id="id-toolbar-menu-new-form-color" style="padding-left:12px;">' + me.textNewColor + '</a>')}
]
}));
me.mnuFormsColorPicker = new Common.UI.ThemeColorPalette({
el: $('#id-toolbar-menu-form-color')
});
var colorVal = $('<div class="btn-color-value-line"></div>');
$('button:first-child', me.btnHighlight.cmpEl).append(colorVal);
colorVal.css('background-color', me.btnHighlight.currentColor ? '#' + me.btnHighlight.currentColor : 'transparent');
} else {
me.btnHighlight.cmpEl.parents('.group').hide().prev('.separator').hide();
}
me.btnTextField.updateHint(me.tipTextField);
me.btnComboBox.updateHint(me.tipComboBox);
me.btnDropDown.updateHint(me.tipDropDown);
me.btnCheckBox.updateHint(me.tipCheckBox);
me.btnRadioBox.updateHint(me.tipRadioBox);
me.btnImageField.updateHint(me.tipImageField);
me.btnViewForm.updateHint(me.tipViewForm);
setEvents.call(me);
});
},
show: function () {
Common.UI.BaseView.prototype.show.call(this);
this.fireEvent('show', this);
},
getButtons: function() {
return this.paragraphControls;
},
SetDisabled: function (state) {
this._state.disabled = state;
this.paragraphControls.forEach(function(button) {
if ( button ) {
button.setDisabled(state);
}
}, this);
},
capBtnText: 'Text Field',
capBtnComboBox: 'Combo Box',
capBtnDropDown: 'Dropdown',
capBtnCheckBox: 'Checkbox',
capBtnRadioBox: 'Radio Button',
capBtnImage: 'Image',
capBtnView: 'View Form',
textClearFields: 'Clear All Fields',
textHighlight: 'Highlight Settings',
tipTextField: 'Insert text field',
tipComboBox: 'Insert combo box',
tipDropDown: 'Insert dropdown list',
tipCheckBox: 'Insert checkbox',
tipRadioBox: 'Insert radio button',
tipImageField: 'Insert image',
tipViewForm: 'Fill form mode',
textNoHighlight: 'No highlighting',
textNewColor: 'Add New Custom Color'
}
}()), DE.Views.FormsTab || {}));
});

View file

@ -58,6 +58,7 @@ define([
'documenteditor/main/app/view/MailMergeSettings',
'documenteditor/main/app/view/TextArtSettings',
'documenteditor/main/app/view/SignatureSettings',
'documenteditor/main/app/view/FormSettings',
'common/main/lib/component/Scroller'
], function (menuTemplate, $, _, Backbone) {
'use strict';
@ -210,6 +211,22 @@ define([
this.signatureSettings = new DE.Views.SignatureSettings();
}
if (mode && mode.canFeatureContentControl && mode.canEditContentControl) {
this.btnForm = new Common.UI.Button({
hint: this.txtFormSettings,
asctype: Common.Utils.documentSettingsType.Form,
enableToggle: true,
disabled: true,
toggleGroup: 'tabpanelbtnsGroup',
allowMouseEventsOnDisabled: true
});
this._settings[Common.Utils.documentSettingsType.Form] = {panel: "id-form-settings", btn: this.btnForm};
this.btnForm.setElement($markup.findById('#id-right-menu-form'), false); this.btnForm.render().setVisible(true);
this.btnForm.on('click', this.onBtnMenuClick.bind(this));
this.formSettings = new DE.Views.FormSettings();
}
if (_.isUndefined(this.scroller)) {
this.scroller = new Common.UI.Scroller({
el: $(this.el).find('.right-panel'),
@ -242,12 +259,14 @@ define([
this.textartSettings.setApi(api).on('editcomplete', _fire_editcomplete);
if (this.mergeSettings) this.mergeSettings.setApi(api).on('editcomplete', _fire_editcomplete);
if (this.signatureSettings) this.signatureSettings.setApi(api).on('editcomplete', _fire_editcomplete);
if (this.formSettings) this.formSettings.setApi(api).on('editcomplete', _fire_editcomplete);
},
setMode: function(mode) {
this.mergeSettings && this.mergeSettings.setMode(mode);
this.imageSettings && this.imageSettings.setMode(mode);
this.shapeSettings && this.shapeSettings.setMode(mode);
this.formSettings && this.formSettings.setMode(mode);
},
onBtnMenuClick: function(btn, e) {
@ -326,6 +345,7 @@ define([
txtTextArtSettings: 'Text Art Settings',
txtChartSettings: 'Chart Settings',
txtMailMergeSettings: 'Mail Merge Settings',
txtSignatureSettings: 'Signature Settings'
txtSignatureSettings: 'Signature Settings',
txtFormSettings: 'Form Settings'
}, DE.Views.RightMenu || {}));
});

View file

@ -645,31 +645,6 @@ define([
value: 'checkbox'
},
{caption: '--'},
{
caption: this.textNewFieldControl,
value: 'new-field'
},
{
caption: this.textNewPictureControl,
value: 'new-picture'
},
{
caption: this.textNewComboboxControl,
value: 'new-combobox'
},
{
caption: this.textNewDropdownControl,
value: 'new-dropdown'
},
{
caption: this.textNewCheckboxControl,
value: 'new-checkbox'
},
{
caption: this.textNewRadioboxControl,
value: 'new-radiobox'
},
{caption: '--'},
{
caption: this.textRemoveControl,
iconCls: 'menu__icon cc-remove',
@ -2041,7 +2016,7 @@ define([
this.btnMailRecepients.setVisible(mode.canCoAuthoring == true && mode.canUseMailMerge);
this.listStylesAdditionalMenuItem.setVisible(mode.canEditStyles);
this.btnContentControls.menu.items[17].setVisible(mode.canEditContentControl);
this.btnContentControls.menu.items[10].setVisible(mode.canEditContentControl);
this.mnuInsertImage.items[2].setVisible(this.mode.canRequestInsertImage || this.mode.fileChoiceUrl && this.mode.fileChoiceUrl.indexOf("{documentType}")>-1);
},
@ -2407,12 +2382,6 @@ define([
textListSettings: 'List Settings',
capBtnDateTime: 'Date & Time',
tipDateTime: 'Insert current date and time',
textNewFieldControl: 'New text field',
textNewPictureControl: 'New picture',
textNewComboboxControl: 'New combo box',
textNewCheckboxControl: 'New check box',
textNewRadioboxControl: 'New radio box',
textNewDropdownControl: 'New drop-down list',
capBtnLineNumbers: 'Line Numbers',
textContinuous: 'Continuous',
textRestartEachPage: 'Restart Each Page',

View file

@ -141,6 +141,7 @@ require([
'Toolbar',
'Statusbar',
'Links',
'FormsTab',
'Navigation',
'RightMenu',
'LeftMenu',
@ -166,6 +167,7 @@ require([
'documenteditor/main/app/controller/DocumentHolder',
'documenteditor/main/app/controller/Toolbar',
'documenteditor/main/app/controller/Links',
'documenteditor/main/app/controller/FormsTab',
'documenteditor/main/app/controller/Navigation',
'documenteditor/main/app/controller/Statusbar',
'documenteditor/main/app/controller/RightMenu',

Binary file not shown.

After

Width:  |  Height:  |  Size: 413 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1,004 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 576 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 525 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 512 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 909 B