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([
|
|
|
|
'common/main/lib/util/utils',
|
|
|
|
'common/main/lib/component/BaseView',
|
|
|
|
'common/main/lib/component/Layout'
|
|
|
|
], function () {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
DE.Views.ViewTab = Common.UI.BaseView.extend(_.extend((function(){
|
2022-02-06 17:58:45 +00:00
|
|
|
var template =
|
|
|
|
'<section class="panel" data-tab="view">' +
|
|
|
|
'<div class="group" data-layout-name="toolbar-view-navigation">' +
|
|
|
|
'<span class="btn-slot text x-huge" id="slot-btn-navigation"></span>' +
|
|
|
|
'</div>' +
|
|
|
|
'<div class="separator long" data-layout-name="toolbar-view-navigation"></div>' +
|
|
|
|
'<div class="group small">' +
|
|
|
|
'<div class="elset" style="display: flex;">' +
|
|
|
|
'<span class="btn-slot" id="slot-field-zoom" style="flex-grow: 1;"></span>' +
|
|
|
|
'</div>' +
|
|
|
|
'<div class="elset" style="text-align: center;">' +
|
|
|
|
'<span class="btn-slot text" id="slot-lbl-zoom" style="font-size: 11px;text-align: center;margin-top: 4px;"></span>' +
|
|
|
|
'</div>' +
|
|
|
|
'</div>' +
|
|
|
|
'<div class="group small">' +
|
|
|
|
'<div class="elset">' +
|
|
|
|
'<span class="btn-slot text" id="slot-btn-ftp" style="font-size: 11px;text-align: center;"></span>' +
|
|
|
|
'</div>' +
|
|
|
|
'<div class="elset">' +
|
|
|
|
'<span class="btn-slot text" id="slot-btn-ftw" style="font-size: 11px;text-align: center;"></span>' +
|
|
|
|
'</div>' +
|
|
|
|
'</div>' +
|
|
|
|
'<div class="separator long"></div>' +
|
|
|
|
'<div class="group">' +
|
|
|
|
'<span class="btn-slot text x-huge" id="slot-btn-interface-theme"></span>' +
|
|
|
|
'<span class="btn-slot text x-huge" id="slot-btn-dark-document"></span>' +
|
|
|
|
'</div>' +
|
|
|
|
'<div class="separator long"></div>' +
|
|
|
|
'<div class="group small">' +
|
|
|
|
'<div class="elset">' +
|
|
|
|
'<span class="btn-slot text" id="slot-chk-toolbar"></span>' +
|
|
|
|
'</div>' +
|
|
|
|
'<div class="elset">' +
|
|
|
|
'<span class="btn-slot text" id="slot-chk-statusbar"></span>' +
|
|
|
|
'</div>' +
|
|
|
|
'</div>' +
|
2022-02-07 15:55:42 +00:00
|
|
|
'<div class="separator long separator-rulers"></div>' +
|
2022-02-06 17:58:45 +00:00
|
|
|
'<div class="group small">' +
|
|
|
|
'<div class="elset">' +
|
|
|
|
'<span class="btn-slot text" id="slot-chk-rulers"></span>' +
|
|
|
|
'</div>' +
|
|
|
|
'<div class="elset"></div>' +
|
|
|
|
'</div>' +
|
|
|
|
'</section>';
|
|
|
|
|
2021-12-07 18:18:48 +00:00
|
|
|
return {
|
|
|
|
options: {},
|
|
|
|
|
2021-12-14 11:25:50 +00:00
|
|
|
setEvents: function () {
|
2021-12-08 15:01:00 +00:00
|
|
|
var me = this;
|
2021-12-12 16:33:44 +00:00
|
|
|
me.btnNavigation.on('click', function (btn, e) {
|
2021-12-08 15:01:00 +00:00
|
|
|
me.fireEvent('viewtab:navigation', [btn.pressed]);
|
|
|
|
});
|
2021-12-12 16:33:44 +00:00
|
|
|
me.btnFitToPage.on('click', function () {
|
2021-12-09 13:06:11 +00:00
|
|
|
me.fireEvent('zoom:topage');
|
|
|
|
});
|
2021-12-12 16:33:44 +00:00
|
|
|
me.btnFitToWidth.on('click', function () {
|
2021-12-09 13:06:11 +00:00
|
|
|
me.fireEvent('zoom:towidth');
|
|
|
|
});
|
2021-12-12 16:33:44 +00:00
|
|
|
me.chToolbar.on('change', _.bind(function(checkbox, state) {
|
2021-12-10 12:24:58 +00:00
|
|
|
me.fireEvent('toolbar:setcompact', [me.chToolbar, state !== 'checked']);
|
|
|
|
}, me));
|
2021-12-12 16:33:44 +00:00
|
|
|
me.chStatusbar.on('change', _.bind(function (checkbox, state) {
|
2021-12-10 12:24:58 +00:00
|
|
|
me.fireEvent('statusbar:hide', [me.chStatusbar, state !== 'checked']);
|
|
|
|
}, me));
|
2021-12-12 16:33:44 +00:00
|
|
|
me.chRulers.on('change', _.bind(function (checkbox, state) {
|
2021-12-10 12:24:58 +00:00
|
|
|
me.fireEvent('rulers:change', [me.chRulers, state === 'checked']);
|
|
|
|
}, me));
|
2021-12-12 16:33:44 +00:00
|
|
|
me.btnDarkDocument.on('click', _.bind(function () {
|
|
|
|
me.fireEvent('darkmode:change');
|
|
|
|
}, me));
|
2021-12-17 08:10:53 +00:00
|
|
|
me.cmbZoom.on('combo:focusin', _.bind(this.onComboOpen, this, false));
|
|
|
|
me.cmbZoom.on('show:after', _.bind(this.onComboOpen, this, true));
|
2021-12-08 15:01:00 +00:00
|
|
|
},
|
|
|
|
|
2021-12-07 18:18:48 +00:00
|
|
|
initialize: function (options) {
|
|
|
|
Common.UI.BaseView.prototype.initialize.call(this);
|
|
|
|
this.toolbar = options.toolbar;
|
|
|
|
this.appConfig = options.mode;
|
|
|
|
|
|
|
|
this.lockedControls = [];
|
|
|
|
|
2022-02-07 15:55:42 +00:00
|
|
|
var me = this;
|
2021-12-29 16:32:43 +00:00
|
|
|
var _set = Common.enumLock;
|
2021-12-07 18:18:48 +00:00
|
|
|
|
|
|
|
this.btnNavigation = new Common.UI.Button({
|
|
|
|
cls: 'btn-toolbar x-huge icon-top',
|
2021-12-12 16:33:44 +00:00
|
|
|
iconCls: 'toolbar__icon btn-menu-navigation',
|
2021-12-29 10:14:42 +00:00
|
|
|
lock: [_set.lostConnect, _set.disableOnStart],
|
2022-04-22 16:52:40 +00:00
|
|
|
caption: this.textOutline,
|
2021-12-08 15:01:00 +00:00
|
|
|
enableToggle: true,
|
2021-12-07 18:18:48 +00:00
|
|
|
dataHint: '1',
|
|
|
|
dataHintDirection: 'bottom',
|
|
|
|
dataHintOffset: 'small'
|
|
|
|
});
|
|
|
|
this.lockedControls.push(this.btnNavigation);
|
|
|
|
|
|
|
|
this.cmbZoom = new Common.UI.ComboBox({
|
|
|
|
cls: 'input-group-nr',
|
2021-12-29 10:14:42 +00:00
|
|
|
lock: [_set.lostConnect, _set.disableOnStart],
|
2021-12-07 18:18:48 +00:00
|
|
|
menuStyle: 'min-width: 55px;',
|
2021-12-14 20:12:20 +00:00
|
|
|
editable: true,
|
2021-12-07 18:18:48 +00:00
|
|
|
data: [
|
|
|
|
{ displayValue: "50%", value: 50 },
|
|
|
|
{ displayValue: "75%", value: 75 },
|
|
|
|
{ displayValue: "100%", value: 100 },
|
|
|
|
{ displayValue: "125%", value: 125 },
|
|
|
|
{ displayValue: "150%", value: 150 },
|
|
|
|
{ displayValue: "175%", value: 175 },
|
2021-12-14 10:10:32 +00:00
|
|
|
{ displayValue: "200%", value: 200 },
|
|
|
|
{ displayValue: "300%", value: 300 },
|
|
|
|
{ displayValue: "400%", value: 400 },
|
|
|
|
{ displayValue: "500%", value: 500 }
|
2021-12-07 18:18:48 +00:00
|
|
|
],
|
|
|
|
dataHint : '1',
|
|
|
|
dataHintDirection: 'top',
|
|
|
|
dataHintOffset: 'small'
|
|
|
|
});
|
|
|
|
this.cmbZoom.setValue(100);
|
|
|
|
this.lockedControls.push(this.cmbZoom);
|
|
|
|
|
|
|
|
this.btnFitToPage = new Common.UI.Button({
|
|
|
|
cls: 'btn-toolbar',
|
|
|
|
iconCls: 'toolbar__icon btn-ic-zoomtopage',
|
2021-12-29 10:14:42 +00:00
|
|
|
lock: [_set.lostConnect, _set.disableOnStart],
|
2021-12-07 18:18:48 +00:00
|
|
|
caption: this.textFitToPage,
|
2021-12-09 13:06:11 +00:00
|
|
|
toggleGroup: 'view-zoom',
|
|
|
|
enableToggle: true,
|
2021-12-07 18:18:48 +00:00
|
|
|
dataHint: '1',
|
|
|
|
dataHintDirection: 'left',
|
|
|
|
dataHintOffset: 'medium'
|
|
|
|
});
|
|
|
|
this.lockedControls.push(this.btnFitToPage);
|
|
|
|
|
|
|
|
this.btnFitToWidth = new Common.UI.Button({
|
|
|
|
cls: 'btn-toolbar',
|
|
|
|
iconCls: 'toolbar__icon btn-ic-zoomtowidth',
|
2021-12-29 10:14:42 +00:00
|
|
|
lock: [_set.lostConnect, _set.disableOnStart],
|
2021-12-07 18:18:48 +00:00
|
|
|
caption: this.textFitToWidth,
|
2021-12-09 13:06:11 +00:00
|
|
|
toggleGroup: 'view-zoom',
|
|
|
|
enableToggle: true,
|
2021-12-07 18:18:48 +00:00
|
|
|
dataHint: '1',
|
|
|
|
dataHintDirection: 'left',
|
|
|
|
dataHintOffset: 'medium'
|
|
|
|
});
|
|
|
|
this.lockedControls.push(this.btnFitToWidth);
|
|
|
|
|
|
|
|
this.btnInterfaceTheme = new Common.UI.Button({
|
|
|
|
cls: 'btn-toolbar x-huge icon-top',
|
2021-12-12 16:33:44 +00:00
|
|
|
iconCls: 'toolbar__icon day',
|
2021-12-29 10:14:42 +00:00
|
|
|
lock: [_set.lostConnect, _set.disableOnStart],
|
2021-12-07 18:18:48 +00:00
|
|
|
caption: this.textInterfaceTheme,
|
|
|
|
menu: true,
|
|
|
|
dataHint: '1',
|
|
|
|
dataHintDirection: 'bottom',
|
|
|
|
dataHintOffset: 'small'
|
|
|
|
});
|
|
|
|
this.lockedControls.push(this.btnInterfaceTheme);
|
|
|
|
|
2021-12-08 20:54:07 +00:00
|
|
|
this.btnDarkDocument = new Common.UI.Button({
|
|
|
|
cls: 'btn-toolbar x-huge icon-top',
|
2021-12-15 09:55:33 +00:00
|
|
|
iconCls: 'toolbar__icon dark-mode',
|
2021-12-29 10:14:42 +00:00
|
|
|
lock: [_set.inLightTheme, _set.lostConnect, _set.disableOnStart],
|
2021-12-08 20:54:07 +00:00
|
|
|
caption: this.textDarkDocument,
|
2021-12-12 16:33:44 +00:00
|
|
|
enableToggle: true,
|
2021-12-08 20:54:07 +00:00
|
|
|
dataHint: '1',
|
|
|
|
dataHintDirection: 'bottom',
|
|
|
|
dataHintOffset: 'small'
|
|
|
|
});
|
|
|
|
this.lockedControls.push(this.btnDarkDocument);
|
|
|
|
|
2021-12-07 18:18:48 +00:00
|
|
|
this.chStatusbar = new Common.UI.CheckBox({
|
2021-12-29 10:14:42 +00:00
|
|
|
lock: [_set.lostConnect, _set.disableOnStart],
|
2021-12-07 18:18:48 +00:00
|
|
|
labelText: this.textStatusBar,
|
2021-12-10 12:24:58 +00:00
|
|
|
value: !Common.localStorage.getBool("de-hidden-status"),
|
2021-12-07 18:18:48 +00:00
|
|
|
dataHint: '1',
|
|
|
|
dataHintDirection: 'left',
|
|
|
|
dataHintOffset: 'small'
|
|
|
|
});
|
|
|
|
this.lockedControls.push(this.chStatusbar);
|
|
|
|
|
|
|
|
this.chToolbar = new Common.UI.CheckBox({
|
2021-12-29 10:14:42 +00:00
|
|
|
lock: [_set.lostConnect, _set.disableOnStart],
|
2021-12-07 18:18:48 +00:00
|
|
|
labelText: this.textAlwaysShowToolbar,
|
2021-12-10 12:24:58 +00:00
|
|
|
value: !options.compactToolbar,
|
2021-12-07 18:18:48 +00:00
|
|
|
dataHint : '1',
|
|
|
|
dataHintDirection: 'left',
|
|
|
|
dataHintOffset: 'small'
|
|
|
|
});
|
|
|
|
this.lockedControls.push(this.chToolbar);
|
|
|
|
|
|
|
|
this.chRulers = new Common.UI.CheckBox({
|
2021-12-29 10:14:42 +00:00
|
|
|
lock: [_set.lostConnect, _set.disableOnStart],
|
2021-12-07 18:18:48 +00:00
|
|
|
labelText: this.textRulers,
|
2021-12-10 12:24:58 +00:00
|
|
|
value: !Common.Utils.InternalSettings.get("de-hidden-rulers"),
|
2021-12-07 18:18:48 +00:00
|
|
|
dataHint: '1',
|
|
|
|
dataHintDirection: 'left',
|
|
|
|
dataHintOffset: 'small'
|
|
|
|
});
|
|
|
|
this.lockedControls.push(this.chRulers);
|
2022-01-12 14:41:48 +00:00
|
|
|
|
2021-12-29 10:14:42 +00:00
|
|
|
Common.Utils.lockControls(_set.disableOnStart, true, {array: this.lockedControls});
|
2021-12-07 18:18:48 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
render: function (el) {
|
2022-02-06 17:58:45 +00:00
|
|
|
if ( el ) el.html( this.getPanel() );
|
|
|
|
|
2021-12-07 18:18:48 +00:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2022-02-06 17:58:45 +00:00
|
|
|
getPanel: function () {
|
|
|
|
this.$el = $(_.template(template)( {} ));
|
|
|
|
var $host = this.$el;
|
|
|
|
|
|
|
|
this.btnNavigation.render($host.find('#slot-btn-navigation'));
|
|
|
|
this.cmbZoom.render($host.find('#slot-field-zoom'));
|
|
|
|
$host.find('#slot-lbl-zoom').text(this.textZoom);
|
|
|
|
this.btnFitToPage.render($host.find('#slot-btn-ftp'));
|
|
|
|
this.btnFitToWidth.render($host.find('#slot-btn-ftw'));
|
|
|
|
this.btnInterfaceTheme.render($host.find('#slot-btn-interface-theme'));
|
|
|
|
this.btnDarkDocument.render($host.find('#slot-btn-dark-document'));
|
|
|
|
this.chStatusbar.render($host.find('#slot-chk-statusbar'));
|
|
|
|
this.chToolbar.render($host.find('#slot-chk-toolbar'));
|
|
|
|
this.chRulers.render($host.find('#slot-chk-rulers'));
|
|
|
|
return this.$el;
|
|
|
|
},
|
|
|
|
|
2021-12-07 18:18:48 +00:00
|
|
|
show: function () {
|
|
|
|
Common.UI.BaseView.prototype.show.call(this);
|
|
|
|
this.fireEvent('show', this);
|
|
|
|
},
|
|
|
|
|
|
|
|
getButtons: function(type) {
|
|
|
|
if (type===undefined)
|
|
|
|
return this.lockedControls;
|
|
|
|
return [];
|
|
|
|
},
|
|
|
|
|
|
|
|
SetDisabled: function (state) {
|
|
|
|
this.lockedControls && this.lockedControls.forEach(function(button) {
|
|
|
|
if ( button ) {
|
|
|
|
button.setDisabled(state);
|
|
|
|
}
|
|
|
|
}, this);
|
|
|
|
},
|
|
|
|
|
2021-12-08 15:01:00 +00:00
|
|
|
turnNavigation: function (state) {
|
|
|
|
this.btnNavigation && this.btnNavigation.toggle(state, true);
|
|
|
|
},
|
|
|
|
|
2021-12-17 08:10:53 +00:00
|
|
|
onComboOpen: function (needfocus, combo) {
|
|
|
|
_.delay(function() {
|
|
|
|
var input = $('input', combo.cmpEl).select();
|
|
|
|
if (needfocus) input.focus();
|
|
|
|
else if (!combo.isMenuOpen()) input.one('mouseup', function (e) { e.preventDefault(); });
|
|
|
|
}, 10);
|
|
|
|
},
|
|
|
|
|
2021-12-07 18:18:48 +00:00
|
|
|
textNavigation: 'Navigation',
|
2022-04-22 16:52:40 +00:00
|
|
|
textOutline: 'Outline',
|
2021-12-07 18:18:48 +00:00
|
|
|
textZoom: 'Zoom',
|
|
|
|
textFitToPage: 'Fit To Page',
|
|
|
|
textFitToWidth: 'Fit To Width',
|
|
|
|
textInterfaceTheme: 'Interface theme',
|
|
|
|
textStatusBar: 'Status Bar',
|
|
|
|
textAlwaysShowToolbar: 'Always show toolbar',
|
2021-12-08 20:54:07 +00:00
|
|
|
textRulers: 'Rulers',
|
|
|
|
textDarkDocument: 'Dark document'
|
2021-12-07 18:18:48 +00:00
|
|
|
}
|
|
|
|
}()), DE.Views.ViewTab || {}));
|
|
|
|
});
|