2021-12-07 18:18:48 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* (c) Copyright Ascensio System SIA 2010-2020
|
|
|
|
*
|
|
|
|
* This program is a free software product. You can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
|
|
|
* version 3 as published by the Free Software Foundation. In accordance with
|
|
|
|
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
|
|
|
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
|
|
|
* of any third-party rights.
|
|
|
|
*
|
|
|
|
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
|
|
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
|
|
|
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
|
|
|
*
|
|
|
|
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
|
|
|
|
* street, Riga, Latvia, EU, LV-1050.
|
|
|
|
*
|
|
|
|
* The interactive user interfaces in modified source and object code versions
|
|
|
|
* of the Program must display Appropriate Legal Notices, as required under
|
|
|
|
* Section 5 of the GNU AGPL version 3.
|
|
|
|
*
|
|
|
|
* Pursuant to Section 7(b) of the License you must retain the original Product
|
|
|
|
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
|
|
|
* grant you any rights under trademark law for use of our trademarks.
|
|
|
|
*
|
|
|
|
* All the Product's GUI elements, including illustrations and icon sets, as
|
|
|
|
* well as technical writing content are licensed under the terms of the
|
|
|
|
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
|
|
|
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ViewTab.js
|
|
|
|
*
|
|
|
|
* Created by Julia Svinareva on 06.12.2021
|
|
|
|
* Copyright (c) 2021 Ascensio System SIA. All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
define([
|
|
|
|
'core',
|
|
|
|
'documenteditor/main/app/view/ViewTab'
|
|
|
|
], function () {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
DE.Controllers.ViewTab = Backbone.Controller.extend(_.extend({
|
|
|
|
models : [],
|
|
|
|
collections : [
|
|
|
|
],
|
|
|
|
views : [
|
|
|
|
'ViewTab'
|
|
|
|
],
|
|
|
|
sdkViewName : '#id_main',
|
|
|
|
|
|
|
|
initialize: function () {
|
|
|
|
},
|
|
|
|
onLaunch: function () {
|
|
|
|
this._state = {};
|
2021-12-08 15:01:00 +00:00
|
|
|
Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this));
|
2021-12-12 16:33:44 +00:00
|
|
|
Common.NotificationCenter.on('contenttheme:dark', this.onContentThemeChangedToDark.bind(this));
|
2021-12-07 18:18:48 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
setApi: function (api) {
|
|
|
|
if (api) {
|
|
|
|
this.api = api;
|
2021-12-09 13:06:11 +00:00
|
|
|
this.api.asc_registerCallback('asc_onZoomChange', _.bind(this.onZoomChange, this));
|
2021-12-07 18:18:48 +00:00
|
|
|
}
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
setConfig: function(config) {
|
|
|
|
this.toolbar = config.toolbar;
|
|
|
|
this.view = this.createView('ViewTab', {
|
|
|
|
toolbar: this.toolbar.toolbar,
|
2021-12-10 12:24:58 +00:00
|
|
|
mode: config.mode,
|
|
|
|
compactToolbar: this.toolbar.toolbar.isCompactView
|
2021-12-07 18:18:48 +00:00
|
|
|
});
|
|
|
|
this.addListeners({
|
|
|
|
'ViewTab': {
|
2021-12-09 13:06:11 +00:00
|
|
|
'zoom:value': _.bind(this.onChangeZoomValue, this),
|
|
|
|
'zoom:topage': _.bind(this.onBtnZoomTo, this, 'topage'),
|
2021-12-10 12:24:58 +00:00
|
|
|
'zoom:towidth': _.bind(this.onBtnZoomTo, this, 'towidth'),
|
2021-12-12 16:33:44 +00:00
|
|
|
'rulers:change': _.bind(this.onChangeRulers, this),
|
|
|
|
'darkmode:change': _.bind(this.onChangeDarkMode, this)
|
2021-12-10 12:24:58 +00:00
|
|
|
},
|
|
|
|
'Toolbar': {
|
|
|
|
'view:compact': _.bind(function (toolbar, state) {
|
|
|
|
this.view.chToolbar.setValue(!state, true);
|
|
|
|
}, this)
|
2021-12-07 18:18:48 +00:00
|
|
|
},
|
|
|
|
'Statusbar': {
|
2021-12-10 12:24:58 +00:00
|
|
|
'view:hide': _.bind(function (statusbar, state) {
|
|
|
|
this.view.chStatusbar.setValue(!state, true);
|
|
|
|
}, this)
|
|
|
|
},
|
|
|
|
'Common.Views.Header': {
|
2021-12-10 17:09:53 +00:00
|
|
|
'rulers:hide': _.bind(function (isChecked) {
|
2021-12-10 12:24:58 +00:00
|
|
|
this.view.chRulers.setValue(!isChecked, true);
|
|
|
|
}, this)
|
2021-12-07 18:18:48 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
SetDisabled: function(state) {
|
|
|
|
this.view && this.view.SetDisabled(state);
|
|
|
|
},
|
|
|
|
|
|
|
|
getView: function(name) {
|
|
|
|
return !name && this.view ?
|
|
|
|
this.view : Backbone.Controller.prototype.getView.call(this, name);
|
|
|
|
},
|
|
|
|
|
|
|
|
onCoAuthoringDisconnect: function() {
|
|
|
|
this.SetDisabled(true);
|
|
|
|
},
|
|
|
|
|
2021-12-08 15:01:00 +00:00
|
|
|
onAppReady: function (config) {
|
|
|
|
var me = this;
|
2021-12-12 13:46:42 +00:00
|
|
|
if (me.view) {
|
|
|
|
(new Promise(function (accept, reject) {
|
|
|
|
accept();
|
|
|
|
})).then(function(){
|
|
|
|
me.view.setEvents();
|
|
|
|
});
|
|
|
|
|
|
|
|
me.getApplication().getController('LeftMenu').leftMenu.btnNavigation.on('toggle', function (btn, state) {
|
2021-12-08 15:01:00 +00:00
|
|
|
if (state !== me.view.btnNavigation.pressed)
|
|
|
|
me.view.turnNavigation(state);
|
|
|
|
});
|
2021-12-08 20:54:07 +00:00
|
|
|
|
2021-12-12 13:46:42 +00:00
|
|
|
var menuItems = [],
|
|
|
|
currentTheme = Common.UI.Themes.currentThemeId() || Common.UI.Themes.defaultThemeId();
|
|
|
|
for (var t in Common.UI.Themes.map()) {
|
|
|
|
menuItems.push({
|
|
|
|
value: t,
|
|
|
|
caption: Common.UI.Themes.get(t).text,
|
|
|
|
checked: t === currentTheme,
|
|
|
|
checkable: true,
|
|
|
|
toggleGroup: 'interface-theme'
|
|
|
|
});
|
|
|
|
}
|
2021-12-08 20:54:07 +00:00
|
|
|
|
2021-12-12 13:46:42 +00:00
|
|
|
if (menuItems.length) {
|
|
|
|
this.view.btnInterfaceTheme.setMenu(new Common.UI.Menu({items: menuItems}));
|
|
|
|
this.view.btnInterfaceTheme.menu.on('item:click', _.bind(function (menu, item) {
|
|
|
|
var value = item.value;
|
|
|
|
Common.UI.Themes.setTheme(value);
|
|
|
|
this.view.btnDarkDocument.setDisabled(value !== 'theme-dark');
|
|
|
|
}, this));
|
|
|
|
}
|
2021-12-08 20:54:07 +00:00
|
|
|
}
|
2021-12-08 15:01:00 +00:00
|
|
|
},
|
|
|
|
|
2021-12-09 13:06:11 +00:00
|
|
|
onZoomChange: function (percent, type) {
|
|
|
|
this.view.btnFitToPage.toggle(type == 2, true);
|
|
|
|
this.view.btnFitToWidth.toggle(type == 1, true);
|
|
|
|
|
|
|
|
this.view.cmbZoom.setValue(percent, percent + '%');
|
|
|
|
},
|
|
|
|
|
|
|
|
onChangeZoomValue: function (value) {
|
|
|
|
this.api.zoom(value);
|
|
|
|
Common.NotificationCenter.trigger('edit:complete', this.view);
|
|
|
|
},
|
|
|
|
|
|
|
|
onBtnZoomTo: function(type) {
|
|
|
|
var btn, func;
|
|
|
|
if ( type === 'topage' ) {
|
|
|
|
btn = 'btnFitToPage';
|
|
|
|
func = 'zoomFitToPage';
|
|
|
|
} else {
|
|
|
|
btn = 'btnFitToWidth';
|
|
|
|
func = 'zoomFitToWidth';
|
|
|
|
}
|
|
|
|
if ( !this.view[btn].pressed )
|
|
|
|
this.api.zoomCustomMode();
|
|
|
|
else
|
|
|
|
this.api[func]();
|
|
|
|
Common.NotificationCenter.trigger('edit:complete', this.view);
|
|
|
|
},
|
|
|
|
|
2021-12-10 12:24:58 +00:00
|
|
|
onChangeRulers: function (btn, checked) {
|
|
|
|
this.api.asc_SetViewRulers(checked);
|
|
|
|
Common.localStorage.setBool('de-hidden-rulers', !checked);
|
|
|
|
Common.Utils.InternalSettings.set("de-hidden-rulers", !checked);
|
|
|
|
this.view.fireEvent('rulers:hide', [!checked]);
|
|
|
|
Common.NotificationCenter.trigger('layout:changed', 'rulers');
|
|
|
|
Common.NotificationCenter.trigger('edit:complete', this.view);
|
|
|
|
},
|
|
|
|
|
2021-12-12 16:33:44 +00:00
|
|
|
onChangeDarkMode: function () {
|
|
|
|
Common.UI.Themes.toggleContentTheme();
|
|
|
|
},
|
|
|
|
|
|
|
|
onContentThemeChangedToDark: function (isdark) {
|
|
|
|
this.view && this.view.btnDarkDocument.toggle(isdark, true);
|
|
|
|
},
|
|
|
|
|
2021-12-07 18:18:48 +00:00
|
|
|
}, DE.Controllers.ViewTab || {}));
|
|
|
|
});
|