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
|
|
|
/**
|
|
|
|
* StatusBar View
|
|
|
|
*
|
|
|
|
* Created by Maxim Kadushkin on 27 March 2014
|
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([
|
|
|
|
'text!spreadsheeteditor/main/app/template/StatusBar.template',
|
|
|
|
'tip',
|
|
|
|
'common/main/lib/component/TabBar',
|
|
|
|
'common/main/lib/component/Menu',
|
|
|
|
'common/main/lib/component/Window',
|
|
|
|
'common/main/lib/component/ThemeColorPalette'
|
|
|
|
],
|
|
|
|
function(template){
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
if (SSE.Views.Statusbar) {
|
|
|
|
var RenameDialog = SSE.Views.Statusbar.RenameDialog;
|
|
|
|
var CopyDialog = SSE.Views.Statusbar.CopyDialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
SSE.Views.Statusbar = Common.UI.BaseView.extend(_.extend({
|
|
|
|
el: '#statusbar',
|
|
|
|
template: _.template(template),
|
|
|
|
|
|
|
|
events: function() {
|
|
|
|
return {
|
|
|
|
'click #status-btn-tabback': _.bind(this.onBtnTabScroll, this, 'backward'),
|
2022-05-11 16:55:52 +00:00
|
|
|
'click #status-btn-tabnext': _.bind(this.onBtnTabScroll, this, 'forward')
|
2016-03-11 00:48:53 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
api: undefined,
|
|
|
|
|
|
|
|
initialize: function (options) {
|
|
|
|
_.extend(this, options);
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function () {
|
|
|
|
var me = this;
|
|
|
|
$(this.el).html(this.template({
|
|
|
|
scope: this
|
|
|
|
}));
|
|
|
|
|
2021-07-26 13:57:01 +00:00
|
|
|
this.cntStatusbar = $('.statusbar', this.el);
|
2021-08-10 15:34:00 +00:00
|
|
|
this.isCompact = Common.localStorage.getBool('sse-compact-statusbar', true);
|
2021-07-26 13:57:01 +00:00
|
|
|
if (!this.isCompact) {
|
|
|
|
this.cntStatusbar.addClass('no-compact');
|
|
|
|
}
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
this.editMode = false;
|
2019-10-15 09:36:27 +00:00
|
|
|
this.rangeSelectionMode = Asc.c_oAscSelectionDialogType.None;
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
this.btnZoomDown = new Common.UI.Button({
|
|
|
|
el: $('#status-btn-zoomdown',this.el),
|
|
|
|
hint: this.tipZoomOut+' (Ctrl+-)',
|
|
|
|
hintAnchor: 'top'
|
|
|
|
});
|
|
|
|
|
|
|
|
this.btnZoomUp = new Common.UI.Button({
|
|
|
|
el: $('#status-btn-zoomup',this.el),
|
|
|
|
hint: this.tipZoomIn+' (Ctrl++)',
|
|
|
|
hintAnchor: 'top-right'
|
|
|
|
});
|
|
|
|
|
|
|
|
this.btnScrollBack = new Common.UI.Button({
|
|
|
|
el: $('#status-btn-tabback',this.el),
|
|
|
|
hint: this.tipPrev,
|
|
|
|
disabled: true,
|
|
|
|
hintAnchor: 'top'
|
|
|
|
});
|
|
|
|
|
|
|
|
this.btnScrollNext = new Common.UI.Button({
|
|
|
|
el: $('#status-btn-tabnext',this.el),
|
|
|
|
hint: this.tipNext,
|
|
|
|
disabled: true,
|
|
|
|
hintAnchor: 'top'
|
|
|
|
});
|
|
|
|
|
|
|
|
this.btnAddWorksheet = new Common.UI.Button({
|
|
|
|
el: $('#status-btn-addtab',this.el),
|
|
|
|
hint: this.tipAddTab,
|
|
|
|
disabled: true,
|
|
|
|
hintAnchor: 'top'
|
|
|
|
});
|
|
|
|
|
2021-06-30 12:36:53 +00:00
|
|
|
this.cntSheetList = new Common.UI.Button({
|
2021-06-26 13:16:33 +00:00
|
|
|
el: $('.cnt-tabslist', this.el),
|
|
|
|
hint: this.tipListOfSheets,
|
|
|
|
hintAnchor: 'top'
|
|
|
|
});
|
2021-06-30 12:36:53 +00:00
|
|
|
this.btnSheetList = $('#status-btn-tabslist',this.$el);
|
2021-06-26 13:16:33 +00:00
|
|
|
this.sheetListMenu = new Common.UI.Menu({
|
|
|
|
style: 'margin-top:-3px;',
|
|
|
|
menuAlign: 'bl-tl',
|
|
|
|
maxHeight: 300
|
|
|
|
});
|
|
|
|
this.sheetListMenu.on('item:click', function(obj,item) {
|
|
|
|
me.fireEvent('show:tab', [item.value]);
|
|
|
|
});
|
2021-06-30 12:36:53 +00:00
|
|
|
this.cntSheetList.cmpEl.on({
|
2021-06-26 13:16:33 +00:00
|
|
|
'show.bs.dropdown': function () {
|
|
|
|
_.defer(function(){
|
2021-06-30 12:36:53 +00:00
|
|
|
me.cntSheetList.cmpEl.find('ul').focus();
|
2021-06-26 13:16:33 +00:00
|
|
|
}, 100);
|
|
|
|
},
|
|
|
|
'hide.bs.dropdown': function () {
|
|
|
|
_.defer(function(){
|
|
|
|
me.api.asc_enableKeyEvents(true);
|
|
|
|
}, 100);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
this.sheetListMenu.render($('.cnt-tabslist',this.el));
|
|
|
|
this.sheetListMenu.cmpEl.attr({tabindex: -1});
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
this.cntZoom = new Common.UI.Button({
|
|
|
|
el: $('.cnt-zoom',this.el),
|
|
|
|
hint: this.tipZoomFactor,
|
|
|
|
hintAnchor: 'top'
|
|
|
|
});
|
|
|
|
this.cntZoom.cmpEl.on({
|
|
|
|
'show.bs.dropdown': function () {
|
|
|
|
_.defer(function(){
|
|
|
|
me.cntZoom.cmpEl.find('ul').focus();
|
|
|
|
}, 100);
|
|
|
|
},
|
|
|
|
'hide.bs.dropdown': function () {
|
|
|
|
_.defer(function(){
|
|
|
|
me.api.asc_enableKeyEvents(true);
|
|
|
|
}, 100);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
this.zoomMenu = new Common.UI.Menu({
|
|
|
|
style: 'margin-top:-5px;',
|
|
|
|
menuAlign: 'bl-tl',
|
|
|
|
items: [
|
|
|
|
{ caption: "50%", value: 50 },
|
|
|
|
{ caption: "75%", value: 75 },
|
|
|
|
{ caption: "100%", value: 100 },
|
|
|
|
{ caption: "125%", value: 125 },
|
|
|
|
{ caption: "150%", value: 150 },
|
|
|
|
{ caption: "175%", value: 175 },
|
2021-11-29 10:20:45 +00:00
|
|
|
{ caption: "200%", value: 200 },
|
|
|
|
{ caption: "300%", value: 300 },
|
|
|
|
{ caption: "400%", value: 400 },
|
|
|
|
{ caption: "500%", value: 500 }
|
2016-03-11 00:48:53 +00:00
|
|
|
]
|
|
|
|
});
|
|
|
|
this.zoomMenu.render($('.cnt-zoom',this.el));
|
|
|
|
this.zoomMenu.cmpEl.attr({tabindex: -1});
|
|
|
|
|
|
|
|
this.labelZoom = $('#status-label-zoom',this.$el);
|
|
|
|
|
|
|
|
this.tabBarBox = $('#status-sheets-bar-box', this.el);
|
|
|
|
this.tabbar = new Common.UI.TabBar({
|
|
|
|
el: '#status-sheets-bar',
|
|
|
|
placement: 'bottom',
|
|
|
|
draggable: false
|
|
|
|
}).render();
|
|
|
|
|
|
|
|
this.tabbar.on({
|
|
|
|
'tab:invisible' : _.bind(this.onTabInvisible, this),
|
|
|
|
'tab:changed' : _.bind(this.onSheetChanged, this),
|
|
|
|
//'tab:manual' : _.bind(this.onAddTabClick, this),
|
|
|
|
'tab:contextmenu' : _.bind(this.onTabMenu, this),
|
|
|
|
'tab:dblclick' : _.bind(function () {
|
2021-02-16 11:49:13 +00:00
|
|
|
if (me.editMode && !(me.mode && me.mode.isDisconnected) && (me.rangeSelectionMode !== Asc.c_oAscSelectionDialogType.Chart) &&
|
2020-03-19 09:15:45 +00:00
|
|
|
(me.rangeSelectionMode !== Asc.c_oAscSelectionDialogType.FormatTable)&&
|
|
|
|
(me.rangeSelectionMode !== Asc.c_oAscSelectionDialogType.PrintTitles)) {
|
2016-03-11 00:48:53 +00:00
|
|
|
me.fireEvent('sheet:changename');
|
|
|
|
}
|
|
|
|
}, this),
|
2020-02-18 11:43:56 +00:00
|
|
|
'tab:dragstart': _.bind(function (dataTransfer, selectTabs) {
|
2021-04-05 14:58:06 +00:00
|
|
|
Common.Utils.isIE && (this.isDrop = false);
|
2020-09-03 17:08:47 +00:00
|
|
|
Common.UI.Menu.Manager.hideAll();
|
2020-02-25 09:05:23 +00:00
|
|
|
this.api.asc_closeCellEditor();
|
2020-02-13 09:09:05 +00:00
|
|
|
var arrTabs = [],
|
2020-01-14 08:53:55 +00:00
|
|
|
arrName = [],
|
|
|
|
me = this;
|
2020-02-13 09:09:05 +00:00
|
|
|
var wc = me.api.asc_getWorksheetsCount(), items = [], i = -1;
|
|
|
|
while (++i < wc) {
|
|
|
|
if (!this.api.asc_isWorksheetHidden(i)) {
|
|
|
|
items.push({
|
|
|
|
value: me.api.asc_getWorksheetName(i),
|
|
|
|
inindex: i
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var arrSelectIndex = [];
|
|
|
|
selectTabs.forEach(function (item) {
|
|
|
|
arrSelectIndex.push(item.sheetindex);
|
|
|
|
});
|
|
|
|
items.forEach(function (item) {
|
|
|
|
if (arrSelectIndex.indexOf(item.inindex) !== -1) {
|
|
|
|
arrTabs.push(item.inindex);
|
|
|
|
arrName.push(item.value);
|
|
|
|
}
|
2020-01-13 08:36:22 +00:00
|
|
|
});
|
2020-02-18 11:43:56 +00:00
|
|
|
var stringSheet, arr = [];
|
|
|
|
stringSheet = this.api.asc_StartMoveSheet(_.clone(arrTabs));
|
|
|
|
arr.push({type: 'onlyoffice', value: stringSheet});
|
|
|
|
arr.push({type: 'indexes', value: arrTabs});
|
|
|
|
arr.push({type: 'names', value: arrName});
|
|
|
|
arr.push({type: 'key', value: Common.Utils.InternalSettings.get("sse-doc-info-key")});
|
|
|
|
var json = JSON.stringify(arr);
|
2021-04-05 14:58:06 +00:00
|
|
|
if (!Common.Utils.isIE) {
|
|
|
|
dataTransfer.setData('onlyoffice', json);
|
|
|
|
} else {
|
|
|
|
dataTransfer.setData('text', 'sheet');
|
|
|
|
this.dataTransfer = json;
|
|
|
|
}
|
2020-02-18 11:43:56 +00:00
|
|
|
this.dropTabs = selectTabs;
|
2019-12-12 11:35:57 +00:00
|
|
|
}, this),
|
2021-08-31 14:03:39 +00:00
|
|
|
'tab:drop': _.bind(function (dataTransfer, index, copy) {
|
2021-04-05 14:58:06 +00:00
|
|
|
if (this.isEditFormula || (Common.Utils.isIE && this.dataTransfer === undefined)) return;
|
|
|
|
Common.Utils.isIE && (this.isDrop = true);
|
|
|
|
var data = !Common.Utils.isIE ? dataTransfer.getData('onlyoffice') : this.dataTransfer;
|
2020-02-18 11:43:56 +00:00
|
|
|
if (data) {
|
|
|
|
var arrData = JSON.parse(data);
|
2020-02-25 09:05:23 +00:00
|
|
|
if (arrData) {
|
2020-02-18 11:43:56 +00:00
|
|
|
var key = _.findWhere(arrData, {type: 'key'}).value;
|
|
|
|
if (Common.Utils.InternalSettings.get("sse-doc-info-key") === key) {
|
2021-08-31 14:03:39 +00:00
|
|
|
this.fireEvent('sheet:move', [_.findWhere(arrData, {type: 'indexes'}).value, !copy, true, _.isNumber(index) ? index : this.api.asc_getWorksheetsCount()]);
|
2020-02-25 11:37:43 +00:00
|
|
|
Common.NotificationCenter.trigger('tabs:dragend', this);
|
2020-02-18 11:43:56 +00:00
|
|
|
} else {
|
|
|
|
var names = [], wc = this.api.asc_getWorksheetsCount();
|
|
|
|
while (wc--) {
|
|
|
|
names.push(this.api.asc_getWorksheetName(wc).toLowerCase());
|
|
|
|
}
|
|
|
|
var newNames = [];
|
|
|
|
var arrNames = _.findWhere(arrData, {type: 'names'}).value;
|
|
|
|
arrNames.forEach(function (name) {
|
2020-08-06 11:51:59 +00:00
|
|
|
var ind = 1,
|
2020-02-18 11:43:56 +00:00
|
|
|
name = name;
|
2020-08-06 11:51:59 +00:00
|
|
|
var re = /^(.*)\((\d)\)$/.exec(name);
|
|
|
|
var first = re ? re[1] : name + ' ';
|
|
|
|
var arr = [];
|
|
|
|
newNames.length > 0 && newNames.forEach(function (item) {
|
|
|
|
arr.push(item.toLowerCase());
|
|
|
|
});
|
|
|
|
while (names.indexOf(name.toLowerCase()) !== -1 || arr.indexOf(name.toLowerCase()) !== -1) {
|
|
|
|
ind++;
|
|
|
|
name = first + '(' + ind + ')';
|
2020-02-18 11:43:56 +00:00
|
|
|
}
|
2020-08-06 11:51:59 +00:00
|
|
|
newNames.push(name);
|
2020-02-18 11:43:56 +00:00
|
|
|
});
|
2020-08-31 11:29:07 +00:00
|
|
|
var index = _.isNumber(index) ? index : this.api.asc_getWorksheetsCount();
|
2020-02-18 11:43:56 +00:00
|
|
|
this.api.asc_EndMoveSheet(index, newNames, _.findWhere(arrData, {type: 'onlyoffice'}).value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, this),
|
|
|
|
'tab:dragend': _.bind(function (cut) {
|
2021-04-05 14:58:06 +00:00
|
|
|
if (cut && !(Common.Utils.isIE && this.isDrop === false)) {
|
2020-02-18 11:43:56 +00:00
|
|
|
if (this.dropTabs.length > 0) {
|
|
|
|
var arr = [];
|
|
|
|
this.dropTabs.forEach(function (tab) {
|
|
|
|
arr.push(tab.sheetindex);
|
|
|
|
});
|
|
|
|
me.api.asc_deleteWorksheet(arr);
|
2020-02-13 09:09:05 +00:00
|
|
|
}
|
2020-01-24 11:26:16 +00:00
|
|
|
}
|
2020-02-18 11:43:56 +00:00
|
|
|
this.dropTabs = undefined;
|
2021-04-05 14:58:06 +00:00
|
|
|
if (Common.Utils.isIE) {
|
|
|
|
this.isDrop = undefined;
|
|
|
|
this.dataTransfer = undefined;
|
|
|
|
}
|
2020-02-25 11:37:43 +00:00
|
|
|
Common.NotificationCenter.trigger('tabs:dragend', this);
|
2016-03-11 00:48:53 +00:00
|
|
|
}, this)
|
|
|
|
});
|
|
|
|
|
|
|
|
var menuHiddenItems = new Common.UI.Menu({
|
2021-11-30 13:35:42 +00:00
|
|
|
maxHeight: 267,
|
2016-03-11 00:48:53 +00:00
|
|
|
menuAlign: 'tl-tr'
|
2016-11-10 07:19:17 +00:00
|
|
|
}).on('show:after', function () {
|
|
|
|
this.scroller.update({alwaysVisibleY: true});
|
2016-03-11 00:48:53 +00:00
|
|
|
});
|
|
|
|
menuHiddenItems.on('item:click', function(obj,item,e) {
|
|
|
|
me.fireEvent('show:hidden', [me, item.value]);
|
|
|
|
});
|
|
|
|
|
|
|
|
var menuColorItems = new Common.UI.Menu({
|
|
|
|
menuAlign: 'tl-tr',
|
|
|
|
cls: 'color-tab',
|
|
|
|
items: [
|
2022-04-22 20:18:17 +00:00
|
|
|
{ template: _.template('<div id="id-tab-menu-color" style="width: 164px;display: inline-block;"></div>') },
|
2022-04-22 18:34:30 +00:00
|
|
|
{caption: '--'},
|
2022-04-28 12:09:38 +00:00
|
|
|
{
|
|
|
|
id: "id-tab-menu-new-color",
|
|
|
|
template: _.template('<a tabindex="-1" type="menuitem" style="padding-left:12px;">' + me.textNewColor + '</a>')
|
|
|
|
}
|
2016-03-11 00:48:53 +00:00
|
|
|
]
|
|
|
|
});
|
|
|
|
|
|
|
|
function dummyCmp() {
|
|
|
|
return {
|
|
|
|
isDummy : true,
|
|
|
|
on : function() {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
me.mnuTabColor = dummyCmp();
|
|
|
|
this.tabMenu = new Common.UI.Menu({
|
|
|
|
menuAlign: 'bl-tl',
|
|
|
|
items: [
|
|
|
|
{caption: this.itemInsert, value: 'ins'},
|
|
|
|
{caption: this.itemDelete, value: 'del'},
|
|
|
|
{caption: this.itemRename, value: 'ren'},
|
|
|
|
{caption: this.itemCopy, value: 'copy'},
|
|
|
|
{caption: this.itemMove, value: 'move'},
|
|
|
|
{caption: this.itemHide, value: 'hide'},
|
|
|
|
{
|
|
|
|
caption: this.itemHidden,
|
|
|
|
menu: menuHiddenItems
|
|
|
|
},
|
2021-08-04 21:37:48 +00:00
|
|
|
{caption: this.itemProtect, value: 'protect'},
|
2016-03-11 00:48:53 +00:00
|
|
|
{
|
|
|
|
caption: this.itemTabColor,
|
|
|
|
menu: menuColorItems
|
2019-09-06 10:07:47 +00:00
|
|
|
},
|
|
|
|
{ caption: '--' },
|
|
|
|
{caption: this.selectAllSheets, value: 'selectall'},
|
|
|
|
{caption: this.ungroupSheets, value: 'noselect'}
|
2016-03-11 00:48:53 +00:00
|
|
|
]
|
|
|
|
}).on('render:after', function(btn) {
|
|
|
|
me.mnuTabColor = new Common.UI.ThemeColorPalette({
|
|
|
|
el: $('#id-tab-menu-color'),
|
2022-04-28 14:18:06 +00:00
|
|
|
outerMenu: {menu: menuColorItems, index: 0, focusOnShow: true},
|
2016-08-08 14:13:39 +00:00
|
|
|
transparent: true
|
2016-03-11 00:48:53 +00:00
|
|
|
});
|
2022-04-28 12:09:38 +00:00
|
|
|
menuColorItems.setInnerMenu([{menu: me.mnuTabColor, index: 0}]);
|
2016-03-11 00:48:53 +00:00
|
|
|
me.mnuTabColor.on('select', function(picker, color) {
|
|
|
|
me.fireEvent('sheet:setcolor', [color]);
|
2022-04-28 14:18:06 +00:00
|
|
|
setTimeout(function(){
|
|
|
|
me.tabMenu.hide();
|
|
|
|
}, 1);
|
2016-03-11 00:48:53 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-06-23 19:05:25 +00:00
|
|
|
var customizeStatusBarMenuTemplate = _.template('<a id="<%= id %>" tabindex="-1" type="menuitem">'+
|
|
|
|
'<div style="position: relative;">'+
|
2021-11-15 16:27:26 +00:00
|
|
|
'<div class="item-caption"><%= caption %></div>' +
|
|
|
|
'<label class="item-value"><%= options.exampleval ? options.exampleval : "" %></label>' +
|
2020-06-23 19:05:25 +00:00
|
|
|
'</div></a>');
|
|
|
|
|
2020-06-17 14:39:13 +00:00
|
|
|
this.customizeStatusBarMenu = new Common.UI.Menu({
|
|
|
|
menuAlign: 'bl-tl',
|
2021-07-29 12:47:51 +00:00
|
|
|
menuAlignEl: $(this.el),
|
2020-06-17 14:39:13 +00:00
|
|
|
items: [
|
2020-06-17 20:03:34 +00:00
|
|
|
//{template: _.template('<div style="padding-left: 6px; padding-top: 2px;">' + this.textCustomizeStatusBar + '</div>')},
|
|
|
|
//{caption: '--'},
|
2021-08-16 14:22:13 +00:00
|
|
|
{
|
|
|
|
id: 'saved-status',
|
|
|
|
caption: this.itemStatus,
|
|
|
|
value: 'status',
|
|
|
|
checkable: true,
|
|
|
|
checked: true,
|
|
|
|
template: customizeStatusBarMenuTemplate,
|
|
|
|
exampleval: ''
|
|
|
|
},
|
|
|
|
{caption: '--'},
|
2020-06-23 19:05:25 +00:00
|
|
|
{
|
|
|
|
id: 'math-item-average',
|
|
|
|
caption: this.itemAverage,
|
|
|
|
value: 'average',
|
|
|
|
checkable: true,
|
|
|
|
checked: true,
|
|
|
|
template: customizeStatusBarMenuTemplate,
|
|
|
|
exampleval: ''
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'math-item-count',
|
|
|
|
caption: this.itemCount,
|
|
|
|
value: 'count',
|
|
|
|
checkable: true,
|
|
|
|
checked: true,
|
|
|
|
template: customizeStatusBarMenuTemplate,
|
|
|
|
exampleval: ''
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'math-item-min',
|
|
|
|
caption: this.itemMinimum,
|
|
|
|
value: 'min',
|
|
|
|
checkable: true,
|
|
|
|
checked: true,
|
|
|
|
template: customizeStatusBarMenuTemplate,
|
|
|
|
exampleval: ''
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'math-item-max',
|
|
|
|
caption: this.itemMaximum,
|
|
|
|
value: 'max',
|
|
|
|
checkable: true,
|
|
|
|
checked: true,
|
|
|
|
template: customizeStatusBarMenuTemplate,
|
|
|
|
exampleval: ''
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'math-item-sum',
|
|
|
|
caption: this.itemSum,
|
|
|
|
value: 'sum',
|
|
|
|
checkable: true,
|
|
|
|
checked: true,
|
|
|
|
template: customizeStatusBarMenuTemplate,
|
|
|
|
exampleval: ''
|
|
|
|
}
|
|
|
|
]
|
2020-06-17 14:39:13 +00:00
|
|
|
});
|
|
|
|
|
2020-06-05 13:10:48 +00:00
|
|
|
this.tabbar.$el.append('<div class="dropdown-toggle" data-toggle="dropdown" style="width:0; height:0;"></div>');
|
2016-03-11 00:48:53 +00:00
|
|
|
this.tabMenu.render(this.tabbar.$el);
|
2016-11-18 08:23:29 +00:00
|
|
|
this.tabMenu.cmpEl.attr({tabindex: -1});
|
2016-03-11 00:48:53 +00:00
|
|
|
this.tabMenu.on('show:after', _.bind(this.onTabMenuAfterShow, this));
|
|
|
|
this.tabMenu.on('hide:after', _.bind(this.onTabMenuAfterHide, this));
|
|
|
|
this.tabMenu.on('item:click', _.bind(this.onTabMenuClick, this));
|
|
|
|
|
|
|
|
this.boxMath = $('#status-math-box', this.el);
|
|
|
|
this.labelSum = $('#status-math-sum', this.boxMath);
|
|
|
|
this.labelCount = $('#status-math-count', this.boxMath);
|
|
|
|
this.labelAverage = $('#status-math-average', this.boxMath);
|
2019-02-28 08:31:15 +00:00
|
|
|
this.labelMin = $('#status-math-min', this.boxMath);
|
|
|
|
this.labelMax = $('#status-math-max', this.boxMath);
|
2016-03-11 00:48:53 +00:00
|
|
|
this.boxMath.hide();
|
|
|
|
|
2017-02-06 11:22:34 +00:00
|
|
|
this.boxFiltered = $('#status-filtered-box', this.el);
|
|
|
|
this.labelFiltered = $('#status-filtered-records', this.boxFiltered);
|
|
|
|
this.boxFiltered.hide();
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
this.boxZoom = $('#status-zoom-box', this.el);
|
|
|
|
this.boxZoom.find('.separator').css('border-left-color','transparent');
|
|
|
|
|
2021-07-26 13:57:01 +00:00
|
|
|
this.boxNumberSheets = $('#status-number-of-sheet', this.el);
|
|
|
|
this.isCompact && this.boxNumberSheets.hide();
|
2021-07-28 16:49:34 +00:00
|
|
|
this.labelNumberSheets = $('#label-sheets', this.boxNumberSheets);
|
2021-07-26 13:57:01 +00:00
|
|
|
|
|
|
|
this.boxAction = $('#status-action', this.el);
|
2021-08-16 14:22:13 +00:00
|
|
|
this.boxAction.hide();
|
2021-07-28 16:49:34 +00:00
|
|
|
this.labelAction = $('#label-action', this.boxAction);
|
2021-07-26 13:57:01 +00:00
|
|
|
|
2020-06-17 14:39:13 +00:00
|
|
|
this.$el.append('<div id="statusbar-menu" style="width:0; height:0;"></div>');
|
|
|
|
this.$customizeStatusBarMenu = this.$el.find('#statusbar-menu');
|
|
|
|
this.$customizeStatusBarMenu.on({
|
|
|
|
'show.bs.dropdown': function () {
|
|
|
|
_.defer(function(){
|
|
|
|
me.$customizeStatusBarMenu.find('ul').focus();
|
|
|
|
}, 100);
|
|
|
|
},
|
|
|
|
'hide.bs.dropdown': function () {
|
|
|
|
_.defer(function(){
|
|
|
|
me.api.asc_enableKeyEvents(true);
|
|
|
|
}, 100);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
this.$customizeStatusBarMenu.append('<div class="dropdown-toggle" data-toggle="dropdown" style="width:0; height:0;"></div>');
|
|
|
|
this.customizeStatusBarMenu.render(this.$customizeStatusBarMenu);
|
|
|
|
this.customizeStatusBarMenu.cmpEl.attr({tabindex: -1});
|
|
|
|
this.customizeStatusBarMenu.on('show:after', _.bind(this.onCustomizeStatusBarAfterShow, this));
|
|
|
|
this.customizeStatusBarMenu.on('hide:after', _.bind(this.onCustomizeStatusBarAfterHide, this));
|
|
|
|
this.customizeStatusBarMenu.on('item:click', _.bind(this.onCustomizeStatusBarClick, this));
|
2020-06-17 20:03:34 +00:00
|
|
|
this.$el.on('contextmenu', _.bind(this.showCustomizeStatusBar, this));
|
2020-06-17 14:39:13 +00:00
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
setApi: function(api) {
|
|
|
|
this.api = api;
|
|
|
|
this.api.asc_registerCallback('asc_onSheetsChanged', _.bind(this.update, this));
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
setMode: function(mode) {
|
|
|
|
this.mode = _.extend({}, this.mode, mode);
|
|
|
|
// this.$el.find('.el-edit')[mode.isEdit?'show':'hide']();
|
2021-10-08 17:00:17 +00:00
|
|
|
//this.btnAddWorksheet.setVisible(this.mode.isEdit);
|
2022-03-16 11:17:25 +00:00
|
|
|
$('#status-addtabs-box')[(this.mode.isEdit) ? 'show' : 'hide']();
|
2021-06-28 17:12:31 +00:00
|
|
|
this.btnAddWorksheet.setDisabled(this.mode.isDisconnected || this.api && (this.api.asc_isWorkbookLocked() || this.api.isCellEdited) || this.rangeSelectionMode!=Asc.c_oAscSelectionDialogType.None);
|
2022-03-16 13:24:14 +00:00
|
|
|
if (this.mode.isEditOle) { // change hints order
|
2022-03-18 18:41:25 +00:00
|
|
|
this.btnAddWorksheet.$el.find('button').addBack().filter('button').attr('data-hint', '1');
|
|
|
|
this.btnScrollBack.$el.find('button').addBack().filter('button').attr('data-hint', '1');
|
|
|
|
this.btnScrollNext.$el.find('button').addBack().filter('button').attr('data-hint', '1');
|
2022-03-16 13:24:14 +00:00
|
|
|
this.cntSheetList.$el.find('button').attr('data-hint', '1');
|
|
|
|
this.cntSheetList.$el.find('button').removeAttr('data-hint-title'); // 'v' hint is used for paste
|
|
|
|
this.cntZoom.$el.find('.dropdown-toggle').attr('data-hint', '1');
|
|
|
|
}
|
2016-03-11 00:48:53 +00:00
|
|
|
this.updateTabbarBorders();
|
|
|
|
},
|
|
|
|
|
|
|
|
setVisible: function(visible) {
|
|
|
|
visible ? this.show(): this.hide();
|
|
|
|
},
|
|
|
|
|
2021-12-13 16:20:55 +00:00
|
|
|
isVisible: function() {
|
|
|
|
return this.$el && this.$el.is(':visible');
|
|
|
|
},
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
update: function() {
|
|
|
|
var me = this;
|
|
|
|
|
|
|
|
this.tabbar.empty(true);
|
|
|
|
this.tabMenu.items[6].menu.removeAll();
|
|
|
|
this.tabMenu.items[6].hide();
|
|
|
|
this.btnAddWorksheet.setDisabled(true);
|
2021-06-26 13:16:33 +00:00
|
|
|
this.sheetListMenu.removeAll();
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
if (this.api) {
|
|
|
|
var wc = this.api.asc_getWorksheetsCount(), i = -1;
|
2021-06-26 13:16:33 +00:00
|
|
|
var hidentems = [], items = [], allItems = [], tab, locked, name;
|
2016-03-11 00:48:53 +00:00
|
|
|
var sindex = this.api.asc_getActiveWorksheetIndex();
|
2021-06-25 15:29:17 +00:00
|
|
|
var wbprotected = this.api.asc_isProtectedWorkbook();
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
while (++i < wc) {
|
|
|
|
locked = me.api.asc_isWorksheetLockedOrDeleted(i);
|
2020-09-29 11:22:39 +00:00
|
|
|
name = me.api.asc_getActiveNamedSheetView ? me.api.asc_getActiveNamedSheetView(i) || '' : '';
|
2016-03-11 00:48:53 +00:00
|
|
|
tab = {
|
|
|
|
sheetindex : i,
|
2020-01-13 08:36:22 +00:00
|
|
|
index : items.length,
|
2016-03-11 00:48:53 +00:00
|
|
|
active : sindex == i,
|
|
|
|
label : me.api.asc_getWorksheetName(i),
|
|
|
|
// reorderable : !locked,
|
|
|
|
cls : locked ? 'coauth-locked':'',
|
2021-06-25 15:29:17 +00:00
|
|
|
isLockTheDrag : locked || me.mode.isDisconnected || wbprotected,
|
2020-07-16 15:04:34 +00:00
|
|
|
iconCls : 'btn-sheet-view',
|
|
|
|
iconTitle : name,
|
|
|
|
iconVisible : name!==''
|
2016-03-11 00:48:53 +00:00
|
|
|
};
|
2021-11-16 13:56:34 +00:00
|
|
|
this.api.asc_isWorksheetHidden(i)? hidentems.push(tab) : items.push(tab);
|
|
|
|
allItems.push(tab);
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (hidentems.length) {
|
|
|
|
hidentems.forEach(function(item){
|
|
|
|
me.tabMenu.items[6].menu.addItem(new Common.UI.MenuItem({
|
|
|
|
style: 'white-space: pre-wrap',
|
|
|
|
caption: Common.Utils.String.htmlEncode(item.label),
|
|
|
|
value: item.sheetindex
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
this.tabMenu.items[6].show();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.tabbar.add(items);
|
|
|
|
|
2021-06-26 13:16:33 +00:00
|
|
|
allItems.forEach(function(item){
|
2021-11-16 13:56:34 +00:00
|
|
|
var hidden = me.api.asc_isWorksheetHidden(item.sheetindex);
|
2021-06-26 13:16:33 +00:00
|
|
|
me.sheetListMenu.addItem(new Common.UI.MenuItem({
|
2021-07-15 19:39:57 +00:00
|
|
|
style: 'white-space: pre',
|
2021-06-26 13:16:33 +00:00
|
|
|
caption: Common.Utils.String.htmlEncode(item.label),
|
|
|
|
value: item.sheetindex,
|
|
|
|
checkable: true,
|
|
|
|
checked: item.active,
|
2021-11-16 13:56:34 +00:00
|
|
|
hidden: hidden,
|
|
|
|
visible: !hidden || !wbprotected,
|
2021-06-26 13:16:33 +00:00
|
|
|
textHidden: me.itemHidden,
|
|
|
|
template: _.template([
|
2021-06-30 12:36:53 +00:00
|
|
|
'<a id="<%= id %>" style="<%= style %>" tabindex="-1" type="menuitem" <% if (options.hidden) { %> data-hidden="true" <% } %>>',
|
2021-06-26 13:16:33 +00:00
|
|
|
'<div class="color"></div>',
|
|
|
|
'<span class="name"><%= caption %></span>',
|
|
|
|
'<% if (options.hidden) { %>',
|
|
|
|
'<span class="hidden-mark"><%= options.textHidden %></span>',
|
|
|
|
'<% } %>',
|
|
|
|
'</a>'
|
|
|
|
].join(''))
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
if (!_.isUndefined(this.tabBarScroll)) {
|
|
|
|
this.tabbar.$bar.scrollLeft(this.tabBarScroll.scrollLeft);
|
|
|
|
this.tabBarScroll = undefined;
|
|
|
|
}
|
|
|
|
if (!this.tabbar.isTabVisible(sindex))
|
|
|
|
this.tabbar.setTabVisible(sindex);
|
|
|
|
|
2021-11-11 13:53:43 +00:00
|
|
|
this.btnAddWorksheet.setDisabled(me.mode.isDisconnected || me.api.asc_isWorkbookLocked() || wbprotected || me.api.isCellEdited);
|
2022-03-18 18:41:25 +00:00
|
|
|
if (this.mode.isEdit) {
|
2021-10-08 17:00:17 +00:00
|
|
|
this.tabbar.addDataHint(_.findIndex(items, function (item) {
|
|
|
|
return item.sheetindex === sindex;
|
2022-03-18 18:41:25 +00:00
|
|
|
}), this.mode.isEditOle ? '1' : '0');
|
2021-10-08 17:00:17 +00:00
|
|
|
}
|
2021-07-05 17:17:04 +00:00
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
$('#status-label-zoom').text(Common.Utils.String.format(this.zoomText, Math.floor((this.api.asc_getZoom() +.005)*100)));
|
|
|
|
|
2021-07-28 16:49:34 +00:00
|
|
|
this.updateNumberOfSheet(sindex, wc);
|
2021-08-16 14:22:13 +00:00
|
|
|
this.updateTabbarBorders();
|
2021-07-28 16:49:34 +00:00
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
me.fireEvent('sheet:changed', [me, sindex]);
|
|
|
|
me.fireEvent('sheet:updateColors', [true]);
|
2018-11-16 13:44:11 +00:00
|
|
|
Common.NotificationCenter.trigger('comments:updatefilter', ['doc', 'sheet' + me.api.asc_getActiveWorksheetId()], false);
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
setMathInfo: function(info) {
|
|
|
|
if (info.count>1) {
|
|
|
|
if (!this.boxMath.is(':visible')) this.boxMath.show();
|
2020-06-26 14:54:44 +00:00
|
|
|
this.labelCount.text(this.textCount + ': ' + info.count);
|
|
|
|
this.labelMin.text((info.min && info.min.length) ? (this.textMin + ': ' + info.min) : '');
|
|
|
|
this.labelMax.text((info.max && info.max.length) ? (this.textMax + ': ' + info.max) : '');
|
|
|
|
this.labelSum.text((info.sum && info.sum.length) ? (this.textSum + ': ' + info.sum) : '');
|
|
|
|
this.labelAverage.text((info.average && info.average.length) ? (this.textAverage + ': ' + info.average) : '');
|
2020-06-23 19:05:25 +00:00
|
|
|
|
2021-08-11 16:26:28 +00:00
|
|
|
this.labelMin[info.min && info.min.length > 0 ? 'show' : 'hide']();
|
|
|
|
this.labelMax[info.max && info.max.length > 0 ? 'show' : 'hide']();
|
|
|
|
this.labelSum[info.sum && info.sum.length > 0 ? 'show' : 'hide']();
|
|
|
|
this.labelAverage[info.average && info.average.length > 0 ? 'show' : 'hide']();
|
|
|
|
|
2020-06-23 19:05:25 +00:00
|
|
|
this.customizeStatusBarMenu.items.forEach(function (item) {
|
|
|
|
if (item.options.id === 'math-item-average') {
|
|
|
|
item.options.exampleval = (info.average && info.average.length) ? info.average : '';
|
|
|
|
} else if (item.options.id === 'math-item-min') {
|
|
|
|
item.options.exampleval = (info.min && info.min.length) ? info.min : '';
|
|
|
|
} else if (item.options.id === 'math-item-max') {
|
|
|
|
item.options.exampleval = (info.max && info.max.length) ? info.max : '';
|
|
|
|
} else if (item.options.id === 'math-item-count') {
|
|
|
|
item.options.exampleval = (info.count) ? String(info.count) : '';
|
|
|
|
} else if (item.options.id === 'math-item-sum') {
|
|
|
|
item.options.exampleval = (info.sum && info.sum.length) ? info.sum : '';
|
|
|
|
}
|
|
|
|
$(item.el).find('label').text(item.options.exampleval);
|
|
|
|
});
|
2016-03-11 00:48:53 +00:00
|
|
|
} else {
|
2020-06-23 19:05:25 +00:00
|
|
|
this.customizeStatusBarMenu.items.forEach(function (item) {
|
|
|
|
item.options.exampleval = '';
|
|
|
|
$(item.el).find('label').text('');
|
|
|
|
});
|
2016-03-11 00:48:53 +00:00
|
|
|
if (this.boxMath.is(':visible')) this.boxMath.hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
var me = this;
|
|
|
|
_.delay(function(){
|
2020-06-26 14:54:44 +00:00
|
|
|
me.updateVisibleItemsBoxMath();
|
|
|
|
me.updateTabbarBorders();
|
2016-03-11 00:48:53 +00:00
|
|
|
me.onTabInvisible(undefined, me.tabbar.checkInvisible(true));
|
|
|
|
},30);
|
|
|
|
},
|
|
|
|
|
2017-02-06 11:22:34 +00:00
|
|
|
setFilteredInfo: function(countFilter, countRecords) {
|
|
|
|
if (countFilter>0 && countRecords>0) {//filter is applied
|
|
|
|
if (!this.boxFiltered.is(':visible')) this.boxFiltered.show();
|
|
|
|
this.labelFiltered.text(Common.Utils.String.format(this.filteredRecordsText, countFilter, countRecords));
|
|
|
|
} else if (countFilter) {// filter mode
|
|
|
|
if (!this.boxFiltered.is(':visible')) this.boxFiltered.show();
|
|
|
|
this.labelFiltered.text(this.filteredText);
|
2017-04-11 11:05:56 +00:00
|
|
|
} else if (countFilter !== undefined && countFilter !== null){
|
2017-02-06 11:22:34 +00:00
|
|
|
if (this.boxFiltered.is(':visible')) this.boxFiltered.hide();
|
2017-04-11 11:05:56 +00:00
|
|
|
} else {
|
|
|
|
var filterInfo = this.api.asc_getCellInfo().asc_getAutoFilterInfo(),
|
|
|
|
need_disable = !filterInfo || (filterInfo.asc_getIsApplyAutoFilter()!==true);
|
|
|
|
this.setFilteredInfo(!need_disable);
|
2017-02-06 11:22:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var me = this;
|
|
|
|
_.delay(function(){
|
|
|
|
me.onTabInvisible(undefined, me.tabbar.checkInvisible(true));
|
|
|
|
},30);
|
|
|
|
},
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
onSheetChanged: function(o, index, tab) {
|
|
|
|
this.api.asc_showWorksheet(tab.sheetindex);
|
|
|
|
|
2021-07-28 16:49:34 +00:00
|
|
|
this.updateNumberOfSheet(tab.sheetindex, this.api.asc_getWorksheetsCount());
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
if (this.hasTabInvisible && !this.tabbar.isTabVisible(index)) {
|
|
|
|
this.tabbar.setTabVisible(index);
|
|
|
|
}
|
|
|
|
|
2022-03-18 18:41:25 +00:00
|
|
|
if (this.mode.isEdit) {
|
|
|
|
this.tabbar.addDataHint(index, this.mode.isEditOle ? '1' : '0');
|
2021-10-08 17:00:17 +00:00
|
|
|
}
|
2021-07-05 17:17:04 +00:00
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
this.fireEvent('sheet:changed', [this, tab.sheetindex]);
|
|
|
|
this.fireEvent('sheet:updateColors', [true]);
|
|
|
|
|
2018-11-16 13:44:11 +00:00
|
|
|
// Common.NotificationCenter.trigger('comments:updatefilter', ['doc', 'sheet' + this.api.asc_getActiveWorksheetId()], false); // hide popover
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
2019-09-03 11:09:22 +00:00
|
|
|
onTabMenu: function (o, index, tab, select) {
|
2019-10-23 09:43:34 +00:00
|
|
|
var me = this;
|
2022-03-18 18:41:25 +00:00
|
|
|
if (this.mode.isEdit && !this.isEditFormula && (this.rangeSelectionMode !== Asc.c_oAscSelectionDialogType.Chart) &&
|
2016-11-03 12:00:48 +00:00
|
|
|
(this.rangeSelectionMode !== Asc.c_oAscSelectionDialogType.FormatTable) &&
|
2020-03-19 09:15:45 +00:00
|
|
|
(this.rangeSelectionMode !== Asc.c_oAscSelectionDialogType.PrintTitles) &&
|
2016-11-03 12:00:48 +00:00
|
|
|
!this.mode.isDisconnected ) {
|
2016-03-11 00:48:53 +00:00
|
|
|
if (tab && tab.sheetindex >= 0) {
|
|
|
|
var rect = tab.$el.get(0).getBoundingClientRect(),
|
|
|
|
childPos = tab.$el.offset(),
|
|
|
|
parentPos = tab.$el.parent().offset();
|
|
|
|
|
|
|
|
if (!tab.isActive()) this.tabbar.setActive(tab);
|
|
|
|
|
2019-10-23 09:43:34 +00:00
|
|
|
if (!_.isUndefined(select)) {
|
|
|
|
var issheetlocked = false;
|
|
|
|
select.forEach(function (item) {
|
|
|
|
if (me.api.asc_isWorksheetLockedOrDeleted(item.sheetindex)) {
|
|
|
|
issheetlocked = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
var issheetlocked = me.api.asc_isWorksheetLockedOrDeleted(tab.sheetindex);
|
|
|
|
}
|
|
|
|
|
|
|
|
var isdoclocked = this.api.asc_isWorkbookLocked();
|
2021-06-25 15:29:17 +00:00
|
|
|
var isdocprotected = this.api.asc_isProtectedWorkbook();
|
2016-03-11 00:48:53 +00:00
|
|
|
|
2021-06-25 15:29:17 +00:00
|
|
|
this.tabMenu.items[0].setDisabled(isdoclocked || isdocprotected);
|
|
|
|
this.tabMenu.items[1].setDisabled(issheetlocked || isdocprotected);
|
|
|
|
this.tabMenu.items[2].setDisabled(issheetlocked || isdocprotected);
|
|
|
|
this.tabMenu.items[3].setDisabled(issheetlocked || isdocprotected);
|
|
|
|
this.tabMenu.items[4].setDisabled(issheetlocked || isdocprotected);
|
|
|
|
this.tabMenu.items[5].setDisabled(issheetlocked || isdocprotected);
|
|
|
|
this.tabMenu.items[6].setDisabled(isdoclocked || isdocprotected);
|
2021-08-04 21:37:48 +00:00
|
|
|
this.tabMenu.items[7].setDisabled(select.length>1);
|
|
|
|
this.tabMenu.items[8].setDisabled(issheetlocked || isdocprotected);
|
|
|
|
|
2022-03-18 18:41:25 +00:00
|
|
|
this.tabMenu.items[7].setVisible(!this.mode.isEditOle);
|
2021-08-04 21:37:48 +00:00
|
|
|
this.tabMenu.items[7].setCaption(this.api.asc_isProtectedSheet() ? this.itemUnProtect : this.itemProtect);
|
2016-03-11 00:48:53 +00:00
|
|
|
|
2019-09-06 10:07:47 +00:00
|
|
|
if (select.length === 1) {
|
2021-08-04 21:37:48 +00:00
|
|
|
this.tabMenu.items[11].hide();
|
2019-09-06 10:07:47 +00:00
|
|
|
} else {
|
2021-08-04 21:37:48 +00:00
|
|
|
this.tabMenu.items[11].show();
|
2019-09-06 10:07:47 +00:00
|
|
|
}
|
|
|
|
|
2021-06-25 15:29:17 +00:00
|
|
|
this.tabMenu.items[10].setDisabled(issheetlocked || isdocprotected);
|
2021-08-04 21:37:48 +00:00
|
|
|
this.tabMenu.items[11].setDisabled(issheetlocked || isdocprotected);
|
2019-09-06 10:07:47 +00:00
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
this.api.asc_closeCellEditor();
|
|
|
|
this.api.asc_enableKeyEvents(false);
|
|
|
|
|
|
|
|
this.tabMenu.atposition = (function () {
|
|
|
|
return {
|
|
|
|
top : rect.top,
|
|
|
|
left: rect.left - parentPos.left - 2
|
|
|
|
};
|
|
|
|
})();
|
|
|
|
|
|
|
|
this.tabMenu.hide();
|
|
|
|
this.tabMenu.show();
|
2016-11-21 10:26:12 +00:00
|
|
|
var menu = this.tabMenu;
|
|
|
|
_.defer(function(){
|
|
|
|
menu.cmpEl.focus();
|
|
|
|
}, 10);
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onTabMenuAfterShow: function (obj) {
|
|
|
|
if (obj.atposition) {
|
|
|
|
obj.setOffset(obj.atposition.left);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.enableKeyEvents = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
onTabMenuAfterHide: function () {
|
|
|
|
if (!_.isUndefined(this.enableKeyEvents)) {
|
|
|
|
if (this.api) {
|
|
|
|
this.api.asc_enableKeyEvents(this.enableKeyEvents);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.enableKeyEvents = undefined;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onTabMenuClick: function (o, item) {
|
|
|
|
if (item && this.api) {
|
|
|
|
this.enableKeyEvents = (item.value === 'ins' || item.value === 'hide');
|
2019-09-06 10:07:47 +00:00
|
|
|
if (item.value === 'selectall') {
|
|
|
|
this.tabbar.setSelectAll(true);
|
|
|
|
} else if (item.value === 'noselect') {
|
|
|
|
this.tabbar.setSelectAll(false);
|
|
|
|
}
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onTabInvisible: function(obj, opts) {
|
2022-05-11 16:55:52 +00:00
|
|
|
if (this.btnScrollBack.isDisabled() !== (!opts.first)) {
|
2016-03-11 00:48:53 +00:00
|
|
|
this.btnScrollBack.setDisabled(!opts.first);
|
|
|
|
}
|
|
|
|
if (this.btnScrollNext.isDisabled() !== (!opts.last)) {
|
|
|
|
this.btnScrollNext.setDisabled(!opts.last);
|
|
|
|
}
|
|
|
|
this.hasTabInvisible = opts.first || opts.last;
|
|
|
|
},
|
|
|
|
|
|
|
|
onBtnTabScroll: function(action, e) {
|
|
|
|
this.tabbar.setTabVisible(action);
|
|
|
|
},
|
|
|
|
|
|
|
|
updateTabbarBorders: function() {
|
2021-07-26 13:57:01 +00:00
|
|
|
var visible = false;
|
|
|
|
var right = parseInt(this.boxZoom.css('width'));
|
2016-03-11 00:48:53 +00:00
|
|
|
if (this.boxMath.is(':visible')) {
|
2021-07-26 13:57:01 +00:00
|
|
|
this.boxMath.css({'right': right + 'px'});
|
|
|
|
right += parseInt(this.boxMath.css('width'));
|
2016-03-11 00:48:53 +00:00
|
|
|
visible = true;
|
|
|
|
}
|
2017-02-06 11:22:34 +00:00
|
|
|
if (this.boxFiltered.is(':visible')) {
|
2021-07-26 13:57:01 +00:00
|
|
|
this.boxFiltered.css({'right': right + 'px'});
|
|
|
|
right += parseInt(this.boxFiltered.css('width'));
|
2017-02-06 11:22:34 +00:00
|
|
|
visible = true;
|
|
|
|
}
|
|
|
|
|
2021-07-26 13:57:01 +00:00
|
|
|
if (this.isCompact) {
|
2021-08-10 15:34:00 +00:00
|
|
|
if (this.boxAction.is(':visible')) {
|
2021-08-16 14:22:13 +00:00
|
|
|
var tabsWidth = this.tabbar.getWidth();
|
2021-11-19 18:17:33 +00:00
|
|
|
var actionWidth = this.actionWidth || 140;
|
2022-05-11 16:55:52 +00:00
|
|
|
if (Common.Utils.innerWidth() - right - 129 - actionWidth - tabsWidth > 0) { // docWidth - right - left - this.boxAction.width
|
|
|
|
var left = tabsWidth + 129;
|
2021-08-16 14:22:13 +00:00
|
|
|
this.boxAction.css({'right': right + 'px', 'left': left + 'px', 'width': 'auto'});
|
|
|
|
this.boxAction.find('.separator').css('border-left-color', 'transparent');
|
|
|
|
} else {
|
2021-11-19 18:17:33 +00:00
|
|
|
this.boxAction.css({'right': right + 'px', 'left': 'auto', 'width': actionWidth + 'px'});
|
2021-08-16 14:22:13 +00:00
|
|
|
this.boxAction.find('.separator').css('border-left-color', '');
|
|
|
|
visible = true;
|
|
|
|
}
|
2021-08-10 15:34:00 +00:00
|
|
|
right += parseInt(this.boxAction.css('width'));
|
|
|
|
}
|
|
|
|
|
2021-07-26 13:57:01 +00:00
|
|
|
this.boxMath.is(':visible') && this.boxMath.css({'top': '0px', 'bottom': 'auto'});
|
|
|
|
this.boxFiltered.is(':visible') && this.boxFiltered.css({'top': '0px', 'bottom': 'auto'});
|
|
|
|
this.boxZoom.css({'top': '0px', 'bottom': 'auto'});
|
|
|
|
this.tabBarBox.css('right', right + 'px');
|
|
|
|
} else {
|
2021-08-10 15:34:00 +00:00
|
|
|
if (this.boxAction.is(':visible')) {
|
|
|
|
this.boxAction.css({'right': right + 'px', 'left': '135px', 'width': 'auto'});
|
|
|
|
this.boxAction.find('.separator').css('border-left-color', 'transparent');
|
|
|
|
}
|
2021-07-26 13:57:01 +00:00
|
|
|
this.boxMath.is(':visible') && this.boxMath.css({'top': 'auto', 'bottom': '0px'});
|
|
|
|
this.boxFiltered.is(':visible') && this.boxFiltered.css({'top': 'auto', 'bottom': '0px'});
|
|
|
|
this.boxZoom.css({'top': 'auto', 'bottom': '0px'});
|
|
|
|
this.tabBarBox.css('right', '0px');
|
|
|
|
}
|
2021-08-10 15:34:00 +00:00
|
|
|
this.boxZoom.find('.separator').css('border-left-color', visible ? '' : 'transparent');
|
2021-11-16 11:47:35 +00:00
|
|
|
|
|
|
|
if (this.statusMessage) {
|
|
|
|
var status = this.getStatusMessage(this.statusMessage);
|
|
|
|
if (status !== this.boxAction.text().trim()) {
|
|
|
|
this.labelAction.text(status);
|
|
|
|
}
|
|
|
|
}
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
2020-06-26 14:54:44 +00:00
|
|
|
updateVisibleItemsBoxMath: function () {
|
|
|
|
var widthStatusbar = parseInt(this.$el.css('width'));
|
|
|
|
var width = parseInt(this.boxZoom.css('width')) + parseInt($('#status-tabs-scroll').css('width')) + parseInt($('#status-addtabs-box').css('width'));
|
|
|
|
if (this.boxFiltered.is(':visible')) {
|
|
|
|
width += parseInt(this.boxFiltered.css('width'));
|
|
|
|
}
|
|
|
|
this.$el.find('.over-box').removeClass('over-box');
|
|
|
|
while (width + parseInt(this.boxMath.css('width')) + 100 > widthStatusbar) {
|
|
|
|
var items = this.boxMath.find('label:not(.hide, .over-box)');
|
2020-08-12 15:22:14 +00:00
|
|
|
(items.length>0) && $(items[items.length - 1]).addClass('over-box');
|
|
|
|
if (items.length<=1)
|
|
|
|
break;
|
2020-06-26 14:54:44 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2022-03-16 11:17:25 +00:00
|
|
|
changeViewMode: function (mode) {
|
2022-03-18 18:41:25 +00:00
|
|
|
var edit = mode.isEdit;
|
2016-03-11 00:48:53 +00:00
|
|
|
if (edit) {
|
2022-05-11 16:55:52 +00:00
|
|
|
this.tabBarBox.css('left', '129px');
|
2016-03-11 00:48:53 +00:00
|
|
|
} else {
|
2022-03-18 18:41:25 +00:00
|
|
|
this.tabBarBox.css('left', '');
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.tabbar.options.draggable = edit;
|
|
|
|
this.editMode = edit;
|
|
|
|
},
|
|
|
|
|
2020-06-17 14:39:13 +00:00
|
|
|
showCustomizeStatusBar: function (e) {
|
2020-06-17 20:03:34 +00:00
|
|
|
var el = $(e.target);
|
|
|
|
if ($('#status-zoom-box').find(el).length > 0
|
2020-07-16 15:04:34 +00:00
|
|
|
|| $(e.target).closest('.statusbar .list-item').length>0
|
2020-06-17 20:03:34 +00:00
|
|
|
|| $('#status-tabs-scroll').find(el).length > 0
|
|
|
|
|| $('#status-addtabs-box').find(el).length > 0) return;
|
|
|
|
this.customizeStatusBarMenu.hide();
|
2020-06-17 14:39:13 +00:00
|
|
|
this.customizeStatusBarMenu.atposition = {
|
2020-06-17 20:03:34 +00:00
|
|
|
left: e.clientX*Common.Utils.zoom(),
|
|
|
|
top: e.clientY*Common.Utils.zoom()
|
2020-06-17 14:39:13 +00:00
|
|
|
};
|
|
|
|
this.customizeStatusBarMenu.show();
|
|
|
|
},
|
|
|
|
|
|
|
|
onCustomizeStatusBarAfterShow: function (obj) {
|
|
|
|
if (obj.atposition) {
|
2021-08-18 14:29:07 +00:00
|
|
|
var statusHeight = $(this.el).height(),
|
|
|
|
offsetTop = !this.isCompact && (obj.atposition.top - $(this.el).offset().top > statusHeight/2) ? statusHeight/2 : 0;
|
|
|
|
obj.setOffset(obj.atposition.left, offsetTop);
|
2020-06-17 14:39:13 +00:00
|
|
|
}
|
|
|
|
this.enableKeyEvents = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
onCustomizeStatusBarAfterHide: function () {
|
|
|
|
if (!_.isUndefined(this.enableKeyEvents)) {
|
|
|
|
if (this.api) {
|
|
|
|
this.api.asc_enableKeyEvents(this.enableKeyEvents);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.enableKeyEvents = undefined;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-06-17 20:03:34 +00:00
|
|
|
onCustomizeStatusBarClick: function (o, item, event) {
|
2020-06-17 14:39:13 +00:00
|
|
|
var value = item.value,
|
|
|
|
checked = item.checked;
|
2021-08-10 15:34:00 +00:00
|
|
|
if (value === 'status') {
|
|
|
|
this.boxAction[checked ? 'removeClass' : 'addClass']('hide');
|
2020-06-17 20:03:34 +00:00
|
|
|
} else {
|
2021-08-10 15:34:00 +00:00
|
|
|
this.boxMath.find('#status-math-' + value)[checked ? 'removeClass' : 'addClass']('hide');
|
|
|
|
if (this.boxMath.find('label').length === this.boxMath.find('label.hide').length) {
|
|
|
|
this.boxMath.find('.separator').hide();
|
|
|
|
} else {
|
|
|
|
if (this.boxMath.find('.separator').is(":hidden")) {
|
|
|
|
this.boxMath.find('.separator').show();
|
|
|
|
}
|
2020-06-17 20:03:34 +00:00
|
|
|
}
|
|
|
|
}
|
2020-06-26 14:54:44 +00:00
|
|
|
this.updateVisibleItemsBoxMath();
|
2020-06-23 19:05:25 +00:00
|
|
|
this.updateTabbarBorders();
|
2020-06-26 14:54:44 +00:00
|
|
|
this.onTabInvisible(undefined, this.tabbar.checkInvisible(true));
|
2020-06-17 20:03:34 +00:00
|
|
|
event.stopPropagation();
|
|
|
|
item.$el.find('a').blur();
|
2020-06-17 14:39:13 +00:00
|
|
|
},
|
|
|
|
|
2021-07-26 13:57:01 +00:00
|
|
|
onChangeCompact: function (compact) {
|
|
|
|
this.isCompact = compact;
|
|
|
|
if (compact) {
|
|
|
|
this.cntStatusbar.removeClass('no-compact');
|
|
|
|
this.boxNumberSheets.hide();
|
2021-08-10 15:34:00 +00:00
|
|
|
//this.boxAction.hide();
|
2021-07-26 13:57:01 +00:00
|
|
|
} else {
|
|
|
|
this.cntStatusbar.addClass('no-compact');
|
|
|
|
this.boxNumberSheets.show();
|
2021-08-10 15:34:00 +00:00
|
|
|
//this.boxAction.show();
|
2021-07-26 13:57:01 +00:00
|
|
|
}
|
|
|
|
this.updateTabbarBorders();
|
2022-03-16 14:40:53 +00:00
|
|
|
(this.tabbar.getCount()>0) && this.onTabInvisible(undefined, this.tabbar.checkInvisible(true));
|
2021-07-26 13:57:01 +00:00
|
|
|
},
|
|
|
|
|
2021-07-28 16:49:34 +00:00
|
|
|
updateNumberOfSheet: function (active, count) {
|
|
|
|
this.labelNumberSheets.text(
|
|
|
|
Common.Utils.String.format(this.sheetIndexText, active + 1, count)
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
2021-11-16 11:47:35 +00:00
|
|
|
getStatusMessage: function (message) {
|
|
|
|
var _message;
|
2021-11-19 18:17:33 +00:00
|
|
|
if (this.isCompact && message.length > 23 && this.boxAction.width() < 180) {
|
|
|
|
_message = message.substr(0, 23).trim() + '...'
|
2021-11-16 11:47:35 +00:00
|
|
|
} else {
|
|
|
|
_message = message;
|
|
|
|
}
|
|
|
|
return _message;
|
|
|
|
},
|
|
|
|
|
2021-12-13 21:07:24 +00:00
|
|
|
showStatusMessage: function(message, callback) {
|
2021-11-16 11:47:35 +00:00
|
|
|
this.statusMessage = message;
|
2021-11-19 18:17:33 +00:00
|
|
|
if (!this.actionWidth) {
|
|
|
|
this.actionWidth = message.length > 22 ? 166 : 140;
|
|
|
|
}
|
2021-11-16 11:47:35 +00:00
|
|
|
this.labelAction.text(this.getStatusMessage(message));
|
2021-08-10 15:34:00 +00:00
|
|
|
this.customizeStatusBarMenu.items.forEach(function (item) {
|
|
|
|
if (item.options.id === 'saved-status') {
|
|
|
|
item.options.exampleval = message;
|
|
|
|
}
|
|
|
|
$(item.el).find('label').text(item.options.exampleval);
|
|
|
|
});
|
2021-08-16 14:22:13 +00:00
|
|
|
if (!this.boxAction.is(':visible')) {
|
|
|
|
this.boxAction.show();
|
|
|
|
}
|
|
|
|
var me = this;
|
|
|
|
_.delay(function(){
|
|
|
|
me.updateTabbarBorders();
|
|
|
|
me.onTabInvisible(undefined, me.tabbar.checkInvisible(true));
|
2021-12-13 21:07:24 +00:00
|
|
|
callback && callback();
|
2021-08-16 14:22:13 +00:00
|
|
|
},30);
|
2021-07-28 16:49:34 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
clearStatusMessage: function() {
|
|
|
|
this.labelAction.text('');
|
2021-11-16 11:47:35 +00:00
|
|
|
this.statusMessage = undefined;
|
2021-07-28 16:49:34 +00:00
|
|
|
},
|
|
|
|
|
2021-12-13 16:20:55 +00:00
|
|
|
getStatusLabel: function() {
|
|
|
|
return this.labelAction;
|
|
|
|
},
|
|
|
|
|
2021-07-28 16:49:34 +00:00
|
|
|
sheetIndexText : 'Sheet {0} of {1}',
|
2016-03-11 00:48:53 +00:00
|
|
|
tipZoomIn : 'Zoom In',
|
|
|
|
tipZoomOut : 'Zoom Out',
|
|
|
|
tipZoomFactor : 'Magnification',
|
|
|
|
tipPrev : 'Previous Sheet',
|
|
|
|
tipNext : 'Next Sheet',
|
|
|
|
tipAddTab : 'Add Worksheet',
|
2021-06-26 13:16:33 +00:00
|
|
|
tipListOfSheets : 'List of Sheets',
|
2016-03-11 00:48:53 +00:00
|
|
|
itemInsert : 'Insert',
|
|
|
|
itemDelete : 'Delete',
|
|
|
|
itemRename : 'Rename',
|
|
|
|
itemCopy : 'Copy',
|
|
|
|
itemMove : 'Move',
|
|
|
|
itemHide : 'Hide',
|
|
|
|
itemHidden : 'Hidden',
|
|
|
|
itemTabColor : 'Tab Color',
|
|
|
|
textNoColor : 'No Color',
|
|
|
|
textNewColor : 'Add New Custom Color',
|
|
|
|
zoomText : 'Zoom {0}%',
|
2019-11-12 09:50:14 +00:00
|
|
|
textSum : 'Sum',
|
|
|
|
textCount : 'Count',
|
|
|
|
textAverage : 'Average',
|
|
|
|
textMin : 'Min',
|
|
|
|
textMax : 'Max',
|
2017-02-06 11:22:34 +00:00
|
|
|
filteredRecordsText : '{0} of {1} records filtered',
|
2019-09-06 10:07:47 +00:00
|
|
|
filteredText : 'Filter mode',
|
|
|
|
selectAllSheets : 'Select All Sheets',
|
2020-06-17 14:39:13 +00:00
|
|
|
ungroupSheets : 'Ungroup Sheets',
|
2020-06-18 11:16:30 +00:00
|
|
|
//textCustomizeStatusBar: 'Customize status bar',
|
2020-06-17 14:39:13 +00:00
|
|
|
itemAverage : 'Average',
|
|
|
|
itemCount : 'Count',
|
|
|
|
itemMinimum : 'Minimum',
|
|
|
|
itemMaximum : 'Maximum',
|
2021-08-10 15:34:00 +00:00
|
|
|
itemSum : 'Sum',
|
2021-08-18 16:46:55 +00:00
|
|
|
itemStatus : 'Saving status',
|
2021-08-04 21:37:48 +00:00
|
|
|
itemProtect : 'Protect',
|
|
|
|
itemUnProtect : 'Unprotect'
|
2016-03-11 00:48:53 +00:00
|
|
|
}, SSE.Views.Statusbar || {}));
|
|
|
|
|
|
|
|
SSE.Views.Statusbar.RenameDialog = Common.UI.Window.extend(_.extend({
|
|
|
|
options: {
|
|
|
|
header: false,
|
|
|
|
width: 280,
|
2019-09-11 08:38:08 +00:00
|
|
|
cls: 'modal-dlg',
|
2019-11-05 10:34:44 +00:00
|
|
|
buttons: ['ok', 'cancel']
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
template: '<div class="box">' +
|
|
|
|
'<div class="input-row">' +
|
|
|
|
'<label><%= label %></label>' +
|
|
|
|
'</div>' +
|
2020-06-05 13:10:48 +00:00
|
|
|
'<div class="input-row" id="txt-sheet-name"></div>' +
|
2016-03-11 00:48:53 +00:00
|
|
|
'</div>',
|
|
|
|
|
|
|
|
initialize : function(options) {
|
|
|
|
_.extend(this.options, options || {}, {
|
2019-09-11 08:38:08 +00:00
|
|
|
label: this.labelSheetName
|
2016-03-11 00:48:53 +00:00
|
|
|
});
|
2017-04-21 08:10:07 +00:00
|
|
|
this.options.tpl = _.template(this.template)(this.options);
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
Common.UI.Window.prototype.initialize.call(this, this.options);
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
|
|
|
Common.UI.Window.prototype.render.call(this);
|
|
|
|
|
|
|
|
var $window = this.getChild();
|
|
|
|
$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
|
|
|
|
|
|
|
|
this.txtName = new Common.UI.InputField({
|
|
|
|
el: $window.find('#txt-sheet-name'),
|
|
|
|
style: 'width:100%;',
|
2019-04-08 14:08:17 +00:00
|
|
|
value: Common.Utils.String.htmlEncode(this.options.current),
|
2016-03-11 00:48:53 +00:00
|
|
|
allowBlank: false,
|
|
|
|
maxLength: 31,
|
|
|
|
validation: _.bind(this.nameValidator, this)
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
show: function(x,y) {
|
|
|
|
Common.UI.Window.prototype.show.apply(this, arguments);
|
|
|
|
var edit = this.txtName.$el.find('input');
|
|
|
|
_.delay(function(me){
|
|
|
|
edit.focus();
|
|
|
|
edit.select();
|
|
|
|
}, 100, this);
|
|
|
|
},
|
|
|
|
|
|
|
|
onBtnClick: function(event) {
|
|
|
|
this.doClose(event.currentTarget.attributes['result'].value);
|
|
|
|
},
|
|
|
|
|
|
|
|
doClose: function(res) {
|
|
|
|
if (res == 'ok') {
|
|
|
|
if (this.txtName.checkValidate() !== true) {
|
|
|
|
_.delay(function(me){
|
|
|
|
me.txtName.focus();
|
|
|
|
}, 100, this);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.options.handler) {
|
|
|
|
this.options.handler.call(this, res, this.txtName.getValue());
|
|
|
|
}
|
|
|
|
|
|
|
|
this.close();
|
|
|
|
},
|
|
|
|
|
2018-09-21 13:01:09 +00:00
|
|
|
onPrimary: function(e) {
|
|
|
|
this.doClose('ok');
|
|
|
|
return false;
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
nameValidator: function(value) {
|
|
|
|
var items = this.options.names;
|
|
|
|
if (!items && this.options.api) {
|
|
|
|
var api = this.options.api,
|
|
|
|
sindex = api.asc_getActiveWorksheetIndex(),
|
|
|
|
wc = api.asc_getWorksheetsCount();
|
|
|
|
items = [];
|
|
|
|
while (wc--) {
|
|
|
|
if (sindex !== wc) {
|
|
|
|
items.push(api.asc_getWorksheetName(wc).toLowerCase());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (items) {
|
|
|
|
var testval = value.toLowerCase();
|
|
|
|
for (var i = items.length - 1; i >= 0; --i) {
|
|
|
|
if (items[i] === testval) {
|
|
|
|
return this.errNameExists;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value.length > 2 && value[0]=='"' && value[value.length-1]=='"') return true;
|
|
|
|
if (!/[:\\\/\*\?\[\]\']/.test(value)) return true;
|
|
|
|
|
|
|
|
return this.errNameWrongChar;
|
|
|
|
},
|
|
|
|
|
|
|
|
errNameExists : 'Worksheet with such name already exist.',
|
|
|
|
errNameWrongChar: 'A sheet name cannot contains characters: \\, \/, *, ?, [, ], :',
|
|
|
|
labelSheetName : 'Sheet Name'
|
|
|
|
}, RenameDialog||{}));
|
|
|
|
|
|
|
|
SSE.Views.Statusbar.CopyDialog = Common.UI.Window.extend(_.extend({
|
|
|
|
options: {
|
|
|
|
width: 270,
|
2019-09-11 08:38:08 +00:00
|
|
|
cls: 'modal-dlg',
|
2019-11-05 10:34:44 +00:00
|
|
|
buttons: ['ok', 'cancel']
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
template: '<div class="box">' +
|
|
|
|
'<div class="input-row">' +
|
|
|
|
'<label><%= label %></label>' +
|
|
|
|
'</div>' +
|
2020-06-05 13:10:48 +00:00
|
|
|
'<div id="status-list-names" style="height: 162px;"></div>' +
|
2016-03-11 00:48:53 +00:00
|
|
|
'</div>',
|
|
|
|
|
|
|
|
initialize : function(options) {
|
|
|
|
_.extend(this.options, options || {}, {
|
2019-09-11 08:38:08 +00:00
|
|
|
label: options.ismove ? this.textMoveBefore : this.textCopyBefore
|
2016-03-11 00:48:53 +00:00
|
|
|
});
|
2017-04-21 08:10:07 +00:00
|
|
|
this.options.tpl = _.template(this.template)(this.options);
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
Common.UI.Window.prototype.initialize.call(this, this.options);
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
|
|
|
Common.UI.Window.prototype.render.call(this);
|
|
|
|
|
|
|
|
var $window = this.getChild();
|
|
|
|
$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
|
|
|
|
|
|
|
|
var pages = [];
|
|
|
|
this.options.names.forEach(function(item){
|
|
|
|
pages.push(new Common.UI.DataViewModel(item));
|
|
|
|
}, this);
|
|
|
|
|
|
|
|
if (pages.length) {
|
|
|
|
pages.push(new Common.UI.DataViewModel({
|
|
|
|
value : this.options.ismove ? this.itemMoveToEnd : this.itemCopyToEnd,
|
|
|
|
inindex : -255
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
this.listNames = new Common.UI.ListView({
|
|
|
|
el: $('#status-list-names', $window),
|
|
|
|
store: new Common.UI.DataViewStore(pages),
|
2021-05-13 17:30:57 +00:00
|
|
|
cls: 'dbl-clickable',
|
|
|
|
itemTemplate: _.template('<div id="<%= id %>" class="list-item"><%= Common.Utils.String.htmlEncode(value) %></div>')
|
2016-03-11 00:48:53 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
this.listNames.selectByIndex(0);
|
|
|
|
this.listNames.on('entervalue', _.bind(this.onPrimary, this));
|
|
|
|
this.listNames.on('item:dblclick', _.bind(this.onPrimary, this));
|
|
|
|
|
|
|
|
this.mask = $('.modals-mask');
|
|
|
|
this.mask.on('mousedown',_.bind(this.onUpdateFocus, this));
|
|
|
|
},
|
|
|
|
|
|
|
|
show: function(x,y) {
|
|
|
|
Common.UI.Window.prototype.show.apply(this, arguments);
|
|
|
|
|
|
|
|
_.delay(function(me){
|
2020-09-26 17:16:29 +00:00
|
|
|
me.listNames.focus();
|
2016-03-11 00:48:53 +00:00
|
|
|
}, 100, this);
|
|
|
|
},
|
|
|
|
|
|
|
|
hide: function () {
|
|
|
|
Common.UI.Window.prototype.hide.apply(this, arguments);
|
|
|
|
|
|
|
|
this.mask.off('mousedown',_.bind(this.onUpdateFocus, this));
|
|
|
|
},
|
|
|
|
|
|
|
|
onBtnClick: function(event) {
|
|
|
|
var active = this.listNames.getSelectedRec();
|
|
|
|
|
|
|
|
if (this.options.handler) {
|
|
|
|
this.options.handler.call(this,
|
2019-06-27 11:18:01 +00:00
|
|
|
event.currentTarget.attributes['result'].value, active.get('inindex'));
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.close();
|
|
|
|
},
|
|
|
|
|
|
|
|
onPrimary: function() {
|
|
|
|
if (this.options.handler) {
|
2019-06-27 11:18:01 +00:00
|
|
|
this.options.handler.call(this, 'ok', this.listNames.getSelectedRec().get('inindex'));
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.close();
|
|
|
|
},
|
|
|
|
|
|
|
|
onUpdateFocus: function () {
|
|
|
|
_.delay(function(me){
|
2020-09-26 17:16:29 +00:00
|
|
|
me.listNames.focus();
|
2016-03-11 00:48:53 +00:00
|
|
|
}, 100, this);
|
|
|
|
},
|
|
|
|
|
|
|
|
itemCopyToEnd : '(Copy to end)',
|
|
|
|
itemMoveToEnd : '(Move to end)',
|
|
|
|
textCopyBefore : 'Copy before sheet',
|
|
|
|
textMoveBefore : 'Move before sheet'
|
|
|
|
}, CopyDialog||{}));
|
|
|
|
|
|
|
|
}
|
|
|
|
);
|