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
|
|
|
define([
|
|
|
|
'text!spreadsheeteditor/main/app/template/FileMenu.template',
|
|
|
|
'underscore',
|
|
|
|
'common/main/lib/component/BaseView'
|
|
|
|
], function (tpl, _) {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
SSE.Views.FileMenu = Common.UI.BaseView.extend(_.extend({
|
|
|
|
el: '#file-menu-panel',
|
2019-08-27 14:26:14 +00:00
|
|
|
rendered: false,
|
2017-04-27 14:51:53 +00:00
|
|
|
options: {alias:'FileMenu'},
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
template: _.template(tpl),
|
|
|
|
|
|
|
|
events: function() {
|
|
|
|
return {
|
|
|
|
'click .fm-btn': _.bind(function(event){
|
|
|
|
var $item = $(event.currentTarget);
|
|
|
|
if (!$item.hasClass('active')) {
|
|
|
|
$('.fm-btn',this.el).removeClass('active');
|
|
|
|
$item.addClass('active');
|
|
|
|
}
|
|
|
|
|
|
|
|
var item = _.findWhere(this.items, {el: event.currentTarget});
|
|
|
|
if (item) {
|
|
|
|
var panel = this.panels[item.options.action];
|
2022-10-11 19:12:02 +00:00
|
|
|
if (item.options.action === 'help') {
|
|
|
|
if ( panel.noHelpContents === true && navigator.onLine ) {
|
|
|
|
this.fireEvent('item:click', [this, 'external-help', true]);
|
|
|
|
window.open(panel.urlHelpCenter, '_blank');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2016-03-11 00:48:53 +00:00
|
|
|
this.fireEvent('item:click', [this, item.options.action, !!panel]);
|
|
|
|
|
|
|
|
if (panel) {
|
|
|
|
this.$el.find('.content-box:visible').hide();
|
|
|
|
this.active = item.options.action;
|
|
|
|
panel.show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, this)
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
initialize: function () {
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function () {
|
2019-08-27 14:26:14 +00:00
|
|
|
var $markup = $(this.template());
|
2016-03-11 00:48:53 +00:00
|
|
|
|
2021-11-01 22:07:29 +00:00
|
|
|
this.miClose = new Common.UI.MenuItem({
|
|
|
|
el : $markup.elementById('#fm-btn-return'),
|
|
|
|
action : 'back',
|
|
|
|
caption : this.btnCloseMenuCaption,
|
|
|
|
canFocused: false,
|
|
|
|
dataHint: 1,
|
|
|
|
dataHintDirection: 'left-top',
|
|
|
|
dataHintOffset: [2, 14]
|
|
|
|
});
|
|
|
|
|
2017-07-18 13:33:10 +00:00
|
|
|
this.miSave = new Common.UI.MenuItem({
|
2019-08-27 14:26:14 +00:00
|
|
|
el : $markup.elementById('#fm-btn-save'),
|
2017-07-18 13:33:10 +00:00
|
|
|
action : 'save',
|
|
|
|
caption : this.btnSaveCaption,
|
2018-07-25 08:21:18 +00:00
|
|
|
canFocused: false,
|
2021-06-10 20:05:49 +00:00
|
|
|
disabled: true,
|
|
|
|
dataHint: 1,
|
|
|
|
dataHintDirection: 'left-top',
|
2021-11-12 15:54:49 +00:00
|
|
|
dataHintOffset: [2, 14],
|
|
|
|
dataHintTitle: 'S'
|
2017-07-18 13:33:10 +00:00
|
|
|
});
|
2019-08-27 14:26:14 +00:00
|
|
|
if ( !!this.options.miSave ) {
|
|
|
|
this.miSave.setDisabled(this.options.miSave.isDisabled());
|
|
|
|
delete this.options.miSave;
|
|
|
|
}
|
2017-07-18 13:33:10 +00:00
|
|
|
|
|
|
|
this.miEdit = new Common.UI.MenuItem({
|
2019-08-27 14:26:14 +00:00
|
|
|
el : $markup.elementById('#fm-btn-edit'),
|
2017-07-18 13:33:10 +00:00
|
|
|
action : 'edit',
|
|
|
|
caption : this.btnToEditCaption,
|
2021-06-10 20:05:49 +00:00
|
|
|
canFocused: false,
|
|
|
|
dataHint: 1,
|
|
|
|
dataHintDirection: 'left-top',
|
|
|
|
dataHintOffset: [2, 14]
|
2017-07-18 13:33:10 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
this.miDownload = new Common.UI.MenuItem({
|
2019-08-27 14:26:14 +00:00
|
|
|
el : $markup.elementById('#fm-btn-download'),
|
2017-07-18 13:33:10 +00:00
|
|
|
action : 'saveas',
|
|
|
|
caption : this.btnDownloadCaption,
|
2021-06-10 20:05:49 +00:00
|
|
|
canFocused: false,
|
|
|
|
dataHint: 1,
|
|
|
|
dataHintDirection: 'left-top',
|
|
|
|
dataHintOffset: [2, 14]
|
2017-07-18 13:33:10 +00:00
|
|
|
});
|
|
|
|
|
2018-09-27 12:25:15 +00:00
|
|
|
this.miSaveCopyAs = new Common.UI.MenuItem({
|
2019-08-27 14:26:14 +00:00
|
|
|
el : $markup.elementById('#fm-btn-save-copy'),
|
2018-09-27 12:25:15 +00:00
|
|
|
action : 'save-copy',
|
|
|
|
caption : this.btnSaveCopyAsCaption,
|
2021-06-10 20:05:49 +00:00
|
|
|
canFocused: false,
|
|
|
|
dataHint: 1,
|
|
|
|
dataHintDirection: 'left-top',
|
|
|
|
dataHintOffset: [2, 14]
|
2018-09-27 12:25:15 +00:00
|
|
|
});
|
|
|
|
|
2017-07-18 13:33:10 +00:00
|
|
|
this.miSaveAs = new Common.UI.MenuItem({
|
2019-08-27 14:26:14 +00:00
|
|
|
el : $markup.elementById('#fm-btn-save-desktop'),
|
2017-07-18 13:33:10 +00:00
|
|
|
action : 'save-desktop',
|
|
|
|
caption : this.btnSaveAsCaption,
|
2021-06-10 20:05:49 +00:00
|
|
|
canFocused: false,
|
|
|
|
dataHint: 1,
|
|
|
|
dataHintDirection: 'left-top',
|
|
|
|
dataHintOffset: [2, 14]
|
2017-07-18 13:33:10 +00:00
|
|
|
});
|
|
|
|
|
2021-10-18 08:21:30 +00:00
|
|
|
this.miPrintWithPreview = new Common.UI.MenuItem({
|
|
|
|
el : $markup.elementById('#fm-btn-print-with-preview'),
|
2021-10-21 13:01:30 +00:00
|
|
|
action : 'printpreview',
|
2017-07-18 13:33:10 +00:00
|
|
|
caption : this.btnPrintCaption,
|
2021-06-10 20:05:49 +00:00
|
|
|
canFocused: false,
|
|
|
|
dataHint: 1,
|
|
|
|
dataHintDirection: 'left-top',
|
2021-11-12 15:54:49 +00:00
|
|
|
dataHintOffset: [2, 14],
|
|
|
|
dataHintTitle: 'P'
|
2017-07-18 13:33:10 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
this.miRename = new Common.UI.MenuItem({
|
2019-08-27 14:26:14 +00:00
|
|
|
el : $markup.elementById('#fm-btn-rename'),
|
2017-07-18 13:33:10 +00:00
|
|
|
action : 'rename',
|
|
|
|
caption : this.btnRenameCaption,
|
2021-06-10 20:05:49 +00:00
|
|
|
canFocused: false,
|
|
|
|
dataHint: 1,
|
|
|
|
dataHintDirection: 'left-top',
|
|
|
|
dataHintOffset: [2, 14]
|
2017-07-18 13:33:10 +00:00
|
|
|
});
|
2021-06-28 17:03:50 +00:00
|
|
|
if ( !!this.options.miRename ) {
|
|
|
|
this.miRename.setDisabled(this.options.miRename.isDisabled());
|
|
|
|
delete this.options.miRename;
|
|
|
|
}
|
2017-07-18 13:33:10 +00:00
|
|
|
|
2017-11-28 12:48:24 +00:00
|
|
|
this.miProtect = new Common.UI.MenuItem({
|
2019-08-27 14:26:14 +00:00
|
|
|
el : $markup.elementById('#fm-btn-protect'),
|
2017-11-28 12:48:24 +00:00
|
|
|
action : 'protect',
|
|
|
|
caption : this.btnProtectCaption,
|
2021-06-10 20:05:49 +00:00
|
|
|
canFocused: false,
|
|
|
|
dataHint: 1,
|
|
|
|
dataHintDirection: 'left-top',
|
|
|
|
dataHintOffset: [2, 14]
|
2017-11-28 12:48:24 +00:00
|
|
|
});
|
2020-09-07 11:27:35 +00:00
|
|
|
if ( !!this.options.miProtect ) {
|
|
|
|
this.miProtect.setDisabled(this.options.miProtect.isDisabled());
|
|
|
|
delete this.options.miProtect;
|
|
|
|
}
|
2017-11-28 12:48:24 +00:00
|
|
|
|
2017-07-18 13:33:10 +00:00
|
|
|
this.miRecent = new Common.UI.MenuItem({
|
2019-08-27 14:26:14 +00:00
|
|
|
el : $markup.elementById('#fm-btn-recent'),
|
2017-07-18 13:33:10 +00:00
|
|
|
action : 'recent',
|
|
|
|
caption : this.btnRecentFilesCaption,
|
2021-06-10 20:05:49 +00:00
|
|
|
canFocused: false,
|
|
|
|
dataHint: 1,
|
|
|
|
dataHintDirection: 'left-top',
|
|
|
|
dataHintOffset: [2, 14]
|
2017-07-18 13:33:10 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
this.miNew = new Common.UI.MenuItem({
|
2019-08-27 14:26:14 +00:00
|
|
|
el : $markup.elementById('#fm-btn-create'),
|
2017-07-18 13:33:10 +00:00
|
|
|
action : 'new',
|
|
|
|
caption : this.btnCreateNewCaption,
|
2021-06-10 20:05:49 +00:00
|
|
|
canFocused: false,
|
|
|
|
dataHint: 1,
|
|
|
|
dataHintDirection: 'left-top',
|
|
|
|
dataHintOffset: [2, 14]
|
2017-07-18 13:33:10 +00:00
|
|
|
});
|
|
|
|
|
2021-11-01 22:07:29 +00:00
|
|
|
this.miInfo = new Common.UI.MenuItem({
|
|
|
|
el : $markup.elementById('#fm-btn-info'),
|
|
|
|
action : 'info',
|
|
|
|
caption : this.btnInfoCaption,
|
|
|
|
canFocused: false,
|
|
|
|
dataHint: 1,
|
|
|
|
dataHintDirection: 'left-top',
|
|
|
|
dataHintOffset: [2, 14]
|
|
|
|
});
|
|
|
|
|
2017-07-18 13:33:10 +00:00
|
|
|
this.miAccess = new Common.UI.MenuItem({
|
2019-08-27 14:26:14 +00:00
|
|
|
el : $markup.elementById('#fm-btn-rights'),
|
2017-07-18 13:33:10 +00:00
|
|
|
action : 'rights',
|
|
|
|
caption : this.btnRightsCaption,
|
2021-06-10 20:05:49 +00:00
|
|
|
canFocused: false,
|
|
|
|
dataHint: 1,
|
|
|
|
dataHintDirection: 'left-top',
|
|
|
|
dataHintOffset: [2, 14]
|
2017-07-18 13:33:10 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
this.miSettings = new Common.UI.MenuItem({
|
2019-08-27 14:26:14 +00:00
|
|
|
el : $markup.elementById('#fm-btn-settings'),
|
2017-07-18 13:33:10 +00:00
|
|
|
action : 'opts',
|
|
|
|
caption : this.btnSettingsCaption,
|
2021-06-10 20:05:49 +00:00
|
|
|
canFocused: false,
|
|
|
|
dataHint: 1,
|
|
|
|
dataHintDirection: 'left-top',
|
|
|
|
dataHintOffset: [2, 14]
|
2017-07-21 10:44:49 +00:00
|
|
|
});
|
2017-07-18 13:33:10 +00:00
|
|
|
|
2018-04-19 14:26:42 +00:00
|
|
|
this.miHelp = new Common.UI.MenuItem({
|
2019-08-27 14:26:14 +00:00
|
|
|
el : $markup.elementById('#fm-btn-help'),
|
2018-04-19 14:26:42 +00:00
|
|
|
action : 'help',
|
|
|
|
caption : this.btnHelpCaption,
|
2021-06-10 20:05:49 +00:00
|
|
|
canFocused: false,
|
|
|
|
dataHint: 1,
|
|
|
|
dataHintDirection: 'left-top',
|
|
|
|
dataHintOffset: [2, 14]
|
2018-04-19 14:26:42 +00:00
|
|
|
});
|
|
|
|
|
2021-06-28 17:18:53 +00:00
|
|
|
this.miHistory = new Common.UI.MenuItem({
|
|
|
|
el : $markup.elementById('#fm-btn-history'),
|
|
|
|
action : 'history',
|
|
|
|
caption : this.btnHistoryCaption,
|
2021-08-17 12:39:32 +00:00
|
|
|
canFocused: false,
|
|
|
|
dataHint: 1,
|
|
|
|
dataHintDirection: 'left-top',
|
|
|
|
dataHintOffset: [2, 14]
|
2021-06-28 17:18:53 +00:00
|
|
|
});
|
|
|
|
|
2021-11-01 22:07:29 +00:00
|
|
|
this.miBack = new Common.UI.MenuItem({
|
|
|
|
el : $markup.elementById('#fm-btn-back'),
|
|
|
|
action : 'exit',
|
|
|
|
caption : this.btnBackCaption,
|
|
|
|
canFocused: false,
|
|
|
|
dataHint: 1,
|
|
|
|
dataHintDirection: 'left-top',
|
|
|
|
dataHintOffset: [2, 14]
|
|
|
|
});
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
this.items = [];
|
|
|
|
this.items.push(
|
2021-11-01 22:07:29 +00:00
|
|
|
this.miClose,
|
2017-07-18 13:33:10 +00:00
|
|
|
this.miSave,
|
|
|
|
this.miEdit,
|
|
|
|
this.miDownload,
|
2018-09-27 12:25:15 +00:00
|
|
|
this.miSaveCopyAs,
|
2017-07-18 13:33:10 +00:00
|
|
|
this.miSaveAs,
|
2021-10-18 08:21:30 +00:00
|
|
|
this.miPrintWithPreview,
|
2017-07-18 13:33:10 +00:00
|
|
|
this.miRename,
|
2017-11-28 12:48:24 +00:00
|
|
|
this.miProtect,
|
2017-07-18 13:33:10 +00:00
|
|
|
this.miRecent,
|
|
|
|
this.miNew,
|
2021-11-01 22:07:29 +00:00
|
|
|
this.miInfo,
|
2017-07-18 13:33:10 +00:00
|
|
|
this.miAccess,
|
2021-06-28 17:18:53 +00:00
|
|
|
this.miHistory,
|
2017-07-18 13:33:10 +00:00
|
|
|
this.miSettings,
|
2018-04-19 14:26:42 +00:00
|
|
|
this.miHelp,
|
2021-11-01 22:07:29 +00:00
|
|
|
this.miBack
|
2016-03-11 00:48:53 +00:00
|
|
|
);
|
|
|
|
|
2019-08-27 14:26:14 +00:00
|
|
|
this.rendered = true;
|
|
|
|
this.$el.html($markup);
|
|
|
|
this.$el.find('.content-box').hide();
|
2021-07-14 21:35:56 +00:00
|
|
|
if (_.isUndefined(this.scroller)) {
|
|
|
|
var me = this;
|
|
|
|
this.scroller = new Common.UI.Scroller({
|
|
|
|
el: this.$el.find('.panel-menu'),
|
|
|
|
suppressScrollX: true,
|
|
|
|
alwaysVisibleY: true
|
|
|
|
});
|
|
|
|
Common.NotificationCenter.on('window:resize', function() {
|
|
|
|
me.scroller.update();
|
|
|
|
});
|
|
|
|
}
|
2019-08-27 14:26:14 +00:00
|
|
|
this.applyMode();
|
|
|
|
|
|
|
|
if ( !!this.api ) {
|
|
|
|
this.panels['info'].setApi(this.api);
|
|
|
|
if ( this.panels['protect'] )
|
|
|
|
this.panels['protect'].setApi(this.api);
|
|
|
|
if (this.panels['opts'])
|
|
|
|
this.panels['opts'].setApi(this.api);
|
|
|
|
}
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2020-08-25 16:38:52 +00:00
|
|
|
show: function(panel, opts) {
|
2018-02-06 10:54:40 +00:00
|
|
|
if (this.isVisible() && panel===undefined || !this.mode) return;
|
2016-03-11 00:48:53 +00:00
|
|
|
|
2019-08-27 14:26:14 +00:00
|
|
|
if ( !this.rendered )
|
|
|
|
this.render();
|
|
|
|
|
2017-11-28 12:48:24 +00:00
|
|
|
var defPanel = (this.mode.canDownload && (!this.mode.isDesktopApp || !this.mode.isOffline)) ? 'saveas' : 'info';
|
2016-03-11 00:48:53 +00:00
|
|
|
if (!panel)
|
2017-11-28 12:48:24 +00:00
|
|
|
panel = this.active || defPanel;
|
2016-03-11 00:48:53 +00:00
|
|
|
this.$el.show();
|
2021-07-14 21:35:56 +00:00
|
|
|
this.scroller.update();
|
2020-08-25 16:38:52 +00:00
|
|
|
this.selectMenu(panel, opts, defPanel);
|
2017-11-28 12:48:24 +00:00
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
this.api.asc_enableKeyEvents(false);
|
2017-04-27 15:40:27 +00:00
|
|
|
|
|
|
|
this.fireEvent('menu:show', [this]);
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
hide: function() {
|
|
|
|
this.$el.hide();
|
2018-02-06 10:54:40 +00:00
|
|
|
this.api && this.api.asc_enableKeyEvents(true);
|
2017-04-27 15:40:27 +00:00
|
|
|
this.fireEvent('menu:hide', [this]);
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
applyMode: function() {
|
2021-07-01 21:54:55 +00:00
|
|
|
if (!this.rendered) return;
|
|
|
|
|
2019-08-27 14:26:14 +00:00
|
|
|
if (!this.panels) {
|
|
|
|
this.panels = {
|
2022-06-21 07:42:57 +00:00
|
|
|
'opts' : (new SSE.Views.FileMenuPanels.MainSettingsGeneral({menu:this})).render(this.$el.find('#panel-settings')),
|
2019-08-27 14:26:14 +00:00
|
|
|
'info' : (new SSE.Views.FileMenuPanels.DocumentInfo({menu:this})).render(this.$el.find('#panel-info')),
|
|
|
|
'rights' : (new SSE.Views.FileMenuPanels.DocumentRights({menu:this})).render(this.$el.find('#panel-rights'))
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.mode) return;
|
|
|
|
|
2021-11-01 22:07:29 +00:00
|
|
|
var lastSeparator,
|
|
|
|
separatorVisible = false;
|
|
|
|
|
|
|
|
var isVisible = Common.UI.LayoutManager.isElementVisible('toolbar-file-close');
|
|
|
|
this.miClose[isVisible?'show':'hide']();
|
|
|
|
this.miClose.$el.find('+.devider')[isVisible?'show':'hide']();
|
|
|
|
isVisible && (lastSeparator = this.miClose.$el.find('+.devider'));
|
|
|
|
|
2019-08-19 11:49:58 +00:00
|
|
|
this.miDownload[(this.mode.canDownload && (!this.mode.isDesktopApp || !this.mode.isOffline))?'show':'hide']();
|
2019-10-28 14:23:53 +00:00
|
|
|
var isBCSupport = window["AscDesktopEditor"] ? window["AscDesktopEditor"]["isBlockchainSupport"]() : false;
|
|
|
|
this.miSaveCopyAs[(this.mode.canDownload && (!this.mode.isDesktopApp || !this.mode.isOffline)) && (this.mode.canRequestSaveAs || this.mode.saveAsUrl) && !isBCSupport ?'show':'hide']();
|
2019-08-19 11:49:58 +00:00
|
|
|
this.miSaveAs[(this.mode.canDownload && this.mode.isDesktopApp && this.mode.isOffline)?'show':'hide']();
|
2021-11-18 14:46:14 +00:00
|
|
|
this.miSave[this.mode.isEdit && Common.UI.LayoutManager.isElementVisible('toolbar-file-save') ?'show':'hide']();
|
2019-08-19 11:49:58 +00:00
|
|
|
this.miEdit[!this.mode.isEdit && this.mode.canEdit && this.mode.canRequestEditRights ?'show':'hide']();
|
2021-10-18 08:21:30 +00:00
|
|
|
this.miPrintWithPreview[this.mode.canPrint?'show':'hide']();
|
2017-07-18 13:33:10 +00:00
|
|
|
this.miRename[(this.mode.canRename && !this.mode.isDesktopApp) ?'show':'hide']();
|
2018-08-01 16:08:24 +00:00
|
|
|
this.miProtect[this.mode.canProtect ?'show':'hide']();
|
2021-11-18 14:46:14 +00:00
|
|
|
separatorVisible = (this.mode.canDownload || this.mode.isEdit && Common.UI.LayoutManager.isElementVisible('toolbar-file-save') || this.mode.canPrint || this.mode.canProtect ||
|
2021-11-01 22:07:29 +00:00
|
|
|
!this.mode.isEdit && this.mode.canEdit && this.mode.canRequestEditRights || this.mode.canRename && !this.mode.isDesktopApp) && !this.mode.isDisconnected;
|
|
|
|
this.miProtect.$el.find('+.devider')[separatorVisible?'show':'hide']();
|
|
|
|
separatorVisible && (lastSeparator = this.miProtect.$el.find('+.devider'));
|
|
|
|
|
2017-07-18 13:33:10 +00:00
|
|
|
this.miRecent[this.mode.canOpenRecent?'show':'hide']();
|
|
|
|
this.miNew[this.mode.canCreateNew?'show':'hide']();
|
2021-11-01 22:07:29 +00:00
|
|
|
separatorVisible = this.mode.canCreateNew;
|
|
|
|
this.miNew.$el.find('+.devider')[separatorVisible?'show':'hide']();
|
|
|
|
separatorVisible && (lastSeparator = this.miNew.$el.find('+.devider'));
|
|
|
|
|
|
|
|
isVisible = Common.UI.LayoutManager.isElementVisible('toolbar-file-info');
|
|
|
|
separatorVisible = isVisible;
|
|
|
|
this.miInfo[isVisible?'show':'hide']();
|
|
|
|
isVisible = !this.mode.isOffline && this.document&&this.document.info &&
|
|
|
|
(this.document.info.sharingSettings&&this.document.info.sharingSettings.length>0 ||
|
|
|
|
(this.mode.sharingSettingsUrl&&this.mode.sharingSettingsUrl.length || this.mode.canRequestSharingSettings));
|
|
|
|
separatorVisible = separatorVisible || isVisible;
|
|
|
|
this.miAccess[isVisible?'show':'hide']();
|
|
|
|
isVisible = this.mode.canUseHistory&&!this.mode.isDisconnected;
|
|
|
|
separatorVisible = separatorVisible || isVisible;
|
|
|
|
this.miHistory[isVisible?'show':'hide']();
|
|
|
|
this.miHistory.$el.find('+.devider')[separatorVisible?'show':'hide']();
|
|
|
|
separatorVisible && (lastSeparator = this.miHistory.$el.find('+.devider'));
|
|
|
|
|
|
|
|
isVisible = Common.UI.LayoutManager.isElementVisible('toolbar-file-settings');
|
|
|
|
this.miSettings[isVisible?'show':'hide']();
|
|
|
|
this.miSettings.$el.find('+.devider')[isVisible?'show':'hide']();
|
|
|
|
isVisible && (lastSeparator = this.miSettings.$el.find('+.devider'));
|
|
|
|
|
|
|
|
isVisible = this.mode.canHelp;
|
|
|
|
this.miHelp[isVisible ?'show':'hide']();
|
|
|
|
this.miHelp.$el.find('+.devider')[isVisible?'show':'hide']();
|
|
|
|
isVisible && (lastSeparator = this.miHelp.$el.find('+.devider'));
|
|
|
|
|
|
|
|
isVisible = this.mode.canBack;
|
|
|
|
this.miBack[isVisible ?'show':'hide']();
|
|
|
|
lastSeparator && !isVisible && lastSeparator.hide();
|
2017-07-18 13:33:10 +00:00
|
|
|
|
2020-01-31 14:25:22 +00:00
|
|
|
if (!this.customizationDone) {
|
|
|
|
this.customizationDone = true;
|
|
|
|
Common.Utils.applyCustomization(this.mode.customization, {goback: '#fm-btn-back > a'});
|
|
|
|
}
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
this.panels['opts'].setMode(this.mode);
|
2018-11-28 10:17:12 +00:00
|
|
|
this.panels['info'].setMode(this.mode);
|
|
|
|
!this.mode.isDisconnected && this.panels['info'].updateInfo(this.document);
|
|
|
|
this.panels['rights'].setMode(this.mode);
|
|
|
|
!this.mode.isDisconnected && this.panels['rights'].updateInfo(this.document);
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
if ( this.mode.canCreateNew ) {
|
|
|
|
if (this.mode.templates && this.mode.templates.length) {
|
2021-08-24 15:30:55 +00:00
|
|
|
!this.panels['new'] && (this.panels['new'] = (new SSE.Views.FileMenuPanels.CreateNew({menu: this, docs: this.mode.templates, blank: this.mode.canRequestCreateNew || !!this.mode.createUrl})).render());
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-27 14:26:14 +00:00
|
|
|
if ( this.mode.canOpenRecent && this.mode.recent) {
|
|
|
|
!this.panels['recent'] && (this.panels['recent'] = (new SSE.Views.FileMenuPanels.RecentFiles({menu:this, recent: this.mode.recent})).render());
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
2018-08-01 16:08:24 +00:00
|
|
|
if (this.mode.canProtect) {
|
2019-08-27 14:26:14 +00:00
|
|
|
!this.panels['protect'] && (this.panels['protect'] = (new SSE.Views.FileMenuPanels.ProtectDoc({menu:this})).render());
|
2017-11-27 11:15:10 +00:00
|
|
|
this.panels['protect'].setMode(this.mode);
|
|
|
|
}
|
|
|
|
|
2019-07-26 09:54:20 +00:00
|
|
|
if (this.mode.canDownload) {
|
2021-07-20 18:30:09 +00:00
|
|
|
!this.panels['saveas'] && (this.panels['saveas'] = (new SSE.Views.FileMenuPanels.ViewSaveAs({menu: this, fileType: this.document.fileType})).render());
|
2019-07-26 09:54:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (this.mode.canDownload && (this.mode.canRequestSaveAs || this.mode.saveAsUrl)) {
|
2021-07-20 18:30:09 +00:00
|
|
|
!this.panels['save-copy'] && (this.panels['save-copy'] = (new SSE.Views.FileMenuPanels.ViewSaveCopy({menu: this, fileType: this.document.fileType})).render());
|
2019-07-26 09:54:20 +00:00
|
|
|
}
|
|
|
|
|
2019-08-27 14:26:14 +00:00
|
|
|
if (this.mode.canHelp && !this.panels['help']) {
|
2018-04-19 14:26:42 +00:00
|
|
|
this.panels['help'] = ((new SSE.Views.FileMenuPanels.Help({menu: this})).render());
|
|
|
|
this.panels['help'].setLangConfig(this.mode.lang);
|
|
|
|
}
|
2020-09-23 16:26:59 +00:00
|
|
|
|
|
|
|
if ( this.mode.disableEditing != undefined ) {
|
2021-06-28 17:12:31 +00:00
|
|
|
this.panels['opts'].SetDisabled(this.mode.disableEditing);
|
2020-09-23 16:26:59 +00:00
|
|
|
delete this.mode.disableEditing;
|
|
|
|
}
|
2021-10-18 08:21:30 +00:00
|
|
|
|
|
|
|
if (this.mode.canPrint) {
|
2021-10-19 16:03:31 +00:00
|
|
|
var printPanel = SSE.getController('Print').getView('PrintWithPreview');
|
|
|
|
printPanel.menu = this;
|
2022-02-18 12:23:47 +00:00
|
|
|
!this.panels['printpreview'] && (this.panels['printpreview'] = printPanel.render(this.$el.find('#panel-print')));
|
2021-10-18 08:21:30 +00:00
|
|
|
}
|
2021-12-07 15:49:59 +00:00
|
|
|
|
2021-11-30 17:13:56 +00:00
|
|
|
if ( Common.Controllers.Desktop.isActive() ) {
|
|
|
|
$('<li id="fm-btn-local-open" class="fm-btn"/>').insertAfter($('#fm-btn-recent', this.$el));
|
|
|
|
this.items.push(
|
|
|
|
new Common.UI.MenuItem({
|
|
|
|
el : $('#fm-btn-local-open', this.$el),
|
|
|
|
action : 'file:open',
|
|
|
|
caption : this.btnFileOpenCaption,
|
|
|
|
canFocused: false,
|
|
|
|
dataHint: 1,
|
|
|
|
dataHintDirection: 'left-top',
|
|
|
|
dataHintOffset: [2, 14]
|
|
|
|
}));
|
|
|
|
|
|
|
|
$('<li class="devider" />' +
|
|
|
|
'<li id="fm-btn-exit" class="fm-btn"/>').insertAfter($('#fm-btn-back', this.$el));
|
|
|
|
this.items.push(
|
|
|
|
new Common.UI.MenuItem({
|
|
|
|
el : $('#fm-btn-exit', this.$el),
|
|
|
|
action : 'file:exit',
|
|
|
|
caption : this.btnExitCaption,
|
|
|
|
canFocused: false,
|
|
|
|
dataHint: 1,
|
|
|
|
dataHintDirection: 'left-top',
|
|
|
|
dataHintOffset: [2, 14]
|
|
|
|
}));
|
|
|
|
}
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
setMode: function(mode, delay) {
|
|
|
|
if (mode.isDisconnected) {
|
|
|
|
this.mode.canEdit = this.mode.isEdit = false;
|
|
|
|
this.mode.canOpenRecent = this.mode.canCreateNew = false;
|
2016-10-12 13:32:48 +00:00
|
|
|
this.mode.isDisconnected = mode.isDisconnected;
|
2016-09-27 12:09:32 +00:00
|
|
|
this.mode.canRename = false;
|
2018-10-25 13:19:29 +00:00
|
|
|
if (!mode.enableDownload)
|
|
|
|
this.mode.canPrint = this.mode.canDownload = false;
|
2016-03-11 00:48:53 +00:00
|
|
|
} else {
|
|
|
|
this.mode = mode;
|
|
|
|
}
|
|
|
|
|
2019-08-27 14:26:14 +00:00
|
|
|
if (!delay) {
|
2021-07-01 21:54:55 +00:00
|
|
|
this.applyMode();
|
2019-08-27 14:26:14 +00:00
|
|
|
}
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
setApi: function(api) {
|
|
|
|
this.api = api;
|
2019-08-27 14:26:14 +00:00
|
|
|
if ( this.rendered ) {
|
|
|
|
this.panels['info'].setApi(api);
|
|
|
|
if (this.panels['opts']) this.panels['opts'].setApi(api);
|
|
|
|
if (this.panels['protect']) this.panels['protect'].setApi(api);
|
|
|
|
}
|
2016-03-11 00:48:53 +00:00
|
|
|
this.api.asc_registerCallback('asc_onDocumentName', _.bind(this.onDocumentName, this));
|
|
|
|
},
|
|
|
|
|
|
|
|
loadDocument: function(data) {
|
|
|
|
this.document = data.doc;
|
|
|
|
},
|
|
|
|
|
2020-08-25 16:38:52 +00:00
|
|
|
selectMenu: function(menu, opts, defMenu) {
|
2016-03-11 00:48:53 +00:00
|
|
|
if ( menu ) {
|
2017-11-28 12:48:24 +00:00
|
|
|
var item = this._getMenuItem(menu),
|
2016-03-11 00:48:53 +00:00
|
|
|
panel = this.panels[menu];
|
2018-05-15 10:57:32 +00:00
|
|
|
if ( item.isDisabled() || !item.isVisible()) {
|
2017-11-28 12:48:24 +00:00
|
|
|
item = this._getMenuItem(defMenu);
|
|
|
|
panel = this.panels[defMenu];
|
|
|
|
}
|
2016-03-11 00:48:53 +00:00
|
|
|
if ( item && panel ) {
|
|
|
|
$('.fm-btn',this.el).removeClass('active');
|
|
|
|
item.$el.addClass('active');
|
|
|
|
|
|
|
|
this.$el.find('.content-box:visible').hide();
|
2020-08-25 16:38:52 +00:00
|
|
|
panel.show(opts);
|
2016-03-11 00:48:53 +00:00
|
|
|
|
2021-07-14 21:35:56 +00:00
|
|
|
if (this.scroller) {
|
|
|
|
var itemTop = item.$el.position().top,
|
|
|
|
itemHeight = item.$el.outerHeight(),
|
|
|
|
listHeight = this.$el.outerHeight();
|
|
|
|
if (itemTop < 0 || itemTop + itemHeight > listHeight) {
|
|
|
|
var height = this.scroller.$el.scrollTop() + itemTop + (itemHeight - listHeight)/2;
|
|
|
|
height = (Math.floor(height/itemHeight) * itemHeight);
|
|
|
|
this.scroller.scrollTop(height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
this.active = menu;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_getMenuItem: function(action) {
|
|
|
|
return _.find(this.items, function(item) {
|
|
|
|
return item.options.action == action;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
onDocumentName: function(name) {
|
|
|
|
this.document.title = name;
|
2019-08-27 14:26:14 +00:00
|
|
|
if (this.rendered)
|
|
|
|
this.panels['info'].updateInfo(this.document);
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
2017-04-27 15:34:19 +00:00
|
|
|
isVisible: function () {
|
|
|
|
return !this.$el.is(':hidden');
|
|
|
|
},
|
|
|
|
|
2017-09-05 07:54:44 +00:00
|
|
|
getButton: function(type) {
|
2020-09-07 11:27:35 +00:00
|
|
|
if ( !this.rendered ) {
|
|
|
|
if (type == 'save') {
|
2019-08-27 14:26:14 +00:00
|
|
|
return this.options.miSave ? this.options.miSave : (this.options.miSave = new Common.UI.MenuItem({}));
|
2021-06-28 17:03:50 +00:00
|
|
|
} else if (type == 'rename') {
|
|
|
|
return this.options.miRename ? this.options.miRename : (this.options.miRename = new Common.UI.MenuItem({}));
|
2020-09-07 11:27:35 +00:00
|
|
|
} else
|
|
|
|
if (type == 'protect') {
|
|
|
|
return this.options.miProtect ? this.options.miProtect : (this.options.miProtect = new Common.UI.MenuItem({}));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (type == 'save') {
|
|
|
|
return this.miSave;
|
|
|
|
} else
|
2021-06-28 17:03:50 +00:00
|
|
|
if (type == 'rename') {
|
|
|
|
return this.miRename;
|
|
|
|
}else
|
2020-09-07 11:27:35 +00:00
|
|
|
if (type == 'protect') {
|
|
|
|
return this.miProtect;
|
|
|
|
}
|
2019-08-27 14:26:14 +00:00
|
|
|
}
|
2017-09-05 07:54:44 +00:00
|
|
|
},
|
|
|
|
|
2021-07-01 21:54:55 +00:00
|
|
|
SetDisabled: function(disable, options) {
|
2020-09-23 16:01:44 +00:00
|
|
|
if ( !this.panels ) {
|
2021-06-28 17:12:31 +00:00
|
|
|
this.mode.disableEditing = disable;
|
2020-09-23 16:01:44 +00:00
|
|
|
} else {
|
2021-06-28 17:12:31 +00:00
|
|
|
this.panels['opts'].SetDisabled(disable);
|
2020-09-23 16:01:44 +00:00
|
|
|
}
|
2021-06-28 17:12:31 +00:00
|
|
|
|
2021-07-01 21:54:55 +00:00
|
|
|
var _btn_protect = this.getButton('protect');
|
|
|
|
options && options.protect && _btn_protect.setDisabled(disable || !this.mode.isEdit);
|
2020-09-23 16:01:44 +00:00
|
|
|
},
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
btnSaveCaption : 'Save',
|
|
|
|
btnDownloadCaption : 'Download as...',
|
|
|
|
btnInfoCaption : 'Document Info...',
|
|
|
|
btnRightsCaption : 'Access Rights...',
|
|
|
|
btnCreateNewCaption : 'Create New',
|
|
|
|
btnRecentFilesCaption : 'Open Recent...',
|
|
|
|
btnPrintCaption : 'Print',
|
|
|
|
btnHelpCaption : 'Help...',
|
|
|
|
btnReturnCaption : 'Back to Document',
|
|
|
|
btnToEditCaption : 'Edit Document',
|
|
|
|
btnBackCaption : 'Go to Documents',
|
|
|
|
btnSettingsCaption : 'Advanced Settings...',
|
2016-09-27 12:09:32 +00:00
|
|
|
btnSaveAsCaption : 'Save as',
|
2016-10-05 13:33:10 +00:00
|
|
|
btnRenameCaption : 'Rename...',
|
2017-11-27 11:15:10 +00:00
|
|
|
btnCloseMenuCaption : 'Close Menu',
|
2018-09-27 12:25:15 +00:00
|
|
|
btnProtectCaption: 'Protect',
|
2021-06-28 17:18:53 +00:00
|
|
|
btnSaveCopyAsCaption : 'Save Copy as...',
|
2021-11-30 17:13:56 +00:00
|
|
|
btnHistoryCaption : 'Versions History',
|
|
|
|
btnExitCaption : 'Exit',
|
|
|
|
btnFileOpenCaption : 'Open...'
|
2016-03-11 00:48:53 +00:00
|
|
|
}, SSE.Views.FileMenu || {}));
|
|
|
|
});
|