2016-04-01 13:17:09 +00:00
|
|
|
/*
|
|
|
|
*
|
2019-01-17 12:58:05 +00:00
|
|
|
* (c) Copyright Ascensio System Limited 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
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
var SCALE_MIN = 40;
|
|
|
|
var MENU_SCALE_PART = 260;
|
|
|
|
|
|
|
|
define([
|
|
|
|
'text!spreadsheeteditor/main/app/template/RightMenu.template',
|
|
|
|
'jquery',
|
|
|
|
'underscore',
|
|
|
|
'backbone',
|
|
|
|
'common/main/lib/component/Button',
|
|
|
|
'common/main/lib/component/MetricSpinner',
|
|
|
|
'common/main/lib/component/CheckBox',
|
|
|
|
'spreadsheeteditor/main/app/view/ParagraphSettings',
|
|
|
|
'spreadsheeteditor/main/app/view/ImageSettings',
|
|
|
|
'spreadsheeteditor/main/app/view/ChartSettings',
|
|
|
|
'spreadsheeteditor/main/app/view/ShapeSettings',
|
|
|
|
'spreadsheeteditor/main/app/view/TextArtSettings',
|
2016-03-29 08:11:58 +00:00
|
|
|
'spreadsheeteditor/main/app/view/TableSettings',
|
2017-07-11 11:02:16 +00:00
|
|
|
'spreadsheeteditor/main/app/view/PivotSettings',
|
2017-09-13 08:57:30 +00:00
|
|
|
'spreadsheeteditor/main/app/view/SignatureSettings',
|
2018-06-09 11:11:56 +00:00
|
|
|
'spreadsheeteditor/main/app/view/CellSettings',
|
2016-03-11 00:48:53 +00:00
|
|
|
'common/main/lib/component/Scroller'
|
|
|
|
], function (menuTemplate, $, _, Backbone) {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
SSE.Views.RightMenu = Backbone.View.extend(_.extend({
|
|
|
|
el: '#right-menu',
|
|
|
|
|
|
|
|
// Compile our stats template
|
|
|
|
template: _.template(menuTemplate),
|
|
|
|
|
|
|
|
// Delegated events for creating new items, and clearing completed ones.
|
|
|
|
events: {
|
|
|
|
},
|
|
|
|
|
|
|
|
initialize: function () {
|
|
|
|
this.minimizedMode = true;
|
|
|
|
|
|
|
|
this.btnText = new Common.UI.Button({
|
|
|
|
hint: this.txtParagraphSettings,
|
|
|
|
asctype: Common.Utils.documentSettingsType.Paragraph,
|
|
|
|
enableToggle: true,
|
|
|
|
disabled: true,
|
2017-04-11 11:05:56 +00:00
|
|
|
toggleGroup: 'tabpanelbtnsGroup',
|
|
|
|
allowMouseEventsOnDisabled: true
|
2016-03-11 00:48:53 +00:00
|
|
|
});
|
|
|
|
this.btnImage = new Common.UI.Button({
|
|
|
|
hint: this.txtImageSettings,
|
|
|
|
asctype: Common.Utils.documentSettingsType.Image,
|
|
|
|
enableToggle: true,
|
|
|
|
disabled: true,
|
2017-04-11 11:05:56 +00:00
|
|
|
toggleGroup: 'tabpanelbtnsGroup',
|
|
|
|
allowMouseEventsOnDisabled: true
|
2016-03-11 00:48:53 +00:00
|
|
|
});
|
|
|
|
this.btnChart = new Common.UI.Button({
|
|
|
|
hint: this.txtChartSettings,
|
|
|
|
asctype: Common.Utils.documentSettingsType.Chart,
|
|
|
|
enableToggle: true,
|
|
|
|
disabled: true,
|
2017-04-11 11:05:56 +00:00
|
|
|
toggleGroup: 'tabpanelbtnsGroup',
|
|
|
|
allowMouseEventsOnDisabled: true
|
2016-03-11 00:48:53 +00:00
|
|
|
});
|
|
|
|
this.btnShape = new Common.UI.Button({
|
|
|
|
hint: this.txtShapeSettings,
|
|
|
|
asctype: Common.Utils.documentSettingsType.Shape,
|
|
|
|
enableToggle: true,
|
|
|
|
disabled: true,
|
2017-04-11 11:05:56 +00:00
|
|
|
toggleGroup: 'tabpanelbtnsGroup',
|
|
|
|
allowMouseEventsOnDisabled: true
|
2016-03-11 00:48:53 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
this.btnTextArt = new Common.UI.Button({
|
|
|
|
hint: this.txtTextArtSettings,
|
|
|
|
asctype: Common.Utils.documentSettingsType.TextArt,
|
|
|
|
enableToggle: true,
|
|
|
|
disabled: true,
|
2017-04-11 11:05:56 +00:00
|
|
|
toggleGroup: 'tabpanelbtnsGroup',
|
|
|
|
allowMouseEventsOnDisabled: true
|
2016-03-11 00:48:53 +00:00
|
|
|
});
|
|
|
|
|
2016-03-29 08:11:58 +00:00
|
|
|
this.btnTable = new Common.UI.Button({
|
|
|
|
hint: this.txtTableSettings,
|
|
|
|
asctype: Common.Utils.documentSettingsType.Table,
|
|
|
|
enableToggle: true,
|
|
|
|
disabled: true,
|
2017-04-11 11:05:56 +00:00
|
|
|
toggleGroup: 'tabpanelbtnsGroup',
|
|
|
|
allowMouseEventsOnDisabled: true
|
2016-03-29 08:11:58 +00:00
|
|
|
});
|
|
|
|
|
2017-07-11 11:02:16 +00:00
|
|
|
this.btnPivot = new Common.UI.Button({
|
|
|
|
hint: this.txtPivotSettings,
|
|
|
|
asctype: Common.Utils.documentSettingsType.Pivot,
|
|
|
|
enableToggle: true,
|
|
|
|
disabled: true,
|
|
|
|
toggleGroup: 'tabpanelbtnsGroup',
|
|
|
|
allowMouseEventsOnDisabled: true
|
|
|
|
});
|
2018-06-09 11:11:56 +00:00
|
|
|
this.btnCell = new Common.UI.Button({
|
|
|
|
hint: this.txtCellSettings,
|
|
|
|
asctype: Common.Utils.documentSettingsType.Cell,
|
|
|
|
enableToggle: true,
|
|
|
|
disabled: true,
|
|
|
|
toggleGroup: 'tabpanelbtnsGroup',
|
|
|
|
allowMouseEventsOnDisabled: true
|
|
|
|
});
|
2017-07-11 11:02:16 +00:00
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
this._settings = [];
|
|
|
|
this._settings[Common.Utils.documentSettingsType.Paragraph] = {panel: "id-paragraph-settings", btn: this.btnText};
|
|
|
|
this._settings[Common.Utils.documentSettingsType.Image] = {panel: "id-image-settings", btn: this.btnImage};
|
|
|
|
this._settings[Common.Utils.documentSettingsType.Shape] = {panel: "id-shape-settings", btn: this.btnShape};
|
|
|
|
this._settings[Common.Utils.documentSettingsType.Chart] = {panel: "id-chart-settings", btn: this.btnChart};
|
|
|
|
this._settings[Common.Utils.documentSettingsType.TextArt] = {panel: "id-textart-settings", btn: this.btnTextArt};
|
2016-03-29 08:11:58 +00:00
|
|
|
this._settings[Common.Utils.documentSettingsType.Table] = {panel: "id-table-settings", btn: this.btnTable};
|
2017-07-11 11:02:16 +00:00
|
|
|
this._settings[Common.Utils.documentSettingsType.Pivot] = {panel: "id-pivot-settings", btn: this.btnPivot};
|
2018-06-09 11:11:56 +00:00
|
|
|
this._settings[Common.Utils.documentSettingsType.Cell] = {panel: "id-cell-settings", btn: this.btnCell};
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2017-09-13 08:57:30 +00:00
|
|
|
render: function (mode) {
|
2016-03-11 00:48:53 +00:00
|
|
|
var el = $(this.el);
|
|
|
|
|
|
|
|
this.trigger('render:before', this);
|
|
|
|
|
2018-06-29 09:42:41 +00:00
|
|
|
var open = !Common.localStorage.getBool("sse-hide-right-settings");
|
|
|
|
el.css('width', ((open) ? MENU_SCALE_PART : SCALE_MIN) + 'px');
|
2016-03-11 00:48:53 +00:00
|
|
|
el.css('z-index', 101);
|
|
|
|
el.show();
|
|
|
|
|
|
|
|
el.html(this.template({}));
|
|
|
|
|
2017-04-28 14:12:07 +00:00
|
|
|
this.btnText.setElement($('#id-right-menu-text'), false); this.btnText.render();
|
|
|
|
this.btnImage.setElement($('#id-right-menu-image'), false); this.btnImage.render();
|
|
|
|
this.btnChart.setElement($('#id-right-menu-chart'), false); this.btnChart.render();
|
|
|
|
this.btnShape.setElement($('#id-right-menu-shape'), false); this.btnShape.render();
|
|
|
|
this.btnTextArt.setElement($('#id-right-menu-textart'), false); this.btnTextArt.render();
|
|
|
|
this.btnTable.setElement($('#id-right-menu-table'), false); this.btnTable.render();
|
2017-07-11 11:02:16 +00:00
|
|
|
this.btnPivot.setElement($('#id-right-menu-pivot'), false); this.btnPivot.render();
|
2018-06-09 11:11:56 +00:00
|
|
|
this.btnCell.setElement($('#id-right-menu-cell'), false); this.btnCell.render();
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
this.btnText.on('click', _.bind(this.onBtnMenuClick, this));
|
|
|
|
this.btnImage.on('click', _.bind(this.onBtnMenuClick, this));
|
|
|
|
this.btnChart.on('click', _.bind(this.onBtnMenuClick, this));
|
|
|
|
this.btnShape.on('click', _.bind(this.onBtnMenuClick, this));
|
|
|
|
this.btnTextArt.on('click', _.bind(this.onBtnMenuClick, this));
|
2016-03-29 08:11:58 +00:00
|
|
|
this.btnTable.on('click', _.bind(this.onBtnMenuClick, this));
|
2017-07-11 11:02:16 +00:00
|
|
|
this.btnPivot.on('click', _.bind(this.onBtnMenuClick, this));
|
2018-06-09 11:11:56 +00:00
|
|
|
this.btnCell.on('click', _.bind(this.onBtnMenuClick, this));
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
this.paragraphSettings = new SSE.Views.ParagraphSettings();
|
|
|
|
this.imageSettings = new SSE.Views.ImageSettings();
|
|
|
|
this.chartSettings = new SSE.Views.ChartSettings();
|
|
|
|
this.shapeSettings = new SSE.Views.ShapeSettings();
|
|
|
|
this.textartSettings = new SSE.Views.TextArtSettings();
|
2016-03-29 08:11:58 +00:00
|
|
|
this.tableSettings = new SSE.Views.TableSettings();
|
2017-07-11 11:02:16 +00:00
|
|
|
this.pivotSettings = new SSE.Views.PivotSettings();
|
2018-06-09 11:11:56 +00:00
|
|
|
this.cellSettings = new SSE.Views.CellSettings();
|
2016-03-11 00:48:53 +00:00
|
|
|
|
2018-09-24 09:18:00 +00:00
|
|
|
if (mode && mode.isSignatureSupport) {
|
2017-11-27 11:15:10 +00:00
|
|
|
this.btnSignature = new Common.UI.Button({
|
|
|
|
hint: this.txtSignatureSettings,
|
|
|
|
asctype: Common.Utils.documentSettingsType.Signature,
|
|
|
|
enableToggle: true,
|
|
|
|
disabled: true,
|
|
|
|
toggleGroup: 'tabpanelbtnsGroup'
|
|
|
|
});
|
|
|
|
this._settings[Common.Utils.documentSettingsType.Signature] = {panel: "id-signature-settings", btn: this.btnSignature};
|
|
|
|
|
|
|
|
this.btnSignature.el = $('#id-right-menu-signature'); this.btnSignature.render().setVisible(true);
|
|
|
|
this.btnSignature.on('click', _.bind(this.onBtnMenuClick, this));
|
|
|
|
this.signatureSettings = new SSE.Views.SignatureSettings();
|
|
|
|
}
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
if (_.isUndefined(this.scroller)) {
|
|
|
|
this.scroller = new Common.UI.Scroller({
|
|
|
|
el: $(this.el).find('.right-panel'),
|
|
|
|
suppressScrollX: true,
|
|
|
|
useKeyboard: false
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-06-29 09:42:41 +00:00
|
|
|
if (open) {
|
|
|
|
$('#id-cell-settings').parent().css("display", "inline-block" );
|
|
|
|
$('#id-cell-settings').addClass("active");
|
|
|
|
}
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
this.trigger('render:after', this);
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
setApi: function(api) {
|
|
|
|
this.api = api;
|
|
|
|
this.paragraphSettings.setApi(api);
|
|
|
|
this.imageSettings.setApi(api);
|
|
|
|
this.chartSettings.setApi(api);
|
|
|
|
this.shapeSettings.setApi(api);
|
|
|
|
this.textartSettings.setApi(api);
|
2016-03-29 08:11:58 +00:00
|
|
|
this.tableSettings.setApi(api);
|
2017-07-11 11:02:16 +00:00
|
|
|
this.pivotSettings.setApi(api);
|
2018-06-09 11:11:56 +00:00
|
|
|
this.cellSettings.setApi(api);
|
2017-09-13 08:57:30 +00:00
|
|
|
if (this.signatureSettings) this.signatureSettings.setApi(api);
|
2017-04-27 14:51:53 +00:00
|
|
|
return this;
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
setMode: function(mode) {
|
2017-10-19 10:14:12 +00:00
|
|
|
this.mode = mode;
|
2017-04-27 14:51:53 +00:00
|
|
|
return this;
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onBtnMenuClick: function(btn, e) {
|
|
|
|
var target_pane = $("#" + this._settings[btn.options.asctype].panel);
|
|
|
|
var target_pane_parent = target_pane.parent();
|
|
|
|
|
|
|
|
if (btn.pressed) {
|
|
|
|
if ( this.minimizedMode ) {
|
|
|
|
$(this.el).width(MENU_SCALE_PART);
|
|
|
|
target_pane_parent.css("display", "inline-block" );
|
|
|
|
this.minimizedMode = false;
|
2016-03-30 08:51:07 +00:00
|
|
|
Common.localStorage.setItem("sse-hide-right-settings", 0);
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
target_pane_parent.find('> .active').removeClass('active');
|
|
|
|
target_pane.addClass("active");
|
|
|
|
|
|
|
|
if (this.scroller) {
|
|
|
|
this.scroller.scrollTop(0);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
target_pane_parent.css("display", "none" );
|
|
|
|
$(this.el).width(SCALE_MIN);
|
|
|
|
this.minimizedMode = true;
|
2016-03-30 08:51:07 +00:00
|
|
|
Common.localStorage.setItem("sse-hide-right-settings", 1);
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.fireEvent('rightmenuclick', [this, btn.options.asctype, this.minimizedMode]);
|
|
|
|
},
|
|
|
|
|
|
|
|
SetActivePane: function(type, open) {
|
|
|
|
if (this.minimizedMode && open!==true || this._settings[type]===undefined ) return;
|
|
|
|
|
|
|
|
if (this.minimizedMode) {
|
|
|
|
this._settings[type].btn.toggle(true, false);
|
|
|
|
this._settings[type].btn.trigger('click', this._settings[type].btn);
|
|
|
|
} else {
|
|
|
|
var target_pane = $("#" + this._settings[type].panel );
|
|
|
|
if ( !target_pane.hasClass('active') ) {
|
|
|
|
target_pane.parent().find('> .active').removeClass('active');
|
|
|
|
target_pane.addClass("active");
|
|
|
|
if (this.scroller)
|
|
|
|
this.scroller.update();
|
|
|
|
}
|
|
|
|
if (!this._settings[type].btn.isActive())
|
|
|
|
this._settings[type].btn.toggle(true, false);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
GetActivePane: function() {
|
2016-10-18 08:58:27 +00:00
|
|
|
return (this.minimizedMode) ? null : this.$el.find(".settings-panel.active")[0].id;
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
clearSelection: function() {
|
|
|
|
var target_pane = $(".right-panel");
|
|
|
|
target_pane.find('> .active').removeClass('active');
|
2016-10-27 11:39:54 +00:00
|
|
|
this._settings.forEach(function(item){
|
2016-03-11 00:48:53 +00:00
|
|
|
if (item.btn.isActive())
|
|
|
|
item.btn.toggle(false, true);
|
|
|
|
});
|
|
|
|
target_pane.css("display", "none" );
|
|
|
|
$(this.el).width(SCALE_MIN);
|
|
|
|
this.minimizedMode = true;
|
|
|
|
Common.NotificationCenter.trigger('layout:changed', 'rightmenu');
|
|
|
|
},
|
|
|
|
|
|
|
|
txtParagraphSettings: 'Paragraph Settings',
|
|
|
|
txtImageSettings: 'Image Settings',
|
|
|
|
txtShapeSettings: 'Shape Settings',
|
|
|
|
txtTextArtSettings: 'Text Art Settings',
|
2016-03-29 08:11:58 +00:00
|
|
|
txtChartSettings: 'Chart Settings',
|
2016-12-23 10:03:08 +00:00
|
|
|
txtSparklineSettings: 'Sparkline Settings',
|
2017-07-11 11:02:16 +00:00
|
|
|
txtTableSettings: 'Table Settings',
|
2017-09-29 08:26:45 +00:00
|
|
|
txtPivotSettings: 'Pivot Table Settings',
|
2018-06-09 11:11:56 +00:00
|
|
|
txtSignatureSettings: 'Signature Settings',
|
|
|
|
txtCellSettings: 'Cell Settings'
|
2016-03-11 00:48:53 +00:00
|
|
|
}, SSE.Views.RightMenu || {}));
|
|
|
|
});
|