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
|
|
|
/**
|
|
|
|
* FileMenu.js
|
|
|
|
*
|
|
|
|
* Describes menu 'File' for the left tool menu
|
|
|
|
*
|
|
|
|
* Created by Maxim Kadushkin on 14 February 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!documenteditor/main/app/template/FileMenu.template',
|
|
|
|
'underscore',
|
|
|
|
'common/main/lib/component/BaseView'
|
|
|
|
], function (tpl, _) {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
DE.Views.FileMenu = Common.UI.BaseView.extend(_.extend({
|
|
|
|
el: '#file-menu-panel',
|
2019-07-29 14:00:21 +00:00
|
|
|
rendered: false,
|
2017-02-20 14:54:12 +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];
|
|
|
|
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-01 08:50:22 +00:00
|
|
|
var $markup = $(this.template());
|
2016-03-11 00:48:53 +00:00
|
|
|
|
2017-07-18 13:33:10 +00:00
|
|
|
this.miSave = new Common.UI.MenuItem({
|
2019-07-29 14:00:21 +00:00
|
|
|
el : $markup.elementById('#fm-btn-save'),
|
2017-07-18 13:33:10 +00:00
|
|
|
action : 'save',
|
|
|
|
caption : this.btnSaveCaption,
|
|
|
|
canFocused: false
|
|
|
|
});
|
|
|
|
|
2019-07-29 14:00:21 +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-07-29 14:00:21 +00:00
|
|
|
el : $markup.elementById('#fm-btn-edit'),
|
2017-07-18 13:33:10 +00:00
|
|
|
action : 'edit',
|
|
|
|
caption : this.btnToEditCaption,
|
|
|
|
canFocused: false
|
|
|
|
});
|
|
|
|
|
|
|
|
this.miDownload = new Common.UI.MenuItem({
|
2019-07-29 14:00:21 +00:00
|
|
|
el : $markup.elementById('#fm-btn-download'),
|
2017-07-18 13:33:10 +00:00
|
|
|
action : 'saveas',
|
|
|
|
caption : this.btnDownloadCaption,
|
|
|
|
canFocused: false
|
|
|
|
});
|
|
|
|
|
2018-08-22 08:13:37 +00:00
|
|
|
this.miSaveCopyAs = new Common.UI.MenuItem({
|
2019-07-29 14:00:21 +00:00
|
|
|
el : $markup.elementById('#fm-btn-save-copy'),
|
2018-08-22 08:13:37 +00:00
|
|
|
action : 'save-copy',
|
|
|
|
caption : this.btnSaveCopyAsCaption,
|
|
|
|
canFocused: false
|
|
|
|
});
|
|
|
|
|
2017-07-18 13:33:10 +00:00
|
|
|
this.miSaveAs = new Common.UI.MenuItem({
|
2019-07-29 14:00:21 +00:00
|
|
|
el : $markup.elementById('#fm-btn-save-desktop'),
|
2017-07-18 13:33:10 +00:00
|
|
|
action : 'save-desktop',
|
|
|
|
caption : this.btnSaveAsCaption,
|
|
|
|
canFocused: false
|
|
|
|
});
|
|
|
|
|
|
|
|
this.miPrint = new Common.UI.MenuItem({
|
2019-07-29 14:00:21 +00:00
|
|
|
el : $markup.elementById('#fm-btn-print'),
|
2017-07-18 13:33:10 +00:00
|
|
|
action : 'print',
|
|
|
|
caption : this.btnPrintCaption,
|
|
|
|
canFocused: false
|
|
|
|
});
|
|
|
|
|
|
|
|
this.miRename = new Common.UI.MenuItem({
|
2019-07-29 14:00:21 +00:00
|
|
|
el : $markup.elementById('#fm-btn-rename'),
|
2017-07-18 13:33:10 +00:00
|
|
|
action : 'rename',
|
|
|
|
caption : this.btnRenameCaption,
|
|
|
|
canFocused: false
|
|
|
|
});
|
|
|
|
|
2019-07-29 14:00:21 +00:00
|
|
|
if ( !!this.options.miRename ) {
|
|
|
|
this.miRename.setDisabled(this.options.miRename.isDisabled());
|
|
|
|
delete this.options.miRename;
|
|
|
|
}
|
|
|
|
|
2017-11-28 12:32:07 +00:00
|
|
|
this.miProtect = new Common.UI.MenuItem({
|
2019-07-29 14:00:21 +00:00
|
|
|
el : $markup.elementById('#fm-btn-protect'),
|
2017-11-28 12:32:07 +00:00
|
|
|
action : 'protect',
|
|
|
|
caption : this.btnProtectCaption,
|
|
|
|
canFocused: false
|
|
|
|
});
|
|
|
|
|
2019-08-23 08:42:21 +00:00
|
|
|
if ( !!this.options.miProtect ) {
|
|
|
|
this.miProtect.setDisabled(this.options.miProtect.isDisabled());
|
|
|
|
delete this.options.miProtect;
|
|
|
|
}
|
|
|
|
|
2017-07-18 13:33:10 +00:00
|
|
|
this.miRecent = new Common.UI.MenuItem({
|
2019-07-29 14:00:21 +00:00
|
|
|
el : $markup.elementById('#fm-btn-recent'),
|
2017-07-18 13:33:10 +00:00
|
|
|
action : 'recent',
|
|
|
|
caption : this.btnRecentFilesCaption,
|
|
|
|
canFocused: false
|
|
|
|
});
|
|
|
|
|
|
|
|
this.miNew = new Common.UI.MenuItem({
|
2019-07-29 14:00:21 +00:00
|
|
|
el : $markup.elementById('#fm-btn-create'),
|
2017-07-18 13:33:10 +00:00
|
|
|
action : 'new',
|
|
|
|
caption : this.btnCreateNewCaption,
|
|
|
|
canFocused: false
|
|
|
|
});
|
|
|
|
|
|
|
|
this.miAccess = new Common.UI.MenuItem({
|
2019-07-29 14:00:21 +00:00
|
|
|
el : $markup.elementById('#fm-btn-rights'),
|
2017-07-18 13:33:10 +00:00
|
|
|
action : 'rights',
|
|
|
|
caption : this.btnRightsCaption,
|
|
|
|
canFocused: false
|
|
|
|
});
|
|
|
|
|
|
|
|
this.miHistory = new Common.UI.MenuItem({
|
2019-07-29 14:00:21 +00:00
|
|
|
el : $markup.elementById('#fm-btn-history'),
|
2017-07-18 13:33:10 +00:00
|
|
|
action : 'history',
|
|
|
|
caption : this.btnHistoryCaption,
|
|
|
|
canFocused: false
|
|
|
|
});
|
|
|
|
|
2018-04-19 14:26:42 +00:00
|
|
|
this.miHelp = new Common.UI.MenuItem({
|
2019-07-29 14:00:21 +00:00
|
|
|
el : $markup.elementById('#fm-btn-help'),
|
2018-04-19 14:26:42 +00:00
|
|
|
action : 'help',
|
|
|
|
caption : this.btnHelpCaption,
|
|
|
|
canFocused: false
|
|
|
|
});
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
this.items = [];
|
|
|
|
this.items.push(
|
|
|
|
new Common.UI.MenuItem({
|
2019-07-29 14:00:21 +00:00
|
|
|
el : $markup.elementById('#fm-btn-return'),
|
2016-03-11 00:48:53 +00:00
|
|
|
action : 'back',
|
2016-10-05 13:33:10 +00:00
|
|
|
caption : this.btnCloseMenuCaption,
|
2016-03-11 00:48:53 +00:00
|
|
|
canFocused: false
|
|
|
|
}),
|
2017-07-18 13:33:10 +00:00
|
|
|
this.miSave,
|
|
|
|
this.miEdit,
|
|
|
|
this.miDownload,
|
2018-08-22 08:13:37 +00:00
|
|
|
this.miSaveCopyAs,
|
2017-07-18 13:33:10 +00:00
|
|
|
this.miSaveAs,
|
|
|
|
this.miPrint,
|
|
|
|
this.miRename,
|
2017-11-28 12:32:07 +00:00
|
|
|
this.miProtect,
|
2017-07-18 13:33:10 +00:00
|
|
|
this.miRecent,
|
|
|
|
this.miNew,
|
2016-03-11 00:48:53 +00:00
|
|
|
new Common.UI.MenuItem({
|
2019-07-29 14:00:21 +00:00
|
|
|
el : $markup.elementById('#fm-btn-info'),
|
2016-03-11 00:48:53 +00:00
|
|
|
action : 'info',
|
|
|
|
caption : this.btnInfoCaption,
|
|
|
|
canFocused: false
|
|
|
|
}),
|
2017-07-18 13:33:10 +00:00
|
|
|
this.miAccess,
|
|
|
|
this.miHistory,
|
2016-03-11 00:48:53 +00:00
|
|
|
new Common.UI.MenuItem({
|
2019-07-29 14:00:21 +00:00
|
|
|
el : $markup.elementById('#fm-btn-settings'),
|
2016-03-11 00:48:53 +00:00
|
|
|
action : 'opts',
|
|
|
|
caption : this.btnSettingsCaption,
|
|
|
|
canFocused: false
|
|
|
|
}),
|
2018-04-19 14:26:42 +00:00
|
|
|
this.miHelp,
|
2016-03-11 00:48:53 +00:00
|
|
|
new Common.UI.MenuItem({
|
2019-07-29 14:00:21 +00:00
|
|
|
el : $markup.elementById('#fm-btn-back'),
|
|
|
|
// el : _get_el('fm-btn-back'),
|
2016-03-11 00:48:53 +00:00
|
|
|
action : 'exit',
|
|
|
|
caption : this.btnBackCaption,
|
|
|
|
canFocused: false
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
2019-08-01 10:46:25 +00:00
|
|
|
this.rendered = true;
|
|
|
|
this.$el.html($markup);
|
|
|
|
this.$el.find('.content-box').hide();
|
|
|
|
this.applyMode();
|
|
|
|
|
|
|
|
if ( !!this.api ) {
|
|
|
|
this.panels['info'].setApi(this.api);
|
|
|
|
if ( this.panels['protect'] )
|
2019-08-27 14:26:14 +00:00
|
|
|
this.panels['protect'].setApi(this.api);
|
2019-07-29 14:00:21 +00:00
|
|
|
}
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
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-07-29 14:00:21 +00:00
|
|
|
if ( !this.rendered )
|
|
|
|
this.render();
|
|
|
|
|
2017-11-28 12:32:07 +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:32:07 +00:00
|
|
|
panel = this.active || defPanel;
|
2016-03-11 00:48:53 +00:00
|
|
|
this.$el.show();
|
2017-11-28 12:32:07 +00:00
|
|
|
this.selectMenu(panel, opts, defPanel);
|
2016-03-11 00:48:53 +00:00
|
|
|
this.api.asc_enableKeyEvents(false);
|
2017-04-27 14:34:34 +00:00
|
|
|
|
|
|
|
this.fireEvent('menu:show', [this]);
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
hide: function() {
|
|
|
|
this.$el.hide();
|
2017-04-10 13:39:03 +00:00
|
|
|
// if (this.mode.isEdit) DE.getController('Toolbar').DisableToolbar(false);
|
2017-04-27 14:34:34 +00:00
|
|
|
this.fireEvent('menu:hide', [this]);
|
2017-04-10 13:39:03 +00:00
|
|
|
// this.api.asc_enableKeyEvents(true);
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
applyMode: function() {
|
2019-08-01 10:46:25 +00:00
|
|
|
if (!this.panels) {
|
|
|
|
this.panels = {
|
|
|
|
'opts' : (new DE.Views.FileMenuPanels.Settings({menu:this})).render(this.$el.find('#panel-settings')),
|
|
|
|
'info' : (new DE.Views.FileMenuPanels.DocumentInfo({menu:this})).render(this.$el.find('#panel-info')),
|
|
|
|
'rights' : (new DE.Views.FileMenuPanels.DocumentRights({menu:this})).render(this.$el.find('#panel-rights'))
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.mode) return;
|
|
|
|
|
2019-08-19 11:49:58 +00:00
|
|
|
this.miDownload[((this.mode.canDownload || this.mode.canDownloadOrigin) && (!this.mode.isDesktopApp || !this.mode.isOffline))?'show':'hide']();
|
|
|
|
this.miSaveCopyAs[((this.mode.canDownload || this.mode.canDownloadOrigin) && (!this.mode.isDesktopApp || !this.mode.isOffline)) && (this.mode.canRequestSaveAs || this.mode.saveAsUrl) ?'show':'hide']();
|
|
|
|
this.miSaveAs[((this.mode.canDownload || this.mode.canDownloadOrigin) && this.mode.isDesktopApp && this.mode.isOffline)?'show':'hide']();
|
|
|
|
this.miSave[this.mode.isEdit?'show':'hide']();
|
|
|
|
this.miEdit[!this.mode.isEdit && this.mode.canEdit && this.mode.canRequestEditRights ?'show':'hide']();
|
2017-07-18 13:33:10 +00:00
|
|
|
this.miPrint[this.mode.canPrint?'show':'hide']();
|
|
|
|
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']();
|
2019-08-19 11:49:58 +00:00
|
|
|
var isVisible = this.mode.canDownload || this.mode.canDownloadOrigin || this.mode.isEdit || this.mode.canPrint || this.mode.canProtect ||
|
|
|
|
!this.mode.isEdit && this.mode.canEdit && this.mode.canRequestEditRights || this.mode.canRename && !this.mode.isDesktopApp;
|
|
|
|
this.miProtect.$el.find('+.devider')[isVisible && !this.mode.isDisconnected?'show':'hide']();
|
2017-07-18 13:33:10 +00:00
|
|
|
this.miRecent[this.mode.canOpenRecent?'show':'hide']();
|
|
|
|
this.miNew[this.mode.canCreateNew?'show':'hide']();
|
|
|
|
this.miNew.$el.find('+.devider')[this.mode.canCreateNew?'show':'hide']();
|
|
|
|
|
|
|
|
this.miAccess[(!this.mode.isOffline && !this.mode.isReviewOnly && this.document&&this.document.info &&
|
2016-03-11 00:48:53 +00:00
|
|
|
(this.document.info.sharingSettings&&this.document.info.sharingSettings.length>0 ||
|
|
|
|
this.mode.sharingSettingsUrl&&this.mode.sharingSettingsUrl.length))?'show':'hide']();
|
|
|
|
|
2018-04-19 14:26:42 +00:00
|
|
|
this.miHelp[this.mode.canHelp ?'show':'hide']();
|
|
|
|
this.miHelp.$el.prev()[this.mode.canHelp ?'show':'hide']();
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
this.mode.canBack ? this.$el.find('#fm-btn-back').show().prev().show() :
|
|
|
|
this.$el.find('#fm-btn-back').hide().prev().hide();
|
|
|
|
|
|
|
|
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) {
|
2017-07-18 13:33:10 +00:00
|
|
|
$('a',this.miNew.$el).text(this.btnCreateNewCaption + '...');
|
2019-08-01 10:46:25 +00:00
|
|
|
!this.panels['new'] && (this.panels['new'] = ((new DE.Views.FileMenuPanels.CreateNew({menu: this, docs: this.mode.templates})).render()));
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-01 10:46:25 +00:00
|
|
|
if ( this.mode.canOpenRecent && this.mode.recent ) {
|
|
|
|
!this.panels['recent'] && (this.panels['recent'] = (new DE.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-01 10:46:25 +00:00
|
|
|
!this.panels['protect'] && (this.panels['protect'] = (new DE.Views.FileMenuPanels.ProtectDoc({menu:this})).render());
|
2017-11-27 11:15:10 +00:00
|
|
|
this.panels['protect'].setMode(this.mode);
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (this.mode.canDownload) {
|
2019-08-01 10:46:25 +00:00
|
|
|
!this.panels['saveas'] && (this.panels['saveas'] = ((new DE.Views.FileMenuPanels.ViewSaveAs({menu: this})).render()));
|
2016-03-11 00:48:53 +00:00
|
|
|
} else if (this.mode.canDownloadOrigin)
|
2017-07-18 13:33:10 +00:00
|
|
|
$('a',this.miDownload.$el).text(this.textDownload);
|
2016-03-11 00:48:53 +00:00
|
|
|
|
2019-07-26 09:54:20 +00:00
|
|
|
if (this.mode.canDownload && (this.mode.canRequestSaveAs || this.mode.saveAsUrl)) {
|
2019-08-01 10:46:25 +00:00
|
|
|
!this.panels['save-copy'] && (this.panels['save-copy'] = ((new DE.Views.FileMenuPanels.ViewSaveCopy({menu: this})).render()));
|
2018-08-22 08:13:37 +00:00
|
|
|
}
|
|
|
|
|
2019-08-01 10:46:25 +00:00
|
|
|
if (this.mode.canHelp && !this.panels['help']) {
|
2018-04-19 14:26:42 +00:00
|
|
|
this.panels['help'] = ((new DE.Views.FileMenuPanels.Help({menu: this})).render());
|
|
|
|
this.panels['help'].setLangConfig(this.mode.lang);
|
|
|
|
}
|
2016-03-11 00:48:53 +00:00
|
|
|
|
2017-07-18 13:33:10 +00:00
|
|
|
this.miHistory[this.mode.canUseHistory&&!this.mode.isDisconnected?'show':'hide']();
|
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;
|
|
|
|
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 = this.mode.canDownloadOrigin = false;
|
2016-03-11 00:48:53 +00:00
|
|
|
} else {
|
|
|
|
this.mode = mode;
|
|
|
|
}
|
|
|
|
|
2019-07-29 14:00:21 +00:00
|
|
|
if (!delay) {
|
|
|
|
if ( this.rendered )
|
|
|
|
this.applyMode();
|
|
|
|
}
|
|
|
|
return this;
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
setApi: function(api) {
|
|
|
|
this.api = api;
|
2019-07-29 14:00:21 +00:00
|
|
|
|
|
|
|
if ( this.rendered ) {
|
|
|
|
this.panels['info'].setApi(api);
|
|
|
|
if (this.panels['protect']) this.panels['protect'].setApi(api);
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
loadDocument: function(data) {
|
|
|
|
this.document = data.doc;
|
|
|
|
},
|
|
|
|
|
2017-11-28 12:32:07 +00:00
|
|
|
selectMenu: function(menu, opts, defMenu) {
|
2016-03-11 00:48:53 +00:00
|
|
|
if ( menu ) {
|
2017-11-28 12:32:07 +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:32:07 +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();
|
|
|
|
panel.show(opts);
|
|
|
|
|
|
|
|
this.active = menu;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_getMenuItem: function(action) {
|
|
|
|
return _.find(this.items, function(item) {
|
|
|
|
return item.options.action == action;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
SetDisabled: function(disable) {
|
2019-07-29 14:00:21 +00:00
|
|
|
var _btn_save = this.getButton('save'),
|
|
|
|
_btn_rename = this.getButton('rename');
|
|
|
|
|
|
|
|
_btn_save[(disable || !this.mode.isEdit)?'hide':'show']();
|
|
|
|
_btn_rename[(disable || !this.mode.canRename || this.mode.isDesktopApp) ?'hide':'show']();
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
2017-02-20 14:54:12 +00:00
|
|
|
isVisible: function () {
|
|
|
|
return !this.$el.is(':hidden');
|
|
|
|
},
|
|
|
|
|
2017-09-05 07:54:44 +00:00
|
|
|
getButton: function(type) {
|
2019-07-29 14:00:21 +00:00
|
|
|
if ( !this.rendered ) {
|
|
|
|
if (type == 'save') {
|
|
|
|
return this.options.miSave ? this.options.miSave : (this.options.miSave = new Common.UI.MenuItem({}));
|
|
|
|
} else
|
|
|
|
if (type == 'rename') {
|
|
|
|
return this.options.miRename ? this.options.miRename : (this.options.miRename = new Common.UI.MenuItem({}));
|
2019-08-23 08:42:21 +00:00
|
|
|
} else
|
|
|
|
if (type == 'protect') {
|
|
|
|
return this.options.miProtect ? this.options.miProtect : (this.options.miProtect = new Common.UI.MenuItem({}));
|
2019-07-29 14:00:21 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (type == 'save') {
|
|
|
|
return this.miSave;
|
2019-08-22 14:41:41 +00:00
|
|
|
} else
|
|
|
|
if (type == 'rename') {
|
|
|
|
return this.miRename;
|
2019-08-23 08:42:21 +00:00
|
|
|
}else
|
|
|
|
if (type == 'protect') {
|
|
|
|
return this.miProtect;
|
2019-07-29 14:00:21 +00:00
|
|
|
}
|
|
|
|
}
|
2017-09-05 07:54: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...',
|
|
|
|
btnHistoryCaption : 'Versions History',
|
|
|
|
btnSaveAsCaption : 'Save as',
|
2016-09-27 12:09:32 +00:00
|
|
|
textDownload : 'Download',
|
2016-10-05 13:33:10 +00:00
|
|
|
btnRenameCaption : 'Rename...',
|
2017-11-27 11:15:10 +00:00
|
|
|
btnCloseMenuCaption : 'Close Menu',
|
2018-08-22 08:13:37 +00:00
|
|
|
btnProtectCaption: 'Protect',
|
|
|
|
btnSaveCopyAsCaption : 'Save Copy as...'
|
2016-03-11 00:48:53 +00:00
|
|
|
}, DE.Views.FileMenu || {}));
|
|
|
|
});
|