2017-12-26 14:31:14 +00:00
|
|
|
/*
|
|
|
|
*
|
2019-01-17 13:05:03 +00:00
|
|
|
* (c) Copyright Ascensio System SIA 2010-2019
|
2017-12-26 14:31:14 +00:00
|
|
|
*
|
|
|
|
* This program is a free software product. You can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
|
|
|
* version 3 as published by the Free Software Foundation. In accordance with
|
|
|
|
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
|
|
|
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
|
|
|
* of any third-party rights.
|
|
|
|
*
|
|
|
|
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
|
|
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
|
|
|
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
|
|
|
*
|
2019-01-17 13:00:34 +00:00
|
|
|
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
|
|
|
|
* street, Riga, Latvia, EU, LV-1050.
|
2017-12-26 14:31:14 +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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2020-10-15 07:32:46 +00:00
|
|
|
* TableOfContentsSettings.js
|
2017-12-26 14:31:14 +00:00
|
|
|
*
|
|
|
|
* Created by Julia Radzhabova on 26.12.2017
|
2018-03-01 12:16:38 +00:00
|
|
|
* Copyright (c) 2018 Ascensio System SIA. All rights reserved.
|
2017-12-26 14:31:14 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
define([
|
|
|
|
'common/main/lib/util/utils',
|
|
|
|
'common/main/lib/component/MetricSpinner',
|
|
|
|
'common/main/lib/component/ComboBox',
|
|
|
|
'common/main/lib/view/AdvancedSettingsWindow'
|
|
|
|
], function () { 'use strict';
|
|
|
|
|
|
|
|
DE.Views.TableOfContentsSettings = Common.Views.AdvancedSettingsWindow.extend(_.extend({
|
|
|
|
options: {
|
|
|
|
contentWidth: 500,
|
2018-01-17 09:32:12 +00:00
|
|
|
height: 455
|
2017-12-26 14:31:14 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
initialize : function(options) {
|
|
|
|
var me = this;
|
|
|
|
|
2020-10-15 07:32:46 +00:00
|
|
|
var height = options.type ? 385 : 455;
|
2017-12-26 14:31:14 +00:00
|
|
|
_.extend(this.options, {
|
2020-10-15 07:32:46 +00:00
|
|
|
title: options.type ? this.textTitleTOF : this.textTitle,
|
|
|
|
height: height,
|
2017-12-26 14:31:14 +00:00
|
|
|
template: [
|
2020-10-15 07:32:46 +00:00
|
|
|
'<div class="box" style="height:' + (height - 85) + 'px;">',
|
2017-12-26 14:31:14 +00:00
|
|
|
'<div class="content-panel" style="padding: 15px 10px;"><div class="inner-content">',
|
|
|
|
'<div class="settings-panel active">',
|
|
|
|
'<table cols="2" style="width: 100%;">',
|
|
|
|
'<tr>',
|
|
|
|
'<td class="padding-small">',
|
|
|
|
'<div id="tableofcontents-chb-pages"></div>',
|
|
|
|
'</td>',
|
2018-01-16 11:12:13 +00:00
|
|
|
'<td rowspan="5" class="padding-small" style="vertical-align: top;">',
|
2021-02-02 11:59:45 +00:00
|
|
|
'<div class="canvas-box" style="width: 240px; height: 182px; float: right;position:relative;overflow:hidden;">',
|
2018-03-01 13:58:33 +00:00
|
|
|
'<div id="tableofcontents-img" style="width: 230px; height: 100%;"></div>',
|
2017-12-26 14:31:14 +00:00
|
|
|
'</div>',
|
|
|
|
'</td>',
|
|
|
|
'</tr>',
|
|
|
|
'<tr>',
|
|
|
|
'<td class="padding-small">',
|
|
|
|
'<div id="tableofcontents-chb-align"></div>',
|
|
|
|
'</td>',
|
|
|
|
'</tr>',
|
|
|
|
'<tr>',
|
|
|
|
'<td class="padding-large">',
|
|
|
|
'<label class="input-label">' + me.textLeader + '</label>',
|
|
|
|
'<div id="tableofcontents-combo-leader" class="input-group-nr" style="display: inline-block; width:95px; margin-left: 10px;"></div>',
|
|
|
|
'</td>',
|
|
|
|
'</tr>',
|
|
|
|
'<tr>',
|
|
|
|
'<td class="padding-large">',
|
2018-01-16 11:12:13 +00:00
|
|
|
'<div id="tableofcontents-chb-links"></div>',
|
2017-12-26 14:31:14 +00:00
|
|
|
'</td>',
|
|
|
|
'</tr>',
|
|
|
|
'<tr>',
|
2018-01-11 15:02:27 +00:00
|
|
|
'<td class="padding-small">',
|
2020-10-15 07:32:46 +00:00
|
|
|
'<% if (type == 1) { %>',
|
|
|
|
'<label class="input-label padding-small" style="display: block;">' + me.textBuildTableOF + '</label>',
|
|
|
|
'<div id="tableofcontents-radio-caption" class="padding-small" style="display: block;"></div>',
|
|
|
|
'<div id="tableofcontents-radio-style" class="" style="display: block;"></div>',
|
|
|
|
'<% } else { %>',
|
2017-12-26 14:31:14 +00:00
|
|
|
'<label class="input-label padding-small" style="display: block;">' + me.textBuildTable + '</label>',
|
2018-03-15 14:57:36 +00:00
|
|
|
'<div id="tableofcontents-radio-levels" class="padding-small" style="display: block;"></div>',
|
|
|
|
'<div id="tableofcontents-radio-styles" class="" style="display: block;"></div>',
|
2020-10-15 07:32:46 +00:00
|
|
|
'<% } %>',
|
2017-12-26 14:31:14 +00:00
|
|
|
'</td>',
|
|
|
|
'</tr>',
|
|
|
|
'<tr>',
|
2018-01-11 15:02:27 +00:00
|
|
|
'<td class="padding-small" style="vertical-align: top;">',
|
2020-10-15 07:32:46 +00:00
|
|
|
'<% if (type == 1) { %>',
|
|
|
|
'<div id="tableofcontents-tof-from-caption" style="width:220px;">',
|
|
|
|
'<div id="tableofcontents-combo-captions" style="display: inline-block; width:129px; margin-bottom: 10px;"></div>',
|
|
|
|
'</div>',
|
|
|
|
'<div id="tableofcontents-tof-from-style" style="width:220px;" class="hidden">',
|
|
|
|
'<div id="tableofcontents-combo-tof-styles" style="display: inline-block; width:129px; margin-bottom: 10px;"></div>',
|
|
|
|
'</div>',
|
|
|
|
'<div id="tableofcontents-chb-full-caption"></div>',
|
|
|
|
'<% } else { %>',
|
2018-01-16 11:12:13 +00:00
|
|
|
'<div id="tableofcontents-from-levels" style="width:220px;">',
|
2018-01-11 15:02:27 +00:00
|
|
|
'<label class="input-label">' + me.textLevels + '</label>',
|
|
|
|
'<div id="tableofcontents-spin-levels" style="display: inline-block; width:95px; margin-left: 10px;"></div>',
|
|
|
|
'</div>',
|
|
|
|
'<div id="tableofcontents-from-styles" class="hidden">',
|
|
|
|
'<table><tr><td style="height: 25px;">',
|
|
|
|
'<label class="input-label" style="width: 144px; margin-left: 23px;">' + me.textStyle + '</label>',
|
|
|
|
'<label class="input-label" style="">' + me.textLevel + '</label>',
|
|
|
|
'</td></tr>',
|
2018-01-17 09:32:12 +00:00
|
|
|
'<tr><td>',
|
2020-04-09 13:29:04 +00:00
|
|
|
'<div id="tableofcontents-styles-list" class="header-styles-tableview" style="width:100%; height: 121px;"></div>',
|
2018-01-11 15:02:27 +00:00
|
|
|
'</td></tr></table>',
|
|
|
|
'</div>',
|
2020-10-15 07:32:46 +00:00
|
|
|
'<% } %>',
|
2017-12-26 14:31:14 +00:00
|
|
|
'</td>',
|
2018-01-11 15:02:27 +00:00
|
|
|
'<td class="padding-small" style="vertical-align: top;">',
|
2018-03-01 13:58:33 +00:00
|
|
|
'<label class="input-label" style="margin-left: 10px;">' + me.textStyles + '</label>',
|
2017-12-26 14:31:14 +00:00
|
|
|
'<div id="tableofcontents-combo-styles" class="input-group-nr" style="display: inline-block; width:95px; margin-left: 10px;"></div>',
|
|
|
|
'</td>',
|
|
|
|
'</tr>',
|
|
|
|
'</table>',
|
|
|
|
'</div></div>',
|
|
|
|
'</div>',
|
|
|
|
'</div>',
|
2020-06-05 13:10:48 +00:00
|
|
|
'<div class="separator horizontal"></div>'
|
2017-12-26 14:31:14 +00:00
|
|
|
].join('')
|
|
|
|
}, options);
|
|
|
|
|
|
|
|
this.api = options.api;
|
|
|
|
this.handler = options.handler;
|
|
|
|
this.props = options.props;
|
2020-10-15 07:32:46 +00:00
|
|
|
this.type = options.type || 0; // 0 - TOC, 1 - TOF
|
2018-01-18 08:58:24 +00:00
|
|
|
this.startLevel = 1;
|
|
|
|
this.endLevel = 3;
|
2018-01-22 08:42:46 +00:00
|
|
|
this._noApply = true;
|
|
|
|
this._originalProps = null;
|
2017-12-26 14:31:14 +00:00
|
|
|
|
|
|
|
Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options);
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
|
|
|
Common.Views.AdvancedSettingsWindow.prototype.render.call(this);
|
|
|
|
var me = this;
|
|
|
|
|
|
|
|
this.chPages = new Common.UI.CheckBox({
|
|
|
|
el: $('#tableofcontents-chb-pages'),
|
|
|
|
labelText: this.strShowPages,
|
|
|
|
value: 'checked'
|
|
|
|
});
|
|
|
|
this.chPages.on('change', _.bind(function(field, newValue, oldValue, eOpts){
|
2020-10-22 12:47:17 +00:00
|
|
|
var checked = (field.getValue()=='checked'),
|
|
|
|
centered = (this.type==1) && (this.cmbStyles.getValue()==Asc.c_oAscTOFStylesType.Centered);
|
|
|
|
this.chAlign.setDisabled(!checked || centered);
|
|
|
|
this.cmbLeader.setDisabled(!checked || centered);
|
2018-01-22 08:42:46 +00:00
|
|
|
if (this.api && !this._noApply) {
|
|
|
|
var properties = (this._originalProps) ? this._originalProps : new Asc.CTableOfContentsPr();
|
|
|
|
properties.put_ShowPageNumbers(checked);
|
2020-10-22 12:47:17 +00:00
|
|
|
if (checked && !centered) {
|
2018-01-22 08:42:46 +00:00
|
|
|
properties.put_RightAlignTab(this.chAlign.getValue() == 'checked');
|
|
|
|
properties.put_TabLeader(this.cmbLeader.getValue());
|
|
|
|
}
|
2020-10-15 11:39:44 +00:00
|
|
|
(this.type==1) ? this.api.SetDrawImagePlaceTableOfFigures('tableofcontents-img', properties) : this.api.SetDrawImagePlaceContents('tableofcontents-img', properties);
|
2018-03-01 13:58:33 +00:00
|
|
|
this.scrollerY.update();
|
2017-12-26 14:31:14 +00:00
|
|
|
}
|
|
|
|
}, this));
|
|
|
|
|
|
|
|
this.chAlign = new Common.UI.CheckBox({
|
|
|
|
el: $('#tableofcontents-chb-align'),
|
|
|
|
labelText: this.strAlign,
|
|
|
|
value: 'checked'
|
|
|
|
});
|
2018-01-22 08:42:46 +00:00
|
|
|
this.chAlign.on('change', _.bind(function(field, newValue, oldValue, eOpts){
|
|
|
|
var checked = (field.getValue()=='checked');
|
|
|
|
this.cmbLeader.setDisabled(!checked);
|
|
|
|
if (this.api && !this._noApply) {
|
|
|
|
var properties = (this._originalProps) ? this._originalProps : new Asc.CTableOfContentsPr();
|
|
|
|
properties.put_RightAlignTab(checked);
|
|
|
|
if (checked) {
|
|
|
|
properties.put_TabLeader(this.cmbLeader.getValue());
|
|
|
|
}
|
2020-10-15 11:39:44 +00:00
|
|
|
(this.type==1) ? this.api.SetDrawImagePlaceTableOfFigures('tableofcontents-img', properties) : this.api.SetDrawImagePlaceContents('tableofcontents-img', properties);
|
2018-03-01 13:58:33 +00:00
|
|
|
this.scrollerY.update();
|
2018-01-22 08:42:46 +00:00
|
|
|
}
|
|
|
|
}, this));
|
2017-12-26 14:31:14 +00:00
|
|
|
|
|
|
|
this.cmbLeader = new Common.UI.ComboBox({
|
|
|
|
el : $('#tableofcontents-combo-leader'),
|
|
|
|
style : 'width: 85px;',
|
|
|
|
menuStyle : 'min-width: 85px;',
|
|
|
|
editable : false,
|
2021-04-13 13:54:53 +00:00
|
|
|
takeFocusOnClose: true,
|
2017-12-26 14:31:14 +00:00
|
|
|
cls : 'input-group-nr',
|
|
|
|
data : [
|
|
|
|
{ value: Asc.c_oAscTabLeader.None, displayValue: this.textNone },
|
|
|
|
{ value: Asc.c_oAscTabLeader.Dot, displayValue: '....................' },
|
|
|
|
{ value: Asc.c_oAscTabLeader.Hyphen, displayValue: '-----------------' },
|
|
|
|
{ value: Asc.c_oAscTabLeader.Underscore,displayValue: '__________' }
|
|
|
|
]
|
|
|
|
});
|
2018-01-17 09:32:12 +00:00
|
|
|
this.cmbLeader.setValue(Asc.c_oAscTabLeader.Dot);
|
2018-01-22 08:42:46 +00:00
|
|
|
this.cmbLeader.on('selected', _.bind(function(combo, record) {
|
|
|
|
if (this.api && !this._noApply) {
|
|
|
|
var properties = (this._originalProps) ? this._originalProps : new Asc.CTableOfContentsPr();
|
|
|
|
properties.put_TabLeader(record.value);
|
2020-10-15 11:39:44 +00:00
|
|
|
(this.type==1) ? this.api.SetDrawImagePlaceTableOfFigures('tableofcontents-img', properties) : this.api.SetDrawImagePlaceContents('tableofcontents-img', properties);
|
2018-03-01 13:58:33 +00:00
|
|
|
this.scrollerY.update();
|
2018-01-22 08:42:46 +00:00
|
|
|
}
|
|
|
|
}, this));
|
2017-12-26 14:31:14 +00:00
|
|
|
|
|
|
|
this.chLinks = new Common.UI.CheckBox({
|
|
|
|
el: $('#tableofcontents-chb-links'),
|
2021-02-08 15:31:00 +00:00
|
|
|
labelText: (this.type==1) ? this.strLinksOF : this.strLinks,
|
2018-01-22 08:42:46 +00:00
|
|
|
value: 'checked'
|
2017-12-26 14:31:14 +00:00
|
|
|
});
|
|
|
|
this.chLinks.on('change', _.bind(function(field, newValue, oldValue, eOpts){
|
2018-01-22 08:42:46 +00:00
|
|
|
if (this.api && !this._noApply) {
|
|
|
|
var properties = (this._originalProps) ? this._originalProps : new Asc.CTableOfContentsPr();
|
|
|
|
properties.put_Hyperlink(field.getValue()=='checked');
|
2020-10-15 11:39:44 +00:00
|
|
|
(this.type==1) ? this.api.SetDrawImagePlaceTableOfFigures('tableofcontents-img', properties) : this.api.SetDrawImagePlaceContents('tableofcontents-img', properties);
|
2018-03-01 13:58:33 +00:00
|
|
|
this.scrollerY.update();
|
2018-01-22 08:42:46 +00:00
|
|
|
}
|
2017-12-26 14:31:14 +00:00
|
|
|
}, this));
|
|
|
|
|
2020-10-15 07:32:46 +00:00
|
|
|
if (this.type==1) {
|
|
|
|
this.radioCaption = new Common.UI.RadioBox({
|
|
|
|
el: $('#tableofcontents-radio-caption'),
|
|
|
|
labelText: this.textRadioCaption,
|
|
|
|
name: 'asc-radio-content-tof-build',
|
|
|
|
checked: true
|
|
|
|
});
|
|
|
|
this.radioCaption.on('change', _.bind(function(field, newValue, eOpts) {
|
|
|
|
if (newValue) {
|
|
|
|
this.captionContainer.toggleClass('hidden', !newValue);
|
|
|
|
this.styleContainer.toggleClass('hidden', newValue);
|
|
|
|
this.changeCaption(this.cmbCaptions.getSelectedRecord());
|
|
|
|
this.disableButtons();
|
|
|
|
}
|
|
|
|
}, this));
|
2017-12-26 14:31:14 +00:00
|
|
|
|
2020-10-15 07:32:46 +00:00
|
|
|
this.radioStyle = new Common.UI.RadioBox({
|
|
|
|
el: $('#tableofcontents-radio-style'),
|
|
|
|
labelText: this.textRadioStyle,
|
|
|
|
name: 'asc-radio-content-tof-build'
|
|
|
|
});
|
|
|
|
this.radioStyle.on('change', _.bind(function(field, newValue, eOpts) {
|
|
|
|
if (newValue) {
|
|
|
|
this.styleContainer.toggleClass('hidden', !newValue);
|
|
|
|
this.captionContainer.toggleClass('hidden', newValue);
|
|
|
|
this.changeTOFStyle(this.cmbTOFStyles.getSelectedRecord());
|
|
|
|
this.disableButtons();
|
|
|
|
}
|
|
|
|
}, this));
|
|
|
|
|
|
|
|
this.cmbCaptions = new Common.UI.ComboBox({
|
|
|
|
el: $('#tableofcontents-combo-captions'),
|
|
|
|
cls: 'input-group-nr',
|
|
|
|
menuStyle: 'min-width: 100%;max-height: 233px;',
|
|
|
|
editable: false,
|
2021-04-13 13:54:53 +00:00
|
|
|
takeFocusOnClose: true,
|
2020-10-15 07:32:46 +00:00
|
|
|
data: []
|
|
|
|
});
|
|
|
|
this.cmbCaptions.on('selected', _.bind(function(combo, record) {
|
|
|
|
this.changeCaption(record);
|
|
|
|
this.disableButtons();
|
|
|
|
}, this));
|
|
|
|
|
|
|
|
this.cmbTOFStyles = new Common.UI.ComboBox({
|
|
|
|
el: $('#tableofcontents-combo-tof-styles'),
|
|
|
|
cls: 'input-group-nr',
|
|
|
|
menuStyle: 'min-width: 100%;max-height: 233px;',
|
|
|
|
editable: false,
|
2021-04-13 13:54:53 +00:00
|
|
|
takeFocusOnClose: true,
|
2020-10-15 07:32:46 +00:00
|
|
|
data: []
|
|
|
|
});
|
|
|
|
this.cmbTOFStyles.on('selected', _.bind(function(combo, record) {
|
|
|
|
this.changeTOFStyle(record);
|
|
|
|
}, this));
|
|
|
|
|
|
|
|
this.chFullCaption = new Common.UI.CheckBox({
|
|
|
|
el: $('#tableofcontents-chb-full-caption'),
|
|
|
|
labelText: this.strFullCaption,
|
|
|
|
value: 'checked'
|
|
|
|
});
|
|
|
|
this.chFullCaption.on('change', _.bind(function(field, newValue, oldValue, eOpts){
|
|
|
|
if (this.api && !this._noApply) {
|
|
|
|
var properties = (this._originalProps) ? this._originalProps : new Asc.CTableOfContentsPr();
|
|
|
|
properties.put_IncludeLabelAndNumber(field.getValue()=='checked');
|
2020-10-15 11:39:44 +00:00
|
|
|
this.api.SetDrawImagePlaceTableOfFigures('tableofcontents-img', properties);
|
2020-10-15 07:32:46 +00:00
|
|
|
this.scrollerY.update();
|
|
|
|
}
|
|
|
|
}, this));
|
|
|
|
|
|
|
|
this.captionContainer = $('#tableofcontents-tof-from-caption');
|
|
|
|
this.styleContainer = $('#tableofcontents-tof-from-style');
|
|
|
|
} else {
|
|
|
|
this.radioLevels = new Common.UI.RadioBox({
|
|
|
|
el: $('#tableofcontents-radio-levels'),
|
|
|
|
labelText: this.textRadioLevels,
|
|
|
|
name: 'asc-radio-content-build',
|
|
|
|
checked: true
|
|
|
|
});
|
|
|
|
this.radioLevels.on('change', _.bind(function(field, newValue, eOpts) {
|
|
|
|
if (newValue) {
|
|
|
|
this.levelsContainer.toggleClass('hidden', !newValue);
|
|
|
|
this.stylesContainer.toggleClass('hidden', newValue);
|
2021-09-02 20:26:46 +00:00
|
|
|
if (this._needUpdateOutlineLevels || this._forceUpdateOutlineLevels)
|
|
|
|
this.synchronizeLevelsFromStyles(true);
|
2020-10-15 07:32:46 +00:00
|
|
|
}
|
|
|
|
}, this));
|
|
|
|
|
|
|
|
this.radioStyles = new Common.UI.RadioBox({
|
|
|
|
el: $('#tableofcontents-radio-styles'),
|
|
|
|
labelText: this.textRadioStyles,
|
|
|
|
name: 'asc-radio-content-build'
|
|
|
|
});
|
|
|
|
this.radioStyles.on('change', _.bind(function(field, newValue, eOpts) {
|
|
|
|
if (newValue) {
|
|
|
|
this.stylesContainer.toggleClass('hidden', !newValue);
|
|
|
|
this.levelsContainer.toggleClass('hidden', newValue);
|
|
|
|
if (this._needUpdateStyles)
|
|
|
|
this.synchronizeLevelsFromOutline();
|
|
|
|
this.stylesList.scroller.update({alwaysVisibleY: true});
|
|
|
|
setTimeout(function(){
|
|
|
|
var rec = me.stylesLevels.findWhere({checked: true});
|
|
|
|
if (rec)
|
|
|
|
me.stylesList.scrollToRecord(rec);
|
|
|
|
}, 10);
|
|
|
|
}
|
|
|
|
}, this));
|
|
|
|
this.spnLevels = new Common.UI.CustomSpinner({
|
|
|
|
el: $('#tableofcontents-spin-levels'),
|
|
|
|
step: 1,
|
|
|
|
width: 85,
|
|
|
|
defaultUnit : "",
|
|
|
|
value: this.endLevel,
|
|
|
|
maxValue: 9,
|
|
|
|
minValue: 1,
|
|
|
|
allowDecimal: false,
|
|
|
|
maskExp: /[1-9]/
|
|
|
|
});
|
2021-09-02 20:26:46 +00:00
|
|
|
this.spnLevels.on('change', _.bind(this.onLevelsChange, this));
|
2020-10-15 07:32:46 +00:00
|
|
|
|
|
|
|
this.stylesLevels = new Common.UI.DataViewStore();
|
|
|
|
|
|
|
|
if (this.stylesLevels) {
|
|
|
|
this.stylesList = new Common.UI.ListView({
|
|
|
|
el: $('#tableofcontents-styles-list', this.$window),
|
|
|
|
store: this.stylesLevels,
|
|
|
|
simpleAddMode: true,
|
|
|
|
showLast: false,
|
2021-04-13 13:54:53 +00:00
|
|
|
tabindex: 1,
|
2020-10-15 07:32:46 +00:00
|
|
|
template: _.template(['<div class="listview inner" style=""></div>'].join('')),
|
|
|
|
itemTemplate: _.template([
|
|
|
|
'<div id="<%= id %>" class="list-item">',
|
2021-02-02 11:30:07 +00:00
|
|
|
'<div class="<% if (checked) { %>checked<% } %>"><%= displayValue %></div>',
|
2020-10-15 07:32:46 +00:00
|
|
|
'<div>',
|
|
|
|
'<div class="input-field" style="width:40px;"><input type="text" class="form-control" value="<%= value %>" style="text-align: right;" maxLength="1">',
|
|
|
|
'</div>',
|
|
|
|
'</div>',
|
|
|
|
'</div>'
|
|
|
|
].join(''))
|
|
|
|
});
|
|
|
|
this.stylesList.on('item:change', _.bind(this.onItemChange, this));
|
|
|
|
this.stylesList.on('item:add', _.bind(this.addEvents, this));
|
2018-01-11 15:02:27 +00:00
|
|
|
}
|
2020-10-15 07:32:46 +00:00
|
|
|
|
|
|
|
this.levelsContainer = $('#tableofcontents-from-levels');
|
|
|
|
this.stylesContainer = $('#tableofcontents-from-styles');
|
|
|
|
}
|
2017-12-26 14:31:14 +00:00
|
|
|
|
2020-10-20 16:56:21 +00:00
|
|
|
var arr = (this.type==1) ? [
|
|
|
|
{ displayValue: this.txtCurrent, value: Asc.c_oAscTOFStylesType.Current },
|
|
|
|
{ displayValue: this.txtSimple, value: Asc.c_oAscTOFStylesType.Simple },
|
|
|
|
{ displayValue: this.txtOnline, value: Asc.c_oAscTOFStylesType.Web },
|
|
|
|
{ displayValue: this.txtClassic, value: Asc.c_oAscTOFStylesType.Classic },
|
|
|
|
{ displayValue: this.txtDistinctive, value: Asc.c_oAscTOFStylesType.Distinctive },
|
|
|
|
{ displayValue: this.txtCentered, value: Asc.c_oAscTOFStylesType.Centered },
|
|
|
|
{ displayValue: this.txtFormal, value: Asc.c_oAscTOFStylesType.Formal }
|
|
|
|
] : [
|
|
|
|
{ displayValue: this.txtCurrent, value: Asc.c_oAscTOCStylesType.Current },
|
|
|
|
{ displayValue: this.txtSimple, value: Asc.c_oAscTOCStylesType.Simple },
|
|
|
|
{ displayValue: this.txtOnline, value: Asc.c_oAscTOCStylesType.Web },
|
|
|
|
{ displayValue: this.txtStandard, value: Asc.c_oAscTOCStylesType.Standard },
|
|
|
|
{ displayValue: this.txtModern, value: Asc.c_oAscTOCStylesType.Modern },
|
|
|
|
{ displayValue: this.txtClassic, value: Asc.c_oAscTOCStylesType.Classic }
|
|
|
|
];
|
2017-12-26 14:31:14 +00:00
|
|
|
this.cmbStyles = new Common.UI.ComboBox({
|
|
|
|
el: $('#tableofcontents-combo-styles'),
|
|
|
|
cls: 'input-group-nr',
|
2018-08-15 12:12:05 +00:00
|
|
|
menuStyle: 'min-width: 95px;',
|
2017-12-26 14:31:14 +00:00
|
|
|
editable: false,
|
2021-04-13 13:54:53 +00:00
|
|
|
takeFocusOnClose: true,
|
2020-10-20 16:56:21 +00:00
|
|
|
data: arr
|
2017-12-26 14:31:14 +00:00
|
|
|
});
|
2020-10-20 16:56:21 +00:00
|
|
|
this.cmbStyles.setValue(this.type==1 ? Asc.c_oAscTOFStylesType.Current : Asc.c_oAscTOCStylesType.Current);
|
2018-01-22 08:42:46 +00:00
|
|
|
this.cmbStyles.on('selected', _.bind(function(combo, record) {
|
|
|
|
if (this.api && !this._noApply) {
|
|
|
|
var properties = (this._originalProps) ? this._originalProps : new Asc.CTableOfContentsPr();
|
|
|
|
properties.put_StylesType(record.value);
|
2020-10-22 12:47:17 +00:00
|
|
|
if (this.type==1) {
|
|
|
|
var checked = (record.value!==Asc.c_oAscTOFStylesType.Centered);
|
|
|
|
this.chAlign.setValue(checked, true);
|
|
|
|
this.chAlign.setDisabled(!checked);
|
|
|
|
this.cmbLeader.setDisabled(!checked);
|
|
|
|
properties.put_RightAlignTab(checked);
|
|
|
|
checked && properties.put_TabLeader(this.cmbLeader.getValue());
|
|
|
|
}
|
2020-10-15 11:39:44 +00:00
|
|
|
(this.type==1) ? this.api.SetDrawImagePlaceTableOfFigures('tableofcontents-img', properties) : this.api.SetDrawImagePlaceContents('tableofcontents-img', properties);
|
2018-03-01 13:58:33 +00:00
|
|
|
this.scrollerY.update();
|
2018-01-22 08:42:46 +00:00
|
|
|
}
|
|
|
|
}, this));
|
2017-12-26 14:31:14 +00:00
|
|
|
|
2018-03-01 13:58:33 +00:00
|
|
|
this.scrollerY = new Common.UI.Scroller({
|
|
|
|
el: this.$window.find('#tableofcontents-img').parent(),
|
|
|
|
minScrollbarLength : 20
|
|
|
|
});
|
|
|
|
this.scrollerY.update();
|
|
|
|
this.scrollerY.scrollTop(0);
|
|
|
|
|
2020-10-15 07:32:46 +00:00
|
|
|
this.btnOk = new Common.UI.Button({
|
|
|
|
el: this.$window.find('.primary')
|
|
|
|
});
|
|
|
|
|
2017-12-26 14:31:14 +00:00
|
|
|
this.afterRender();
|
|
|
|
},
|
|
|
|
|
2021-04-13 13:54:53 +00:00
|
|
|
getFocusedComponents: function() {
|
2021-04-14 15:16:27 +00:00
|
|
|
return [ this.chPages, this.chAlign, this.cmbLeader, this.chLinks, this.radioLevels, this.radioStyles, this.spnLevels, this.stylesList, this.cmbStyles,
|
|
|
|
this.radioCaption, this.radioStyle, this.cmbCaptions, this.cmbTOFStyles, this.chFullCaption];
|
2021-04-13 13:54:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
getDefaultFocusableComponent: function () {
|
|
|
|
return this.chPages;
|
2017-12-26 14:31:14 +00:00
|
|
|
},
|
|
|
|
|
2021-04-13 13:54:53 +00:00
|
|
|
afterRender: function() {
|
|
|
|
this._setDefaults(this.props);
|
2017-12-26 14:31:14 +00:00
|
|
|
},
|
|
|
|
|
2018-02-19 09:33:21 +00:00
|
|
|
close: function() {
|
2020-10-15 11:39:44 +00:00
|
|
|
(this.type==1) ? this.api.SetDrawImagePlaceTableOfFigures(null) : this.api.SetDrawImagePlaceContents(null);
|
2018-03-01 13:58:33 +00:00
|
|
|
this.scrollerY.update();
|
2018-02-19 09:33:21 +00:00
|
|
|
Common.Views.AdvancedSettingsWindow.prototype.close.apply(this);
|
|
|
|
},
|
|
|
|
|
2017-12-26 14:31:14 +00:00
|
|
|
_setDefaults: function (props) {
|
2018-01-22 08:42:46 +00:00
|
|
|
this._noApply = true;
|
|
|
|
|
2018-01-17 09:32:12 +00:00
|
|
|
if (props) {
|
|
|
|
var value = props.get_Hyperlink();
|
|
|
|
this.chLinks.setValue((value !== null && value !== undefined) ? value : 'indeterminate', true);
|
2018-01-19 11:47:26 +00:00
|
|
|
value = props.get_StylesType();
|
|
|
|
this.cmbStyles.setValue((value!==null) ? value : Asc.c_oAscTOCStylesType.Current);
|
2018-02-05 10:41:49 +00:00
|
|
|
value = props.get_ShowPageNumbers();
|
|
|
|
this.chPages.setValue((value !== null && value !== undefined) ? value : 'indeterminate');
|
|
|
|
if (this.chPages.getValue() == 'checked') {
|
|
|
|
value = props.get_RightAlignTab();
|
|
|
|
this.chAlign.setValue((value !== null && value !== undefined) ? value : 'indeterminate');
|
2018-09-06 10:15:01 +00:00
|
|
|
if (this.chAlign.getValue() == 'checked') {
|
|
|
|
value = props.get_TabLeader();
|
|
|
|
(value!==undefined) && this.cmbLeader.setValue(value);
|
|
|
|
}
|
2020-10-22 12:47:17 +00:00
|
|
|
} else {
|
|
|
|
(this.type==1) && (this.cmbStyles.getValue()==Asc.c_oAscTOFStylesType.Centered) && this.chAlign.setValue(false);
|
2018-02-05 10:41:49 +00:00
|
|
|
}
|
2020-10-15 07:32:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
(this.type==1) ? this.fillTOFProps(props) : this.fillTOCProps(props);
|
2018-01-17 09:32:12 +00:00
|
|
|
|
2020-10-15 07:32:46 +00:00
|
|
|
// Show Pages is always true when window is opened
|
|
|
|
this._originalProps = (props) ? props : new Asc.CTableOfContentsPr();
|
|
|
|
if (!props) {
|
|
|
|
if (this.type==1) {
|
|
|
|
this._originalProps.put_Caption(this.textFigure);
|
|
|
|
this._originalProps.put_IncludeLabelAndNumber(this.chFullCaption.getValue() == 'checked');
|
|
|
|
} else {
|
|
|
|
this._originalProps.put_OutlineRange(this.startLevel, this.endLevel);
|
|
|
|
}
|
|
|
|
this._originalProps.put_Hyperlink(this.chLinks.getValue() == 'checked');
|
|
|
|
this._originalProps.put_ShowPageNumbers(this.chPages.getValue() == 'checked');
|
|
|
|
if (this.chPages.getValue() == 'checked') {
|
|
|
|
this._originalProps.put_RightAlignTab(this.chAlign.getValue() == 'checked');
|
|
|
|
this._originalProps.put_TabLeader(this.cmbLeader.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-15 11:39:44 +00:00
|
|
|
(this.type==1) ? this.api.SetDrawImagePlaceTableOfFigures('tableofcontents-img', this._originalProps) : this.api.SetDrawImagePlaceContents('tableofcontents-img', this._originalProps);
|
2020-10-15 07:32:46 +00:00
|
|
|
this.scrollerY.update();
|
|
|
|
|
|
|
|
this._noApply = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
fillTOCProps: function(props) {
|
|
|
|
var me = this,
|
|
|
|
docStyles = this.api.asc_GetStylesArray(),
|
|
|
|
styles = [],
|
|
|
|
checkStyles = false;
|
|
|
|
_.each(docStyles, function (style) {
|
|
|
|
var name = style.get_Name(),
|
|
|
|
level = me.api.asc_GetHeadingLevel(name);
|
|
|
|
if (style.get_QFormat() || level>=0) {
|
|
|
|
styles.push({
|
|
|
|
name: name,
|
2021-02-02 11:30:07 +00:00
|
|
|
displayValue: style.get_TranslatedName(),
|
2020-10-15 07:32:46 +00:00
|
|
|
allowSelected: false,
|
|
|
|
checked: false,
|
|
|
|
value: '',
|
|
|
|
headerLevel: (level>=0) ? level+1 : -1 // -1 if is not header
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (props) {
|
2018-01-17 09:32:12 +00:00
|
|
|
var start = props.get_OutlineStart(),
|
2018-01-18 08:58:24 +00:00
|
|
|
end = props.get_OutlineEnd(),
|
|
|
|
count = props.get_StylesCount();
|
|
|
|
|
|
|
|
this.startLevel = start;
|
|
|
|
this.endLevel = end;
|
2018-01-17 09:32:12 +00:00
|
|
|
|
2018-01-18 08:58:24 +00:00
|
|
|
if ((start<0 || end<0) && count<1) {
|
|
|
|
start = 1;
|
|
|
|
end = 9;
|
|
|
|
this.spnLevels.setValue(end, true);
|
|
|
|
}
|
2018-01-17 09:32:12 +00:00
|
|
|
|
2018-01-18 08:58:24 +00:00
|
|
|
var disable_outlines = false;
|
2018-01-17 09:32:12 +00:00
|
|
|
for (var i=0; i<count; i++) {
|
|
|
|
var style = props.get_StyleName(i),
|
|
|
|
level = props.get_StyleLevel(i),
|
|
|
|
rec = _.findWhere(styles, {name: style});
|
|
|
|
if (rec) {
|
2018-01-18 08:58:24 +00:00
|
|
|
rec.checked = true;
|
|
|
|
rec.value = level;
|
|
|
|
if (rec.headerLevel !== level)
|
|
|
|
disable_outlines = true;
|
2018-01-17 09:32:12 +00:00
|
|
|
} else {
|
2018-01-18 08:58:24 +00:00
|
|
|
styles.push({
|
2018-01-17 09:32:12 +00:00
|
|
|
name: style,
|
2021-02-02 11:30:07 +00:00
|
|
|
displayValue: style,
|
2018-01-17 09:32:12 +00:00
|
|
|
allowSelected: false,
|
|
|
|
checked: true,
|
2018-01-18 08:58:24 +00:00
|
|
|
value: level,
|
|
|
|
headerLevel: -1
|
|
|
|
});
|
|
|
|
disable_outlines = true;
|
2018-01-17 09:32:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-18 08:58:24 +00:00
|
|
|
if (start>0 && end>0) {
|
|
|
|
for (var i=start; i<=end; i++) {
|
|
|
|
var rec = _.findWhere(styles, {headerLevel: i});
|
|
|
|
if (rec) {
|
|
|
|
rec.checked = true;
|
|
|
|
rec.value = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var new_start = -1, new_end = -1, empty_index = -1;
|
|
|
|
for (var i=0; i<9; i++) {
|
|
|
|
var rec = _.findWhere(styles, {headerLevel: i+1});
|
|
|
|
if (rec) {
|
|
|
|
var headerLevel = rec.headerLevel,
|
|
|
|
level = rec.value;
|
|
|
|
if (headerLevel == level) {
|
|
|
|
if (empty_index<1) {
|
|
|
|
if (new_start<1)
|
|
|
|
new_start = level;
|
|
|
|
new_end = level;
|
|
|
|
} else {
|
|
|
|
new_start = new_end = -1;
|
|
|
|
disable_outlines = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else if (!rec.checked) {
|
|
|
|
(new_start>0) && (empty_index = i+1);
|
|
|
|
} else {
|
|
|
|
new_start = new_end = -1;
|
|
|
|
disable_outlines = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.spnLevels.setValue(new_end>0 ? new_end : '', true);
|
2018-03-16 15:27:07 +00:00
|
|
|
checkStyles = (disable_outlines || new_start>1);
|
2018-02-28 11:40:28 +00:00
|
|
|
} else {
|
|
|
|
for (var i=this.startLevel; i<=this.endLevel; i++) {
|
|
|
|
var rec = _.findWhere(styles, {headerLevel: i});
|
|
|
|
if (rec) {
|
|
|
|
rec.checked = true;
|
|
|
|
rec.value = i;
|
|
|
|
}
|
|
|
|
}
|
2018-01-17 09:32:12 +00:00
|
|
|
}
|
2018-03-15 14:57:36 +00:00
|
|
|
styles.sort(function(a, b){
|
2021-02-02 11:30:07 +00:00
|
|
|
var aname = a.displayValue.toLocaleLowerCase(),
|
|
|
|
bname = b.displayValue.toLocaleLowerCase();
|
2018-03-15 14:57:36 +00:00
|
|
|
if (aname < bname) return -1;
|
|
|
|
if (aname > bname) return 1;
|
|
|
|
return 0;
|
|
|
|
});
|
2018-01-17 09:32:12 +00:00
|
|
|
this.stylesLevels.reset(styles);
|
2018-03-16 15:27:07 +00:00
|
|
|
if (checkStyles) {
|
2021-09-02 20:26:46 +00:00
|
|
|
this._forceUpdateOutlineLevels = true;
|
2018-01-18 08:58:24 +00:00
|
|
|
this.radioStyles.setValue(true);
|
2018-01-23 11:35:35 +00:00
|
|
|
this.stylesList.scroller.update({alwaysVisibleY: true});
|
|
|
|
var rec = this.stylesLevels.findWhere({checked: true});
|
|
|
|
if (rec)
|
|
|
|
this.stylesList.scrollToRecord(rec);
|
|
|
|
}
|
2020-10-15 07:32:46 +00:00
|
|
|
},
|
2018-01-11 15:02:27 +00:00
|
|
|
|
2020-10-15 07:32:46 +00:00
|
|
|
fillTOFProps: function(props) {
|
|
|
|
var me = this,
|
|
|
|
isCaption = true;
|
|
|
|
var arr = Common.Utils.InternalSettings.get("de-settings-captions");
|
|
|
|
if (arr==null || arr==undefined) {
|
|
|
|
arr = Common.localStorage.getItem("de-settings-captions") || '';
|
|
|
|
Common.Utils.InternalSettings.set("de-settings-captions", arr);
|
|
|
|
}
|
|
|
|
arr = arr ? JSON.parse(arr) : [];
|
|
|
|
|
|
|
|
// 0 - not removable
|
|
|
|
arr = arr.concat([{ value: this.textEquation, displayValue: this.textEquation },
|
|
|
|
{ value: this.textFigure, displayValue: this.textFigure },
|
|
|
|
{ value: this.textTable, displayValue: this.textTable }
|
|
|
|
]);
|
|
|
|
arr.sort(function(a,b){
|
|
|
|
var sa = a.displayValue.toLowerCase(),
|
|
|
|
sb = b.displayValue.toLowerCase();
|
|
|
|
return sa>sb ? 1 : (sa<sb ? -1 : 0);
|
|
|
|
});
|
|
|
|
arr = [{ value: null, displayValue: this.textNone }].concat(arr);
|
|
|
|
this.cmbCaptions.setData(arr);
|
|
|
|
var value;
|
|
|
|
if (props) {
|
|
|
|
isCaption = !!props.get_Caption();
|
|
|
|
var rec = this.cmbCaptions.store.findWhere({value: props.get_Caption()});
|
|
|
|
rec && (value = rec.get('value'));
|
|
|
|
}
|
|
|
|
(arr.length>0) && this.cmbCaptions.setValue(value ? value : this.textFigure);
|
|
|
|
|
|
|
|
arr = [];
|
|
|
|
_.each(this.api.asc_getAllUsedParagraphStyles(), function (style, index) {
|
|
|
|
arr.push({
|
2021-02-02 11:30:07 +00:00
|
|
|
displayValue: style.get_TranslatedName(),
|
|
|
|
styleName: style.get_Name(),
|
2020-10-15 07:38:12 +00:00
|
|
|
value: index
|
2020-10-15 07:32:46 +00:00
|
|
|
});
|
|
|
|
});
|
2021-02-02 11:30:07 +00:00
|
|
|
arr.sort(function(a, b){
|
|
|
|
var aname = a.displayValue.toLocaleLowerCase(),
|
|
|
|
bname = b.displayValue.toLocaleLowerCase();
|
|
|
|
if (aname < bname) return -1;
|
|
|
|
if (aname > bname) return 1;
|
|
|
|
return 0;
|
|
|
|
});
|
2020-10-15 07:32:46 +00:00
|
|
|
this.cmbTOFStyles.setData(arr);
|
|
|
|
value = undefined;
|
|
|
|
if (props) {
|
|
|
|
var count = props.get_StylesCount();
|
|
|
|
if (count>0) {
|
2021-02-02 11:30:07 +00:00
|
|
|
var rec = this.cmbTOFStyles.store.findWhere({styleName: props.get_StyleName(0)});
|
2020-10-15 07:32:46 +00:00
|
|
|
rec && (value = rec.get('value'));
|
2018-02-05 10:41:49 +00:00
|
|
|
}
|
2018-01-22 08:42:46 +00:00
|
|
|
}
|
2020-10-15 07:32:46 +00:00
|
|
|
(arr.length>0) && this.cmbTOFStyles.setValue(value ? value : arr[0].value);
|
2018-01-22 08:42:46 +00:00
|
|
|
|
2020-10-15 07:32:46 +00:00
|
|
|
if (props) {
|
|
|
|
value = props.get_IncludeLabelAndNumber();
|
|
|
|
this.chFullCaption.setValue((value !== null && value !== undefined) ? value : 'indeterminate', true);
|
|
|
|
}
|
|
|
|
!isCaption && this.radioStyle.setValue(true);
|
2017-12-26 14:31:14 +00:00
|
|
|
},
|
|
|
|
|
2018-01-18 08:58:24 +00:00
|
|
|
synchronizeLevelsFromOutline: function() {
|
|
|
|
var start = 1, end = this.spnLevels.getNumberValue();
|
|
|
|
this.stylesLevels.each(function (style) {
|
|
|
|
var header = style.get('headerLevel');
|
|
|
|
if (header>=start && header<=end) {
|
|
|
|
style.set('checked', true);
|
|
|
|
style.set('value', header);
|
|
|
|
} else {
|
|
|
|
style.set('checked', false);
|
|
|
|
style.set('value', '');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
this._needUpdateStyles = false;
|
|
|
|
},
|
|
|
|
|
2021-09-02 20:26:46 +00:00
|
|
|
synchronizeLevelsFromStyles: function(reset) {
|
2018-01-18 08:58:24 +00:00
|
|
|
var new_start = -1, new_end = -1, empty_index = -1,
|
|
|
|
disable_outlines = false;
|
|
|
|
|
|
|
|
for (var i=0; i<9; i++) {
|
|
|
|
var rec = this.stylesLevels.findWhere({headerLevel: i+1});
|
|
|
|
if (rec) {
|
|
|
|
var headerLevel = rec.get('headerLevel'),
|
|
|
|
level = rec.get('value');
|
|
|
|
if (headerLevel == level) {
|
|
|
|
if (empty_index<1) {
|
|
|
|
if (new_start<1)
|
|
|
|
new_start = level;
|
|
|
|
new_end = level;
|
|
|
|
} else {
|
|
|
|
new_start = new_end = -1;
|
|
|
|
disable_outlines = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else if (!rec.get('checked')) {
|
|
|
|
(new_start>0) && (empty_index = i+1);
|
|
|
|
} else {
|
|
|
|
new_start = new_end = -1;
|
|
|
|
disable_outlines = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (new_start<0 && new_end<0) {
|
|
|
|
var rec = this.stylesLevels.findWhere({checked: true});
|
|
|
|
if (rec) { // has checked style
|
|
|
|
disable_outlines = true;
|
|
|
|
} else { // all levels are empty
|
|
|
|
new_start = 1;
|
|
|
|
new_end = 9;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.startLevel = new_start;
|
|
|
|
this.endLevel = new_end;
|
|
|
|
|
2021-09-02 20:26:46 +00:00
|
|
|
this.spnLevels.setValue(new_end>0 ? new_end : (reset ? 9 : ''), true);
|
|
|
|
reset && (new_end<=0) && this.onLevelsChange(this.spnLevels);
|
2018-01-18 08:58:24 +00:00
|
|
|
this._needUpdateOutlineLevels = false;
|
2021-09-02 20:26:46 +00:00
|
|
|
this._forceUpdateOutlineLevels = false;
|
2018-01-18 08:58:24 +00:00
|
|
|
},
|
|
|
|
|
2017-12-26 14:31:14 +00:00
|
|
|
getSettings: function () {
|
2018-03-15 13:05:38 +00:00
|
|
|
var props = this._originalProps;
|
2018-01-18 08:58:24 +00:00
|
|
|
|
|
|
|
props.put_Hyperlink(this.chLinks.getValue() == 'checked');
|
|
|
|
props.put_ShowPageNumbers(this.chPages.getValue() == 'checked');
|
2018-01-19 12:20:45 +00:00
|
|
|
if (this.chPages.getValue() == 'checked') {
|
2018-01-18 08:58:24 +00:00
|
|
|
props.put_RightAlignTab(this.chAlign.getValue() == 'checked');
|
2018-01-19 12:20:45 +00:00
|
|
|
props.put_TabLeader(this.cmbLeader.getValue());
|
|
|
|
}
|
2018-01-19 11:47:26 +00:00
|
|
|
props.put_StylesType(this.cmbStyles.getValue());
|
2018-01-18 08:58:24 +00:00
|
|
|
|
|
|
|
props.clear_Styles();
|
2020-10-15 07:32:46 +00:00
|
|
|
if (this.type==1) {
|
|
|
|
if (this.radioCaption.getValue()) {
|
|
|
|
props.put_Caption(this.cmbCaptions.getValue());
|
|
|
|
} else {
|
|
|
|
props.put_Caption(null);
|
|
|
|
var rec = this.cmbTOFStyles.getSelectedRecord();
|
2021-02-02 11:30:07 +00:00
|
|
|
rec && props.add_Style(rec.styleName);
|
2020-10-15 07:32:46 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (this._needUpdateOutlineLevels) {
|
|
|
|
this.synchronizeLevelsFromStyles();
|
|
|
|
}
|
|
|
|
if (!this._needUpdateStyles) // if this._needUpdateStyles==true - fill only OutlineRange
|
|
|
|
this.stylesLevels.each(function (style) {
|
|
|
|
if (style.get('checked'))
|
|
|
|
props.add_Style(style.get('name'), style.get('value'));
|
|
|
|
});
|
|
|
|
props.put_OutlineRange(this.startLevel, this.endLevel);
|
2018-01-18 08:58:24 +00:00
|
|
|
}
|
2017-12-26 14:31:14 +00:00
|
|
|
return props;
|
|
|
|
},
|
|
|
|
|
2018-01-11 15:02:27 +00:00
|
|
|
addEvents: function(listView, itemView, record) {
|
2018-01-18 08:58:24 +00:00
|
|
|
var input = itemView.$el.find('input'),
|
|
|
|
me = this;
|
2018-01-11 15:02:27 +00:00
|
|
|
input.on('keypress', function(e) {
|
|
|
|
var charCode = String.fromCharCode(e.which);
|
2018-11-30 14:04:47 +00:00
|
|
|
if(!/[1-9]/.test(charCode) && !e.ctrlKey){
|
2018-01-11 15:02:27 +00:00
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
input.on('input', function(e) {
|
|
|
|
// console.log(input.val());
|
2018-01-19 11:47:26 +00:00
|
|
|
var isEmpty = _.isEmpty(input.val());
|
|
|
|
if (record.get('checked') !== !isEmpty) {
|
|
|
|
record.set('checked', !isEmpty);
|
2018-01-11 15:02:27 +00:00
|
|
|
}
|
2018-01-19 11:47:26 +00:00
|
|
|
record.set('value', (isEmpty) ? '' : parseInt(input.val()));
|
2018-01-18 08:58:24 +00:00
|
|
|
me._needUpdateOutlineLevels = true;
|
2018-01-22 08:42:46 +00:00
|
|
|
|
|
|
|
if (me.api && !me._noApply) {
|
|
|
|
var properties = (me._originalProps) ? me._originalProps : new Asc.CTableOfContentsPr();
|
|
|
|
properties.clear_Styles();
|
|
|
|
me.stylesLevels.each(function (style) {
|
|
|
|
if (style.get('checked'))
|
|
|
|
properties.add_Style(style.get('name'), style.get('value'));
|
|
|
|
});
|
|
|
|
if (properties.get_StylesCount()>0)
|
|
|
|
properties.put_OutlineRange(-1, -1);
|
|
|
|
else
|
|
|
|
properties.put_OutlineRange(1, 9);
|
2018-02-28 11:40:28 +00:00
|
|
|
me.api.SetDrawImagePlaceContents('tableofcontents-img', properties);
|
2018-03-05 07:37:30 +00:00
|
|
|
me.scrollerY.update();
|
2018-01-22 08:42:46 +00:00
|
|
|
}
|
|
|
|
|
2018-01-11 15:02:27 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
onItemChange: function(listView, itemView, record) {
|
|
|
|
this.addEvents(listView, itemView, record);
|
2018-03-23 09:09:09 +00:00
|
|
|
var inp = itemView.$el.find('input');
|
2018-01-11 15:02:27 +00:00
|
|
|
setTimeout(function(){
|
2018-03-23 09:09:09 +00:00
|
|
|
inp.focus();
|
|
|
|
inp[0].selectionStart = inp[0].selectionEnd = inp[0].value.length;
|
2018-01-11 15:02:27 +00:00
|
|
|
}, 10);
|
|
|
|
},
|
|
|
|
|
2020-10-15 07:32:46 +00:00
|
|
|
changeCaption: function(record) {
|
|
|
|
if (this.api && !this._noApply && record) {
|
|
|
|
var properties = (this._originalProps) ? this._originalProps : new Asc.CTableOfContentsPr();
|
|
|
|
properties.put_Caption(record.value);
|
|
|
|
properties.clear_Styles();
|
2020-10-15 11:39:44 +00:00
|
|
|
this.api.SetDrawImagePlaceTableOfFigures('tableofcontents-img', properties);
|
2020-10-15 07:32:46 +00:00
|
|
|
this.scrollerY.update();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
changeTOFStyle: function(record) {
|
|
|
|
if (this.api && !this._noApply) {
|
|
|
|
var properties = (this._originalProps) ? this._originalProps : new Asc.CTableOfContentsPr();
|
|
|
|
properties.put_Caption(null);
|
|
|
|
properties.clear_Styles();
|
2021-02-02 11:30:07 +00:00
|
|
|
properties.add_Style(record.styleName);
|
2020-10-15 11:39:44 +00:00
|
|
|
this.api.SetDrawImagePlaceTableOfFigures('tableofcontents-img', properties);
|
2021-09-02 20:26:46 +00:00
|
|
|
this.scrollerY.update();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onLevelsChange: function(field, newValue, oldValue, eOpts){
|
|
|
|
this._needUpdateStyles = true;
|
|
|
|
this.startLevel = 1;
|
|
|
|
this.endLevel = field.getNumberValue();
|
|
|
|
|
|
|
|
if (this.api && !this._noApply) {
|
|
|
|
var properties = (this._originalProps) ? this._originalProps : new Asc.CTableOfContentsPr();
|
|
|
|
properties.clear_Styles();
|
|
|
|
properties.put_OutlineRange(this.startLevel, this.endLevel);
|
|
|
|
this.api.SetDrawImagePlaceContents('tableofcontents-img', properties);
|
2020-10-15 07:32:46 +00:00
|
|
|
this.scrollerY.update();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
disableButtons: function() {
|
|
|
|
this.type && this.btnOk.setDisabled(this.radioCaption.getValue() && this.cmbCaptions.getValue()===null || this.radioStyle.getValue() && this.cmbTOFStyles.length<1);
|
|
|
|
},
|
|
|
|
|
|
|
|
onDlgBtnClick: function(event) {
|
|
|
|
this._handleInput(event.currentTarget.attributes['result'].value);
|
|
|
|
},
|
|
|
|
|
|
|
|
onPrimary: function() {
|
|
|
|
this._handleInput('ok');
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
|
|
|
_handleInput: function(state) {
|
|
|
|
if (this.handler) {
|
|
|
|
if (state == 'ok' && this.btnOk.isDisabled()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.handler.call(this, state, this.getSettings());
|
|
|
|
}
|
|
|
|
|
|
|
|
this.close();
|
|
|
|
},
|
|
|
|
|
2017-12-26 14:31:14 +00:00
|
|
|
textTitle: 'Table of Contents',
|
|
|
|
textLeader: 'Leader',
|
|
|
|
textBuildTable: 'Build table of contents from',
|
|
|
|
textLevels: 'Levels',
|
|
|
|
textStyles: 'Styles',
|
|
|
|
strShowPages: 'Show page numbers',
|
|
|
|
strAlign: 'Right align page numbers',
|
2018-01-15 14:25:18 +00:00
|
|
|
strLinks: 'Format Table of Contents as links',
|
2017-12-26 14:31:14 +00:00
|
|
|
textNone: 'None',
|
|
|
|
textRadioLevels: 'Outline levels',
|
|
|
|
textRadioStyles: 'Selected styles',
|
2018-01-11 15:02:27 +00:00
|
|
|
textStyle: 'Style',
|
|
|
|
textLevel: 'Level',
|
|
|
|
txtCurrent: 'Current',
|
|
|
|
txtSimple: 'Simple',
|
|
|
|
txtStandard: 'Standard',
|
|
|
|
txtModern: 'Modern',
|
2020-02-06 12:49:17 +00:00
|
|
|
txtClassic: 'Classic',
|
2020-10-15 07:32:46 +00:00
|
|
|
txtOnline: 'Online',
|
|
|
|
textTitleTOF: 'Table of Figures',
|
|
|
|
textBuildTableOF: 'Build table of figures from',
|
|
|
|
textRadioCaption: 'Caption',
|
|
|
|
textRadioStyle: 'Style',
|
|
|
|
strFullCaption: 'Include label and number',
|
|
|
|
textEquation: 'Equation',
|
|
|
|
textFigure: 'Figure',
|
2020-10-20 16:56:21 +00:00
|
|
|
textTable: 'Table',
|
|
|
|
txtDistinctive: 'Distinctive',
|
|
|
|
txtCentered: 'Centered',
|
2021-02-08 15:31:00 +00:00
|
|
|
txtFormal: 'Formal',
|
|
|
|
strLinksOF: 'Format table of figures as links'
|
2017-12-26 14:31:14 +00:00
|
|
|
|
|
|
|
}, DE.Views.TableOfContentsSettings || {}))
|
|
|
|
});
|