2019-06-20 09:51:27 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* (c) Copyright Ascensio System SIA 2010-2019
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* FormulaTab.js
|
|
|
|
*
|
|
|
|
* Created by Julia Radzhabova on 14.06.2019
|
|
|
|
* Copyright (c) 2019 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';
|
|
|
|
|
|
|
|
SSE.Views.FormulaTab = Common.UI.BaseView.extend(_.extend((function(){
|
|
|
|
function setEvents() {
|
|
|
|
var me = this;
|
2019-06-24 12:57:28 +00:00
|
|
|
me.btnAutosum.on('click', function(){
|
|
|
|
me.fireEvent('function:apply', [{name: me.api.asc_getFormulaLocaleName('SUM'), origin: 'SUM'}, true]);
|
|
|
|
});
|
|
|
|
me.btnAutosum.menu.on('item:click', function (menu, item, e) {
|
|
|
|
me.fireEvent('function:apply', [{name: item.caption, origin: item.value}, true]);
|
|
|
|
});
|
|
|
|
me.btnFormula.on('click', function(){
|
|
|
|
me.fireEvent('function:apply', [{name: 'more', origin: 'more'}]);
|
|
|
|
});
|
2019-08-27 12:24:10 +00:00
|
|
|
me.btnCalculate.on('click', function () {
|
2019-08-27 13:04:21 +00:00
|
|
|
me.fireEvent('function:calculate', [{type: Asc.c_oAscCalculateType.All}]);
|
2019-08-27 12:24:10 +00:00
|
|
|
});
|
|
|
|
me.btnCalculate.menu.on('item:click', function (menu, item, e) {
|
2019-08-27 13:04:21 +00:00
|
|
|
me.fireEvent('function:calculate', [{type: item.value}]);
|
2019-08-27 12:24:10 +00:00
|
|
|
});
|
2020-02-26 10:49:57 +00:00
|
|
|
me.btnNamedRange.menu.on('show:after', function (menu) {
|
|
|
|
me.fireEvent('function:namedrange-open', [menu]);
|
|
|
|
});
|
|
|
|
me.btnNamedRange.menu.on('item:click', function (menu, item, e) {
|
|
|
|
me.fireEvent('function:namedrange', [menu, item, e]);
|
|
|
|
});
|
2019-06-20 09:51:27 +00:00
|
|
|
}
|
|
|
|
return {
|
|
|
|
options: {},
|
|
|
|
|
|
|
|
initialize: function (options) {
|
|
|
|
Common.UI.BaseView.prototype.initialize.call(this);
|
|
|
|
this.toolbar = options.toolbar;
|
2019-06-24 12:57:28 +00:00
|
|
|
this.formulasGroups = options.formulasGroups;
|
2019-06-20 09:51:27 +00:00
|
|
|
|
|
|
|
this.lockedControls = [];
|
2020-02-26 10:49:57 +00:00
|
|
|
this.formulaControls = [];
|
2019-06-20 09:51:27 +00:00
|
|
|
|
|
|
|
var me = this,
|
|
|
|
$host = me.toolbar.$el,
|
|
|
|
_set = SSE.enumLock;
|
|
|
|
|
|
|
|
var formulaDialog = SSE.getController('FormulaDialog');
|
|
|
|
|
|
|
|
this.btnFinancial = new Common.UI.Button({
|
2020-04-29 07:36:53 +00:00
|
|
|
parentEl: $host.find('#slot-btn-financial'),
|
2019-06-20 09:51:27 +00:00
|
|
|
cls: 'btn-toolbar x-huge icon-top',
|
2019-11-21 16:15:47 +00:00
|
|
|
iconCls: 'toolbar__icon btn-finance',
|
2019-06-20 09:51:27 +00:00
|
|
|
caption: formulaDialog.sCategoryFinancial,
|
|
|
|
hint: formulaDialog.sCategoryFinancial,
|
|
|
|
menu: true,
|
|
|
|
split: false,
|
|
|
|
disabled: true,
|
2020-04-25 11:06:43 +00:00
|
|
|
lock: [_set.editText, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.noSubitems]
|
2019-06-20 09:51:27 +00:00
|
|
|
});
|
|
|
|
this.lockedControls.push(this.btnFinancial);
|
2020-02-26 10:49:57 +00:00
|
|
|
this.formulaControls.push(this.btnFinancial);
|
2019-06-20 09:51:27 +00:00
|
|
|
|
|
|
|
this.btnLogical = new Common.UI.Button({
|
2020-04-29 07:36:53 +00:00
|
|
|
parentEl: $host.find('#slot-btn-logical'),
|
2019-06-20 09:51:27 +00:00
|
|
|
cls: 'btn-toolbar x-huge icon-top',
|
2019-11-21 16:15:47 +00:00
|
|
|
iconCls: 'toolbar__icon btn-logic',
|
2019-06-20 09:51:27 +00:00
|
|
|
caption: formulaDialog.sCategoryLogical,
|
|
|
|
hint: formulaDialog.sCategoryLogical,
|
|
|
|
menu: true,
|
|
|
|
split: false,
|
|
|
|
disabled: true,
|
2020-04-25 11:06:43 +00:00
|
|
|
lock: [_set.editText, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.noSubitems]
|
2019-06-20 09:51:27 +00:00
|
|
|
});
|
|
|
|
this.lockedControls.push(this.btnLogical);
|
2020-02-26 10:49:57 +00:00
|
|
|
this.formulaControls.push(this.btnLogical);
|
2019-06-20 09:51:27 +00:00
|
|
|
|
|
|
|
this.btnTextData = new Common.UI.Button({
|
2020-04-29 07:36:53 +00:00
|
|
|
parentEl: $host.find('#slot-btn-text'),
|
2019-06-20 09:51:27 +00:00
|
|
|
cls: 'btn-toolbar x-huge icon-top',
|
2019-11-21 16:15:47 +00:00
|
|
|
iconCls: 'toolbar__icon btn-func-text',
|
2019-06-20 09:51:27 +00:00
|
|
|
caption: formulaDialog.sCategoryTextAndData,
|
|
|
|
hint: formulaDialog.sCategoryTextAndData,
|
|
|
|
menu: true,
|
|
|
|
split: false,
|
|
|
|
disabled: true,
|
2020-04-25 11:06:43 +00:00
|
|
|
lock: [_set.editText, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.noSubitems]
|
2019-06-20 09:51:27 +00:00
|
|
|
});
|
|
|
|
this.lockedControls.push(this.btnTextData);
|
2020-02-26 10:49:57 +00:00
|
|
|
this.formulaControls.push(this.btnTextData);
|
2019-06-20 09:51:27 +00:00
|
|
|
|
|
|
|
this.btnDateTime = new Common.UI.Button({
|
2020-04-29 07:36:53 +00:00
|
|
|
parentEl: $host.find('#slot-btn-datetime'),
|
2019-06-20 09:51:27 +00:00
|
|
|
cls: 'btn-toolbar x-huge icon-top',
|
2019-11-21 16:15:47 +00:00
|
|
|
iconCls: 'toolbar__icon btn-datetime',
|
2019-06-20 09:51:27 +00:00
|
|
|
caption: formulaDialog.sCategoryDateAndTime,
|
|
|
|
hint: formulaDialog.sCategoryDateAndTime,
|
|
|
|
menu: true,
|
|
|
|
split: false,
|
|
|
|
disabled: true,
|
2020-04-25 11:06:43 +00:00
|
|
|
lock: [_set.editText, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.noSubitems]
|
2019-06-20 09:51:27 +00:00
|
|
|
});
|
|
|
|
this.lockedControls.push(this.btnDateTime);
|
2020-02-26 10:49:57 +00:00
|
|
|
this.formulaControls.push(this.btnDateTime);
|
2019-06-20 09:51:27 +00:00
|
|
|
|
|
|
|
this.btnReference = new Common.UI.Button({
|
2020-04-29 07:36:53 +00:00
|
|
|
parentEl: $host.find('#slot-btn-lookup'),
|
2019-06-20 09:51:27 +00:00
|
|
|
cls: 'btn-toolbar x-huge icon-top',
|
2019-11-21 16:15:47 +00:00
|
|
|
iconCls: 'toolbar__icon btn-lookup',
|
2019-06-20 09:51:27 +00:00
|
|
|
caption: formulaDialog.sCategoryLookupAndReference,
|
|
|
|
hint: formulaDialog.sCategoryLookupAndReference,
|
|
|
|
menu: true,
|
|
|
|
split: false,
|
|
|
|
disabled: true,
|
2020-04-25 11:06:43 +00:00
|
|
|
lock: [_set.editText, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.noSubitems]
|
2019-06-20 09:51:27 +00:00
|
|
|
});
|
|
|
|
this.lockedControls.push(this.btnReference);
|
2020-02-26 10:49:57 +00:00
|
|
|
this.formulaControls.push(this.btnReference);
|
2019-06-20 09:51:27 +00:00
|
|
|
|
|
|
|
this.btnMath = new Common.UI.Button({
|
2020-04-29 07:36:53 +00:00
|
|
|
parentEl: $host.find('#slot-btn-math'),
|
2019-06-20 09:51:27 +00:00
|
|
|
cls: 'btn-toolbar x-huge icon-top',
|
2019-11-21 16:15:47 +00:00
|
|
|
iconCls: 'toolbar__icon btn-func-math',
|
2019-06-20 09:51:27 +00:00
|
|
|
caption: formulaDialog.sCategoryMathematic,
|
|
|
|
hint: formulaDialog.sCategoryMathematic,
|
|
|
|
menu: true,
|
|
|
|
split: false,
|
|
|
|
disabled: true,
|
2020-04-25 11:06:43 +00:00
|
|
|
lock: [_set.editText, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.noSubitems]
|
2019-06-20 09:51:27 +00:00
|
|
|
});
|
|
|
|
this.lockedControls.push(this.btnMath);
|
2020-02-26 10:49:57 +00:00
|
|
|
this.formulaControls.push(this.btnMath);
|
2019-06-20 09:51:27 +00:00
|
|
|
|
2019-06-24 12:57:28 +00:00
|
|
|
this.btnRecent = new Common.UI.Button({
|
2020-04-29 07:36:53 +00:00
|
|
|
parentEl: $host.find('#slot-btn-recent'),
|
2019-06-24 12:57:28 +00:00
|
|
|
cls: 'btn-toolbar x-huge icon-top',
|
2019-11-21 16:15:47 +00:00
|
|
|
iconCls: 'toolbar__icon btn-recent',
|
2019-06-24 12:57:28 +00:00
|
|
|
caption: this.txtRecent,
|
|
|
|
hint: this.txtRecent,
|
|
|
|
menu: true,
|
|
|
|
split: false,
|
|
|
|
disabled: true,
|
2020-04-25 11:06:43 +00:00
|
|
|
lock: [_set.editText, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.noSubitems]
|
2019-06-24 12:57:28 +00:00
|
|
|
});
|
|
|
|
this.lockedControls.push(this.btnRecent);
|
2020-02-26 10:49:57 +00:00
|
|
|
this.formulaControls.push(this.btnRecent);
|
2019-06-24 12:57:28 +00:00
|
|
|
|
|
|
|
this.btnAutosum = new Common.UI.Button({
|
2020-04-29 07:36:53 +00:00
|
|
|
parentEl: $host.find('#slot-btn-autosum'),
|
2019-06-24 12:57:28 +00:00
|
|
|
cls: 'btn-toolbar x-huge icon-top',
|
2019-11-21 16:15:47 +00:00
|
|
|
iconCls: 'toolbar__icon btn-autosum',
|
2019-06-24 12:57:28 +00:00
|
|
|
caption: this.txtAutosum,
|
2019-12-26 12:46:14 +00:00
|
|
|
hint: [this.txtAutosumTip + Common.Utils.String.platformKey('Alt+='), this.txtFormulaTip],
|
2019-06-24 12:57:28 +00:00
|
|
|
split: true,
|
|
|
|
disabled: true,
|
|
|
|
lock: [_set.editText, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selRangeEdit, _set.lostConnect, _set.coAuth],
|
|
|
|
menu: new Common.UI.Menu({
|
|
|
|
items : [
|
|
|
|
{caption: 'SUM', value: 'SUM'},
|
2020-05-07 14:40:10 +00:00
|
|
|
{caption: 'AVERAGE', value: 'AVERAGE'},
|
2019-06-24 12:57:28 +00:00
|
|
|
{caption: 'MIN', value: 'MIN'},
|
|
|
|
{caption: 'MAX', value: 'MAX'},
|
|
|
|
{caption: 'COUNT', value: 'COUNT'},
|
|
|
|
{caption: '--'},
|
|
|
|
{
|
|
|
|
caption: me.txtAdditional,
|
|
|
|
value: 'more'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
})
|
|
|
|
});
|
|
|
|
this.lockedControls.push(this.btnAutosum);
|
2020-02-26 10:49:57 +00:00
|
|
|
this.formulaControls.push(this.btnAutosum);
|
2019-06-24 12:57:28 +00:00
|
|
|
|
|
|
|
this.btnFormula = new Common.UI.Button({
|
2020-04-29 07:36:53 +00:00
|
|
|
parentEl: $host.find('#slot-btn-additional-formula'),
|
2019-06-24 12:57:28 +00:00
|
|
|
cls: 'btn-toolbar x-huge icon-top',
|
2019-11-21 16:15:47 +00:00
|
|
|
iconCls: 'toolbar__icon btn-ins-formula',
|
2019-06-24 12:57:28 +00:00
|
|
|
caption: this.txtFormula,
|
|
|
|
hint: this.txtFormulaTip,
|
|
|
|
disabled: true,
|
|
|
|
lock: [_set.editText, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selRangeEdit, _set.lostConnect, _set.coAuth]
|
|
|
|
});
|
|
|
|
this.lockedControls.push(this.btnFormula);
|
2020-02-26 10:49:57 +00:00
|
|
|
this.formulaControls.push(this.btnFormula);
|
2019-06-24 12:57:28 +00:00
|
|
|
|
2019-06-24 13:53:12 +00:00
|
|
|
this.btnMore = new Common.UI.Button({
|
2020-04-29 07:36:53 +00:00
|
|
|
parentEl: $host.find('#slot-btn-more'),
|
2019-06-24 13:53:12 +00:00
|
|
|
cls: 'btn-toolbar x-huge icon-top',
|
2019-11-21 16:15:47 +00:00
|
|
|
iconCls: 'toolbar__icon btn-more',
|
2019-06-24 13:53:12 +00:00
|
|
|
caption: this.txtMore,
|
|
|
|
hint: this.txtMore,
|
|
|
|
menu: true,
|
|
|
|
split: false,
|
|
|
|
disabled: true,
|
2020-04-25 11:06:43 +00:00
|
|
|
lock: [_set.editText, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.noSubitems]
|
2019-06-24 13:53:12 +00:00
|
|
|
});
|
|
|
|
this.lockedControls.push(this.btnMore);
|
2020-02-26 10:49:57 +00:00
|
|
|
this.formulaControls.push(this.btnMore);
|
2019-06-24 13:53:12 +00:00
|
|
|
|
2019-08-27 12:24:10 +00:00
|
|
|
this.btnCalculate = new Common.UI.Button({
|
2020-04-29 07:36:53 +00:00
|
|
|
parentEl: $host.find('#slot-btn-calculate'),
|
2019-08-27 12:24:10 +00:00
|
|
|
cls: 'btn-toolbar x-huge icon-top',
|
2019-11-21 16:15:47 +00:00
|
|
|
iconCls: 'toolbar__icon btn-calculation',
|
2019-08-27 14:45:50 +00:00
|
|
|
caption: this.txtCalculation,
|
2019-08-27 12:24:10 +00:00
|
|
|
split: true,
|
|
|
|
menu: true,
|
|
|
|
disabled: true,
|
2019-08-27 13:04:21 +00:00
|
|
|
lock: [_set.editCell, _set.selRangeEdit, _set.lostConnect, _set.coAuth]
|
2019-08-27 12:24:10 +00:00
|
|
|
});
|
|
|
|
this.lockedControls.push(this.btnCalculate);
|
2020-02-26 10:49:57 +00:00
|
|
|
this.formulaControls.push(this.btnCalculate);
|
|
|
|
|
|
|
|
this.btnNamedRange = new Common.UI.Button({
|
2020-04-29 07:36:53 +00:00
|
|
|
parentEl: $host.find('#slot-btn-named-range-huge'),
|
2020-02-26 10:49:57 +00:00
|
|
|
cls : 'btn-toolbar x-huge icon-top',
|
|
|
|
iconCls : 'toolbar__icon btn-named-range',
|
|
|
|
caption: this.toolbar.txtNamedRange,
|
|
|
|
hint: this.toolbar.txtNamedRange,
|
|
|
|
split: false,
|
|
|
|
disabled: true,
|
|
|
|
lock : [_set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.selRangeEdit],
|
|
|
|
menu: new Common.UI.Menu({
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
caption: me.toolbar.txtManageRange,
|
|
|
|
lock : [_set.editCell],
|
|
|
|
value: 'manage'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
caption: me.toolbar.txtNewRange,
|
|
|
|
lock : [_set.editCell],
|
|
|
|
value: 'new'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
caption: me.toolbar.txtPasteRange,
|
|
|
|
value: 'paste'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
})
|
|
|
|
});
|
|
|
|
this.lockedControls.push(this.btnNamedRange);
|
2019-08-27 12:24:10 +00:00
|
|
|
|
2019-06-20 09:51:27 +00:00
|
|
|
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(){
|
2019-08-27 13:57:12 +00:00
|
|
|
me.btnCalculate.updateHint([me.tipCalculateTheEntireWorkbook + Common.Utils.String.platformKey('F9'), me.tipCalculate]);
|
2019-08-27 12:24:10 +00:00
|
|
|
var _menu = new Common.UI.Menu({
|
|
|
|
items: [
|
2019-08-27 14:45:50 +00:00
|
|
|
{caption: me.textCalculateWorkbook, value: Asc.c_oAscCalculateType.All},
|
2020-04-25 11:06:43 +00:00
|
|
|
{caption: me.textCalculateCurrentSheet, value: Asc.c_oAscCalculateType.ActiveSheet}
|
2019-08-27 13:23:06 +00:00
|
|
|
//{caption: '--'},
|
2019-08-27 14:45:50 +00:00
|
|
|
//{caption: me.textAutomatic, value: '', toggleGroup: 'menuCalcMode', checkable: true, checked: true},
|
|
|
|
//{caption: me.textManual, value: '', toggleGroup: 'menuCalcMode', checkable: true, checked: false}
|
2019-08-27 12:24:10 +00:00
|
|
|
]
|
|
|
|
});
|
|
|
|
me.btnCalculate.setMenu(_menu);
|
2019-06-24 12:57:28 +00:00
|
|
|
setEvents.call(me);
|
2019-06-20 09:51:27 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
show: function () {
|
|
|
|
Common.UI.BaseView.prototype.show.call(this);
|
|
|
|
this.fireEvent('show', this);
|
|
|
|
},
|
|
|
|
|
|
|
|
getButtons: function(type) {
|
2020-02-26 10:49:57 +00:00
|
|
|
if (type == 'formula')
|
|
|
|
return this.formulaControls;
|
|
|
|
else if (type == 'range')
|
|
|
|
return this.btnNamedRange;
|
|
|
|
else
|
|
|
|
return this.lockedControls;
|
2019-06-20 09:51:27 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
SetDisabled: function (state) {
|
|
|
|
this.lockedControls && this.lockedControls.forEach(function(button) {
|
|
|
|
if ( button ) {
|
|
|
|
button.setDisabled(state);
|
|
|
|
}
|
|
|
|
}, this);
|
|
|
|
},
|
|
|
|
|
2019-08-14 12:21:20 +00:00
|
|
|
focusInner: function(menu, e) {
|
|
|
|
if (e.keyCode == Common.UI.Keys.UP)
|
|
|
|
menu.items[menu.items.length-1].cmpEl.find('> a').focus();
|
|
|
|
else
|
|
|
|
menu.items[0].cmpEl.find('> a').focus();
|
|
|
|
},
|
|
|
|
|
|
|
|
focusOuter: function(menu, e) {
|
|
|
|
menu.items[2].cmpEl.find('> a').focus();
|
|
|
|
},
|
|
|
|
|
|
|
|
onBeforeKeyDown: function(menu, e) {
|
|
|
|
if (e.keyCode == Common.UI.Keys.RETURN) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
var li = $(e.target).closest('li');
|
|
|
|
(li.length>0) && li.click();
|
|
|
|
Common.UI.Menu.Manager.hideAll();
|
|
|
|
} else if (e.namespace!=="after.bs.dropdown" && (e.keyCode == Common.UI.Keys.DOWN || e.keyCode == Common.UI.Keys.UP)) {
|
|
|
|
var $items = $('> [role=menu] > li:not(.divider):not(.disabled):visible', menu.$el).find('> a');
|
|
|
|
if (!$items.length) return;
|
|
|
|
var index = $items.index($items.filter(':focus')),
|
|
|
|
me = this;
|
|
|
|
if (menu._outerMenu && (e.keyCode == Common.UI.Keys.UP && index==0 || e.keyCode == Common.UI.Keys.DOWN && index==$items.length - 1) ||
|
|
|
|
menu._innerMenu && (e.keyCode == Common.UI.Keys.UP || e.keyCode == Common.UI.Keys.DOWN) && index!==-1) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
_.delay(function() {
|
|
|
|
menu._outerMenu ? me.focusOuter(menu._outerMenu, e) : me.focusInner(menu._innerMenu, e);
|
|
|
|
}, 10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2019-06-24 12:57:28 +00:00
|
|
|
setButtonMenu: function(btn, name) {
|
|
|
|
var me = this,
|
|
|
|
arr = [],
|
|
|
|
group = me.formulasGroups.findWhere({name : name});
|
|
|
|
|
|
|
|
if (group) {
|
|
|
|
var functions = group.get('functions');
|
|
|
|
functions && functions.forEach(function(item) {
|
|
|
|
arr.push(new Common.UI.MenuItem({
|
|
|
|
caption: item.get('name'),
|
|
|
|
value: item.get('origin')
|
|
|
|
}));
|
|
|
|
});
|
2019-06-24 13:53:12 +00:00
|
|
|
}
|
|
|
|
if (arr.length) {
|
2019-06-24 12:57:28 +00:00
|
|
|
if (btn.menu && btn.menu.rendered) {
|
2019-08-14 12:21:20 +00:00
|
|
|
var menu = btn.menu._innerMenu;
|
2019-08-12 14:50:52 +00:00
|
|
|
if (menu) {
|
|
|
|
menu.removeAll();
|
|
|
|
arr.forEach(function(item){
|
|
|
|
menu.addItem(item);
|
|
|
|
});
|
|
|
|
}
|
2019-06-24 12:57:28 +00:00
|
|
|
} else {
|
|
|
|
btn.setMenu(new Common.UI.Menu({
|
2019-08-12 14:50:52 +00:00
|
|
|
items: [
|
|
|
|
{template: _.template('<div id="id-toolbar-formula-menu-'+ name +'" style="display: flex;" class="open"></div>')},
|
|
|
|
{ caption: '--' },
|
|
|
|
{
|
|
|
|
caption: me.txtAdditional,
|
|
|
|
value: 'more'
|
|
|
|
}
|
|
|
|
]
|
2019-06-24 12:57:28 +00:00
|
|
|
}));
|
2019-08-12 14:50:52 +00:00
|
|
|
btn.menu.items[2].on('click', function (item, e) {
|
|
|
|
me.fireEvent('function:apply', [{name: item.caption, origin: item.value}, false, name]);
|
|
|
|
});
|
|
|
|
btn.menu.on('show:after', function (menu, e) {
|
2019-08-14 12:21:20 +00:00
|
|
|
var internalMenu = menu._innerMenu;
|
2019-08-12 14:50:52 +00:00
|
|
|
internalMenu.scroller.update({alwaysVisibleY: true});
|
|
|
|
_.delay(function() {
|
2019-08-14 12:21:20 +00:00
|
|
|
menu._innerMenu && menu._innerMenu.cmpEl.focus();
|
2019-08-12 14:50:52 +00:00
|
|
|
}, 10);
|
2019-08-14 12:21:20 +00:00
|
|
|
}).on('keydown:before', _.bind(me.onBeforeKeyDown, this));
|
2019-08-12 14:50:52 +00:00
|
|
|
|
|
|
|
var menu = new Common.UI.Menu({
|
|
|
|
maxHeight: 300,
|
|
|
|
cls: 'internal-menu',
|
|
|
|
items: arr
|
|
|
|
});
|
2019-08-14 12:21:20 +00:00
|
|
|
menu.render(btn.menu.items[0].cmpEl.children(':first'));
|
2019-08-12 14:50:52 +00:00
|
|
|
menu.cmpEl.css({
|
|
|
|
display : 'block',
|
|
|
|
position : 'relative',
|
|
|
|
left : 0,
|
|
|
|
top : 0
|
|
|
|
});
|
|
|
|
menu.cmpEl.attr({tabindex: "-1"});
|
|
|
|
menu.on('item:click', function (menu, item, e) {
|
2019-06-25 07:39:09 +00:00
|
|
|
me.fireEvent('function:apply', [{name: item.caption, origin: item.value}, false, name]);
|
2019-08-14 12:21:20 +00:00
|
|
|
}).on('keydown:before', _.bind(me.onBeforeKeyDown, this));
|
|
|
|
btn.menu._innerMenu = menu;
|
|
|
|
menu._outerMenu = btn.menu;
|
2019-06-24 12:57:28 +00:00
|
|
|
}
|
|
|
|
}
|
2020-04-25 11:06:43 +00:00
|
|
|
Common.Utils.lockControls(SSE.enumLock.noSubitems, arr.length<1, {array: [btn]});
|
2019-06-24 12:57:28 +00:00
|
|
|
},
|
|
|
|
|
2019-08-13 10:28:06 +00:00
|
|
|
setMenuItemMenu: function(name) {
|
|
|
|
var me = this,
|
|
|
|
arr = [],
|
|
|
|
formulaDialog = SSE.getController('FormulaDialog'),
|
|
|
|
group = me.formulasGroups.findWhere({name : name});
|
|
|
|
|
|
|
|
if (group) {
|
|
|
|
var functions = group.get('functions');
|
|
|
|
functions && functions.forEach(function(item) {
|
|
|
|
arr.push(new Common.UI.MenuItem({
|
|
|
|
caption: item.get('name'),
|
|
|
|
value: item.get('origin')
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
if (arr.length) {
|
|
|
|
var mnu = new Common.UI.MenuItem({
|
|
|
|
caption : formulaDialog['sCategory' + name] || name,
|
|
|
|
menu: new Common.UI.Menu({
|
|
|
|
menuAlign: 'tl-tr',
|
|
|
|
items: [
|
|
|
|
{template: _.template('<div id="id-toolbar-formula-menu-'+ name +'" style="display: flex;" class="open"></div>')},
|
|
|
|
{ caption: '--' },
|
|
|
|
{
|
|
|
|
caption: me.txtAdditional,
|
|
|
|
value: 'more'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
})
|
|
|
|
});
|
|
|
|
mnu.menu.items[2].on('click', function (item, e) {
|
|
|
|
me.fireEvent('function:apply', [{name: item.caption, origin: item.value}, false, name]);
|
|
|
|
});
|
|
|
|
mnu.menu.on('show:after', function (menu, e) {
|
2019-08-14 12:21:20 +00:00
|
|
|
var internalMenu = menu._innerMenu;
|
2019-08-13 10:28:06 +00:00
|
|
|
internalMenu.scroller.update({alwaysVisibleY: true});
|
|
|
|
_.delay(function() {
|
2019-08-14 12:34:45 +00:00
|
|
|
menu._innerMenu && menu._innerMenu.items[0].cmpEl.find('> a').focus();
|
2019-08-13 10:28:06 +00:00
|
|
|
}, 10);
|
2019-08-14 12:34:45 +00:00
|
|
|
}).on('keydown:before', _.bind(me.onBeforeKeyDown, this))
|
|
|
|
.on('keydown:before', function(menu, e) {
|
|
|
|
if (e.keyCode == Common.UI.Keys.LEFT || e.keyCode == Common.UI.Keys.ESC) {
|
|
|
|
var $parent = menu.cmpEl.parent();
|
|
|
|
if ($parent.hasClass('dropdown-submenu') && $parent.hasClass('over')) { // close submenu
|
|
|
|
$parent.removeClass('over');
|
|
|
|
$parent.find('> a').focus();
|
|
|
|
}
|
2019-08-13 10:28:06 +00:00
|
|
|
}
|
2019-08-14 12:34:45 +00:00
|
|
|
});
|
2019-08-13 10:28:06 +00:00
|
|
|
|
|
|
|
// internal menu
|
|
|
|
var menu = new Common.UI.Menu({
|
|
|
|
maxHeight: 300,
|
|
|
|
cls: 'internal-menu',
|
|
|
|
items: arr
|
|
|
|
});
|
|
|
|
menu.on('item:click', function (menu, item, e) {
|
|
|
|
me.fireEvent('function:apply', [{name: item.caption, origin: item.value}, false, name]);
|
2019-08-14 12:34:45 +00:00
|
|
|
}).on('keydown:before', _.bind(me.onBeforeKeyDown, this));
|
2019-08-14 12:21:20 +00:00
|
|
|
mnu.menu._innerMenu = menu;
|
2019-08-14 12:34:45 +00:00
|
|
|
menu._outerMenu = mnu.menu;
|
2019-08-13 10:28:06 +00:00
|
|
|
return mnu;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2019-06-20 09:51:27 +00:00
|
|
|
fillFunctions: function () {
|
|
|
|
if (this.formulasGroups) {
|
2019-06-24 12:57:28 +00:00
|
|
|
this.setButtonMenu(this.btnFinancial, 'Financial');
|
|
|
|
this.setButtonMenu(this.btnLogical, 'Logical');
|
|
|
|
this.setButtonMenu(this.btnTextData, 'TextAndData');
|
|
|
|
this.setButtonMenu(this.btnDateTime, 'DateAndTime');
|
|
|
|
this.setButtonMenu(this.btnReference, 'LookupAndReference');
|
|
|
|
this.setButtonMenu(this.btnMath, 'Mathematic');
|
|
|
|
this.setButtonMenu(this.btnRecent, 'Last10');
|
|
|
|
|
|
|
|
var formulas = this.btnAutosum.menu.items;
|
|
|
|
for (var i=0; i<Math.min(4,formulas.length); i++) {
|
|
|
|
this.api && formulas[i].setCaption(this.api.asc_getFormulaLocaleName(formulas[i].value));
|
|
|
|
}
|
2019-06-24 13:53:12 +00:00
|
|
|
|
|
|
|
// more button
|
|
|
|
var me = this,
|
2019-08-13 10:28:06 +00:00
|
|
|
morearr = [];
|
2019-06-24 13:53:12 +00:00
|
|
|
['Cube', 'Database', 'Engineering', 'Information', 'Statistical'].forEach(function(name) {
|
2019-08-13 10:28:06 +00:00
|
|
|
var mnu = me.setMenuItemMenu(name);
|
|
|
|
mnu && morearr.push(mnu);
|
|
|
|
|
2019-06-24 13:53:12 +00:00
|
|
|
});
|
|
|
|
var btn = this.btnMore;
|
|
|
|
if (morearr.length) {
|
|
|
|
if (btn.menu && btn.menu.rendered) {
|
|
|
|
btn.menu.removeAll();
|
|
|
|
morearr.forEach(function(item){
|
|
|
|
btn.menu.addItem(item);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
btn.setMenu(new Common.UI.Menu({
|
|
|
|
items: morearr
|
|
|
|
}));
|
|
|
|
}
|
2019-08-13 10:28:06 +00:00
|
|
|
btn.menu.items.forEach(function(mnu){
|
|
|
|
var menuContainer = mnu.menu.items[0].cmpEl.children(':first'),
|
2019-08-14 12:21:20 +00:00
|
|
|
menu = mnu.menu._innerMenu;
|
2019-08-13 10:28:06 +00:00
|
|
|
menu.render(menuContainer);
|
|
|
|
menu.cmpEl.css({
|
|
|
|
display : 'block',
|
|
|
|
position : 'relative',
|
|
|
|
left : 0,
|
|
|
|
top : 0
|
|
|
|
});
|
|
|
|
menu.cmpEl.attr({tabindex: "-1"});
|
|
|
|
});
|
2019-06-24 13:53:12 +00:00
|
|
|
}
|
2020-04-25 11:06:43 +00:00
|
|
|
Common.Utils.lockControls(SSE.enumLock.noSubitems, morearr.length<1, {array: [btn]});
|
2019-06-20 09:51:27 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2019-06-24 12:57:28 +00:00
|
|
|
updateRecent: function() {
|
|
|
|
this.formulasGroups && this.setButtonMenu(this.btnRecent, 'Last10');
|
|
|
|
},
|
|
|
|
|
|
|
|
setApi: function (api) {
|
|
|
|
this.api = api;
|
|
|
|
},
|
|
|
|
|
|
|
|
txtRecent: 'Recently used',
|
|
|
|
txtAutosum: 'Autosum',
|
|
|
|
txtAutosumTip: 'Summation',
|
|
|
|
txtAdditional: 'Additional',
|
|
|
|
txtFormula: 'Function',
|
2019-06-24 13:53:12 +00:00
|
|
|
txtFormulaTip: 'Insert function',
|
2019-08-27 12:24:10 +00:00
|
|
|
txtMore: 'More functions',
|
2019-08-27 14:45:50 +00:00
|
|
|
txtCalculation: 'Calculation',
|
2019-08-27 12:24:10 +00:00
|
|
|
tipCalculate: 'Calculate',
|
2019-08-27 14:45:50 +00:00
|
|
|
textCalculateWorkbook: 'Calculate workbook',
|
|
|
|
textCalculateCurrentSheet: 'Calculate current sheet',
|
2019-08-27 12:24:10 +00:00
|
|
|
textAutomatic: 'Automatic',
|
|
|
|
textManual: 'Manual',
|
|
|
|
tipCalculateTheEntireWorkbook: 'Calculate the entire workbook'
|
2019-06-20 09:51:27 +00:00
|
|
|
}
|
|
|
|
}()), SSE.Views.FormulaTab || {}));
|
|
|
|
});
|