2016-04-01 13:17:09 +00:00
|
|
|
/*
|
|
|
|
*
|
2019-01-17 13:05:03 +00:00
|
|
|
* (c) Copyright Ascensio System SIA 2010-2019
|
2016-04-01 13:17:09 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
2019-01-17 13:00:34 +00:00
|
|
|
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
|
|
|
|
* street, Riga, Latvia, EU, LV-1050.
|
2016-04-01 13:17:09 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
*/
|
2016-03-11 00:48:53 +00:00
|
|
|
/**
|
|
|
|
* RightMenu.js
|
|
|
|
*
|
|
|
|
* Created by Julia Radzhabova on 3/27/14
|
2018-03-01 12:16:38 +00:00
|
|
|
* Copyright (c) 2018 Ascensio System SIA. All rights reserved.
|
2016-03-11 00:48:53 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
define([
|
|
|
|
'core',
|
|
|
|
'spreadsheeteditor/main/app/view/RightMenu'
|
|
|
|
], function () {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
SSE.Controllers.RightMenu = Backbone.Controller.extend({
|
|
|
|
models: [],
|
|
|
|
collections: [],
|
|
|
|
views: [
|
|
|
|
'RightMenu'
|
|
|
|
],
|
|
|
|
|
|
|
|
initialize: function() {
|
|
|
|
this.editMode = true;
|
2021-09-06 23:02:15 +00:00
|
|
|
this._state = {wsLock: false, wsProps: []};
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
this.addListeners({
|
2017-04-27 15:25:02 +00:00
|
|
|
'Toolbar': {
|
|
|
|
'insertimage': this.onInsertImage.bind(this),
|
|
|
|
'insertshape': this.onInsertShape.bind(this),
|
|
|
|
'insertchart': this.onInsertChart.bind(this),
|
2018-06-14 13:40:27 +00:00
|
|
|
'inserttextart': this.onInsertTextArt.bind(this),
|
|
|
|
'inserttable': this.onInsertTable.bind(this)
|
2017-04-27 15:25:02 +00:00
|
|
|
},
|
2016-03-11 00:48:53 +00:00
|
|
|
'RightMenu': {
|
|
|
|
'rightmenuclick': this.onRightMenuClick
|
2020-03-27 13:46:09 +00:00
|
|
|
},
|
|
|
|
'PivotTable': {
|
|
|
|
'insertpivot': this.onInsertPivot
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
});
|
2020-08-13 19:11:20 +00:00
|
|
|
|
|
|
|
Common.Utils.InternalSettings.set("sse-rightpanel-active-table", 1);
|
|
|
|
Common.Utils.InternalSettings.set("sse-rightpanel-active-pivot", 1);
|
|
|
|
Common.Utils.InternalSettings.set("sse-rightpanel-active-spark", 1);
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onLaunch: function() {
|
|
|
|
this.rightmenu = this.createView('RightMenu');
|
|
|
|
this.rightmenu.on('render:after', _.bind(this.onRightMenuAfterRender, this));
|
|
|
|
},
|
|
|
|
|
|
|
|
onRightMenuAfterRender: function(rightMenu) {
|
|
|
|
rightMenu.shapeSettings.application = rightMenu.textartSettings.application = this.getApplication();
|
|
|
|
|
|
|
|
this._settings = [];
|
|
|
|
this._settings[Common.Utils.documentSettingsType.Paragraph] = {panelId: "id-paragraph-settings", panel: rightMenu.paragraphSettings,btn: rightMenu.btnText, hidden: 1, locked: false};
|
|
|
|
this._settings[Common.Utils.documentSettingsType.Image] = {panelId: "id-image-settings", panel: rightMenu.imageSettings, btn: rightMenu.btnImage, hidden: 1, locked: false};
|
|
|
|
this._settings[Common.Utils.documentSettingsType.Shape] = {panelId: "id-shape-settings", panel: rightMenu.shapeSettings, btn: rightMenu.btnShape, hidden: 1, locked: false};
|
|
|
|
this._settings[Common.Utils.documentSettingsType.TextArt] = {panelId: "id-textart-settings", panel: rightMenu.textartSettings, btn: rightMenu.btnTextArt, hidden: 1, locked: false};
|
2016-03-29 08:11:58 +00:00
|
|
|
this._settings[Common.Utils.documentSettingsType.Chart] = {panelId: "id-chart-settings", panel: rightMenu.chartSettings, btn: rightMenu.btnChart, hidden: 1, locked: false};
|
|
|
|
this._settings[Common.Utils.documentSettingsType.Table] = {panelId: "id-table-settings", panel: rightMenu.tableSettings, btn: rightMenu.btnTable, hidden: 1, locked: false};
|
2017-07-11 11:02:16 +00:00
|
|
|
this._settings[Common.Utils.documentSettingsType.Pivot] = {panelId: "id-pivot-settings", panel: rightMenu.pivotSettings, btn: rightMenu.btnPivot, hidden: 1, locked: false};
|
2017-11-17 14:35:40 +00:00
|
|
|
this._settings[Common.Utils.documentSettingsType.Signature] = {panelId: "id-signature-settings", panel: rightMenu.signatureSettings, btn: rightMenu.btnSignature, hidden: 1, props: {}, locked: false};
|
2018-06-09 11:11:56 +00:00
|
|
|
this._settings[Common.Utils.documentSettingsType.Cell] = {panelId: "id-cell-settings", panel: rightMenu.cellSettings, btn: rightMenu.btnCell, hidden: 1, locked: false};
|
2020-05-27 13:33:34 +00:00
|
|
|
this._settings[Common.Utils.documentSettingsType.Slicer] = {panelId: "id-slicer-settings", panel: rightMenu.slicerSettings, btn: rightMenu.btnSlicer, hidden: 1, locked: false};
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
setApi: function(api) {
|
|
|
|
this.api = api;
|
2017-11-17 14:35:40 +00:00
|
|
|
this.api.asc_registerCallback('asc_onUpdateSignatures', _.bind(this.onApiUpdateSignatures, this));
|
2016-03-11 00:48:53 +00:00
|
|
|
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this));
|
|
|
|
Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this));
|
2016-05-25 14:09:55 +00:00
|
|
|
Common.NotificationCenter.on('cells:range', _.bind(this.onCellsRange, this));
|
2021-07-19 17:48:36 +00:00
|
|
|
Common.NotificationCenter.on('protect:wslock', _.bind(this.onChangeProtectSheet, this));
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
setMode: function(mode) {
|
|
|
|
this.editMode = mode.isEdit;
|
|
|
|
},
|
|
|
|
|
2020-03-27 13:46:09 +00:00
|
|
|
onRightMenuClick: function(menu, type, minimized, event) {
|
2016-03-11 00:48:53 +00:00
|
|
|
if (!minimized && this.editMode) {
|
2020-03-27 13:46:09 +00:00
|
|
|
if (event) { // user click event
|
2020-08-11 12:58:51 +00:00
|
|
|
if (type == Common.Utils.documentSettingsType.Table) {
|
2020-08-13 19:11:20 +00:00
|
|
|
Common.Utils.InternalSettings.set("sse-rightpanel-active-table", 2);
|
|
|
|
if (!this._settings[Common.Utils.documentSettingsType.Chart].hidden) {
|
|
|
|
Common.Utils.InternalSettings.set("sse-rightpanel-active-spark", Math.min(Common.Utils.InternalSettings.get("sse-rightpanel-active-spark"), 1));
|
|
|
|
}
|
2020-08-11 12:58:51 +00:00
|
|
|
} else if (type == Common.Utils.documentSettingsType.Pivot)
|
2020-03-27 13:46:09 +00:00
|
|
|
Common.Utils.InternalSettings.set("sse-rightpanel-active-pivot", 1);
|
2020-08-11 12:58:51 +00:00
|
|
|
else if (type == Common.Utils.documentSettingsType.Chart && !this._settings[Common.Utils.documentSettingsType.Cell].hidden) {//sparkline
|
2020-08-13 19:11:20 +00:00
|
|
|
Common.Utils.InternalSettings.set("sse-rightpanel-active-spark", 2);
|
|
|
|
if (!this._settings[Common.Utils.documentSettingsType.Table].hidden) {
|
|
|
|
Common.Utils.InternalSettings.set("sse-rightpanel-active-table", Math.min(Common.Utils.InternalSettings.get("sse-rightpanel-active-table"), 1));
|
|
|
|
}
|
2020-08-11 12:58:51 +00:00
|
|
|
} else if (Common.Utils.documentSettingsType.Cell) {
|
2020-03-27 13:46:09 +00:00
|
|
|
if (!this._settings[Common.Utils.documentSettingsType.Table].hidden)
|
|
|
|
Common.Utils.InternalSettings.set("sse-rightpanel-active-table", 0);
|
|
|
|
if (!this._settings[Common.Utils.documentSettingsType.Pivot].hidden)
|
|
|
|
Common.Utils.InternalSettings.set("sse-rightpanel-active-pivot", 0);
|
2020-08-11 12:58:51 +00:00
|
|
|
if (!this._settings[Common.Utils.documentSettingsType.Chart].hidden)
|
|
|
|
Common.Utils.InternalSettings.set("sse-rightpanel-active-spark", 0);
|
2020-03-27 13:46:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
var panel = this._settings[type].panel;
|
|
|
|
var props = this._settings[type].props;
|
|
|
|
if (props && panel)
|
2021-07-19 17:52:32 +00:00
|
|
|
panel.ChangeSettings.call(panel, (type==Common.Utils.documentSettingsType.Signature) ? undefined : props, this._state.wsLock, this._state.wsProps);
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
Common.NotificationCenter.trigger('layout:changed', 'rightmenu');
|
|
|
|
},
|
|
|
|
|
|
|
|
onSelectionChanged: function(info) {
|
2016-05-25 14:09:55 +00:00
|
|
|
if (this.rangeSelectionMode) return;
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
var SelectedObjects = [],
|
2020-05-14 08:39:04 +00:00
|
|
|
selectType = info.asc_getSelectionType(),
|
2016-09-14 13:34:08 +00:00
|
|
|
formatTableInfo = info.asc_getFormatTableInfo(),
|
2017-07-11 11:02:16 +00:00
|
|
|
sparkLineInfo = info.asc_getSparklineInfo(),
|
2018-06-09 11:11:56 +00:00
|
|
|
cellInfo = info,
|
2019-07-22 11:40:44 +00:00
|
|
|
pivotInfo = info.asc_getPivotTableInfo();
|
2016-03-11 00:48:53 +00:00
|
|
|
|
2020-06-05 16:28:11 +00:00
|
|
|
if (selectType == Asc.c_oAscSelectionType.RangeImage || selectType == Asc.c_oAscSelectionType.RangeShape || selectType == Asc.c_oAscSelectionType.RangeSlicer ||
|
2016-04-05 11:52:34 +00:00
|
|
|
selectType == Asc.c_oAscSelectionType.RangeChart || selectType == Asc.c_oAscSelectionType.RangeChartText || selectType == Asc.c_oAscSelectionType.RangeShapeText) {
|
2016-03-11 00:48:53 +00:00
|
|
|
SelectedObjects = this.api.asc_getGraphicObjectProps();
|
|
|
|
}
|
2016-03-29 08:11:58 +00:00
|
|
|
|
2018-06-09 11:11:56 +00:00
|
|
|
if (SelectedObjects.length<=0 && !cellInfo && !formatTableInfo && !sparkLineInfo && !pivotInfo && !this.rightmenu.minimizedMode &&
|
2017-11-10 07:50:01 +00:00
|
|
|
this.rightmenu.GetActivePane() !== 'id-signature-settings') {
|
2016-03-11 00:48:53 +00:00
|
|
|
this.rightmenu.clearSelection();
|
2016-04-11 07:29:53 +00:00
|
|
|
this._openRightMenu = true;
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
2018-06-09 11:11:56 +00:00
|
|
|
this.onFocusObject(SelectedObjects, cellInfo, formatTableInfo, sparkLineInfo, pivotInfo);
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
2021-08-30 20:12:11 +00:00
|
|
|
onFocusObject: function(SelectedObjects, cellInfo, formatTableInfo, sparkLineInfo, pivotInfo, forceSignature) {
|
|
|
|
if (!this.editMode && !forceSignature)
|
2016-03-11 00:48:53 +00:00
|
|
|
return;
|
|
|
|
|
2021-08-30 20:12:11 +00:00
|
|
|
var isCellLocked = cellInfo && cellInfo.asc_getLocked() || this._state.wsProps['FormatCells'],
|
|
|
|
isTableLocked = (cellInfo && cellInfo.asc_getLockedTable()===true || !this.rightmenu.mode.canModifyFilter) || this._state.wsProps['FormatCells'],
|
|
|
|
isSparkLocked = (cellInfo && cellInfo.asc_getLockedSparkline()===true) || this._state.wsLock,
|
|
|
|
isPivotLocked = (cellInfo && cellInfo.asc_getLockedPivotTable()===true) || this._state.wsProps['PivotTables'];
|
2018-06-09 11:11:56 +00:00
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
for (var i=0; i<this._settings.length; ++i) {
|
2017-09-13 08:57:30 +00:00
|
|
|
if (i==Common.Utils.documentSettingsType.Signature) continue;
|
2016-03-11 00:48:53 +00:00
|
|
|
if (this._settings[i]) {
|
|
|
|
this._settings[i].hidden = 1;
|
|
|
|
this._settings[i].locked = false;
|
|
|
|
}
|
|
|
|
}
|
2017-09-13 08:57:30 +00:00
|
|
|
this._settings[Common.Utils.documentSettingsType.Signature].locked = false;
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
for (i=0; i<SelectedObjects.length; ++i)
|
|
|
|
{
|
|
|
|
var eltype = SelectedObjects[i].asc_getObjectType(),
|
|
|
|
settingsType = this.getDocumentSettingsType(eltype);
|
|
|
|
if (settingsType===undefined || settingsType>=this._settings.length || this._settings[settingsType]===undefined)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
var value = SelectedObjects[i].asc_getObjectValue();
|
|
|
|
if (settingsType == Common.Utils.documentSettingsType.Image) {
|
|
|
|
if (value.asc_getChartProperties() !== null) {
|
|
|
|
settingsType = Common.Utils.documentSettingsType.Chart;
|
2016-12-23 10:03:08 +00:00
|
|
|
this._settings[settingsType].btn.updateHint(this.rightmenu.txtChartSettings);
|
2016-03-11 00:48:53 +00:00
|
|
|
} else if (value.asc_getShapeProperties() !== null) {
|
|
|
|
settingsType = Common.Utils.documentSettingsType.Shape;
|
|
|
|
if (value.asc_getShapeProperties().asc_getTextArtProperties()) {
|
|
|
|
this._settings[Common.Utils.documentSettingsType.TextArt].props = value;
|
|
|
|
this._settings[Common.Utils.documentSettingsType.TextArt].hidden = 0;
|
2021-07-19 17:48:36 +00:00
|
|
|
this._settings[Common.Utils.documentSettingsType.TextArt].locked = value.asc_getLocked() || this._state.wsProps['Objects'];
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
2020-05-27 13:33:34 +00:00
|
|
|
} else if (value.asc_getSlicerProperties() !== null) {
|
|
|
|
settingsType = Common.Utils.documentSettingsType.Slicer;
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this._settings[settingsType].props = value;
|
|
|
|
this._settings[settingsType].hidden = 0;
|
2021-07-19 17:48:36 +00:00
|
|
|
|
|
|
|
this._settings[settingsType].locked = value.asc_getLocked() || this._state.wsProps['Objects'];
|
2017-09-13 08:57:30 +00:00
|
|
|
|
|
|
|
if (!this._settings[Common.Utils.documentSettingsType.Signature].locked) // lock Signature, если хотя бы один объект locked
|
|
|
|
this._settings[Common.Utils.documentSettingsType.Signature].locked = value.asc_getLocked();
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
2016-03-29 14:35:28 +00:00
|
|
|
if (formatTableInfo) {
|
2016-03-29 08:11:58 +00:00
|
|
|
settingsType = Common.Utils.documentSettingsType.Table;
|
2016-03-29 14:35:28 +00:00
|
|
|
this._settings[settingsType].props = formatTableInfo;
|
2016-11-24 07:23:02 +00:00
|
|
|
this._settings[settingsType].locked = isTableLocked;
|
2016-03-29 08:11:58 +00:00
|
|
|
this._settings[settingsType].hidden = 0;
|
|
|
|
}
|
2016-09-14 13:34:08 +00:00
|
|
|
|
|
|
|
if (sparkLineInfo) {
|
|
|
|
settingsType = Common.Utils.documentSettingsType.Chart;
|
|
|
|
this._settings[settingsType].props = sparkLineInfo;
|
2016-11-24 12:26:22 +00:00
|
|
|
this._settings[settingsType].locked = isSparkLocked;
|
2016-09-14 13:34:08 +00:00
|
|
|
this._settings[settingsType].hidden = 0;
|
2016-12-23 10:03:08 +00:00
|
|
|
this._settings[settingsType].btn.updateHint(this.rightmenu.txtSparklineSettings);
|
2016-09-14 13:34:08 +00:00
|
|
|
}
|
|
|
|
|
2020-03-20 14:58:03 +00:00
|
|
|
if (pivotInfo && this.rightmenu.mode.canFeaturePivot) {
|
2019-07-22 11:40:44 +00:00
|
|
|
settingsType = Common.Utils.documentSettingsType.Pivot;
|
|
|
|
this._settings[settingsType].props = pivotInfo;
|
|
|
|
this._settings[settingsType].locked = isPivotLocked; // disable pivot settings
|
|
|
|
this._settings[settingsType].hidden = 0;
|
|
|
|
}
|
2017-07-11 11:02:16 +00:00
|
|
|
|
2021-08-30 20:12:11 +00:00
|
|
|
if (SelectedObjects.length<=0 && cellInfo) { // cell is selected
|
2018-06-09 11:11:56 +00:00
|
|
|
settingsType = Common.Utils.documentSettingsType.Cell;
|
|
|
|
this._settings[settingsType].props = cellInfo;
|
|
|
|
this._settings[settingsType].locked = isCellLocked;
|
|
|
|
this._settings[settingsType].hidden = 0;
|
|
|
|
}
|
|
|
|
|
2016-10-18 08:58:27 +00:00
|
|
|
var lastactive = -1, currentactive, priorityactive = -1,
|
|
|
|
activePane = this.rightmenu.GetActivePane();
|
2016-03-11 00:48:53 +00:00
|
|
|
for (i=0; i<this._settings.length; ++i) {
|
|
|
|
var pnl = this._settings[i];
|
2017-09-13 08:57:30 +00:00
|
|
|
if (pnl===undefined || pnl.btn===undefined || pnl.panel===undefined) continue;
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
if ( pnl.hidden ) {
|
2018-06-09 11:11:56 +00:00
|
|
|
if (!pnl.btn.isDisabled()) pnl.btn.setDisabled(true);
|
2016-10-18 08:58:27 +00:00
|
|
|
if (activePane == pnl.panelId)
|
2016-03-11 00:48:53 +00:00
|
|
|
currentactive = -1;
|
|
|
|
} else {
|
2018-06-09 11:11:56 +00:00
|
|
|
if (pnl.btn.isDisabled()) pnl.btn.setDisabled(false);
|
2017-09-13 08:57:30 +00:00
|
|
|
if (i!=Common.Utils.documentSettingsType.Signature) lastactive = i;
|
2016-03-11 00:48:53 +00:00
|
|
|
if ( pnl.needShow ) {
|
|
|
|
pnl.needShow = false;
|
|
|
|
priorityactive = i;
|
2016-10-18 08:58:27 +00:00
|
|
|
} else if (activePane == pnl.panelId)
|
2016-03-11 00:48:53 +00:00
|
|
|
currentactive = i;
|
|
|
|
pnl.panel.setLocked(pnl.locked);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-30 08:51:07 +00:00
|
|
|
if (!this.rightmenu.minimizedMode || this._openRightMenu) {
|
2016-03-11 00:48:53 +00:00
|
|
|
var active;
|
|
|
|
|
2020-03-27 13:46:09 +00:00
|
|
|
if (priorityactive<0 && !this._settings[Common.Utils.documentSettingsType.Cell].hidden &&
|
2020-08-11 12:58:51 +00:00
|
|
|
(!this._settings[Common.Utils.documentSettingsType.Table].hidden || !this._settings[Common.Utils.documentSettingsType.Pivot].hidden ||
|
|
|
|
!this._settings[Common.Utils.documentSettingsType.Chart].hidden)) {
|
2020-08-13 19:11:20 +00:00
|
|
|
var tableactive = Common.Utils.InternalSettings.get("sse-rightpanel-active-table"),
|
|
|
|
pivotactive = Common.Utils.InternalSettings.get("sse-rightpanel-active-pivot"),
|
|
|
|
sparkactive = Common.Utils.InternalSettings.get("sse-rightpanel-active-spark");
|
|
|
|
if (!this._settings[Common.Utils.documentSettingsType.Table].hidden && !this._settings[Common.Utils.documentSettingsType.Chart].hidden) {
|
|
|
|
if (tableactive == sparkactive)
|
|
|
|
priorityactive = (tableactive===0) ? Common.Utils.documentSettingsType.Cell : Common.Utils.documentSettingsType.Chart;
|
|
|
|
else
|
|
|
|
priorityactive = (tableactive > sparkactive) ? Common.Utils.documentSettingsType.Table : Common.Utils.documentSettingsType.Chart;
|
|
|
|
} else if (!this._settings[Common.Utils.documentSettingsType.Table].hidden) {
|
|
|
|
priorityactive = (tableactive===0) ? Common.Utils.documentSettingsType.Cell : Common.Utils.documentSettingsType.Table;
|
|
|
|
} else if (!this._settings[Common.Utils.documentSettingsType.Chart].hidden) {
|
|
|
|
priorityactive = (sparkactive===0) ? Common.Utils.documentSettingsType.Cell : Common.Utils.documentSettingsType.Chart;
|
|
|
|
}
|
2020-03-27 13:46:09 +00:00
|
|
|
if (!this._settings[Common.Utils.documentSettingsType.Pivot].hidden)
|
2020-08-13 19:11:20 +00:00
|
|
|
priorityactive = (pivotactive===0) ? Common.Utils.documentSettingsType.Cell : Common.Utils.documentSettingsType.Pivot;
|
2020-03-27 13:46:09 +00:00
|
|
|
}
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
if (priorityactive>-1) active = priorityactive;
|
|
|
|
else if (lastactive>=0 && currentactive<0) active = lastactive;
|
|
|
|
else if (currentactive>=0) active = currentactive;
|
2021-08-30 20:12:11 +00:00
|
|
|
else if (forceSignature && !this._settings[Common.Utils.documentSettingsType.Signature].hidden) active = Common.Utils.documentSettingsType.Signature;
|
2016-03-11 00:48:53 +00:00
|
|
|
|
2016-03-30 08:51:07 +00:00
|
|
|
if (active == undefined && this._openRightMenu && lastactive>=0)
|
|
|
|
active = lastactive;
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
if (active !== undefined) {
|
2016-03-30 08:51:07 +00:00
|
|
|
this.rightmenu.SetActivePane(active, this._openRightMenu);
|
2017-09-13 08:57:30 +00:00
|
|
|
if (active!=Common.Utils.documentSettingsType.Signature)
|
2021-07-19 17:48:36 +00:00
|
|
|
this._settings[active].panel.ChangeSettings.call(this._settings[active].panel, this._settings[active].props, this._state.wsLock, this._state.wsProps);
|
2017-09-13 08:57:30 +00:00
|
|
|
else
|
|
|
|
this._settings[active].panel.ChangeSettings.call(this._settings[active].panel);
|
2016-03-30 08:51:07 +00:00
|
|
|
this._openRightMenu = false;
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this._settings[Common.Utils.documentSettingsType.Image].needShow = false;
|
|
|
|
this._settings[Common.Utils.documentSettingsType.Chart].needShow = false;
|
2018-06-14 13:40:27 +00:00
|
|
|
this._settings[Common.Utils.documentSettingsType.Table].needShow = false;
|
2020-03-27 13:46:09 +00:00
|
|
|
this._settings[Common.Utils.documentSettingsType.Pivot].needShow = false;
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onCoAuthoringDisconnect: function() {
|
2016-04-21 10:15:15 +00:00
|
|
|
this.SetDisabled(true);
|
2016-03-11 00:48:53 +00:00
|
|
|
this.setMode({isEdit: false});
|
|
|
|
},
|
|
|
|
|
|
|
|
onInsertImage: function() {
|
|
|
|
this._settings[Common.Utils.documentSettingsType.Image].needShow = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
onInsertChart: function() {
|
|
|
|
this._settings[Common.Utils.documentSettingsType.Chart].needShow = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
onInsertShape: function() {
|
|
|
|
this._settings[Common.Utils.documentSettingsType.Shape].needShow = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
onInsertTextArt: function() {
|
|
|
|
this._settings[Common.Utils.documentSettingsType.TextArt].needShow = true;
|
|
|
|
},
|
2018-06-14 13:40:27 +00:00
|
|
|
|
|
|
|
onInsertTable: function() {
|
2020-03-27 13:46:09 +00:00
|
|
|
// this._settings[Common.Utils.documentSettingsType.Table].needShow = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
onInsertPivot: function() {
|
|
|
|
// this._settings[Common.Utils.documentSettingsType.Pivot].needShow = true;
|
2018-06-14 13:40:27 +00:00
|
|
|
},
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
UpdateThemeColors: function() {
|
|
|
|
this.rightmenu.shapeSettings.UpdateThemeColors();
|
|
|
|
this.rightmenu.textartSettings.UpdateThemeColors();
|
2016-09-14 13:34:08 +00:00
|
|
|
this.rightmenu.chartSettings.UpdateThemeColors();
|
2018-06-09 11:11:56 +00:00
|
|
|
this.rightmenu.cellSettings.UpdateThemeColors();
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
updateMetricUnit: function() {
|
|
|
|
this.rightmenu.paragraphSettings.updateMetricUnit();
|
|
|
|
this.rightmenu.chartSettings.updateMetricUnit();
|
|
|
|
this.rightmenu.imageSettings.updateMetricUnit();
|
2020-05-27 13:33:34 +00:00
|
|
|
this.rightmenu.slicerSettings.updateMetricUnit();
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
createDelayedElements: function() {
|
|
|
|
var me = this;
|
|
|
|
if (this.api) {
|
2018-10-26 09:49:11 +00:00
|
|
|
this._openRightMenu = !Common.localStorage.getBool("sse-hide-right-settings", this.rightmenu.defaultHideRightMenu);
|
2016-03-30 08:51:07 +00:00
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
this.api.asc_registerCallback('asc_onSelectionChanged', _.bind(this.onSelectionChanged, this));
|
|
|
|
this.api.asc_registerCallback('asc_doubleClickOnObject', _.bind(this.onDoubleClickOnObject, this));
|
2019-10-04 14:12:54 +00:00
|
|
|
// this.rightmenu.shapeSettings.createDelayedElements();
|
2021-07-19 17:48:36 +00:00
|
|
|
this.onChangeProtectSheet();
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onDoubleClickOnObject: function(obj) {
|
|
|
|
if (!this.editMode) return;
|
|
|
|
|
|
|
|
var eltype = obj.asc_getObjectType(),
|
|
|
|
settingsType = this.getDocumentSettingsType(eltype);
|
|
|
|
if (settingsType===undefined || settingsType>=this._settings.length || this._settings[settingsType]===undefined)
|
|
|
|
return;
|
|
|
|
|
|
|
|
var value = obj.asc_getObjectValue();
|
|
|
|
if (settingsType == Common.Utils.documentSettingsType.Image) {
|
|
|
|
if (value.asc_getChartProperties() !== null) {
|
|
|
|
settingsType = Common.Utils.documentSettingsType.Chart;
|
|
|
|
} else if (value.asc_getShapeProperties() !== null) {
|
|
|
|
settingsType = Common.Utils.documentSettingsType.Shape;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settingsType !== Common.Utils.documentSettingsType.Paragraph) {
|
|
|
|
this.rightmenu.SetActivePane(settingsType, true);
|
2021-07-19 17:48:36 +00:00
|
|
|
this._settings[settingsType].panel.ChangeSettings.call(this._settings[settingsType].panel, this._settings[settingsType].props, this._state.wsLock, this._state.wsProps);
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
getDocumentSettingsType: function(type) {
|
|
|
|
switch (type) {
|
2016-04-05 11:52:34 +00:00
|
|
|
case Asc.c_oAscTypeSelectElement.Paragraph:
|
2016-03-11 00:48:53 +00:00
|
|
|
return Common.Utils.documentSettingsType.Paragraph;
|
2016-04-05 11:52:34 +00:00
|
|
|
case Asc.c_oAscTypeSelectElement.Image:
|
2016-03-11 00:48:53 +00:00
|
|
|
return Common.Utils.documentSettingsType.Image;
|
|
|
|
}
|
2016-04-21 10:15:15 +00:00
|
|
|
},
|
|
|
|
|
2017-11-17 14:35:40 +00:00
|
|
|
onApiUpdateSignatures: function(valid, requested){
|
|
|
|
if (!this.rightmenu.signatureSettings) return;
|
|
|
|
|
|
|
|
var disabled = (!valid || valid.length<1) && (!requested || requested.length<1),
|
|
|
|
type = Common.Utils.documentSettingsType.Signature;
|
|
|
|
this._settings[type].hidden = disabled ? 1 : 0;
|
|
|
|
this._settings[type].btn.setDisabled(disabled);
|
|
|
|
this._settings[type].panel.setLocked(this._settings[type].locked);
|
|
|
|
},
|
|
|
|
|
2017-11-10 07:50:01 +00:00
|
|
|
SetDisabled: function(disabled, allowSignature) {
|
|
|
|
this.setMode({isEdit: !disabled});
|
2020-09-22 18:16:38 +00:00
|
|
|
if (this.rightmenu && this.rightmenu.paragraphSettings) {
|
2016-04-21 10:15:15 +00:00
|
|
|
this.rightmenu.paragraphSettings.disableControls(disabled);
|
|
|
|
this.rightmenu.shapeSettings.disableControls(disabled);
|
|
|
|
this.rightmenu.imageSettings.disableControls(disabled);
|
|
|
|
this.rightmenu.chartSettings.disableControls(disabled);
|
|
|
|
this.rightmenu.tableSettings.disableControls(disabled);
|
2017-07-11 11:02:16 +00:00
|
|
|
this.rightmenu.pivotSettings.disableControls(disabled);
|
2018-10-12 12:48:30 +00:00
|
|
|
this.rightmenu.cellSettings.disableControls(disabled);
|
2020-05-27 13:33:34 +00:00
|
|
|
this.rightmenu.slicerSettings.disableControls(disabled);
|
2016-04-21 10:15:15 +00:00
|
|
|
|
2021-08-30 20:12:11 +00:00
|
|
|
if (this.rightmenu.signatureSettings) {
|
|
|
|
!allowSignature && this.rightmenu.btnSignature.setDisabled(disabled);
|
|
|
|
allowSignature && disabled && this.onFocusObject([], undefined, undefined, undefined, undefined, true); // force press signature button
|
2017-11-27 11:15:10 +00:00
|
|
|
}
|
|
|
|
|
2016-04-21 10:15:15 +00:00
|
|
|
if (disabled) {
|
|
|
|
this.rightmenu.btnText.setDisabled(disabled);
|
|
|
|
this.rightmenu.btnTable.setDisabled(disabled);
|
|
|
|
this.rightmenu.btnImage.setDisabled(disabled);
|
|
|
|
this.rightmenu.btnShape.setDisabled(disabled);
|
|
|
|
this.rightmenu.btnTextArt.setDisabled(disabled);
|
|
|
|
this.rightmenu.btnChart.setDisabled(disabled);
|
2017-07-11 11:02:16 +00:00
|
|
|
this.rightmenu.btnPivot.setDisabled(disabled);
|
2018-10-12 12:48:30 +00:00
|
|
|
this.rightmenu.btnCell.setDisabled(disabled);
|
2020-05-27 13:33:34 +00:00
|
|
|
this.rightmenu.btnSlicer.setDisabled(disabled);
|
2016-04-21 10:15:15 +00:00
|
|
|
} else {
|
|
|
|
this.onSelectionChanged(this.api.asc_getCellInfo());
|
|
|
|
}
|
|
|
|
}
|
2016-05-25 14:09:55 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onCellsRange: function(status) {
|
|
|
|
this.rangeSelectionMode = (status != Asc.c_oAscSelectionDialogType.None);
|
2021-07-19 17:48:36 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onChangeProtectSheet: function(props) {
|
|
|
|
if (!props) {
|
|
|
|
var wbprotect = this.getApplication().getController('WBProtection');
|
|
|
|
props = wbprotect ? wbprotect.getWSProps() : null;
|
|
|
|
}
|
2021-09-06 23:02:15 +00:00
|
|
|
if (props) {
|
|
|
|
this._state.wsProps = props.wsProps;
|
|
|
|
this._state.wsLock = props.wsLock;
|
|
|
|
}
|
2021-07-19 17:48:36 +00:00
|
|
|
this.onSelectionChanged(this.api.asc_getCellInfo());
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|