web-apps/apps/documenteditor/main/app/view/FileMenuPanels.js

2333 lines
109 KiB
JavaScript
Raw Normal View History

2016-04-01 13:17:09 +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
*
* 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
/**
* FileMenuPanels.js
*
* Contains views for menu 'File'
*
* Created by Maxim Kadushkin on 20 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([
2020-07-03 11:59:48 +00:00
'common/main/lib/view/DocumentAccessDialog',
'common/main/lib/view/AutoCorrectDialog'
2016-03-11 00:48:53 +00:00
], function () {
'use strict';
!DE.Views.FileMenuPanels && (DE.Views.FileMenuPanels = {});
DE.Views.FileMenuPanels.ViewSaveAs = Common.UI.BaseView.extend({
el: '#panel-saveas',
menu: undefined,
formats: [[
{name: 'DOCX', imgCls: 'docx', type: Asc.c_oAscFileType.DOCX},
{name: 'PDF', imgCls: 'pdf', type: Asc.c_oAscFileType.PDF},
2019-02-21 13:40:18 +00:00
{name: 'ODT', imgCls: 'odt', type: Asc.c_oAscFileType.ODT},
{name: 'TXT', imgCls: 'txt', type: Asc.c_oAscFileType.TXT}
2016-03-11 00:48:53 +00:00
],[
{name: 'DOTX', imgCls: 'dotx', type: Asc.c_oAscFileType.DOTX},
{name: 'PDFA', imgCls: 'pdfa', type: Asc.c_oAscFileType.PDFA},
2019-02-21 13:40:18 +00:00
{name: 'OTT', imgCls: 'ott', type: Asc.c_oAscFileType.OTT},
{name: 'RTF', imgCls: 'rtf', type: Asc.c_oAscFileType.RTF}
],[
2021-07-20 18:30:09 +00:00
{name: 'DOCM', imgCls: 'docm', type: Asc.c_oAscFileType.DOCM},
2021-10-08 16:54:58 +00:00
{name: 'DOCXF', imgCls: 'docxf', type: Asc.c_oAscFileType.DOCXF},
{name: 'OFORM', imgCls: 'oform', type: Asc.c_oAscFileType.OFORM}
],[
{name: 'HTML (Zipped)', imgCls: 'html', type: Asc.c_oAscFileType.HTML},
{name: 'FB2', imgCls: 'fb2', type: Asc.c_oAscFileType.FB2},
{name: 'EPUB', imgCls: 'epub', type: Asc.c_oAscFileType.EPUB}
2016-03-11 00:48:53 +00:00
]],
template: _.template([
'<table><tbody>',
'<% _.each(rows, function(row) { %>',
'<tr>',
'<% _.each(row, function(item) { %>',
2021-07-20 18:30:09 +00:00
'<% if (item.type!==Asc.c_oAscFileType.DOCM || fileType=="docm") { %>',
2022-03-28 02:32:04 +00:00
'<td><div><div class="btn-doc-format" format="<%= item.type %>" data-hint="2" data-hint-direction="left-top" data-hint-offset="4, 4">',
'<div class ="svg-format-<%= item.imgCls %>"></div>',
'</div></div></td>',
2021-07-20 18:30:09 +00:00
'<% } %>',
2016-03-11 00:48:53 +00:00
'<% }) %>',
'</tr>',
'<% }) %>',
'</tbody></table>'
].join('')),
initialize: function(options) {
Common.UI.BaseView.prototype.initialize.call(this,arguments);
this.menu = options.menu;
2021-07-20 18:30:09 +00:00
this.fileType = options.fileType;
2021-12-05 09:12:27 +00:00
this.mode = options.mode;
2016-03-11 00:48:53 +00:00
},
render: function() {
if (/^pdf$/.test(this.fileType)) {
2021-12-10 10:13:27 +00:00
this.formats[0].splice(1, 1); // remove pdf
this.formats[1].splice(1, 1); // remove pdfa
this.formats[3].push({name: 'PDF', imgCls: 'pdf', type: ''}); // original pdf
} else if (/^xps|oxps$/.test(this.fileType)) {
this.formats[3].push({name: this.fileType.toUpperCase(), imgCls: this.fileType, type: ''}); // original xps/oxps
} else if (/^djvu$/.test(this.fileType)) {
this.formats = [[
{name: 'DJVU', imgCls: 'djvu', type: ''}, // original djvu
{name: 'PDF', imgCls: 'pdf', type: Asc.c_oAscFileType.PDF}
]];
2021-12-10 10:13:27 +00:00
}
if (this.mode && !this.mode.canFeatureForms && this.formats.length>2) {
2021-12-01 21:48:56 +00:00
this.formats[2].splice(1, 2);
this.formats[2] = this.formats[2].concat(this.formats[3]);
this.formats[3] = undefined;
}
2021-07-20 18:30:09 +00:00
this.$el.html(this.template({rows:this.formats, fileType: (this.fileType || 'docx').toLowerCase()}));
2016-03-11 00:48:53 +00:00
$('.btn-doc-format',this.el).on('click', _.bind(this.onFormatClick,this));
if (_.isUndefined(this.scroller)) {
this.scroller = new Common.UI.Scroller({
2019-08-01 08:50:22 +00:00
el: this.$el,
suppressScrollX: true,
alwaysVisibleY: true
2016-03-11 00:48:53 +00:00
});
}
return this;
},
show: function() {
Common.UI.BaseView.prototype.show.call(this,arguments);
this.scroller && this.scroller.update();
},
2016-03-11 00:48:53 +00:00
onFormatClick: function(e) {
var type = e.currentTarget.attributes['format'];
if (!_.isUndefined(type) && this.menu) {
2021-12-10 10:13:27 +00:00
this.menu.fireEvent('saveas:format', [this.menu, type.value ? parseInt(type.value) : undefined]);
2016-03-11 00:48:53 +00:00
}
}
});
DE.Views.FileMenuPanels.ViewSaveCopy = Common.UI.BaseView.extend({
el: '#panel-savecopy',
menu: undefined,
formats: [[
{name: 'DOCX', imgCls: 'docx', type: Asc.c_oAscFileType.DOCX, ext: '.docx'},
{name: 'PDF', imgCls: 'pdf', type: Asc.c_oAscFileType.PDF, ext: '.pdf'},
2019-02-21 13:40:18 +00:00
{name: 'ODT', imgCls: 'odt', type: Asc.c_oAscFileType.ODT, ext: '.odt'},
{name: 'TXT', imgCls: 'txt', type: Asc.c_oAscFileType.TXT, ext: '.txt'}
],[
{name: 'DOTX', imgCls: 'dotx', type: Asc.c_oAscFileType.DOTX, ext: '.dotx'},
{name: 'PDFA', imgCls: 'pdfa', type: Asc.c_oAscFileType.PDFA, ext: '.pdf'},
2019-02-21 13:40:18 +00:00
{name: 'OTT', imgCls: 'ott', type: Asc.c_oAscFileType.OTT, ext: '.ott'},
{name: 'RTF', imgCls: 'rtf', type: Asc.c_oAscFileType.RTF, ext: '.rtf'}
],[
2021-07-20 18:30:09 +00:00
{name: 'DOCM', imgCls: 'docm', type: Asc.c_oAscFileType.DOCM, ext: '.docm'},
2021-10-08 16:54:58 +00:00
{name: 'DOCXF', imgCls: 'docxf', type: Asc.c_oAscFileType.DOCXF, ext: '.docxf'},
{name: 'OFORM', imgCls: 'oform', type: Asc.c_oAscFileType.OFORM, ext: '.oform'}
],[
{name: 'HTML (Zipped)', imgCls: 'html', type: Asc.c_oAscFileType.HTML, ext: '.html'},
{name: 'FB2', imgCls: 'fb2', type: Asc.c_oAscFileType.FB2, ext: '.fb2'},
{name: 'EPUB', imgCls: 'epub', type: Asc.c_oAscFileType.EPUB, ext: '.epub'}
]],
template: _.template([
'<table><tbody>',
'<% _.each(rows, function(row) { %>',
'<tr>',
'<% _.each(row, function(item) { %>',
2021-07-20 18:30:09 +00:00
'<% if (item.type!==Asc.c_oAscFileType.DOCM || fileType=="docm") { %>',
2022-03-28 02:32:04 +00:00
'<td><div><div class="btn-doc-format" format="<%= item.type %>", format-ext="<%= item.ext %>" data-hint="2" data-hint-direction="left-top" data-hint-offset="4, 4">',
'<div class ="svg-format-<%= item.imgCls %>"></div>',
'</div></div></td>',
2021-07-20 18:30:09 +00:00
'<% } %>',
'<% }) %>',
'</tr>',
'<% }) %>',
'</tbody></table>'
].join('')),
initialize: function(options) {
Common.UI.BaseView.prototype.initialize.call(this,arguments);
this.menu = options.menu;
2021-07-20 18:30:09 +00:00
this.fileType = options.fileType;
2021-12-05 09:12:27 +00:00
this.mode = options.mode;
},
render: function() {
if (/^pdf$/.test(this.fileType)) {
2021-12-10 10:13:27 +00:00
this.formats[0].splice(1, 1); // remove pdf
this.formats[1].splice(1, 1); // remove pdfa
this.formats[3].push({name: 'PDF', imgCls: 'pdf', type: '', ext: true}); // original pdf
} else if (/^xps|oxps$/.test(this.fileType)) {
this.formats[3].push({name: this.fileType.toUpperCase(), imgCls: this.fileType, type: '', ext: true}); // original xps/oxps
} else if (/^djvu$/.test(this.fileType)) {
this.formats = [[
{name: 'DJVU', imgCls: 'djvu', type: '', ext: true}, // original djvu
{name: 'PDF', imgCls: 'pdf', type: Asc.c_oAscFileType.PDF, ext: '.pdf'}
]];
2021-12-10 10:13:27 +00:00
}
if (this.mode && !this.mode.canFeatureForms && this.formats.length>2) {
2021-12-01 21:48:56 +00:00
this.formats[2].splice(1, 2);
this.formats[2] = this.formats[2].concat(this.formats[3]);
this.formats[3] = undefined;
}
2021-07-20 18:30:09 +00:00
this.$el.html(this.template({rows:this.formats, fileType: (this.fileType || 'docx').toLowerCase()}));
$('.btn-doc-format',this.el).on('click', _.bind(this.onFormatClick,this));
if (_.isUndefined(this.scroller)) {
this.scroller = new Common.UI.Scroller({
2019-08-01 08:50:22 +00:00
el: this.$el,
suppressScrollX: true,
alwaysVisibleY: true
});
}
return this;
},
show: function() {
Common.UI.BaseView.prototype.show.call(this,arguments);
this.scroller && this.scroller.update();
},
onFormatClick: function(e) {
var type = e.currentTarget.attributes['format'],
ext = e.currentTarget.attributes['format-ext'];
if (!_.isUndefined(type) && !_.isUndefined(ext) && this.menu) {
2021-12-10 10:13:27 +00:00
this.menu.fireEvent('saveas:format', [this.menu, type.value ? parseInt(type.value) : undefined, ext.value]);
}
}
});
2016-03-11 00:48:53 +00:00
DE.Views.FileMenuPanels.Settings = Common.UI.BaseView.extend(_.extend({
el: '#panel-settings',
menu: undefined,
template: _.template([
2020-08-07 10:51:26 +00:00
'<div class="flex-settings">',
2022-02-16 22:02:01 +00:00
'<table style="margin: 10px 14px 0;"><tbody>',
2022-02-19 14:14:05 +00:00
'<tr class="editsave">',
2022-02-16 00:58:04 +00:00
'<td colspan="2" class="group-name top"><label><%= scope.txtEditingSaving %></label></td>',
2022-02-14 02:56:29 +00:00
'</tr>',
'<tr class="autosave">',
2022-02-16 00:58:04 +00:00
'<td colspan="2"><span id="fms-chb-autosave"></span></td>',
2022-02-14 02:56:29 +00:00
'</tr>',
2022-02-16 22:02:01 +00:00
'<tr class="forcesave">',
'<td colspan="2"><span id="fms-chb-forcesave"></span></td>',
'</tr>',
2022-02-14 02:56:29 +00:00
'<tr class="edit">',
2022-02-16 00:58:04 +00:00
'<td colspan="2"><div id="fms-chb-paste-settings"></div></td>',
2022-02-14 02:56:29 +00:00
'</tr>',
'<tr class="edit">',
2022-02-16 00:58:04 +00:00
'<td colspan="2"><span id="fms-chb-compatible"></span></td>',
2022-02-14 02:56:29 +00:00
'</tr>',
2022-02-25 02:02:26 +00:00
'<tr class ="editsave divider-group"></tr>',
2022-02-19 14:14:05 +00:00
'<tr class="collaboration">',
2022-02-16 00:58:04 +00:00
'<td colspan="2" class="group-name"><label><%= scope.txtCollaboration %></label></td>',
2022-02-14 02:56:29 +00:00
'</tr>',
'<tr class="coauth changes-mode">',
2022-02-16 00:58:04 +00:00
'<td colspan="2" class="subgroup-name"><label><%= scope.strCoAuthMode %></label></td>',
2022-02-14 02:56:29 +00:00
'</tr>',
'<tr class="coauth changes-mode">',
2022-02-16 00:58:04 +00:00
'<td colspan="2"><div style="display: flex;"><div id="fms-rb-coauth-mode-fast"></div>',
2022-02-14 23:32:33 +00:00
'<span style ="display: flex; flex-direction: column;"><label><%= scope.strFast %></label>',
2022-02-17 14:39:54 +00:00
'<label class="comment-text"><%= scope.txtFastTip %></label></span></div>',
2022-02-14 02:56:29 +00:00
'</td>',
'</tr>',
'<tr class="coauth changes-mode">',
2022-02-16 00:58:04 +00:00
'<td colspan="2"><div style="display: flex;"><div id="fms-rb-coauth-mode-strict"></div>',
2022-02-14 23:32:33 +00:00
'<span style ="display: flex; flex-direction: column;"><label><%= scope.strStrict %></label>',
2022-02-17 14:39:54 +00:00
'<label class="comment-text"><%= scope.txtStrictTip %></label></span>',
2022-02-14 02:56:29 +00:00
'</div></td>',
'</tr>',
2022-02-25 02:02:26 +00:00
'<tr class ="divider-subgroup coauth changes-mode"></tr>',
2022-02-14 02:56:29 +00:00
'<tr class="view-review">',
2022-02-16 00:58:04 +00:00
'<td colspan="2" class="subgroup-name"><label><%= scope.txtShowTrackChanges %></label></td>',
2022-02-14 02:56:29 +00:00
'</tr>',
'<tr class="view-review">',
2022-02-16 00:58:04 +00:00
'<td colspan="2"><div id="fms-rb-show-track-ballons"></div></td>',
2022-02-14 02:56:29 +00:00
'</tr>',
'<tr class="view-review">',
2022-02-16 00:58:04 +00:00
'<td colspan="2"><div id="fms-rb-show-track-tooltips"></div></td>',
2022-02-14 02:56:29 +00:00
'</tr>',
2022-02-25 02:02:26 +00:00
'<tr class ="divider-subgroup view-review"></tr>',
'<tr class="coauth changes-show">',
2022-02-16 00:58:04 +00:00
'<td colspan="2" class="subgroup-name"><label><%= scope.strShowChanges %></label></td>',
2022-02-14 02:56:29 +00:00
'</tr>',
2022-02-19 14:14:05 +00:00
'<tr class="coauth changes-show">',
2022-02-16 00:58:04 +00:00
'<td colspan="2"><div id="fms-rb-show-changes-none"></div></td>',
2022-02-14 02:56:29 +00:00
'</tr>',
2022-02-19 14:14:05 +00:00
'<tr class="coauth changes-show">',
2022-02-16 00:58:04 +00:00
'<td colspan="2"><div id="fms-rb-show-changes-all"></div></td>',
2022-02-14 02:56:29 +00:00
'</tr>',
2022-02-19 14:14:05 +00:00
'<tr class="coauth changes-show">',
2022-02-16 00:58:04 +00:00
'<td colspan="2"><div id="fms-rb-show-changes-last"></div></td>',
2022-02-25 02:02:26 +00:00
'</tr>','<tr class="divider coauth changes-show"></tr>',
2022-02-15 07:41:16 +00:00
'<tr class="live-viewer">',
'<td colspan="2"><div id="fms-chb-live-viewer"></div></td>',
'</tr>',
'<tr class="divider live-viewer"></tr>',
'<tr class="comments">',
2022-02-16 00:58:04 +00:00
'<td colspan="2"><div id="fms-chb-live-comment"></div></td>',
2022-02-14 02:56:29 +00:00
'</tr>',
'<tr class="comments">',
2022-02-16 00:58:04 +00:00
'<td colspan="2"><div id="fms-chb-resolved-comment"></div></td>',
2022-02-14 02:56:29 +00:00
'</tr>',
2022-02-25 02:02:26 +00:00
'<tr class ="collaboration divider-group"></tr>',
2022-02-19 14:14:05 +00:00
'<tr class ="edit">',
'<td colspan="2" class="group-name proofing"><label><%= scope.txtProofing %></label></td>',
2022-02-14 02:56:29 +00:00
'</tr>',
'<tr class="edit spellcheck">',
2022-02-16 00:58:04 +00:00
'<td colspan="2"><div id="fms-chb-spell-check"></div></td>',
2022-02-14 02:56:29 +00:00
'</tr>',
2022-03-29 11:26:21 +00:00
'<tr class="edit spellcheck">',
'<td colspan="2"><span id="fms-chb-ignore-uppercase-words"></span></td>',
'</tr>',
'<tr class="edit spellcheck">',
'<td colspan="2"><span id="fms-chb-ignore-numbers-words"></span></td>',
'</tr>',
2020-07-03 11:59:48 +00:00
'<tr class="edit">',
2022-02-16 00:58:04 +00:00
'<td colspan="2"><button type="button" class="btn btn-text-default" id="fms-btn-auto-correct" style="width:auto; display: inline-block;padding-right: 10px;padding-left: 10px;" data-hint="2" data-hint-direction="bottom" data-hint-offset="medium"><%= scope.txtAutoCorrect %></button></div></td>',
2022-02-14 02:56:29 +00:00
'</tr>',
2022-02-25 02:02:26 +00:00
'<tr class ="edit divider-group"></tr>',
2022-02-19 14:14:05 +00:00
'<tr>',
2022-02-16 00:58:04 +00:00
'<td colspan="2" class="group-name"><label><%= scope.txtWorkspace %></label></td>',
2022-02-14 02:56:29 +00:00
'</tr>',
'<tr class="edit">',
2022-02-16 00:58:04 +00:00
'<td colspan="2"><span id="fms-chb-align-guides"></span></td>',
2022-02-14 02:56:29 +00:00
'</tr>',
2022-05-17 15:55:18 +00:00
'<tr>',
'<td colspan="2"><div id="fms-chb-use-alt-key"></div></td>',
'</tr>',
'<tr class="themes">',
2022-02-14 23:32:33 +00:00
'<td><label><%= scope.strTheme %></label></td>',
'<td>',
2022-02-19 17:18:22 +00:00
'<div><div id="fms-cmb-theme" style="display: inline-block; margin-right: 15px;vertical-align: middle;"></div>',
2021-12-09 15:23:59 +00:00
'<div id="fms-chb-dark-mode" style="display: inline-block; vertical-align: middle;margin-top: 2px;"></div></div></td>',
2022-02-14 02:56:29 +00:00
'</tr>',
'<tr class="edit">',
2022-02-14 23:32:33 +00:00
'<td><label><%= scope.strUnit %></label></td>',
'<td><span id="fms-cmb-unit"></span></td>',
2022-02-14 02:56:29 +00:00
'</tr>',
2016-03-11 00:48:53 +00:00
'<tr>',
2022-02-14 23:32:33 +00:00
'<td><label><%= scope.strZoom %></label></td>',
'<td><div id="fms-cmb-zoom" class="input-group-nr"></div></td>',
2022-02-14 02:56:29 +00:00
'</tr>',
2016-03-11 00:48:53 +00:00
'<tr>',
2022-02-14 23:32:33 +00:00
'<td><label><%= scope.strFontRender %></label></td>',
'<td><span id="fms-cmb-font-render"></span></td>',
2022-02-14 02:56:29 +00:00
'</tr>',
2020-05-21 19:50:18 +00:00
'<tr class="macros">',
2022-02-14 23:32:33 +00:00
'<td><label><%= scope.strMacrosSettings %></label></td>',
'<td>',
2022-02-19 17:18:22 +00:00
'<div><div id="fms-cmb-macros" style="display: inline-block; margin-right: 15px; vertical-align: middle;"></div>',
'</tr>',
2022-02-25 02:02:26 +00:00
'<tr class ="divider-group"></tr>',
'<tr class="fms-btn-apply">',
2022-02-19 17:18:22 +00:00
'<td style="padding-top:15px; padding-bottom: 15px;"><button class="btn normal dlg-btn primary" data-hint="2" data-hint-direction="bottom" data-hint-offset="medium"><%= scope.okButtonText %></button></td>',
'<td></td>',
'</tr>',
'</tbody></table>',
2022-02-14 02:56:29 +00:00
'</div>',
'<div class="fms-flex-apply hidden">',
2022-02-16 22:02:01 +00:00
'<table style="margin: 10px 14px;"><tbody>',
2016-03-11 00:48:53 +00:00
'<tr>',
2022-02-16 22:02:01 +00:00
'<td><button class="btn normal dlg-btn primary" data-hint="2" data-hint-direction="bottom" data-hint-offset="big"><%= scope.okButtonText %></button></td>',
'<td></td>',
2016-03-11 00:48:53 +00:00
'</tr>',
'</tbody></table>',
'</div>'
2016-03-11 00:48:53 +00:00
].join('')),
initialize: function(options) {
Common.UI.BaseView.prototype.initialize.call(this,arguments);
this.menu = options.menu;
},
2019-08-01 08:13:08 +00:00
render: function(node) {
2019-08-01 08:50:22 +00:00
var me = this;
var $markup = $(this.template({scope: this}));
2016-03-11 00:48:53 +00:00
2022-05-17 15:55:18 +00:00
this.chUseAltKey = new Common.UI.CheckBox({
el: $markup.findById('#fms-chb-use-alt-key'),
labelText: Common.Utils.isMac ? this.txtUseOptionKey : this.txtUseAltKey,
dataHint: '2',
dataHintDirection: 'left',
dataHintOffset: 'small'
});
2016-03-11 00:48:53 +00:00
/** coauthoring begin **/
this.chLiveComment = new Common.UI.CheckBox({
2019-08-01 08:13:08 +00:00
el: $markup.findById('#fms-chb-live-comment'),
2022-02-16 00:58:04 +00:00
labelText: this.strShowComments,
dataHint: '2',
dataHintDirection: 'left',
dataHintOffset: 'small'
2019-08-01 08:13:08 +00:00
}).on('change', function(field, newValue, oldValue, eOpts){
me.chResolvedComment.setDisabled(field.getValue()!=='checked');
});
this.chResolvedComment = new Common.UI.CheckBox({
2019-08-01 08:13:08 +00:00
el: $markup.findById('#fms-chb-resolved-comment'),
2022-02-16 00:58:04 +00:00
labelText: this.strShowResolvedComments,
dataHint: '2',
dataHintDirection: 'left',
dataHintOffset: 'small'
2016-03-11 00:48:53 +00:00
});
/** coauthoring end **/
this.chSpell = new Common.UI.CheckBox({
2019-08-01 08:13:08 +00:00
el: $markup.findById('#fms-chb-spell-check'),
2022-02-14 02:56:29 +00:00
labelText: this.txtSpellCheck,
dataHint: '2',
dataHintDirection: 'left',
dataHintOffset: 'small'
2022-03-29 11:26:21 +00:00
}).on('change', function(field, newValue, oldValue, eOpts){
me.chIgnoreUppercase.setDisabled(field.getValue()!=='checked');
me.chIgnoreNumbers.setDisabled(field.getValue()!=='checked');
});
this.chIgnoreUppercase = new Common.UI.CheckBox({
el: $markup.findById('#fms-chb-ignore-uppercase-words'),
labelText: this.strIgnoreWordsInUPPERCASE,
dataHint: '2',
dataHintDirection: 'left',
dataHintOffset: 'small'
});
this.chIgnoreNumbers = new Common.UI.CheckBox({
el: $markup.findById('#fms-chb-ignore-numbers-words'),
labelText: this.strIgnoreWordsWithNumbers,
dataHint: '2',
dataHintDirection: 'left',
dataHintOffset: 'small'
2016-03-11 00:48:53 +00:00
});
this.chCompatible = new Common.UI.CheckBox({
2019-09-19 13:31:05 +00:00
el: $markup.findById('#fms-chb-compatible'),
labelText: this.textOldVersions,
dataHint: '2',
dataHintDirection: 'left',
dataHintOffset: 'small'
});
2016-03-11 00:48:53 +00:00
this.chAutosave = new Common.UI.CheckBox({
2019-08-01 08:13:08 +00:00
el: $markup.findById('#fms-chb-autosave'),
2022-02-14 02:56:29 +00:00
labelText: this.textAutoSave,
dataHint: '2',
dataHintDirection: 'left',
dataHintOffset: 'small'
2019-08-01 08:13:08 +00:00
}).on('change', function(field, newValue, oldValue, eOpts){
2022-02-14 02:56:29 +00:00
if (field.getValue()!=='checked' && me.rbCoAuthModeFast.getValue()) {
me.rbCoAuthModeStrict.setValue(true);
me.onChangeCoAuthMode(me.rbCoAuthModeFast.getValue()?1:0);
2016-03-25 07:48:19 +00:00
}
2019-08-01 08:13:08 +00:00
});
2017-04-11 13:40:01 +00:00
this.chForcesave = new Common.UI.CheckBox({
2019-08-01 08:13:08 +00:00
el: $markup.findById('#fms-chb-forcesave'),
2022-02-16 22:02:01 +00:00
labelText: this.textForceSave,
dataHint: '2',
dataHintDirection: 'left',
dataHintOffset: 'small'
2017-04-11 13:40:01 +00:00
});
2016-03-11 00:48:53 +00:00
this.chAlignGuides = new Common.UI.CheckBox({
2019-08-01 08:13:08 +00:00
el: $markup.findById('#fms-chb-align-guides'),
2022-02-14 02:56:29 +00:00
labelText: this.textAlignGuides,
dataHint: '2',
dataHintDirection: 'left',
dataHintOffset: 'small'
2016-03-11 00:48:53 +00:00
});
this.cmbZoom = new Common.UI.ComboBox({
2019-08-01 08:13:08 +00:00
el : $markup.findById('#fms-cmb-zoom'),
2022-03-01 12:59:21 +00:00
style : 'width: 160px;',
2016-03-11 00:48:53 +00:00
editable : false,
2022-02-25 02:02:26 +00:00
menuCls : 'menu-aligned',
2016-03-11 00:48:53 +00:00
cls : 'input-group-nr',
2022-03-01 12:59:21 +00:00
menuStyle : 'min-width:100%; max-height: 157px;',
2016-03-11 00:48:53 +00:00
data : [
{ value: -1, displayValue: this.txtFitPage },
{ value: -2, displayValue: this.txtFitWidth },
2016-03-11 00:48:53 +00:00
{ value: 50, displayValue: "50%" },
{ value: 60, displayValue: "60%" },
{ value: 70, displayValue: "70%" },
{ value: 80, displayValue: "80%" },
{ value: 90, displayValue: "90%" },
{ value: 100, displayValue: "100%" },
{ value: 110, displayValue: "110%" },
{ value: 120, displayValue: "120%" },
{ value: 150, displayValue: "150%" },
{ value: 175, displayValue: "175%" },
2021-12-01 15:27:40 +00:00
{ value: 200, displayValue: "200%" },
{ value: 300, displayValue: "300%" },
{ value: 400, displayValue: "400%" },
{ value: 500, displayValue: "500%" }
],
dataHint: '2',
dataHintDirection: 'bottom',
dataHintOffset: 'big'
2016-03-11 00:48:53 +00:00
});
2022-02-14 02:56:29 +00:00
this.rbCoAuthModeFast = new Common.UI.RadioBox({
el :$markup.findById('#fms-rb-coauth-mode-fast'),
name : 'coauth-mode',
dataHint: '2',
2022-02-14 02:56:29 +00:00
dataHintDirection: 'left',
dataHintOffset: 'small'
});
this.rbCoAuthModeFast.on('change', function(){
me.chAutosave.setValue(1);
me.onChangeCoAuthMode(1);
2016-03-11 00:48:53 +00:00
});
2022-02-19 17:18:22 +00:00
this.rbCoAuthModeFast.$el.parent().on('click', function (){me.rbCoAuthModeFast.setValue(true);});
2016-03-11 00:48:53 +00:00
2022-02-14 02:56:29 +00:00
this.rbCoAuthModeStrict = new Common.UI.RadioBox({
el :$markup.findById('#fms-rb-coauth-mode-strict'),
name : 'coauth-mode',
dataHint: '2',
2022-02-14 02:56:29 +00:00
dataHintDirection: 'left',
dataHintOffset: 'small'
});
this.rbCoAuthModeStrict.on('change', _.bind(this.onChangeCoAuthMode, this,0));
2022-02-19 17:18:22 +00:00
this.rbCoAuthModeStrict.$el.parent().on('click', function (){me.rbCoAuthModeStrict.setValue(true);});
2022-02-14 02:56:29 +00:00
this.rbChangesBallons = new Common.UI.RadioBox({
el :$markup.findById('#fms-rb-show-track-ballons'),
name : 'show-track-changes',
labelText : this.txtChangesBalloons,
dataHint: '2',
dataHintDirection: 'left',
dataHintOffset: 'small'
});
this.rbChangesTip = new Common.UI.RadioBox({
el :$markup.findById('#fms-rb-show-track-tooltips'),
name : 'show-track-changes',
2022-06-23 18:17:13 +00:00
labelText : this.txtChangesTip,
dataHint: '2',
dataHintDirection: 'left',
dataHintOffset: 'small'
2022-02-14 02:56:29 +00:00
});
this.rbShowChangesNone = new Common.UI.RadioBox({
el :$markup.findById('#fms-rb-show-changes-none'),
name : 'show-changes',
labelText : this.txtNone,
dataHint: '2',
dataHintDirection: 'left',
dataHintOffset: 'small'
});
this.rbShowChangesAll = new Common.UI.RadioBox({
el :$markup.findById('#fms-rb-show-changes-all'),
name : 'show-changes',
labelText : this.txtAll,
dataHint: '2',
dataHintDirection: 'left',
dataHintOffset: 'small'
});
this.rbShowChangesLast = new Common.UI.RadioBox({
el :$markup.findById('#fms-rb-show-changes-last'),
name : 'show-changes',
labelText : this.txtLast,
dataHint: '2',
dataHintDirection: 'left',
dataHintOffset: 'small'
2019-08-01 08:13:08 +00:00
});
2016-03-11 00:48:53 +00:00
/** coauthoring end **/
2022-02-15 07:41:16 +00:00
this.chLiveViewer = new Common.UI.CheckBox({
el: $markup.findById('#fms-chb-live-viewer'),
labelText: this.strShowOthersChanges,
dataHint: '2',
dataHintDirection: 'left',
dataHintOffset: 'small'
});
2020-02-17 13:43:02 +00:00
var itemsTemplate =
_.template([
'<% _.each(items, function(item) { %>',
2021-12-14 13:46:44 +00:00
'<li id="<%= item.id %>" data-value="<%= item.value %>" <% if (item.value === "custom") { %> class="border-top" style="margin-top: 5px;padding-top: 5px;" <% } %> ><a tabindex="-1" type="menuitem" <% if (typeof(item.checked) !== "undefined" && item.checked) { %> class="checked" <% } %> ><%= scope.getDisplayValue(item) %></a></li>',
2020-02-17 13:43:02 +00:00
'<% }); %>'
].join(''));
2016-03-11 00:48:53 +00:00
this.cmbFontRender = new Common.UI.ComboBox({
2019-08-01 08:13:08 +00:00
el : $markup.find('#fms-cmb-font-render'),
2022-03-01 12:59:21 +00:00
style : 'width: 160px;',
2016-03-11 00:48:53 +00:00
editable : false,
2022-02-25 02:02:26 +00:00
menuCls : 'menu-aligned',
2022-03-01 12:59:21 +00:00
menuStyle : 'min-width:100%;',
2016-03-11 00:48:53 +00:00
cls : 'input-group-nr',
2020-02-17 13:43:02 +00:00
itemsTemplate: itemsTemplate,
2016-03-11 00:48:53 +00:00
data : [
{ value: 0, displayValue: this.txtWin },
{ value: 1, displayValue: this.txtMac },
2020-02-17 13:43:02 +00:00
{ value: 2, displayValue: this.txtNative },
{ value: 'custom', displayValue: this.txtCacheMode }
],
dataHint: '2',
dataHintDirection: 'bottom',
dataHintOffset: 'big'
2016-03-11 00:48:53 +00:00
});
2020-02-17 13:43:02 +00:00
this.cmbFontRender.on('selected', _.bind(this.onFontRenderSelected, this));
2016-03-11 00:48:53 +00:00
this.cmbUnit = new Common.UI.ComboBox({
2019-08-01 08:13:08 +00:00
el : $markup.findById('#fms-cmb-unit'),
2022-03-01 12:59:21 +00:00
style : 'width: 160px;',
2022-02-25 02:02:26 +00:00
menuCls : 'menu-aligned',
2022-03-01 12:59:21 +00:00
menuStyle : 'min-width:100%;',
2016-03-11 00:48:53 +00:00
editable : false,
cls : 'input-group-nr',
data : [
{ value: Common.Utils.Metric.c_MetricUnits['cm'], displayValue: this.txtCm },
{ value: Common.Utils.Metric.c_MetricUnits['pt'], displayValue: this.txtPt },
{ value: Common.Utils.Metric.c_MetricUnits['inch'], displayValue: this.txtInch }
],
dataHint: '2',
dataHintDirection: 'bottom',
dataHintOffset: 'big'
2016-03-11 00:48:53 +00:00
});
2020-05-21 19:50:18 +00:00
this.cmbMacros = new Common.UI.ComboBox({
el : $markup.findById('#fms-cmb-macros'),
2022-03-01 12:59:21 +00:00
style : 'width: 160px;',
2020-05-21 19:50:18 +00:00
editable : false,
2020-11-17 21:38:48 +00:00
menuCls : 'menu-aligned',
2022-03-01 12:59:21 +00:00
menuStyle : 'min-width:100%;',
2020-05-21 19:50:18 +00:00
cls : 'input-group-nr',
data : [
{ value: 2, displayValue: this.txtStopMacros, descValue: this.txtStopMacrosDesc },
{ value: 0, displayValue: this.txtWarnMacros, descValue: this.txtWarnMacrosDesc },
{ value: 1, displayValue: this.txtRunMacros, descValue: this.txtRunMacrosDesc }
],
2022-02-14 23:32:33 +00:00
itemsTemplate: _.template([
'<% _.each(items, function(item) { %>',
'<li id="<%= item.id %>" data-value="<%- item.value %>"><a tabindex="-1" type="menuitem" style ="display: flex; flex-direction: column;">',
'<label><%= scope.getDisplayValue(item) %></label><label class="comment-text"><%= item.descValue %></label></a></li>',
'<% }); %>'
].join('')),
dataHint: '2',
dataHintDirection: 'bottom',
dataHintOffset: 'big'
2020-05-21 19:50:18 +00:00
});
this.chPaste = new Common.UI.CheckBox({
el: $markup.findById('#fms-chb-paste-settings'),
labelText: this.strPasteButton,
dataHint: '2',
dataHintDirection: 'left',
dataHintOffset: 'small'
});
2020-07-03 11:59:48 +00:00
this.btnAutoCorrect = new Common.UI.Button({
el: $markup.findById('#fms-btn-auto-correct')
});
this.btnAutoCorrect.on('click', _.bind(this.autoCorrect, this));
2021-02-06 10:06:33 +00:00
this.cmbTheme = new Common.UI.ComboBox({
el : $markup.findById('#fms-cmb-theme'),
2022-03-01 12:59:21 +00:00
style : 'width: 160px;',
menuStyle : 'min-width:100%;',
2021-02-06 10:06:33 +00:00
editable : false,
2022-02-25 02:02:26 +00:00
menuCls : 'menu-aligned',
2021-02-06 10:06:33 +00:00
cls : 'input-group-nr',
dataHint: '2',
dataHintDirection: 'bottom',
dataHintOffset: 'big'
2021-12-09 15:23:59 +00:00
}).on('selected', function(combo, record) {
me.chDarkMode.setDisabled(!Common.UI.Themes.isDarkTheme(record.value));
2021-12-09 15:23:59 +00:00
});
this.chDarkMode = new Common.UI.CheckBox({
el: $markup.findById('#fms-chb-dark-mode'),
labelText: this.txtDarkMode,
dataHint: '2',
dataHintDirection: 'left',
dataHintOffset: 'small'
2021-02-06 10:06:33 +00:00
});
$markup.find('.btn.primary').each(function(index, el){
2020-11-17 21:38:48 +00:00
(new Common.UI.Button({
el: $(el)
})).on('click', _.bind(me.applySettings, me));
});
2016-03-11 00:48:53 +00:00
2020-08-07 10:51:26 +00:00
this.pnlSettings = $markup.find('.flex-settings').addBack().filter('.flex-settings');
this.pnlApply = $markup.find('.fms-flex-apply').addBack().filter('.fms-flex-apply');
2020-11-17 21:38:48 +00:00
this.pnlTable = this.pnlSettings.find('table');
this.trApply = $markup.find('.fms-btn-apply');
2019-08-01 08:50:22 +00:00
this.$el = $(node).html($markup);
2016-03-11 00:48:53 +00:00
if (_.isUndefined(this.scroller)) {
this.scroller = new Common.UI.Scroller({
el: this.pnlSettings,
suppressScrollX: true,
alwaysVisibleY: true
2016-03-11 00:48:53 +00:00
});
}
Common.NotificationCenter.on({
'window:resize': function() {
me.isVisible() && me.updateScroller();
}
});
2016-03-11 00:48:53 +00:00
return this;
},
show: function() {
Common.UI.BaseView.prototype.show.call(this,arguments);
this.updateSettings();
this.updateScroller();
},
updateScroller: function() {
if (this.scroller) {
2020-11-17 21:38:48 +00:00
Common.UI.Menu.Manager.hideAll();
var scrolled = this.$el.height()< this.pnlTable.parent().height() + 25 + this.pnlApply.height();
this.pnlApply.toggleClass('hidden', !scrolled);
this.trApply.toggleClass('hidden', scrolled);
2020-11-17 21:38:48 +00:00
this.pnlSettings.css('overflow', scrolled ? 'hidden' : 'visible');
this.scroller.update();
this.pnlSettings.toggleClass('bordered', this.scroller.isVisible());
}
2016-03-11 00:48:53 +00:00
},
setMode: function(mode) {
this.mode = mode;
var fast_coauth = Common.Utils.InternalSettings.get("de-settings-coauthmode");
2016-03-11 00:48:53 +00:00
$('tr.edit', this.el)[mode.isEdit?'show':'hide']();
$('tr.autosave', this.el)[mode.isEdit && (mode.canChangeCoAuthoring || !fast_coauth) ? 'show' : 'hide']();
2017-04-11 13:40:01 +00:00
$('tr.forcesave', this.el)[mode.canForcesave ? 'show' : 'hide']();
2022-02-19 14:14:05 +00:00
$('tr.editsave',this.el)[mode.isEdit || mode.canForcesave ? 'show' : 'hide']();
if (this.mode.isDesktopApp && this.mode.isOffline) {
2022-02-25 02:02:26 +00:00
this.chAutosave.setCaption(this.textAutoRecover);
2016-03-11 00:48:53 +00:00
}
/** coauthoring begin **/
2022-02-19 17:18:22 +00:00
$('tr.collaboration', this.el)[mode.canCoAuthoring || mode.canViewReview ? 'show' : 'hide']();
2016-03-11 00:48:53 +00:00
$('tr.coauth', this.el)[mode.isEdit && mode.canCoAuthoring ? 'show' : 'hide']();
$('tr.coauth.changes-mode', this.el)[mode.isEdit && !mode.isOffline && mode.canCoAuthoring && mode.canChangeCoAuthoring ? 'show' : 'hide']();
$('tr.coauth.changes-show', this.el)[mode.isEdit && !mode.isOffline && mode.canCoAuthoring ? 'show' : 'hide']();
2022-04-19 15:59:18 +00:00
$('tr.live-viewer', this.el)[mode.canLiveView && !mode.isOffline && mode.canChangeCoAuthoring ? 'show' : 'hide']();
$('tr.view-review', this.el)[mode.canViewReview ? 'show' : 'hide']();
$('tr.spellcheck', this.el)[mode.isEdit && Common.UI.FeaturesManager.canChange('spellcheck') ? 'show' : 'hide']();
$('tr.comments', this.el)[mode.canCoAuthoring ? 'show' : 'hide']();
2022-02-19 14:14:05 +00:00
2016-03-11 00:48:53 +00:00
/** coauthoring end **/
2020-05-21 19:50:18 +00:00
$('tr.macros', this.el)[(mode.customization && mode.customization.macros===false) ? 'hide' : 'show']();
if ( !Common.UI.Themes.available() ) {
$('tr.themes, tr.themes + tr.divider', this.el).hide();
}
2016-03-11 00:48:53 +00:00
},
2020-07-03 11:59:48 +00:00
setApi: function(o) {
this.api = o;
return this;
},
2016-03-11 00:48:53 +00:00
updateSettings: function() {
this.chUseAltKey.setValue(Common.Utils.InternalSettings.get("de-settings-show-alt-hints"));
2022-05-17 15:55:18 +00:00
2017-10-03 11:22:33 +00:00
var value = Common.Utils.InternalSettings.get("de-settings-zoom");
value = (value!==null) ? parseInt(value) : (this.mode.customization && this.mode.customization.zoom ? parseInt(this.mode.customization.zoom) : 100);
var item = this.cmbZoom.store.findWhere({value: value});
this.cmbZoom.setValue(item ? parseInt(item.get('value')) : (value>0 ? value+'%' : 100));
2016-03-11 00:48:53 +00:00
/** coauthoring begin **/
2017-10-03 11:22:33 +00:00
this.chLiveComment.setValue(Common.Utils.InternalSettings.get("de-settings-livecomment"));
this.chResolvedComment.setValue(Common.Utils.InternalSettings.get("de-settings-resolvedcomment"));
2017-10-03 11:22:33 +00:00
var fast_coauth = Common.Utils.InternalSettings.get("de-settings-coauthmode");
2022-02-14 02:56:29 +00:00
this.rbCoAuthModeFast.setValue(fast_coauth);
this.rbCoAuthModeStrict.setValue(!fast_coauth);
2016-03-11 00:48:53 +00:00
this.fillShowChanges(fast_coauth);
2022-02-15 07:41:16 +00:00
this.chLiveViewer.setValue(Common.Utils.InternalSettings.get("de-settings-coauthmode"));
2017-10-03 11:22:33 +00:00
value = Common.Utils.InternalSettings.get((fast_coauth) ? "de-settings-showchanges-fast" : "de-settings-showchanges-strict");
2022-02-14 02:56:29 +00:00
this.rbShowChangesNone.setValue(value=='none');
this.rbShowChangesLast.setValue(value=='last');
this.rbShowChangesAll.setValue(value=='all');
2016-03-11 00:48:53 +00:00
/** coauthoring end **/
2017-10-03 11:22:33 +00:00
value = Common.Utils.InternalSettings.get("de-settings-fontrender");
2017-10-04 15:44:01 +00:00
item = this.cmbFontRender.store.findWhere({value: parseInt(value)});
2020-02-17 08:57:44 +00:00
this.cmbFontRender.setValue(item ? item.get('value') : 0);
2020-02-17 13:43:02 +00:00
this._fontRender = this.cmbFontRender.getValue();
value = Common.Utils.InternalSettings.get("de-settings-cachemode");
item = this.cmbFontRender.store.findWhere({value: 'custom'});
item && value && item.set('checked', !!value);
item && value && this.cmbFontRender.cmpEl.find('#' + item.get('id') + ' a').addClass('checked');
2016-03-11 00:48:53 +00:00
2017-10-03 11:22:33 +00:00
value = Common.Utils.InternalSettings.get("de-settings-unit");
item = this.cmbUnit.store.findWhere({value: value});
this.cmbUnit.setValue(item ? parseInt(item.get('value')) : Common.Utils.Metric.getDefaultMetric());
2016-03-11 00:48:53 +00:00
this._oldUnits = this.cmbUnit.getValue();
2017-10-03 11:22:33 +00:00
value = Common.Utils.InternalSettings.get("de-settings-autosave");
this.chAutosave.setValue(value == 1);
2016-03-11 00:48:53 +00:00
if (this.mode.canForcesave)
2017-10-03 11:22:33 +00:00
this.chForcesave.setValue(Common.Utils.InternalSettings.get("de-settings-forcesave"));
2017-04-11 13:40:01 +00:00
2022-03-29 11:26:21 +00:00
if (Common.UI.FeaturesManager.canChange('spellcheck')) {
this.chSpell.setValue(Common.Utils.InternalSettings.get("de-settings-spellcheck"));
2022-03-29 11:26:21 +00:00
this.chIgnoreUppercase.setValue(Common.Utils.InternalSettings.get("de-spellcheck-ignore-uppercase-words"));
this.chIgnoreNumbers.setValue(Common.Utils.InternalSettings.get("de-spellcheck-ignore-numbers-words"));
}
2017-10-03 11:22:33 +00:00
this.chAlignGuides.setValue(Common.Utils.InternalSettings.get("de-settings-showsnaplines"));
this.chCompatible.setValue(Common.Utils.InternalSettings.get("de-settings-compatible"));
2020-05-21 19:50:18 +00:00
item = this.cmbMacros.store.findWhere({value: Common.Utils.InternalSettings.get("de-macros-mode")});
this.cmbMacros.setValue(item ? item.get('value') : 0);
this.chPaste.setValue(Common.Utils.InternalSettings.get("de-settings-paste-button"));
2021-02-06 10:06:33 +00:00
2021-04-18 14:32:39 +00:00
var data = [];
for (var t in Common.UI.Themes.map()) {
2021-12-09 15:23:59 +00:00
data.push({value: t, displayValue: Common.UI.Themes.get(t).text, themeType: Common.UI.Themes.get(t).type});
2021-04-18 14:32:39 +00:00
}
if ( data.length ) {
this.cmbTheme.setData(data);
item = this.cmbTheme.store.findWhere({value: Common.UI.Themes.currentThemeId()});
this.cmbTheme.setValue(item ? item.get('value') : Common.UI.Themes.defaultThemeId());
}
2021-12-09 15:23:59 +00:00
this.chDarkMode.setValue(Common.UI.Themes.isContentThemeDark());
this.chDarkMode.setDisabled(!Common.UI.Themes.isDarkTheme());
if (this.mode.canViewReview) {
value = Common.Utils.InternalSettings.get("de-settings-review-hover-mode");
2022-02-14 02:56:29 +00:00
this.rbChangesTip.setValue(value);
this.rbChangesBallons.setValue(!value);
}
2016-03-11 00:48:53 +00:00
},
applySettings: function() {
2021-02-06 10:06:33 +00:00
Common.UI.Themes.setTheme(this.cmbTheme.getValue());
2021-12-09 15:23:59 +00:00
if (!this.chDarkMode.isDisabled() && (this.chDarkMode.isChecked() !== Common.UI.Themes.isContentThemeDark()))
Common.UI.Themes.toggleContentTheme();
Common.localStorage.setItem("de-settings-show-alt-hints", this.chUseAltKey.isChecked() ? 1 : 0);
Common.Utils.InternalSettings.set("de-settings-show-alt-hints", Common.localStorage.getBool("de-settings-show-alt-hints"));
2016-03-11 00:48:53 +00:00
Common.localStorage.setItem("de-settings-zoom", this.cmbZoom.getValue());
2017-10-03 11:22:33 +00:00
Common.Utils.InternalSettings.set("de-settings-zoom", Common.localStorage.getItem("de-settings-zoom"));
2016-03-11 00:48:53 +00:00
/** coauthoring begin **/
Common.localStorage.setItem("de-settings-livecomment", this.chLiveComment.isChecked() ? 1 : 0);
Common.localStorage.setItem("de-settings-resolvedcomment", this.chResolvedComment.isChecked() ? 1 : 0);
if (this.mode.isEdit && !this.mode.isOffline && this.mode.canCoAuthoring) {
2022-02-14 02:56:29 +00:00
this.mode.canChangeCoAuthoring && Common.localStorage.setItem("de-settings-coauthmode", this.rbCoAuthModeFast.getValue() ? 1 : 0 );
Common.localStorage.setItem(this.rbCoAuthModeFast.getValue() ? "de-settings-showchanges-fast" : "de-settings-showchanges-strict",
this.rbShowChangesNone.getValue()?'none':this.rbShowChangesLast.getValue()?'last':'all');
2022-04-19 15:59:18 +00:00
} else if (this.mode.canLiveView && !this.mode.isOffline && this.mode.canChangeCoAuthoring) { // viewer
2022-02-15 07:41:16 +00:00
Common.localStorage.setItem("de-settings-view-coauthmode", this.chLiveViewer.isChecked() ? 1 : 0);
2016-03-11 00:48:53 +00:00
}
/** coauthoring end **/
Common.localStorage.setItem("de-settings-fontrender", this.cmbFontRender.getValue());
2020-02-17 13:43:02 +00:00
var item = this.cmbFontRender.store.findWhere({value: 'custom'});
Common.localStorage.setItem("de-settings-cachemode", item && !item.get('checked') ? 0 : 1);
2016-03-11 00:48:53 +00:00
Common.localStorage.setItem("de-settings-unit", this.cmbUnit.getValue());
2022-02-16 11:18:23 +00:00
if (this.mode.isEdit && (this.mode.canChangeCoAuthoring || !Common.Utils.InternalSettings.get("de-settings-coauthmode")))
Common.localStorage.setItem("de-settings-autosave", this.chAutosave.isChecked() ? 1 : 0);
2017-04-11 13:40:01 +00:00
if (this.mode.canForcesave)
Common.localStorage.setItem("de-settings-forcesave", this.chForcesave.isChecked() ? 1 : 0);
2022-03-29 11:26:21 +00:00
if (Common.UI.FeaturesManager.canChange('spellcheck') && this.mode.isEdit) {
Common.localStorage.setItem("de-settings-spellcheck", this.chSpell.isChecked() ? 1 : 0);
2022-03-29 14:51:33 +00:00
Common.localStorage.setBool("de-spellcheck-ignore-uppercase-words", this.chIgnoreUppercase.isChecked());
Common.localStorage.setBool("de-spellcheck-ignore-numbers-words", this.chIgnoreNumbers.isChecked());
2022-03-29 11:26:21 +00:00
}
Common.localStorage.setItem("de-settings-compatible", this.chCompatible.isChecked() ? 1 : 0);
Common.Utils.InternalSettings.set("de-settings-compatible", this.chCompatible.isChecked() ? 1 : 0);
2017-10-04 15:44:01 +00:00
Common.Utils.InternalSettings.set("de-settings-showsnaplines", this.chAlignGuides.isChecked());
2020-05-21 19:50:18 +00:00
Common.localStorage.setItem("de-macros-mode", this.cmbMacros.getValue());
2020-06-05 10:08:32 +00:00
Common.Utils.InternalSettings.set("de-macros-mode", this.cmbMacros.getValue());
2020-05-21 19:50:18 +00:00
if (this.mode.canViewReview) {
2022-02-14 02:56:29 +00:00
var val = this.rbChangesTip.getValue();
Common.localStorage.setBool("de-settings-review-hover-mode", val);
Common.Utils.InternalSettings.set("de-settings-review-hover-mode", val);
this.mode.reviewHoverMode = val;
}
Common.localStorage.setItem("de-settings-paste-button", this.chPaste.isChecked() ? 1 : 0);
2016-03-11 00:48:53 +00:00
Common.localStorage.save();
if (this.menu) {
this.menu.fireEvent('settings:apply', [this.menu]);
2016-03-11 00:48:53 +00:00
if (this._oldUnits !== this.cmbUnit.getValue())
Common.NotificationCenter.trigger('settings:unitschanged', this);
}
},
fillShowChanges: function(fastmode) {
2022-02-19 17:18:22 +00:00
if(fastmode)
this.rbShowChangesLast.$el.parent().hide();
else
this.rbShowChangesLast.$el.parent().show();
2016-03-11 00:48:53 +00:00
},
2016-03-25 07:48:19 +00:00
2022-02-14 02:56:29 +00:00
onChangeCoAuthMode: function (val){
this.fillShowChanges(val == 1);
this.rbShowChangesNone.setValue(val == 1);
this.rbShowChangesLast.setValue(val == 0);
2016-03-25 07:48:19 +00:00
},
2020-02-17 13:43:02 +00:00
onFontRenderSelected: function(combo, record) {
if (record.value == 'custom') {
var item = combo.store.findWhere({value: 'custom'});
item && item.set('checked', !record.checked);
combo.cmpEl.find('#' + record.id + ' a').toggleClass('checked', !record.checked);
combo.setValue(this._fontRender);
}
this._fontRender = combo.getValue();
},
2020-07-03 11:59:48 +00:00
autoCorrect: function() {
2020-10-29 12:12:49 +00:00
if (this.dlgAutoCorrect && this.dlgAutoCorrect.isVisible()) return;
this.dlgAutoCorrect = new Common.Views.AutoCorrectDialog({
2020-07-23 15:34:27 +00:00
api: this.api
2020-10-29 12:12:49 +00:00
});
this.dlgAutoCorrect.show();
2020-07-03 11:59:48 +00:00
},
2016-03-11 00:48:53 +00:00
strZoom: 'Default Zoom Value',
/** coauthoring begin **/
strShowChanges: 'Real-time Collaboration Changes',
2016-03-11 00:48:53 +00:00
txtAll: 'View All',
txtNone: 'View Nothing',
txtLast: 'View Last',
/** coauthoring end **/
okButtonText: 'Apply',
txtWin: 'as Windows',
txtMac: 'as OS X',
txtNative: 'Native',
strFontRender: 'Font Hinting',
strUnit: 'Unit of Measurement',
txtCm: 'Centimeter',
txtPt: 'Point',
textAutoSave: 'Autosave',
txtSpellCheck: 'Spell Checking',
textAlignGuides: 'Alignment Guides',
strCoAuthMode: 'Co-editing mode',
strFast: 'Fast',
strStrict: 'Strict',
2022-02-19 17:18:22 +00:00
textAutoRecover: 'Autorecover',
txtInch: 'Inch',
2016-09-26 12:07:51 +00:00
txtFitPage: 'Fit to Page',
2017-04-11 13:40:01 +00:00
txtFitWidth: 'Fit to Width',
textForceSave: 'Save to Server',
2020-02-17 13:43:02 +00:00
textOldVersions: 'Make the files compatible with older MS Word versions when saved as DOCX',
2020-05-21 19:50:18 +00:00
txtCacheMode: 'Default cache mode',
strMacrosSettings: 'Macros Settings',
txtWarnMacros: 'Show Notification',
txtRunMacros: 'Enable All',
txtStopMacros: 'Disable All',
txtWarnMacrosDesc: 'Disable all macros with notification',
txtRunMacrosDesc: 'Enable all macros without notification',
txtStopMacrosDesc: 'Disable all macros without notification',
2020-07-03 11:59:48 +00:00
strPasteButton: 'Show Paste Options button when content is pasted',
txtProofing: 'Proofing',
2021-02-06 10:06:33 +00:00
strTheme: 'Theme',
txtAutoCorrect: 'AutoCorrect options...',
txtChangesTip: 'Show by hover in tooltips',
2021-12-09 15:23:59 +00:00
txtChangesBalloons: 'Show by click in balloons',
2022-02-14 02:56:29 +00:00
txtDarkMode: 'Turn on document dark mode',
txtEditingSaving: 'Editing and saving',
txtCollaboration: 'Collaboration',
txtShowTrackChanges: 'Show track changes',
txtWorkspace: 'Workspace',
2022-02-16 00:58:04 +00:00
txtHieroglyphs: 'Hieroglyphs',
2022-05-17 15:55:18 +00:00
txtUseAltKey: 'Use Alt key to navigate the user interface using the keyboard',
txtUseOptionKey: 'Use Option key to navigate the user interface using the keyboard',
2022-02-16 00:58:04 +00:00
strShowComments: 'Show comments in text',
2022-02-16 22:02:01 +00:00
strShowResolvedComments: 'Show resolved comments',
txtFastTip: 'Real-time co-editing. All changes are saved automatically',
2022-03-29 11:26:21 +00:00
txtStrictTip: 'Use the \'Save\' button to sync the changes you and others make',
strIgnoreWordsInUPPERCASE: 'Ignore words in UPPERCASE',
strIgnoreWordsWithNumbers: 'Ignore words with numbers',
strShowOthersChanges: 'Show changes from other users'
2016-03-11 00:48:53 +00:00
}, DE.Views.FileMenuPanels.Settings || {}));
DE.Views.FileMenuPanels.RecentFiles = Common.UI.BaseView.extend({
el: '#panel-recentfiles',
menu: undefined,
template: _.template([
'<div id="id-recent-view" style="margin: 20px 0;"></div>'
].join('')),
initialize: function(options) {
Common.UI.BaseView.prototype.initialize.call(this,arguments);
this.menu = options.menu;
this.recent = options.recent;
},
render: function() {
this.$el.html(this.template());
2016-03-11 00:48:53 +00:00
this.viewRecentPicker = new Common.UI.DataView({
el: $('#id-recent-view'),
store: new Common.UI.DataViewStore(this.recent),
itemTemplate: _.template([
'<div class="recent-wrap">',
2020-06-11 16:36:37 +00:00
'<div class="recent-icon">',
2022-03-31 14:27:57 +00:00
'<div>',
'<div class="svg-file-recent"></div>',
'</div>',
2020-06-11 16:36:37 +00:00
'</div>',
2020-04-30 15:35:30 +00:00
'<div class="file-name"><% if (typeof title !== "undefined") {%><%= Common.Utils.String.htmlEncode(title || "") %><% } %></div>',
'<div class="file-info"><% if (typeof folder !== "undefined") {%><%= Common.Utils.String.htmlEncode(folder || "") %><% } %></div>',
2016-03-11 00:48:53 +00:00
'</div>'
].join(''))
});
this.viewRecentPicker.on('item:click', _.bind(this.onRecentFileClick, this));
if (_.isUndefined(this.scroller)) {
this.scroller = new Common.UI.Scroller({
el: this.$el,
suppressScrollX: true,
alwaysVisibleY: true
2016-03-11 00:48:53 +00:00
});
}
return this;
},
show: function() {
Common.UI.BaseView.prototype.show.call(this,arguments);
this.scroller && this.scroller.update();
},
2016-03-11 00:48:53 +00:00
onRecentFileClick: function(view, itemview, record){
if ( this.menu )
this.menu.fireEvent('recent:open', [this.menu, record.get('url')]);
}
});
DE.Views.FileMenuPanels.CreateNew = Common.UI.BaseView.extend(_.extend({
el: '#panel-createnew',
menu: undefined,
events: function() {
return {
'click .blank-document-btn':_.bind(this._onBlankDocument, this),
'click .thumb-list .thumb-wrap': _.bind(this._onDocumentTemplate, this)
};
},
template: _.template([
2021-08-19 00:03:22 +00:00
'<h3 style="margin-top: 20px;"><%= scope.txtCreateNew %></h3>',
2016-03-11 00:48:53 +00:00
'<div class="thumb-list">',
'<% if (blank) { %> ',
2021-08-23 20:13:08 +00:00
'<div class="blank-document">',
2021-11-23 17:29:56 +00:00
'<div class="blank-document-btn" data-hint="2" data-hint-direction="left-top" data-hint-offset="2, 10">',
2022-03-31 05:54:36 +00:00
'<div class="btn-blank-format"><div class ="svg-format-blank"></div></div>',
2016-03-11 00:48:53 +00:00
'</div>',
2021-08-24 11:52:58 +00:00
'<div class="title"><%= scope.txtBlank %></div>',
2021-08-23 00:24:48 +00:00
'</div>',
'<% } %>',
'<% _.each(docs, function(item, index) { %>',
2021-11-23 17:29:56 +00:00
'<div class="thumb-wrap" template="<%= item.url %>" data-hint="2" data-hint-direction="left-top" data-hint-offset="14, 22">',
'<div class="thumb" ',
'<% if (!_.isEmpty(item.image)) {%> ',
' style="background-image: url(<%= item.image %>);">',
' <%} else {' +
2022-03-31 05:54:36 +00:00
'print(\"><div class=\'btn-blank-format\'><div class=\'svg-file-template\'></div></div>\")' +
' } %>',
'</div>',
2021-08-24 10:38:19 +00:00
'<div class="title"><%= Common.Utils.String.htmlEncode(item.title || item.name || "") %></div>',
2021-08-23 00:24:48 +00:00
'</div>',
2016-03-11 00:48:53 +00:00
'<% }) %>',
'</div>'
].join('')),
initialize: function(options) {
Common.UI.BaseView.prototype.initialize.call(this,arguments);
this.menu = options.menu;
this.docs = options.docs;
this.blank = !!options.blank;
2016-03-11 00:48:53 +00:00
},
render: function() {
this.$el.html(this.template({
2016-03-11 00:48:53 +00:00
scope: this,
docs: this.docs,
blank: this.blank
2016-03-11 00:48:53 +00:00
}));
var docs = (this.blank ? [{title: this.txtBlank}] : []).concat(this.docs);
2021-08-23 20:13:08 +00:00
var thumbsElm= this.$el.find('.thumb-wrap, .blank-document');
2021-08-19 22:19:56 +00:00
_.each(thumbsElm, function (tmb, index){
$(tmb).find('.title').tooltip({
title : docs[index].title,
2021-08-24 09:04:32 +00:00
placement : 'cursor'
2021-08-19 22:19:56 +00:00
});
});
2016-03-11 00:48:53 +00:00
if (_.isUndefined(this.scroller)) {
this.scroller = new Common.UI.Scroller({
el: this.$el,
suppressScrollX: true,
alwaysVisibleY: true
2016-03-11 00:48:53 +00:00
});
}
return this;
},
show: function() {
Common.UI.BaseView.prototype.show.call(this,arguments);
this.scroller && this.scroller.update();
},
2016-03-11 00:48:53 +00:00
_onBlankDocument: function() {
if ( this.menu )
this.menu.fireEvent('create:new', [this.menu, 'blank']);
},
_onDocumentTemplate: function(e) {
if ( this.menu )
this.menu.fireEvent('create:new', [this.menu, e.currentTarget.attributes['template'].value]);
},
2021-08-24 11:52:58 +00:00
txtBlank: 'Blank document',
txtCreateNew: 'Create New'
2016-03-11 00:48:53 +00:00
}, DE.Views.FileMenuPanels.CreateNew || {}));
DE.Views.FileMenuPanels.DocumentInfo = Common.UI.BaseView.extend(_.extend({
el: '#panel-info',
menu: undefined,
initialize: function(options) {
Common.UI.BaseView.prototype.initialize.call(this,arguments);
this.rendered = false;
this.template = _.template([
2020-08-07 10:51:26 +00:00
'<div class="flex-settings">',
'<table class="main" style="margin: 30px 0 0;">',
2019-04-02 10:17:26 +00:00
'<tr>',
'<td class="left"><label>' + this.txtPlacement + '</label></td>',
'<td class="right"><label id="id-info-placement">-</label></td>',
'</tr>',
'<tr>',
'<td class="left"><label>' + this.txtOwner + '</label></td>',
'<td class="right"><label id="id-info-owner">-</label></td>',
'</tr>',
'<tr>',
'<td class="left"><label>' + this.txtUploaded + '</label></td>',
'<td class="right"><label id="id-info-uploaded">-</label></td>',
'</tr>',
'<tr class="divider general"></tr>',
'<tr class="divider general"></tr>',
'<tr>',
'<td class="left"><label>' + this.txtPages + '</label></td>',
'<td class="right"><label id="id-info-pages"></label></td>',
'</tr>',
'<tr>',
'<td class="left"><label>' + this.txtParagraphs + '</label></td>',
'<td class="right"><label id="id-info-paragraphs"></label></td>',
'</tr>',
'<tr>',
'<td class="left"><label>' + this.txtWords + '</label></td>',
'<td class="right"><label id="id-info-words"></label></td>',
'</tr>',
'<tr>',
'<td class="left"><label>' + this.txtSymbols + '</label></td>',
'<td class="right"><label id="id-info-symbols"></label></td>',
'</tr>',
'<tr>',
'<td class="left"><label>' + this.txtSpaces + '</label></td>',
'<td class="right"><label id="id-info-spaces"></label></td>',
'</tr>',
2022-03-22 16:30:09 +00:00
'<tr class="pdf-info">',
'<td class="left"><label>' + this.txtPageSize + '</label></td>',
'<td class="right"><label id="id-info-page-size"></label></td>',
'</tr>',
2019-05-15 11:17:29 +00:00
'<tr class="divider"></tr>',
'<tr class="divider"></tr>',
2019-05-15 13:49:11 +00:00
// '<tr>',
// '<td class="left"><label>' + this.txtEditTime + '</label></td>',
// '<td class="right"><label id="id-info-edittime"></label></td>',
// '</tr>',
2022-03-22 16:30:09 +00:00
'<tr class="docx-info">',
2016-03-11 00:48:53 +00:00
'<td class="left"><label>' + this.txtTitle + '</label></td>',
2019-04-02 10:17:26 +00:00
'<td class="right"><div id="id-info-title"></div></td>',
2016-03-11 00:48:53 +00:00
'</tr>',
2022-03-22 16:30:09 +00:00
'<tr class="docx-info">',
2019-08-09 07:04:43 +00:00
'<td class="left"><label>' + this.txtSubject + '</label></td>',
'<td class="right"><div id="id-info-subject"></div></td>',
'</tr>',
2022-03-22 16:30:09 +00:00
'<tr class="docx-info">',
2019-04-02 10:17:26 +00:00
'<td class="left"><label>' + this.txtComment + '</label></td>',
'<td class="right"><div id="id-info-comment"></div></td>',
2016-03-11 00:48:53 +00:00
'</tr>',
2022-03-22 16:30:09 +00:00
'<tr class="divider docx-info"></tr>',
'<tr class="divider docx-info"></tr>',
'<tr class="pdf-info">',
'<td class="left"><label>' + this.txtTitle + '</label></td>',
'<td class="right"><label id="id-lbl-info-title"></label></td>',
'</tr>',
'<tr class="pdf-info">',
'<td class="left"><label>' + this.txtSubject + '</label></td>',
'<td class="right"><label id="id-lbl-info-subject"></label></td>',
'</tr>',
'<tr class="divider pdf-info pdf-title"></tr>',
'<tr class="divider pdf-info pdf-title"></tr>',
2019-04-02 10:17:26 +00:00
'<tr>',
'<td class="left"><label>' + this.txtModifyDate + '</label></td>',
'<td class="right"><label id="id-info-modify-date"></label></td>',
2016-03-11 00:48:53 +00:00
'</tr>',
2019-04-02 10:17:26 +00:00
'<tr>',
2022-03-22 16:30:09 +00:00
'<td class="left"><label>' + this.txtModifyBy + '</label></td>',
'<td class="right"><label id="id-info-modify-by"></label></td>',
2018-11-06 09:58:02 +00:00
'</tr>',
2022-04-27 13:53:45 +00:00
'<tr class="divider modify"></tr>',
'<tr class="divider modify"></tr>',
2019-04-02 10:17:26 +00:00
'<tr>',
'<td class="left"><label>' + this.txtCreated + '</label></td>',
2019-04-02 10:17:26 +00:00
'<td class="right"><label id="id-info-date"></label></td>',
2016-03-11 00:48:53 +00:00
'</tr>',
'<tr>',
2019-04-02 10:17:26 +00:00
'<td class="left"><label>' + this.txtAppName + '</label></td>',
'<td class="right"><label id="id-info-appname"></label></td>',
'</tr>',
2022-03-22 16:30:09 +00:00
'<tr class="pdf-info">',
'<td class="left"><label>' + this.txtAuthor + '</label></td>',
'<td class="right"><label id="id-lbl-info-author"></label></td>',
'</tr>',
2022-04-27 13:53:45 +00:00
'<tr class="divider pdf-info"></tr>',
'<tr class="pdf-info">',
'<td class="left"><label>' + this.txtPdfProducer + '</label></td>',
'<td class="right"><label id="id-info-pdf-produce"></label></td>',
'</tr>',
2022-03-22 16:30:09 +00:00
'<tr class="pdf-info">',
'<td class="left"><label>' + this.txtPdfVer + '</label></td>',
'<td class="right"><label id="id-info-pdf-ver"></label></td>',
'</tr>',
'<tr class="pdf-info">',
'<td class="left"><label>' + this.txtPdfTagged + '</label></td>',
'<td class="right"><label id="id-info-pdf-tagged"></label></td>',
'</tr>',
'<tr class="pdf-info">',
'<td class="left"><label>' + this.txtFastWV + '</label></td>',
'<td class="right"><label id="id-info-fast-wv"></label></td>',
'</tr>',
'<tr class="docx-info">',
2019-04-02 10:17:26 +00:00
'<td class="left" style="vertical-align: top;"><label style="margin-top: 3px;">' + this.txtAuthor + '</label></td>',
'<td class="right" style="vertical-align: top;"><div id="id-info-author">',
2016-03-11 00:48:53 +00:00
'<table>',
2019-04-02 10:17:26 +00:00
'<tr>',
'<td><div id="id-info-add-author"><input type="text" spellcheck="false" class="form-control" placeholder="' + this.txtAddAuthor +'"></div></td>',
'</tr>',
2016-03-11 00:48:53 +00:00
'</table>',
'</div></td>',
'</tr>',
'<tr style="height: 5px;"></tr>',
'</table>',
'</div>',
2020-08-06 20:15:40 +00:00
'<div id="fms-flex-apply">',
'<table class="main" style="margin: 10px 0;">',
2019-09-06 14:38:29 +00:00
'<tr>',
'<td class="left"></td>',
2021-08-17 12:39:32 +00:00
'<td class="right"><button id="fminfo-btn-apply" class="btn normal dlg-btn primary" data-hint="2" data-hint-direction="bottom" data-hint-offset="big"><%= scope.okButtonText %></button></td>',
2019-09-06 14:38:29 +00:00
'</tr>',
'</table>',
'</div>'
2016-03-11 00:48:53 +00:00
].join(''));
this.infoObj = {PageCount: 0, WordsCount: 0, ParagraphCount: 0, SymbolsCount: 0, SymbolsWSCount:0};
this.menu = options.menu;
this.coreProps = null;
this.authors = [];
this._locked = false;
2016-03-11 00:48:53 +00:00
},
2019-08-01 08:13:08 +00:00
render: function(node) {
2019-04-02 10:17:26 +00:00
var me = this;
var $markup = $(me.template({scope: me}));
2019-04-02 10:17:26 +00:00
// server info
2019-08-01 08:13:08 +00:00
this.lblPlacement = $markup.findById('#id-info-placement');
this.lblOwner = $markup.findById('#id-info-owner');
this.lblUploaded = $markup.findById('#id-info-uploaded');
2019-04-02 10:17:26 +00:00
// statistic info
2019-08-01 08:13:08 +00:00
this.lblStatPages = $markup.findById('#id-info-pages');
this.lblStatWords = $markup.findById('#id-info-words');
this.lblStatParagraphs = $markup.findById('#id-info-paragraphs');
this.lblStatSymbols = $markup.findById('#id-info-symbols');
this.lblStatSpaces = $markup.findById('#id-info-spaces');
2022-03-22 16:30:09 +00:00
this.lblPageSize = $markup.findById('#id-info-pages-size');
2019-08-01 08:13:08 +00:00
// this.lblEditTime = $markup.find('#id-info-edittime');
2019-04-02 10:17:26 +00:00
// edited info
var keyDownBefore = function(input, e){
if (e.keyCode === Common.UI.Keys.ESC) {
var newVal = input._input.val(),
oldVal = input.getValue();
if (newVal !== oldVal) {
input.setValue(oldVal);
e.stopPropagation();
}
}
};
2019-04-02 10:17:26 +00:00
this.inputTitle = new Common.UI.InputField({
2019-08-01 08:13:08 +00:00
el : $markup.findById('#id-info-title'),
2019-04-02 10:17:26 +00:00
style : 'width: 200px;',
2019-05-15 11:17:29 +00:00
placeHolder : this.txtAddText,
validateOnBlur: false,
dataHint: '2',
dataHintDirection: 'left',
dataHintOffset: 'small'
}).on('keydown:before', keyDownBefore);
2019-04-02 10:17:26 +00:00
this.inputSubject = new Common.UI.InputField({
2019-08-01 08:13:08 +00:00
el : $markup.findById('#id-info-subject'),
2019-04-02 10:17:26 +00:00
style : 'width: 200px;',
2019-05-15 11:17:29 +00:00
placeHolder : this.txtAddText,
validateOnBlur: false,
dataHint: '2',
dataHintDirection: 'left',
dataHintOffset: 'small'
}).on('keydown:before', keyDownBefore);
2019-04-02 10:17:26 +00:00
this.inputComment = new Common.UI.InputField({
2019-08-01 08:13:08 +00:00
el : $markup.findById('#id-info-comment'),
2019-04-02 10:17:26 +00:00
style : 'width: 200px;',
2019-05-15 11:17:29 +00:00
placeHolder : this.txtAddText,
validateOnBlur: false,
dataHint: '2',
dataHintDirection: 'left',
dataHintOffset: 'small'
}).on('keydown:before', keyDownBefore);
2019-04-02 10:17:26 +00:00
// modify info
2019-08-01 08:13:08 +00:00
this.lblModifyDate = $markup.findById('#id-info-modify-date');
this.lblModifyBy = $markup.findById('#id-info-modify-by');
2019-04-02 10:17:26 +00:00
// creation info
2019-08-01 08:13:08 +00:00
this.lblDate = $markup.findById('#id-info-date');
this.lblApplication = $markup.findById('#id-info-appname');
this.tblAuthor = $markup.findById('#id-info-author table');
this.trAuthor = $markup.findById('#id-info-add-author').closest('tr');
2022-07-22 12:35:24 +00:00
this.authorTpl = '<tr><td><div style="display: inline-block;width: 200px;"><input type="text" spellcheck="false" class="form-control" readonly="true" value="{0}"></div><div class="tool close img-commonctrl img-colored" data-hint="2" data-hint-direction="right" data-hint-offset="small"></div></td></tr>';
2019-04-02 10:17:26 +00:00
this.tblAuthor.on('click', function(e) {
2019-08-01 08:13:08 +00:00
var btn = $markup.find(e.target);
2019-06-21 12:14:24 +00:00
if (btn.hasClass('close') && !btn.hasClass('disabled')) {
2019-04-02 10:17:26 +00:00
var el = btn.closest('tr'),
idx = me.tblAuthor.find('tr').index(el);
el.remove();
me.authors.splice(idx, 1);
me.updateScroller(true);
2019-04-02 10:17:26 +00:00
}
});
this.inputAuthor = new Common.UI.InputField({
2019-08-01 08:13:08 +00:00
el : $markup.findById('#id-info-add-author'),
2019-04-02 10:17:26 +00:00
style : 'width: 200px;',
validateOnBlur: false,
placeHolder: this.txtAddAuthor,
dataHint: '2',
dataHintDirection: 'left',
dataHintOffset: 'small'
2019-09-06 14:38:29 +00:00
}).on('changed:after', function(input, newValue, oldValue, e) {
2019-06-21 12:37:11 +00:00
if (newValue == oldValue) return;
2019-04-02 10:17:26 +00:00
var val = newValue.trim();
if (!!val && val !== oldValue.trim()) {
2019-09-06 14:38:29 +00:00
var isFromApply = e && e.relatedTarget && (e.relatedTarget.id == 'fminfo-btn-apply');
2019-04-02 10:17:26 +00:00
val.split(/\s*[,;]\s*/).forEach(function(item){
var str = item.trim();
if (str) {
me.authors.push(item);
2019-09-06 14:38:29 +00:00
if (!isFromApply) {
var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(str)));
me.trAuthor.before(div);
me.updateScroller();
2019-09-06 14:38:29 +00:00
}
2019-04-02 10:17:26 +00:00
}
});
2019-09-06 14:38:29 +00:00
!isFromApply && me.inputAuthor.setValue('');
2019-04-02 10:17:26 +00:00
}
}).on('keydown:before', keyDownBefore);
2016-03-11 00:48:53 +00:00
2022-03-22 16:30:09 +00:00
// pdf info
this.lblPageSize = $markup.findById('#id-info-page-size');
this.lblPdfTitle = $markup.findById('#id-lbl-info-title');
this.lblPdfSubject = $markup.findById('#id-lbl-info-subject');
this.lblPdfAuthor = $markup.findById('#id-lbl-info-author');
this.lblPdfVer = $markup.findById('#id-info-pdf-ver');
this.lblPdfTagged = $markup.findById('#id-info-pdf-tagged');
2022-04-27 13:53:45 +00:00
this.lblPdfProducer = $markup.findById('#id-info-pdf-produce');
2022-03-22 16:30:09 +00:00
this.lblFastWV = $markup.findById('#id-info-fast-wv');
2019-09-06 14:38:29 +00:00
this.btnApply = new Common.UI.Button({
2019-10-08 09:11:07 +00:00
el: $markup.findById('#fminfo-btn-apply')
2019-09-06 14:38:29 +00:00
});
this.btnApply.on('click', _.bind(this.applySettings, this));
2020-08-07 10:51:26 +00:00
this.pnlInfo = $markup.find('.flex-settings').addBack().filter('.flex-settings');
2020-08-06 20:15:40 +00:00
this.pnlApply = $markup.findById('#fms-flex-apply');
2016-03-11 00:48:53 +00:00
this.rendered = true;
this.updateInfo(this.doc);
2019-08-01 08:50:22 +00:00
this.$el = $(node).html($markup);
2016-03-11 00:48:53 +00:00
if (_.isUndefined(this.scroller)) {
this.scroller = new Common.UI.Scroller({
el: this.pnlInfo,
suppressScrollX: true,
alwaysVisibleY: true
2016-03-11 00:48:53 +00:00
});
}
Common.NotificationCenter.on({
'window:resize': function() {
me.isVisible() && me.updateScroller();
}
});
2016-03-11 00:48:53 +00:00
return this;
},
show: function() {
Common.UI.BaseView.prototype.show.call(this,arguments);
this.updateStatisticInfo();
2019-04-02 10:17:26 +00:00
this.updateFileInfo();
this.scroller && this.scroller.scrollTop(0);
2020-08-06 20:15:40 +00:00
this.updateScroller();
2016-03-11 00:48:53 +00:00
},
hide: function() {
Common.UI.BaseView.prototype.hide.call(this,arguments);
this.stopUpdatingStatisticInfo();
},
updateScroller: function(destroy) {
if (this.scroller) {
2020-08-11 16:33:58 +00:00
this.scroller.update(destroy ? {} : undefined);
this.pnlInfo.toggleClass('bordered', this.scroller.isVisible());
}
},
2016-03-11 00:48:53 +00:00
updateInfo: function(doc) {
this.doc = doc;
if (!this.rendered)
return;
2019-04-02 10:17:26 +00:00
var visible = false;
2016-03-11 00:48:53 +00:00
doc = doc || {};
if (doc.info) {
2019-04-02 10:17:26 +00:00
// server info
2016-03-11 00:48:53 +00:00
if (doc.info.folder )
this.lblPlacement.text( doc.info.folder );
visible = this._ShowHideInfoItem(this.lblPlacement, doc.info.folder!==undefined && doc.info.folder!==null) || visible;
var value = doc.info.owner;
2019-07-30 09:05:48 +00:00
if (value)
this.lblOwner.text(value);
visible = this._ShowHideInfoItem(this.lblOwner, !!value) || visible;
value = doc.info.uploaded;
2019-07-30 09:05:48 +00:00
if (value)
this.lblUploaded.text(value);
visible = this._ShowHideInfoItem(this.lblUploaded, !!value) || visible;
2016-03-11 00:48:53 +00:00
} else
this._ShowHideDocInfo(false);
2019-04-02 10:17:26 +00:00
$('tr.divider.general', this.el)[visible?'show':'hide']();
2022-03-22 16:30:09 +00:00
var pdfProps = (this.api) ? this.api.asc_getPdfProps() : null;
2018-11-06 09:58:02 +00:00
var appname = (this.api) ? this.api.asc_getAppProps() : null;
if (appname) {
2022-03-22 16:30:09 +00:00
$('.pdf-info', this.el).hide();
2020-11-02 13:48:44 +00:00
appname = (appname.asc_getApplication() || '') + (appname.asc_getAppVersion() ? ' ' : '') + (appname.asc_getAppVersion() || '');
2018-11-06 09:58:02 +00:00
this.lblApplication.text(appname);
2022-03-22 16:30:09 +00:00
} else if (pdfProps) {
$('.docx-info', this.el).hide();
2022-04-27 13:53:45 +00:00
appname = pdfProps ? pdfProps.Creator || '' : '';
2022-03-22 16:30:09 +00:00
this.lblApplication.text(appname);
2019-04-02 10:17:26 +00:00
}
2019-05-16 08:52:49 +00:00
this._ShowHideInfoItem(this.lblApplication, !!appname);
this.coreProps = (this.api) ? this.api.asc_getCoreProps() : null;
if (this.coreProps) {
var value = this.coreProps.asc_getCreated();
if (value) {
var lang = (this.mode.lang || 'en').replace('_', '-').toLowerCase();
try {
this.lblDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
} catch (e) {
lang = 'en';
this.lblDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
}
}
2019-04-02 10:17:26 +00:00
this._ShowHideInfoItem(this.lblDate, !!value);
2022-03-22 16:30:09 +00:00
} else if (pdfProps)
this.updatePdfInfo(pdfProps);
2016-03-11 00:48:53 +00:00
},
2019-04-02 10:17:26 +00:00
updateFileInfo: function() {
if (!this.rendered)
return;
var me = this,
props = (this.api) ? this.api.asc_getCoreProps() : null,
value;
this.coreProps = props;
2019-04-02 10:17:26 +00:00
if (props) {
var visible = false;
value = props.asc_getModified();
if (value) {
var lang = (this.mode.lang || 'en').replace('_', '-').toLowerCase();
try {
this.lblModifyDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
} catch (e) {
lang = 'en';
this.lblModifyDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
}
}
visible = this._ShowHideInfoItem(this.lblModifyDate, !!value) || visible;
2019-04-02 10:17:26 +00:00
value = props.asc_getLastModifiedBy();
if (value)
2021-03-26 11:29:16 +00:00
this.lblModifyBy.text(AscCommon.UserInfoParser.getParsedName(value));
visible = this._ShowHideInfoItem(this.lblModifyBy, !!value) || visible;
2019-04-02 10:17:26 +00:00
$('tr.divider.modify', this.el)[visible?'show':'hide']();
value = props.asc_getTitle();
this.inputTitle.setValue(value || '');
value = props.asc_getSubject();
this.inputSubject.setValue(value || '');
value = props.asc_getDescription();
this.inputComment.setValue(value || '');
2019-09-06 14:38:29 +00:00
this.inputAuthor.setValue('');
2019-04-02 10:17:26 +00:00
this.tblAuthor.find('tr:not(:last-of-type)').remove();
this.authors = [];
value = props.asc_getCreator();//"123\"\"\"\<\>,456";
value && value.split(/\s*[,;]\s*/).forEach(function(item) {
2019-04-02 10:17:26 +00:00
var div = $(Common.Utils.String.format(me.authorTpl, Common.Utils.String.htmlEncode(item)));
me.trAuthor.before(div);
me.authors.push(item);
2019-04-02 10:17:26 +00:00
});
this.tblAuthor.find('.close').toggleClass('hidden', !this.mode.isEdit);
2019-10-31 07:16:53 +00:00
!this.mode.isEdit && this._ShowHideInfoItem(this.tblAuthor, !!this.authors.length);
2019-04-02 10:17:26 +00:00
}
this.SetDisabled();
2019-04-02 10:17:26 +00:00
},
2022-03-22 16:30:09 +00:00
updatePdfInfo: function(props) {
if (!this.rendered)
return;
var me = this,
value;
if (props) {
value = props.CreationDate;
if (value) {
value = new Date(value);
var lang = (this.mode.lang || 'en').replace('_', '-').toLowerCase();
try {
this.lblDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
} catch (e) {
lang = 'en';
this.lblDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
}
2022-03-22 16:30:09 +00:00
}
this._ShowHideInfoItem(this.lblDate, !!value);
var visible = false;
value = props.ModDate;
if (value) {
value = new Date(value);
var lang = (this.mode.lang || 'en').replace('_', '-').toLowerCase();
try {
this.lblModifyDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
} catch (e) {
lang = 'en';
this.lblModifyDate.text(value.toLocaleString(lang, {year: 'numeric', month: '2-digit', day: '2-digit'}) + ' ' + value.toLocaleString(lang, {timeStyle: 'short'}));
}
2022-03-22 16:30:09 +00:00
}
visible = this._ShowHideInfoItem(this.lblModifyDate, !!value) || visible;
visible = this._ShowHideInfoItem(this.lblModifyBy, false) || visible;
$('tr.divider.modify', this.el)[visible?'show':'hide']();
if (props.PageWidth && props.PageHeight && (typeof props.PageWidth === 'number') && (typeof props.PageHeight === 'number')) {
var w = props.PageWidth,
h = props.PageHeight;
switch (Common.Utils.Metric.getCurrentMetric()) {
case Common.Utils.Metric.c_MetricUnits.cm:
w = parseFloat((w* 25.4 / 72000.).toFixed(2));
h = parseFloat((h* 25.4 / 72000.).toFixed(2));
break;
case Common.Utils.Metric.c_MetricUnits.pt:
w = parseFloat((w/100.).toFixed(2));
h = parseFloat((h/100.).toFixed(2));
break;
case Common.Utils.Metric.c_MetricUnits.inch:
w = parseFloat((w/7200.).toFixed(2));
h = parseFloat((h/7200.).toFixed(2));
break;
}
this.lblPageSize.text(w + ' ' + Common.Utils.Metric.getCurrentMetricName() + ' x ' + h + ' ' + Common.Utils.Metric.getCurrentMetricName());
this._ShowHideInfoItem(this.lblPageSize, true);
} else
this._ShowHideInfoItem(this.lblPageSize, false);
value = props.Title;
value && this.lblPdfTitle.text(value);
visible = this._ShowHideInfoItem(this.lblPdfTitle, !!value);
value = props.Subject;
value && this.lblPdfSubject.text(value);
visible = this._ShowHideInfoItem(this.lblPdfSubject, !!value) || visible;
$('tr.divider.pdf-title', this.el)[visible?'show':'hide']();
2022-03-22 19:38:33 +00:00
value = props.Author;
2022-03-22 16:30:09 +00:00
value && this.lblPdfAuthor.text(value);
this._ShowHideInfoItem(this.lblPdfAuthor, !!value);
value = props.Version;
value && this.lblPdfVer.text(value);
this._ShowHideInfoItem(this.lblPdfVer, !!value);
value = props.Tagged;
if (value !== undefined)
this.lblPdfTagged.text(value===true ? this.txtYes : this.txtNo);
this._ShowHideInfoItem(this.lblPdfTagged, value !== undefined);
2022-04-27 13:53:45 +00:00
value = props.Producer;
value && this.lblPdfProducer.text(value);
this._ShowHideInfoItem(this.lblPdfProducer, !!value);
2022-03-22 16:30:09 +00:00
value = props.FastWebView;
if (value !== undefined)
this.lblFastWV.text(value===true ? this.txtYes : this.txtNo);
this._ShowHideInfoItem(this.lblFastWV, value !== undefined);
}
},
2019-04-02 10:17:26 +00:00
_ShowHideInfoItem: function(el, visible) {
el.closest('tr')[visible?'show':'hide']();
return visible;
2016-03-11 00:48:53 +00:00
},
_ShowHideDocInfo: function(visible) {
2019-04-02 10:17:26 +00:00
this._ShowHideInfoItem(this.lblPlacement, visible);
this._ShowHideInfoItem(this.lblOwner, visible);
this._ShowHideInfoItem(this.lblUploaded, visible);
2016-03-11 00:48:53 +00:00
},
updateStatisticInfo: function() {
if ( this.api && this.doc ) {
this.api.startGetDocInfo();
}
},
stopUpdatingStatisticInfo: function() {
if ( this.api ) {
this.api.stopGetDocInfo();
}
},
setApi: function(o) {
this.api = o;
this.api.asc_registerCallback('asc_onGetDocInfoStart', _.bind(this._onGetDocInfoStart, this));
this.api.asc_registerCallback('asc_onGetDocInfoStop', _.bind(this._onGetDocInfoEnd, this));
this.api.asc_registerCallback('asc_onDocInfo', _.bind(this._onDocInfo, this));
this.api.asc_registerCallback('asc_onGetDocInfoEnd', _.bind(this._onGetDocInfoEnd, this));
2019-04-02 10:17:26 +00:00
// this.api.asc_registerCallback('asc_onDocumentName', _.bind(this.onDocumentName, this));
2019-06-21 12:14:24 +00:00
this.api.asc_registerCallback('asc_onLockCore', _.bind(this.onLockCore, this));
2018-11-06 09:58:02 +00:00
this.updateInfo(this.doc);
2016-03-11 00:48:53 +00:00
return this;
},
setMode: function(mode) {
this.mode = mode;
this.inputAuthor.setVisible(mode.isEdit);
2020-08-06 20:15:40 +00:00
this.pnlApply.toggleClass('hidden', !mode.isEdit);
this.tblAuthor.find('.close').toggleClass('hidden', !mode.isEdit);
2019-10-31 07:16:53 +00:00
if (!mode.isEdit) {
this.inputTitle._input.attr('placeholder', '');
this.inputSubject._input.attr('placeholder', '');
this.inputComment._input.attr('placeholder', '');
this.inputAuthor._input.attr('placeholder', '');
}
this.SetDisabled();
2016-03-11 00:48:53 +00:00
return this;
},
_onGetDocInfoStart: function() {
var me = this;
this.infoObj = {PageCount: 0, WordsCount: 0, ParagraphCount: 0, SymbolsCount: 0, SymbolsWSCount:0};
this.timerLoading = setTimeout(function(){
2016-03-11 00:48:53 +00:00
me.lblStatPages.text(me.txtLoading);
me.lblStatWords.text(me.txtLoading);
me.lblStatParagraphs.text(me.txtLoading);
me.lblStatSymbols.text(me.txtLoading);
me.lblStatSpaces.text(me.txtLoading);
}, 2000);
},
_onDocInfo: function(obj) {
if (obj) {
clearTimeout(this.timerLoading);
2016-03-11 00:48:53 +00:00
if (obj.get_PageCount()>-1)
this.infoObj.PageCount = obj.get_PageCount();
if (obj.get_WordsCount()>-1)
this.infoObj.WordsCount = obj.get_WordsCount();
if (obj.get_ParagraphCount()>-1)
this.infoObj.ParagraphCount = obj.get_ParagraphCount();
if (obj.get_SymbolsCount()>-1)
this.infoObj.SymbolsCount = obj.get_SymbolsCount();
if (obj.get_SymbolsWSCount()>-1)
this.infoObj.SymbolsWSCount = obj.get_SymbolsWSCount();
if (!this.timerDocInfo) { // start timer for filling info
var me = this;
this.timerDocInfo = setInterval(function(){
me.fillDocInfo();
}, 300);
this.fillDocInfo();
}
2016-03-11 00:48:53 +00:00
}
},
_onGetDocInfoEnd: function() {
clearTimeout(this.timerLoading);
clearInterval(this.timerDocInfo);
this.timerLoading = this.timerDocInfo = undefined;
this.fillDocInfo();
},
fillDocInfo: function() {
2016-03-11 00:48:53 +00:00
this.lblStatPages.text(this.infoObj.PageCount);
this.lblStatWords.text(this.infoObj.WordsCount);
this.lblStatParagraphs.text(this.infoObj.ParagraphCount);
this.lblStatSymbols.text(this.infoObj.SymbolsCount);
this.lblStatSpaces.text(this.infoObj.SymbolsWSCount);
},
onDocumentName: function(name) {
2019-05-16 12:59:39 +00:00
// this.lblTitle.text((name) ? name : '-');
2016-03-11 00:48:53 +00:00
},
2019-06-21 12:14:24 +00:00
onLockCore: function(lock) {
this._locked = lock;
this.updateFileInfo();
},
SetDisabled: function() {
var disable = !this.mode.isEdit || this._locked;
this.inputTitle.setDisabled(disable);
this.inputSubject.setDisabled(disable);
this.inputComment.setDisabled(disable);
this.inputAuthor.setDisabled(disable);
this.tblAuthor.find('.close').toggleClass('disabled', this._locked);
this.tblAuthor.toggleClass('disabled', disable);
2019-09-06 14:38:29 +00:00
this.btnApply.setDisabled(this._locked);
},
applySettings: function() {
if (this.coreProps && this.api) {
this.coreProps.asc_putTitle(this.inputTitle.getValue());
this.coreProps.asc_putSubject(this.inputSubject.getValue());
this.coreProps.asc_putDescription(this.inputComment.getValue());
this.coreProps.asc_putCreator(this.authors.join(';'));
this.api.asc_setCoreProps(this.coreProps);
}
this.menu.hide();
2019-06-21 12:14:24 +00:00
},
2019-05-15 11:17:29 +00:00
txtPlacement: 'Location',
txtOwner: 'Owner',
2019-04-02 10:17:26 +00:00
txtUploaded: 'Uploaded',
2016-03-11 00:48:53 +00:00
txtPages: 'Pages',
txtWords: 'Words',
txtParagraphs: 'Paragraphs',
txtSymbols: 'Symbols',
txtSpaces: 'Symbols with spaces',
2018-11-06 09:58:02 +00:00
txtLoading: 'Loading...',
2019-04-02 10:17:26 +00:00
txtAppName: 'Application',
txtEditTime: 'Total Editing time',
txtTitle: 'Title',
txtSubject: 'Subject',
txtComment: 'Comment',
txtModifyDate: 'Last Modified',
txtModifyBy: 'Last Modified By',
txtCreated: 'Created',
2019-04-02 10:17:26 +00:00
txtAuthor: 'Author',
2019-05-15 11:17:29 +00:00
txtAddAuthor: 'Add Author',
txtAddText: 'Add Text',
2019-09-06 14:38:29 +00:00
txtMinutes: 'min',
2022-03-22 16:30:09 +00:00
okButtonText: 'Apply',
txtPageSize: 'Page Size',
txtPdfVer: 'PDF Version',
txtPdfTagged: 'Tagged PDF',
txtFastWV: 'Fast Web View',
txtYes: 'Yes',
2022-04-27 13:53:45 +00:00
txtNo: 'No',
txtPdfProducer: 'PDF Producer'
2022-03-22 16:30:09 +00:00
2016-03-11 00:48:53 +00:00
}, DE.Views.FileMenuPanels.DocumentInfo || {}));
DE.Views.FileMenuPanels.DocumentRights = Common.UI.BaseView.extend(_.extend({
el: '#panel-rights',
menu: undefined,
initialize: function(options) {
Common.UI.BaseView.prototype.initialize.call(this,arguments);
this.rendered = false;
this.template = _.template([
'<table class="main" style="margin: 30px 0;">',
2016-03-11 00:48:53 +00:00
'<tr class="rights">',
'<td class="left" style="vertical-align: top;"><label>' + this.txtRights + '</label></td>',
'<td class="right"><div id="id-info-rights"></div></td>',
'</tr>',
'<tr class="edit-rights">',
'<td class="left"></td><td class="right"><button id="id-info-btn-edit" class="btn normal dlg-btn primary custom" style="margin-right: 10px;">' + this.txtBtnAccessRights + '</button></td>',
'</tr>',
'</table>'
].join(''));
this.templateRights = _.template([
'<table>',
'<% _.each(users, function(item) { %>',
'<tr>',
'<td><span class="userLink img-commonctrl <% if (item.isLink) { %>sharedLink<% } %>"></span><span><%= Common.Utils.String.htmlEncode(item.user) %></span></td>',
'<td><%= Common.Utils.String.htmlEncode(item.permissions) %></td>',
'</tr>',
'<% }); %>',
'</table>'
].join(''));
this.menu = options.menu;
},
2019-08-01 08:13:08 +00:00
render: function(node) {
var $markup = $(this.template());
2016-03-11 00:48:53 +00:00
2019-08-01 08:13:08 +00:00
this.cntRights = $markup.findById('#id-info-rights');
2016-03-11 00:48:53 +00:00
this.btnEditRights = new Common.UI.Button({
2019-08-01 08:13:08 +00:00
el: $markup.elementById('#id-info-btn-edit')
2016-03-11 00:48:53 +00:00
});
this.btnEditRights.on('click', _.bind(this.changeAccessRights, this));
this.rendered = true;
this.updateInfo(this.doc);
Common.NotificationCenter.on('collaboration:sharingupdate', this.updateSharingSettings.bind(this));
2019-08-01 08:50:22 +00:00
Common.NotificationCenter.on('collaboration:sharingdeny', this.onLostEditRights.bind(this));
this.$el = $(node).html($markup);
2016-03-11 00:48:53 +00:00
if (_.isUndefined(this.scroller)) {
this.scroller = new Common.UI.Scroller({
2019-08-01 08:50:22 +00:00
el: this.$el,
suppressScrollX: true,
alwaysVisibleY: true
2016-03-11 00:48:53 +00:00
});
}
return this;
},
show: function() {
Common.UI.BaseView.prototype.show.call(this,arguments);
this.scroller && this.scroller.update();
2016-03-11 00:48:53 +00:00
},
hide: function() {
Common.UI.BaseView.prototype.hide.call(this,arguments);
},
updateInfo: function(doc) {
this.doc = doc;
if (!this.rendered)
return;
doc = doc || {};
if (doc.info) {
if (doc.info.sharingSettings)
this.cntRights.html(this.templateRights({users: doc.info.sharingSettings}));
this._ShowHideInfoItem('rights', doc.info.sharingSettings!==undefined && doc.info.sharingSettings!==null && doc.info.sharingSettings.length>0);
this._ShowHideInfoItem('edit-rights', (!!this.sharingSettingsUrl && this.sharingSettingsUrl.length || this.mode.canRequestSharingSettings) && this._readonlyRights!==true);
2016-03-11 00:48:53 +00:00
} else
this._ShowHideDocInfo(false);
},
_ShowHideInfoItem: function(cls, visible) {
$('tr.'+cls, this.el)[visible?'show':'hide']();
},
_ShowHideDocInfo: function(visible) {
this._ShowHideInfoItem('rights', visible);
this._ShowHideInfoItem('edit-rights', visible);
},
setApi: function(o) {
this.api = o;
return this;
},
setMode: function(mode) {
this.mode = mode;
2016-03-11 00:48:53 +00:00
this.sharingSettingsUrl = mode.sharingSettingsUrl;
return this;
},
changeAccessRights: function(btn,event,opts) {
Common.NotificationCenter.trigger('collaboration:sharing');
},
updateSharingSettings: function(rights) {
this._ShowHideInfoItem('rights', this.doc.info.sharingSettings!==undefined && this.doc.info.sharingSettings!==null && this.doc.info.sharingSettings.length>0);
this.cntRights.html(this.templateRights({users: this.doc.info.sharingSettings}));
},
2016-03-11 00:48:53 +00:00
onLostEditRights: function() {
this._readonlyRights = true;
if (!this.rendered)
return;
this._ShowHideInfoItem('edit-rights', false);
},
txtRights: 'Persons who have rights',
txtBtnAccessRights: 'Change access rights'
}, DE.Views.FileMenuPanels.DocumentRights || {}));
DE.Views.FileMenuPanels.Help = Common.UI.BaseView.extend({
el: '#panel-help',
menu: undefined,
template: _.template([
'<div style="width:100%; height:100%; position: relative;">',
2018-01-15 14:08:35 +00:00
'<div id="id-help-contents" style="position: absolute; width:220px; top: 0; bottom: 0;" class="no-padding"></div>',
'<div id="id-help-frame" style="position: absolute; left: 220px; top: 0; right: 0; bottom: 0;" class="no-padding"></div>',
2016-03-11 00:48:53 +00:00
'</div>'
].join('')),
initialize: function(options) {
Common.UI.BaseView.prototype.initialize.call(this,arguments);
this.menu = options.menu;
this.urlPref = 'resources/help/{{DEFAULT_LANG}}/';
2020-01-09 09:06:23 +00:00
this.openUrl = null;
2022-10-12 20:02:44 +00:00
this.urlHelpCenter = '{{HELP_CENTER_WEB_DE}}';
2016-03-11 00:48:53 +00:00
this.en_data = [
2018-01-15 14:32:17 +00:00
{"src": "ProgramInterface/ProgramInterface.htm", "name": "Introducing Document Editor user interface", "headername": "Program Interface"},
{"src": "ProgramInterface/FileTab.htm", "name": "File tab"},
{"src": "ProgramInterface/HomeTab.htm", "name": "Home Tab"},
{"src": "ProgramInterface/InsertTab.htm", "name": "Insert tab"},
{"src": "ProgramInterface/LayoutTab.htm", "name": "Layout tab"},
{"src": "ProgramInterface/ReviewTab.htm", "name": "Review tab"},
{"src": "ProgramInterface/PluginsTab.htm", "name": "Plugins tab"},
{"src": "UsageInstructions/ChangeColorScheme.htm", "name": "Change color scheme", "headername": "Basic operations"},
{"src": "UsageInstructions/CopyPasteUndoRedo.htm", "name": "Copy/paste text passages, undo/redo your actions"},
{"src": "UsageInstructions/OpenCreateNew.htm", "name": "Create a new document or open an existing one"},
{"src": "UsageInstructions/SetPageParameters.htm", "name": "Set page parameters", "headername": "Page formatting"},
{"src": "UsageInstructions/NonprintingCharacters.htm", "name": "Show/hide nonprinting characters" },
{"src": "UsageInstructions/SectionBreaks.htm", "name": "Insert section breaks" },
{"src": "UsageInstructions/InsertHeadersFooters.htm", "name": "Insert headers and footers"},
{"src": "UsageInstructions/InsertPageNumbers.htm", "name": "Insert page numbers"},
{"src": "UsageInstructions/InsertFootnotes.htm", "name": "Insert footnotes"},
{"src": "UsageInstructions/AlignText.htm", "name": "Align your text in a paragraph", "headername": "Paragraph formatting"},
{"src": "UsageInstructions/BackgroundColor.htm", "name": "Select background color for a paragraph"},
{"src": "UsageInstructions/ParagraphIndents.htm", "name": "Change paragraph indents"},
{"src": "UsageInstructions/LineSpacing.htm", "name": "Set paragraph line spacing"},
{"src": "UsageInstructions/PageBreaks.htm", "name": "Insert page breaks"},
{"src": "UsageInstructions/AddBorders.htm", "name": "Add borders"},
{"src": "UsageInstructions/SetTabStops.htm", "name": "Set tab stops"},
{"src": "UsageInstructions/CreateLists.htm", "name": "Create lists"},
{"src": "UsageInstructions/FormattingPresets.htm", "name": "Apply formatting styles", "headername": "Text formatting"},
{"src": "UsageInstructions/FontTypeSizeColor.htm", "name": "Set font type, size, and color"},
{"src": "UsageInstructions/DecorationStyles.htm", "name": "Apply font decoration styles"},
{"src": "UsageInstructions/CopyClearFormatting.htm", "name": "Copy/clear text formatting" },
{"src": "UsageInstructions/AddHyperlinks.htm", "name": "Add hyperlinks"},
{"src": "UsageInstructions/InsertDropCap.htm", "name": "Insert a drop cap"},
{"src": "UsageInstructions/InsertTables.htm", "name": "Insert tables", "headername": "Operations on objects"},
{"src": "UsageInstructions/InsertImages.htm", "name": "Insert images"},
{"src": "UsageInstructions/InsertAutoshapes.htm", "name": "Insert autoshapes"},
{"src": "UsageInstructions/InsertCharts.htm", "name": "Insert charts" },
{"src": "UsageInstructions/InsertTextObjects.htm", "name": "Insert text objects" },
{"src": "UsageInstructions/AlignArrangeObjects.htm", "name": "Align and arrange objects on a page" },
{"src": "UsageInstructions/ChangeWrappingStyle.htm", "name": "Change wrapping style" },
{"src": "UsageInstructions/UseMailMerge.htm", "name": "Use mail merge", "headername": "Mail Merge"},
{"src": "UsageInstructions/InsertEquation.htm", "name": "Insert equations", "headername": "Math equations"},
{"src": "HelpfulHints/CollaborativeEditing.htm", "name": "Collaborative document editing", "headername": "Document co-editing"},
{"src": "HelpfulHints/Review.htm", "name": "Document Review"},
{"src": "UsageInstructions/ViewDocInfo.htm", "name": "View document information", "headername": "Tools and settings"},
{"src": "UsageInstructions/SavePrintDownload.htm", "name": "Save/download/print your document" },
{"src": "HelpfulHints/AdvancedSettings.htm", "name": "Advanced settings of Document Editor"},
{"src": "HelpfulHints/Navigation.htm", "name": "View settings and navigation tools"},
{"src": "HelpfulHints/Search.htm", "name": "Search and replace function"},
{"src": "HelpfulHints/SpellChecking.htm", "name": "Spell-checking"},
{"src": "HelpfulHints/About.htm", "name": "About Document Editor", "headername": "Helpful hints"},
{"src": "HelpfulHints/SupportedFormats.htm", "name": "Supported formats of electronic documents" },
{"src": "HelpfulHints/KeyboardShortcuts.htm", "name": "Keyboard shortcuts"}
2016-03-11 00:48:53 +00:00
];
if (Common.Utils.isIE) {
window.onhelp = function () { return false; }
}
},
render: function() {
var me = this;
this.$el.html(this.template());
2016-03-11 00:48:53 +00:00
this.viewHelpPicker = new Common.UI.DataView({
el: $('#id-help-contents'),
store: new Common.UI.DataViewStore([]),
keyMoveDirection: 'vertical',
itemTemplate: _.template([
'<div id="<%= id %>" class="help-item-wrap">',
'<div class="caption"><%= name %></div>',
'</div>'
].join(''))
});
this.viewHelpPicker.on('item:add', function(dataview, itemview, record) {
if (record.has('headername')) {
$(itemview.el).before('<div class="header-name">' + record.get('headername') + '</div>');
}
});
this.viewHelpPicker.on('item:select', function(dataview, itemview, record) {
me.onSelectItem(record.get('src'));
2016-03-11 00:48:53 +00:00
});
this.iFrame = document.createElement('iframe');
this.iFrame.src = "";
this.iFrame.align = "top";
this.iFrame.frameBorder = "0";
this.iFrame.width = "100%";
this.iFrame.height = "100%";
Common.Gateway.on('internalcommand', function(data) {
if (data.type == 'help:hyperlink') {
var src = data.data;
var rec = me.viewHelpPicker.store.find(function(record){
return (src.indexOf(record.get('src'))>0);
});
if (rec) {
me.viewHelpPicker.selectRecord(rec, true);
me.viewHelpPicker.scrollToRecord(rec);
}
}
});
$('#id-help-frame').append(this.iFrame);
return this;
},
setLangConfig: function(lang) {
var me = this;
var store = this.viewHelpPicker.store;
if (lang) {
lang = lang.split(/[\-\_]/)[0];
2016-03-11 00:48:53 +00:00
var config = {
dataType: 'json',
error: function () {
if ( me.urlPref.indexOf('resources/help/{{DEFAULT_LANG}}/')<0 ) {
me.urlPref = 'resources/help/{{DEFAULT_LANG}}/';
store.url = 'resources/help/{{DEFAULT_LANG}}/Contents.json';
2016-03-11 00:48:53 +00:00
store.fetch(config);
} else {
if ( Common.Controllers.Desktop.isActive() ) {
if ( store.contentLang === '{{DEFAULT_LANG}}' || !Common.Controllers.Desktop.helpUrl() ) {
2022-10-11 19:12:02 +00:00
me.noHelpContents = true;
me.iFrame.src = '../../common/main/resources/help/download.html';
} else {
store.contentLang = store.contentLang === lang ? '{{DEFAULT_LANG}}' : lang;
2022-09-16 13:32:15 +00:00
me.urlPref = Common.Controllers.Desktop.helpUrl() + '/' + store.contentLang + '/';
2022-07-07 13:29:19 +00:00
store.url = me.urlPref + 'Contents.json';
store.fetch(config);
}
} else {
me.urlPref = 'resources/help/{{DEFAULT_LANG}}/';
store.reset(me.en_data);
}
2016-03-11 00:48:53 +00:00
}
},
success: function () {
var rec = me.openUrl ? store.find(function(record){
return (me.openUrl.indexOf(record.get('src'))>=0);
}) : store.at(0);
if (rec) {
me.viewHelpPicker.selectRecord(rec, true);
me.viewHelpPicker.scrollToRecord(rec);
}
me.onSelectItem(me.openUrl ? me.openUrl : rec.get('src'));
2016-03-11 00:48:53 +00:00
}
};
store.url = 'resources/help/' + lang + '/Contents.json';
store.fetch(config);
this.urlPref = 'resources/help/' + lang + '/';
}
},
show: function (url) {
Common.UI.BaseView.prototype.show.call(this);
if (!this._scrollerInited) {
this.viewHelpPicker.scroller.update();
this._scrollerInited = true;
}
if (url) {
if (this.viewHelpPicker.store.length>0) {
var rec = this.viewHelpPicker.store.find(function(record){
return (url.indexOf(record.get('src'))>=0);
});
if (rec) {
this.viewHelpPicker.selectRecord(rec, true);
this.viewHelpPicker.scrollToRecord(rec);
}
this.onSelectItem(url);
2020-01-09 09:06:23 +00:00
} else
this.openUrl = url;
2016-03-11 00:48:53 +00:00
}
},
onSelectItem: function(src) {
this.iFrame.src = this.urlPref + src;
2016-03-11 00:48:53 +00:00
}
});
DE.Views.FileMenuPanels.ProtectDoc = Common.UI.BaseView.extend(_.extend({
el: '#panel-protect',
menu: undefined,
template: _.template([
'<label id="id-fms-lbl-protect-header" style="font-size: 18px;"><%= scope.strProtect %></label>',
'<div id="id-fms-password">',
'<label class="header"><%= scope.strEncrypt %></label>',
'<div id="fms-btn-add-pwd" style="width:190px;"></div>',
'<table id="id-fms-view-pwd" cols="2" width="300">',
'<tr>',
2018-04-27 13:14:18 +00:00
'<td colspan="2"><label style="cursor: default;"><%= scope.txtEncrypted %></label></td>',
'</tr>',
'<tr>',
'<td><div id="fms-btn-change-pwd" style="width:190px;"></div></td>',
'<td align="right"><div id="fms-btn-delete-pwd" style="width:190px; margin-left:20px;"></div></td>',
'</tr>',
'</table>',
'</div>',
'<div id="id-fms-signature">',
'<label class="header"><%= scope.strSignature %></label>',
'<div id="fms-btn-invisible-sign" style="width:190px; margin-bottom: 20px;"></div>',
'<div id="id-fms-signature-view"></div>',
'</div>'
].join('')),
initialize: function(options) {
Common.UI.BaseView.prototype.initialize.call(this,arguments);
this.menu = options.menu;
2017-09-13 08:14:25 +00:00
var me = this;
this.templateSignature = _.template([
'<table cols="2" width="300" class="<% if (!hasRequested && !hasSigned) { %>hidden<% } %>"">',
'<tr>',
2018-04-27 13:14:18 +00:00
'<td colspan="2"><label style="cursor: default;"><%= tipText %></label></td>',
'</tr>',
'<tr>',
2021-12-03 12:38:00 +00:00
'<td><label class="link signature-view-link" data-hint="2" data-hint-direction="bottom" data-hint-offset="medium">' + me.txtView + '</label></td>',
'<td align="right"><label class="link signature-edit-link <% if (!hasSigned) { %>hidden<% } %>" data-hint="2" data-hint-direction="bottom" data-hint-offset="medium">' + me.txtEdit + '</label></td>',
'</tr>',
2017-09-13 08:14:25 +00:00
'</table>'
].join(''));
},
render: function() {
this.$el.html(this.template({scope: this}));
var protection = DE.getController('Common.Controllers.Protection').getView();
this.btnAddPwd = protection.getButton('add-password');
this.btnAddPwd.render(this.$el.find('#fms-btn-add-pwd'));
this.btnAddPwd.on('click', _.bind(this.closeMenu, this));
this.btnChangePwd = protection.getButton('change-password');
this.btnChangePwd.render(this.$el.find('#fms-btn-change-pwd'));
this.btnChangePwd.on('click', _.bind(this.closeMenu, this));
this.btnDeletePwd = protection.getButton('del-password');
this.btnDeletePwd.render(this.$el.find('#fms-btn-delete-pwd'));
this.btnDeletePwd.on('click', _.bind(this.closeMenu, this));
this.cntPassword = $('#id-fms-password');
this.cntPasswordView = $('#id-fms-view-pwd');
this.btnAddInvisibleSign = protection.getButton('signature');
this.btnAddInvisibleSign.render(this.$el.find('#fms-btn-invisible-sign'));
this.btnAddInvisibleSign.on('click', _.bind(this.closeMenu, this));
2017-09-13 08:14:25 +00:00
this.cntSignature = $('#id-fms-signature');
this.cntSignatureView = $('#id-fms-signature-view');
if (_.isUndefined(this.scroller)) {
this.scroller = new Common.UI.Scroller({
2019-08-01 08:50:22 +00:00
el: this.$el,
suppressScrollX: true,
alwaysVisibleY: true
});
}
this.$el.on('click', '.signature-edit-link', _.bind(this.onEdit, this));
this.$el.on('click', '.signature-view-link', _.bind(this.onView, this));
return this;
},
show: function() {
Common.UI.BaseView.prototype.show.call(this,arguments);
2017-09-13 08:14:25 +00:00
this.updateSignatures();
this.updateEncrypt();
this.scroller && this.scroller.update();
},
setMode: function(mode) {
this.mode = mode;
this.cntSignature.toggleClass('hidden', !this.mode.isSignatureSupport);
this.cntPassword.toggleClass('hidden', !this.mode.isPasswordSupport);
},
2017-09-13 08:14:25 +00:00
setApi: function(o) {
this.api = o;
return this;
},
closeMenu: function() {
this.menu && this.menu.hide();
},
onEdit: function() {
this.menu && this.menu.hide();
var me = this;
Common.UI.warning({
title: this.notcriticalErrorTitle,
msg: this.txtEditWarning,
buttons: ['ok', 'cancel'],
primary: 'ok',
callback: function(btn) {
if (btn == 'ok') {
me.api.asc_RemoveAllSignatures();
}
}
});
},
onView: function() {
this.menu && this.menu.hide();
DE.getController('RightMenu').rightmenu.SetActivePane(Common.Utils.documentSettingsType.Signature, true);
},
2017-09-13 08:14:25 +00:00
updateSignatures: function(){
2017-05-22 10:33:13 +00:00
var requested = this.api.asc_getRequestSignatures(),
2017-05-23 08:55:06 +00:00
valid = this.api.asc_getSignatures(),
hasRequested = requested && requested.length>0,
hasValid = false,
hasInvalid = false;
2017-05-23 08:55:06 +00:00
_.each(valid, function(item, index){
if (item.asc_getValid()==0)
hasValid = true;
else
hasInvalid = true;
2017-05-23 08:55:06 +00:00
});
// hasRequested = true;
// hasValid = true;
// hasInvalid = true;
var tipText = (hasInvalid) ? this.txtSignedInvalid : (hasValid ? this.txtSigned : "");
if (hasRequested)
tipText = this.txtRequestedSignatures + (tipText!="" ? "<br><br>" : "")+ tipText;
this.cntSignatureView.html(this.templateSignature({tipText: tipText, hasSigned: (hasValid || hasInvalid), hasRequested: hasRequested}));
2017-09-13 08:14:25 +00:00
},
updateEncrypt: function() {
this.cntPasswordView.toggleClass('hidden', this.btnAddPwd.isVisible());
},
strProtect: 'Protect Document',
strSignature: 'With Signature',
txtView: 'View signatures',
txtEdit: 'Edit document',
txtSigned: 'Valid signatures has been added to the document. The document is protected from editing.',
txtSignedInvalid: 'Some of the digital signatures in document are invalid or could not be verified. The document is protected from editing.',
txtRequestedSignatures: 'This document needs to be signed.',
notcriticalErrorTitle: 'Warning',
txtEditWarning: 'Editing will remove the signatures from the document.<br>Are you sure you want to continue?',
strEncrypt: 'With Password',
txtEncrypted: 'This document has been protected by password'
}, DE.Views.FileMenuPanels.ProtectDoc || {}));
2016-03-11 00:48:53 +00:00
});