2020-09-22 13:48:45 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* (c) Copyright Ascensio System SIA 2010-2020
|
|
|
|
*
|
|
|
|
* This program is a free software product. You can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
|
|
|
* version 3 as published by the Free Software Foundation. In accordance with
|
|
|
|
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
|
|
|
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
|
|
|
* of any third-party rights.
|
|
|
|
*
|
|
|
|
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
|
|
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
|
|
|
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
|
|
|
*
|
|
|
|
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
|
|
|
|
* street, Riga, Latvia, EU, LV-1050.
|
|
|
|
*
|
|
|
|
* The interactive user interfaces in modified source and object code versions
|
|
|
|
* of the Program must display Appropriate Legal Notices, as required under
|
|
|
|
* Section 5 of the GNU AGPL version 3.
|
|
|
|
*
|
|
|
|
* Pursuant to Section 7(b) of the License you must retain the original Product
|
|
|
|
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
|
|
|
* grant you any rights under trademark law for use of our trademarks.
|
|
|
|
*
|
|
|
|
* All the Product's GUI elements, including illustrations and icon sets, as
|
|
|
|
* well as technical writing content are licensed under the terms of the
|
|
|
|
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
|
|
|
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CrossReferenceDialog.js
|
|
|
|
*
|
|
|
|
* Created by Julia Radzhabova on 22.09.2020
|
|
|
|
* Copyright (c) 2020 Ascensio System SIA. All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
define([
|
|
|
|
'common/main/lib/component/Window',
|
|
|
|
'common/main/lib/component/ComboBox'
|
|
|
|
], function () { 'use strict';
|
|
|
|
|
|
|
|
DE.Views.CrossReferenceDialog = Common.UI.Window.extend(_.extend({
|
|
|
|
options: {
|
|
|
|
width: 400,
|
2020-09-23 14:45:44 +00:00
|
|
|
height: 407,
|
2020-09-22 13:48:45 +00:00
|
|
|
style: 'min-width: 240px;',
|
2020-09-23 14:36:27 +00:00
|
|
|
cls: 'modal-dlg',
|
|
|
|
modal: false
|
2020-09-22 13:48:45 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
initialize : function(options) {
|
|
|
|
_.extend(this.options, {
|
|
|
|
title: this.txtTitle,
|
|
|
|
buttons: [{value: 'ok', caption: this.textInsert}, 'close']
|
|
|
|
}, options || {});
|
|
|
|
|
|
|
|
this.template = [
|
|
|
|
'<div class="box">',
|
|
|
|
'<table cols="2" style="width: 100%;">',
|
|
|
|
'<tr>',
|
|
|
|
'<td style="padding-right: 5px;">',
|
|
|
|
'<label class="input-label">' + this.txtType + '</label>',
|
|
|
|
'<div id="id-dlg-cross-type" class="input-group-nr" style="width: 100%;margin-bottom: 10px;"></div>',
|
|
|
|
'</td>',
|
|
|
|
'<td style="padding-left: 5px;">',
|
|
|
|
'<label class="input-label">' + this.txtReference + '</label>',
|
|
|
|
'<div id="id-dlg-cross-ref" class="input-group-nr" style="width: 100%;margin-bottom: 10px;"></div>',
|
|
|
|
'</td>',
|
|
|
|
'</tr>',
|
|
|
|
'<tr>',
|
|
|
|
'<td colspan="2" style="padding-bottom: 10px;">',
|
|
|
|
'<div id="id-dlg-cross-insert-as" style="width:100%;"></div>',
|
|
|
|
'</td>',
|
|
|
|
'</tr>',
|
|
|
|
'<tr>',
|
|
|
|
'<td colspan="2" style="padding-bottom: 7px;">',
|
|
|
|
'<div id="id-dlg-cross-below-above" style="width:100%;"></div>',
|
|
|
|
'</td>',
|
|
|
|
'</tr>',
|
|
|
|
'<tr>',
|
|
|
|
'<td colspan="2" style="padding-bottom: 10px;">',
|
|
|
|
'<div id="id-dlg-cross-separate" style="display: inline-block;vertical-align: middle;margin-right: 10px;"></div>',
|
|
|
|
'<div id="id-dlg-cross-separator" style="display: inline-block;vertical-align: middle;"></div>',
|
|
|
|
'</td>',
|
|
|
|
'</tr>',
|
|
|
|
'<tr>',
|
|
|
|
'<td colspan="2" style="width: 100%;">',
|
2020-09-23 10:08:37 +00:00
|
|
|
'<label id="id-dlg-cross-which">' + this.textWhich + '</label>',
|
2020-09-23 12:57:01 +00:00
|
|
|
'<div id="id-dlg-cross-list" class="no-borders" style="width:368px; height:161px;margin-top: 2px; "></div>',
|
2020-09-22 13:48:45 +00:00
|
|
|
'</td>',
|
|
|
|
'</tr>',
|
|
|
|
'</table>',
|
|
|
|
'</div>'
|
|
|
|
].join('');
|
|
|
|
|
2020-09-24 14:03:46 +00:00
|
|
|
this.crossRefProps = options.crossRefProps;
|
2020-09-22 13:48:45 +00:00
|
|
|
this.api = options.api;
|
|
|
|
this.options.tpl = _.template(this.template)(this.options);
|
2020-09-23 14:36:27 +00:00
|
|
|
this._locked = false;
|
2020-09-22 13:48:45 +00:00
|
|
|
|
|
|
|
Common.UI.Window.prototype.initialize.call(this, this.options);
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
|
|
|
Common.UI.Window.prototype.render.call(this);
|
|
|
|
|
|
|
|
var me = this,
|
|
|
|
$window = this.getChild();
|
|
|
|
$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
|
|
|
|
|
2020-09-23 10:08:37 +00:00
|
|
|
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: 5, displayValue: this.textEquation },
|
|
|
|
{ value: 6, displayValue: this.textFigure },
|
|
|
|
{ value: 7, 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);
|
|
|
|
});
|
|
|
|
|
2020-09-22 13:48:45 +00:00
|
|
|
this.cmbType = new Common.UI.ComboBox({
|
|
|
|
el : $window.find('#id-dlg-cross-type'),
|
2020-09-23 10:08:37 +00:00
|
|
|
menuStyle : 'min-width: 100%;max-height: 233px;',
|
2020-09-22 13:48:45 +00:00
|
|
|
editable : false,
|
|
|
|
cls : 'input-group-nr',
|
|
|
|
data : [
|
|
|
|
{ value: 0, displayValue: this.textParagraph },
|
|
|
|
{ value: 1, displayValue: this.textHeading },
|
|
|
|
{ value: 2, displayValue: this.textBookmark },
|
|
|
|
{ value: 3, displayValue: this.textFootnote },
|
2020-09-23 10:08:37 +00:00
|
|
|
{ value: 4, displayValue: this.textEndnote }
|
|
|
|
].concat(arr)
|
2020-09-22 13:48:45 +00:00
|
|
|
});
|
|
|
|
this.cmbType.on('selected', _.bind(this.onTypeSelected, this));
|
|
|
|
|
|
|
|
this.cmbReference = new Common.UI.ComboBox({
|
|
|
|
el : $window.find('#id-dlg-cross-ref'),
|
2020-09-23 10:08:37 +00:00
|
|
|
menuStyle : 'min-width: 100%;max-height: 233px;',
|
2020-09-22 13:48:45 +00:00
|
|
|
editable : false,
|
|
|
|
cls : 'input-group-nr',
|
|
|
|
data : []
|
|
|
|
});
|
2020-09-23 12:57:01 +00:00
|
|
|
this.cmbReference.on('selected', _.bind(this.onReferenceSelected, this));
|
2020-09-22 13:48:45 +00:00
|
|
|
|
|
|
|
this.chInsertAs = new Common.UI.CheckBox({
|
|
|
|
el: $window.find('#id-dlg-cross-insert-as'),
|
2020-09-23 13:35:11 +00:00
|
|
|
labelText: this.textInsertAs,
|
|
|
|
value: true
|
2020-09-22 13:48:45 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
this.chBelowAbove = new Common.UI.CheckBox({
|
|
|
|
el: $window.find('#id-dlg-cross-below-above'),
|
|
|
|
labelText: this.textIncludeAbove
|
|
|
|
});
|
|
|
|
|
|
|
|
this.chSeparator = new Common.UI.CheckBox({
|
|
|
|
el: $window.find('#id-dlg-cross-separate'),
|
|
|
|
labelText: this.textSeparate
|
|
|
|
}).on('change', _.bind(function(field, newValue, oldValue, eOpts){
|
|
|
|
var checked = field.getValue() === 'checked';
|
2020-09-22 17:48:06 +00:00
|
|
|
this.inputSeparator.setDisabled(!checked);
|
2020-09-22 13:48:45 +00:00
|
|
|
}, this));
|
|
|
|
|
|
|
|
this.inputSeparator = new Common.UI.InputField({
|
|
|
|
el: $window.findById('#id-dlg-cross-separator'),
|
|
|
|
style: 'width: 35px;',
|
|
|
|
validateOnBlur: false,
|
|
|
|
disabled: true
|
|
|
|
});
|
|
|
|
|
|
|
|
this.refList = new Common.UI.ListView({
|
|
|
|
el: $window.find('#id-dlg-cross-list'),
|
2020-09-23 12:57:01 +00:00
|
|
|
store: new Common.UI.DataViewStore(),
|
2021-05-13 17:30:57 +00:00
|
|
|
cls: 'dbl-clickable',
|
|
|
|
itemTemplate: _.template('<div id="<%= id %>" class="list-item" style="overflow: hidden; text-overflow: ellipsis;white-space: pre;"><%= Common.Utils.String.htmlEncode(value) %></div>')
|
2020-09-22 13:48:45 +00:00
|
|
|
});
|
2020-09-25 20:01:19 +00:00
|
|
|
this.refList.on('entervalue', _.bind(this.onPrimary, this))
|
|
|
|
.on('item:dblclick', _.bind(this.onPrimary, this));
|
2020-09-22 13:48:45 +00:00
|
|
|
|
2020-09-23 10:08:37 +00:00
|
|
|
this.lblWhich = $window.find('#id-dlg-cross-which');
|
|
|
|
|
2020-09-23 12:57:01 +00:00
|
|
|
this.btnInsert = new Common.UI.Button({
|
|
|
|
el: $window.find('.primary'),
|
|
|
|
disabled: true
|
|
|
|
});
|
|
|
|
|
2020-09-22 13:48:45 +00:00
|
|
|
this.afterRender();
|
|
|
|
},
|
|
|
|
|
|
|
|
afterRender: function() {
|
2020-09-24 14:03:46 +00:00
|
|
|
this._setDefaults();
|
2020-11-17 12:41:55 +00:00
|
|
|
|
|
|
|
var me = this;
|
2020-11-17 12:43:04 +00:00
|
|
|
var onApiEndCalculate = function() {
|
2020-11-21 21:16:12 +00:00
|
|
|
me.refreshReferences(me.cmbType.getSelectedRecord(), true);
|
2020-11-17 12:43:04 +00:00
|
|
|
};
|
|
|
|
this.api.asc_registerCallback('asc_onEndCalculate', onApiEndCalculate);
|
2020-11-17 12:41:55 +00:00
|
|
|
this.on('close', function(obj){
|
2020-11-17 12:43:04 +00:00
|
|
|
me.api.asc_unregisterCallback('asc_onEndCalculate', onApiEndCalculate);
|
2020-11-17 12:41:55 +00:00
|
|
|
});
|
2020-09-22 13:48:45 +00:00
|
|
|
},
|
|
|
|
|
2020-09-25 20:01:19 +00:00
|
|
|
_handleInput: function(state, fromButton) {
|
2020-09-22 13:48:45 +00:00
|
|
|
if (this.options.handler) {
|
2020-09-24 14:03:46 +00:00
|
|
|
this.options.handler.call(this, state);
|
2020-09-22 13:48:45 +00:00
|
|
|
}
|
|
|
|
if (state=='ok') {
|
2020-09-25 20:01:19 +00:00
|
|
|
if(!fromButton && document.activeElement && document.activeElement.localName == 'textarea' && /area_id/.test(document.activeElement.id)){
|
2020-09-25 15:17:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
!this.btnInsert.isDisabled() && this.insertReference();
|
2020-09-22 13:48:45 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.close();
|
|
|
|
},
|
|
|
|
|
|
|
|
onBtnClick: function(event) {
|
2020-09-25 20:01:19 +00:00
|
|
|
this._handleInput(event.currentTarget.attributes['result'].value, true);
|
2020-09-22 13:48:45 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onPrimary: function(event) {
|
|
|
|
this._handleInput('ok');
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
2020-09-24 14:03:46 +00:00
|
|
|
getSettings: function() {
|
|
|
|
return {type: this.cmbType.getValue(), refType: this.cmbReference.getValue()};
|
|
|
|
},
|
|
|
|
|
|
|
|
_setDefaults: function () {
|
|
|
|
var rec,
|
|
|
|
currentRef;
|
|
|
|
if (this.crossRefProps) {
|
|
|
|
rec = this.cmbType.store.findWhere({value: this.crossRefProps.type});
|
|
|
|
rec && (currentRef = this.crossRefProps.refType);
|
2020-09-22 13:48:45 +00:00
|
|
|
}
|
2020-09-24 14:03:46 +00:00
|
|
|
rec ? this.cmbType.selectRecord(rec) : this.cmbType.setValue(0);
|
|
|
|
this.refreshReferenceTypes(this.cmbType.getSelectedRecord(), currentRef);
|
2020-09-22 13:48:45 +00:00
|
|
|
},
|
|
|
|
|
2020-09-23 12:57:01 +00:00
|
|
|
insertReference: function() {
|
|
|
|
var record = this.refList.getSelectedRec(),
|
|
|
|
typeRec = this.cmbType.getSelectedRecord(),
|
|
|
|
type = (typeRec.type==1 || typeRec.value>4) ? 5 : typeRec.value,
|
|
|
|
reftype = this.cmbReference.getValue(),
|
|
|
|
link = this.chInsertAs.getValue()=='checked',
|
|
|
|
below = this.chBelowAbove.getValue()=='checked',
|
|
|
|
separator = (this.chSeparator.getValue()=='checked') ? this.inputSeparator.getValue() : undefined;
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case 0: // paragraph
|
|
|
|
case 1: // heading
|
|
|
|
this.api.asc_AddCrossRefToParagraph(record.get('para'), reftype, link, below, separator);
|
|
|
|
break;
|
|
|
|
case 2: // bookmark
|
|
|
|
this.api.asc_AddCrossRefToBookmark(record.get('value'), reftype, link, below, separator);
|
|
|
|
break;
|
|
|
|
case 3: // footnote
|
|
|
|
case 4: // endnote
|
|
|
|
this.api.asc_AddCrossRefToNote(record.get('para'), reftype, link, below);
|
|
|
|
break;
|
|
|
|
case 5: // caption
|
2020-09-24 13:04:48 +00:00
|
|
|
if (reftype==Asc.c_oAscDocumentRefenceToType.OnlyCaptionText && record.get('para').asc_canAddRefToCaptionText(typeRec.displayValue)===false) {
|
2020-09-23 12:57:01 +00:00
|
|
|
Common.UI.warning({
|
|
|
|
msg : this.textEmpty
|
|
|
|
});
|
|
|
|
} else
|
2020-09-24 13:04:48 +00:00
|
|
|
this.api.asc_AddCrossRefToCaption(typeRec.displayValue, record.get('para'), reftype, link, below);
|
2020-09-23 12:57:01 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-09-22 13:48:45 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onTypeSelected: function (combo, record) {
|
2020-09-24 14:03:46 +00:00
|
|
|
this.refreshReferenceTypes(record);
|
|
|
|
},
|
|
|
|
|
|
|
|
refreshReferenceTypes: function(record, currentRef) {
|
2020-09-23 10:08:37 +00:00
|
|
|
var arr = [],
|
2020-11-18 14:52:24 +00:00
|
|
|
str = this.textWhich;
|
2020-09-23 10:08:37 +00:00
|
|
|
if (record.type==1 || record.value > 4) {
|
|
|
|
// custom labels from caption dialog and Equation, Figure, Table
|
|
|
|
arr = [
|
|
|
|
{ value: Asc.c_oAscDocumentRefenceToType.Text, displayValue: this.textCaption },
|
|
|
|
{ value: Asc.c_oAscDocumentRefenceToType.OnlyLabelAndNumber, displayValue: this.textLabelNum },
|
|
|
|
{ value: Asc.c_oAscDocumentRefenceToType.OnlyCaptionText, displayValue: this.textOnlyCaption },
|
2020-11-17 21:52:01 +00:00
|
|
|
{ value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum },
|
|
|
|
{ value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow }
|
2020-09-23 10:08:37 +00:00
|
|
|
];
|
|
|
|
} else {
|
|
|
|
switch (record.value) {
|
|
|
|
case 0: // paragraph
|
|
|
|
arr = [
|
|
|
|
{ value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum },
|
|
|
|
{ value: Asc.c_oAscDocumentRefenceToType.ParaNum, displayValue: this.textParaNum },
|
|
|
|
{ value: Asc.c_oAscDocumentRefenceToType.ParaNumNoContext, displayValue: this.textParaNumNo },
|
|
|
|
{ value: Asc.c_oAscDocumentRefenceToType.ParaNumFullContex, displayValue: this.textParaNumFull },
|
2020-11-17 21:52:01 +00:00
|
|
|
{ value: Asc.c_oAscDocumentRefenceToType.Text, displayValue: this.textText },
|
|
|
|
{ value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow }
|
2020-09-23 10:08:37 +00:00
|
|
|
];
|
|
|
|
str = this.textWhichPara;
|
|
|
|
break;
|
|
|
|
case 1: // heading
|
|
|
|
arr = [
|
|
|
|
{ value: Asc.c_oAscDocumentRefenceToType.Text, displayValue: this.textHeadingText },
|
|
|
|
{ value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum },
|
|
|
|
{ value: Asc.c_oAscDocumentRefenceToType.ParaNum, displayValue: this.textHeadingNum },
|
|
|
|
{ value: Asc.c_oAscDocumentRefenceToType.ParaNumNoContext, displayValue: this.textHeadingNumNo },
|
2020-11-17 21:52:01 +00:00
|
|
|
{ value: Asc.c_oAscDocumentRefenceToType.ParaNumFullContex, displayValue: this.textHeadingNumFull },
|
|
|
|
{ value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow }
|
2020-09-23 10:08:37 +00:00
|
|
|
];
|
|
|
|
str = this.textWhichHeading;
|
|
|
|
break;
|
|
|
|
case 2: // bookmark
|
|
|
|
arr = [
|
|
|
|
{ value: Asc.c_oAscDocumentRefenceToType.Text, displayValue: this.textBookmarkText },
|
|
|
|
{ value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum },
|
|
|
|
{ value: Asc.c_oAscDocumentRefenceToType.ParaNum, displayValue: this.textParaNum },
|
|
|
|
{ value: Asc.c_oAscDocumentRefenceToType.ParaNumNoContext, displayValue: this.textParaNumNo },
|
2020-11-17 21:52:01 +00:00
|
|
|
{ value: Asc.c_oAscDocumentRefenceToType.ParaNumFullContex, displayValue: this.textParaNumFull },
|
|
|
|
{ value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow }
|
2020-09-23 10:08:37 +00:00
|
|
|
];
|
|
|
|
str = this.textWhichBookmark;
|
|
|
|
break;
|
|
|
|
case 3: // note
|
|
|
|
arr = [
|
|
|
|
{ value: Asc.c_oAscDocumentRefenceToType.NoteNumber, displayValue: this.textNoteNum },
|
|
|
|
{ value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum },
|
2020-11-17 21:52:01 +00:00
|
|
|
{ value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow },
|
2020-09-23 10:08:37 +00:00
|
|
|
{ value: Asc.c_oAscDocumentRefenceToType.NoteNumberFormatted, displayValue: this.textNoteNumForm }
|
|
|
|
];
|
|
|
|
str = this.textWhichNote;
|
|
|
|
break;
|
|
|
|
case 4: // end note
|
|
|
|
arr = [
|
|
|
|
{ value: Asc.c_oAscDocumentRefenceToType.NoteNumber, displayValue: this.textEndNoteNum },
|
|
|
|
{ value: Asc.c_oAscDocumentRefenceToType.PageNum, displayValue: this.textPageNum },
|
2020-11-17 21:52:01 +00:00
|
|
|
{ value: Asc.c_oAscDocumentRefenceToType.AboveBelow, displayValue: this.textAboveBelow },
|
2020-09-23 10:08:37 +00:00
|
|
|
{ value: Asc.c_oAscDocumentRefenceToType.NoteNumberFormatted, displayValue: this.textEndNoteNumForm }
|
|
|
|
];
|
|
|
|
str = this.textWhichEndnote;
|
|
|
|
break;
|
|
|
|
}
|
2020-09-22 13:48:45 +00:00
|
|
|
}
|
|
|
|
this.cmbReference.setData(arr);
|
2020-11-17 12:41:55 +00:00
|
|
|
|
|
|
|
var rec = this.cmbReference.store.findWhere({value: currentRef});
|
|
|
|
this.cmbReference.setValue(rec ? currentRef : arr[0].value);
|
2020-09-23 13:35:11 +00:00
|
|
|
this.onReferenceSelected(this.cmbReference, this.cmbReference.getSelectedRecord());
|
2020-09-23 10:08:37 +00:00
|
|
|
this.lblWhich.text(str);
|
2020-11-18 14:52:24 +00:00
|
|
|
this.refreshReferences(record);
|
2020-09-23 12:57:01 +00:00
|
|
|
},
|
|
|
|
|
2020-11-21 21:16:12 +00:00
|
|
|
refreshReferences: function(record, reselect) {
|
2020-11-18 14:52:24 +00:00
|
|
|
if (!record) return;
|
|
|
|
|
2020-09-23 12:57:01 +00:00
|
|
|
var store = this.refList.store,
|
2020-11-18 14:52:24 +00:00
|
|
|
type = (record.type==1 || record.value > 4) ? 5 : record.value,
|
2020-09-23 12:57:01 +00:00
|
|
|
arr = [],
|
2020-11-21 21:16:12 +00:00
|
|
|
props,
|
|
|
|
oldlength = store.length,
|
|
|
|
oldidx = _.indexOf(store.models, this.refList.getSelectedRec());
|
|
|
|
|
2020-09-23 12:57:01 +00:00
|
|
|
switch (type) {
|
|
|
|
case 0: // paragraph
|
|
|
|
props = this.api.asc_GetAllNumberedParagraphs();
|
|
|
|
break;
|
|
|
|
case 1: // heading
|
|
|
|
props = this.api.asc_GetAllHeadingParagraphs();
|
|
|
|
break;
|
|
|
|
case 2: // bookmark
|
|
|
|
props = this.api.asc_GetBookmarksManager();
|
|
|
|
break;
|
|
|
|
case 3: // footnote
|
|
|
|
props = this.api.asc_GetAllFootNoteParagraphs();
|
|
|
|
break;
|
|
|
|
case 4: // endnote
|
|
|
|
props = this.api.asc_GetAllEndNoteParagraphs();
|
|
|
|
break;
|
|
|
|
case 5: // caption
|
|
|
|
props = this.api.asc_GetAllCaptionParagraphs(this.cmbType.getSelectedRecord().displayValue);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (type==2) { // bookmark
|
|
|
|
var count = props.asc_GetCount();
|
|
|
|
for (var i=0; i<count; i++) {
|
|
|
|
var name = props.asc_GetName(i);
|
2020-09-23 13:35:11 +00:00
|
|
|
if (!props.asc_IsInternalUseBookmark(name) && !props.asc_IsHiddenBookmark(name)) {
|
2020-09-23 12:57:01 +00:00
|
|
|
arr.push({value: name});
|
|
|
|
}
|
|
|
|
}
|
2020-11-17 12:41:55 +00:00
|
|
|
} else if (props) {
|
2020-09-23 12:57:01 +00:00
|
|
|
for (var i=0; i<props.length; i++) {
|
|
|
|
arr.push({value: props[i].asc_getText(), para: props[i]});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
store.reset(arr);
|
|
|
|
if (store.length>0) {
|
2020-11-21 21:16:12 +00:00
|
|
|
var rec = (reselect && store.length == oldlength && oldidx>=0 && oldidx<store.length) ? store.at(oldidx) : store.at(0);
|
2020-09-23 12:57:01 +00:00
|
|
|
this.refList.selectRecord(rec);
|
|
|
|
this.refList.scrollToRecord(rec);
|
|
|
|
}
|
2020-09-23 14:36:27 +00:00
|
|
|
this.btnInsert.setDisabled(arr.length<1 || this._locked);
|
2020-09-23 12:57:01 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onReferenceSelected: function(combo, record) {
|
2020-11-17 12:41:55 +00:00
|
|
|
if (!record) return;
|
|
|
|
|
2020-09-23 13:35:11 +00:00
|
|
|
var refType = record.value,
|
|
|
|
typeRec = this.cmbType.getSelectedRecord(),
|
|
|
|
type = (typeRec.type==1 || typeRec.value>4) ? 5 : typeRec.value;
|
|
|
|
var disable = (type==5 && refType!==Asc.c_oAscDocumentRefenceToType.PageNum) || (type<5) && (refType==Asc.c_oAscDocumentRefenceToType.Text || refType==Asc.c_oAscDocumentRefenceToType.AboveBelow);
|
|
|
|
this.chBelowAbove.setDisabled(disable);
|
|
|
|
disable = !(type==0 || type==2) || (refType!==Asc.c_oAscDocumentRefenceToType.ParaNumFullContex);
|
|
|
|
this.chSeparator.setDisabled(disable);
|
|
|
|
this.inputSeparator.setDisabled(disable || this.chSeparator.getValue()!=='checked');
|
2020-09-22 13:48:45 +00:00
|
|
|
},
|
|
|
|
|
2020-09-23 14:36:27 +00:00
|
|
|
setLocked: function(locked){
|
|
|
|
this._locked = locked;
|
|
|
|
this.btnInsert.setDisabled(this.refList.store.length<1 || this._locked);
|
|
|
|
},
|
|
|
|
|
2020-09-22 13:48:45 +00:00
|
|
|
txtTitle: 'Cross-reference',
|
|
|
|
txtType: 'Reference type',
|
|
|
|
txtReference: 'Insert reference to',
|
|
|
|
textInsertAs: 'Insert as hyperlink',
|
|
|
|
textSeparate: 'Separate numbers with',
|
|
|
|
textIncludeAbove: 'Include above/below',
|
|
|
|
textPageNum: 'Page number',
|
|
|
|
textParaNum: 'Paragraph number',
|
|
|
|
textParaNumNo: 'Paragraph number (no context)',
|
|
|
|
textParaNumFull: 'Paragraph number (full context)',
|
|
|
|
textText: 'Paragraph text',
|
|
|
|
textAboveBelow: 'Above/below',
|
|
|
|
textHeadingText: 'Heading text',
|
|
|
|
textHeadingNum: 'Heading number',
|
|
|
|
textHeadingNumNo: 'Heading number (no context)',
|
|
|
|
textHeadingNumFull: 'Heading number (full context)',
|
|
|
|
textBookmarkText: 'Bookmark text',
|
|
|
|
textNoteNum: 'Footnote number',
|
|
|
|
textNoteNumForm: 'Footnote number (formatted)',
|
|
|
|
textEndNoteNum: 'Endnote number',
|
|
|
|
textEndNoteNumForm: 'Endnote number (formatted)',
|
|
|
|
textCaption: 'Entire caption',
|
|
|
|
textLabelNum: 'Only label and number',
|
|
|
|
textOnlyCaption: 'Only caption text',
|
2020-09-23 13:35:11 +00:00
|
|
|
textParagraph: 'Numbered item',
|
2020-09-22 13:48:45 +00:00
|
|
|
textHeading: 'Heading',
|
|
|
|
textBookmark: 'Bookmark',
|
|
|
|
textFootnote: 'Footnote',
|
|
|
|
textEndnote: 'Endnote',
|
|
|
|
textEquation: 'Equation',
|
|
|
|
textFigure: 'Figure',
|
|
|
|
textTable: 'Table',
|
2020-09-23 10:08:37 +00:00
|
|
|
textInsert: 'Insert',
|
|
|
|
textWhich: 'For which caption',
|
|
|
|
textWhichHeading: 'For which heading',
|
|
|
|
textWhichBookmark: 'For which bookmark',
|
|
|
|
textWhichNote: 'For which footnote',
|
|
|
|
textWhichEndnote: 'For which endnote',
|
2020-09-23 12:57:01 +00:00
|
|
|
textWhichPara: 'For which numbered item',
|
|
|
|
textEmpty: 'The request reference is empty.'
|
2020-09-22 13:48:45 +00:00
|
|
|
|
|
|
|
}, DE.Views.CrossReferenceDialog || {}))
|
|
|
|
});
|