2017-12-23 08:33:49 +00:00
|
|
|
/*
|
|
|
|
*
|
2019-01-17 13:05:03 +00:00
|
|
|
* (c) Copyright Ascensio System SIA 2010-2019
|
2017-12-23 08:33:49 +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-23 08:33:49 +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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Links.js
|
|
|
|
*
|
|
|
|
* Created by Julia Radzhabova on 22.12.2017
|
2018-03-01 12:16:38 +00:00
|
|
|
* Copyright (c) 2018 Ascensio System SIA. All rights reserved.
|
2017-12-23 08:33:49 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
define([
|
|
|
|
'core',
|
2017-12-25 12:55:26 +00:00
|
|
|
'documenteditor/main/app/view/Links',
|
2017-12-26 07:32:52 +00:00
|
|
|
'documenteditor/main/app/view/NoteSettingsDialog',
|
2017-12-26 14:31:14 +00:00
|
|
|
'documenteditor/main/app/view/HyperlinkSettingsDialog',
|
2018-02-19 11:56:44 +00:00
|
|
|
'documenteditor/main/app/view/TableOfContentsSettings',
|
2019-09-11 14:26:20 +00:00
|
|
|
'documenteditor/main/app/view/BookmarksDialog',
|
2020-07-29 11:50:24 +00:00
|
|
|
'documenteditor/main/app/view/CaptionDialog',
|
2020-09-22 13:48:45 +00:00
|
|
|
'documenteditor/main/app/view/NotesRemoveDialog',
|
2020-10-15 11:39:44 +00:00
|
|
|
'documenteditor/main/app/view/CrossReferenceDialog',
|
|
|
|
'common/main/lib/view/OptionsDialog'
|
2017-12-23 08:33:49 +00:00
|
|
|
], function () {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
DE.Controllers.Links = Backbone.Controller.extend(_.extend({
|
|
|
|
models : [],
|
|
|
|
collections : [
|
|
|
|
],
|
|
|
|
views : [
|
|
|
|
'Links'
|
|
|
|
],
|
|
|
|
sdkViewName : '#id_main',
|
|
|
|
|
|
|
|
initialize: function () {
|
|
|
|
|
|
|
|
this.addListeners({
|
|
|
|
'Links': {
|
|
|
|
'links:contents': this.onTableContents,
|
2021-04-13 09:14:15 +00:00
|
|
|
'links:contents-open': this.onTableContentsOpen,
|
2017-12-25 12:55:26 +00:00
|
|
|
'links:update': this.onTableContentsUpdate,
|
2017-12-26 07:32:52 +00:00
|
|
|
'links:notes': this.onNotesClick,
|
2018-02-19 11:56:44 +00:00
|
|
|
'links:hyperlink': this.onHyperlinkClick,
|
2019-09-11 14:26:20 +00:00
|
|
|
'links:bookmarks': this.onBookmarksClick,
|
2020-09-22 13:48:45 +00:00
|
|
|
'links:caption': this.onCaptionClick,
|
2020-10-15 07:32:46 +00:00
|
|
|
'links:crossref': this.onCrossRefClick,
|
|
|
|
'links:tof': this.onTableFigures,
|
2022-03-14 17:19:17 +00:00
|
|
|
'links:tof-update': this.onTableFiguresUpdate,
|
|
|
|
'links:addtext': this.onAddText,
|
|
|
|
'links:addtext-open': this.onAddTextOpen
|
2018-02-08 13:03:10 +00:00
|
|
|
},
|
|
|
|
'DocumentHolder': {
|
|
|
|
'links:contents': this.onTableContents,
|
2021-01-13 15:39:39 +00:00
|
|
|
'links:update': this.onTableContentsUpdate,
|
2021-04-13 09:14:15 +00:00
|
|
|
'links:contents-open': this.onTableContentsOpen,
|
2021-01-13 15:39:39 +00:00
|
|
|
'links:caption': this.onCaptionClick
|
2017-12-23 08:33:49 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onLaunch: function () {
|
2017-12-26 07:32:52 +00:00
|
|
|
this._state = {
|
2021-01-13 15:39:39 +00:00
|
|
|
in_object: undefined
|
2017-12-26 07:32:52 +00:00
|
|
|
};
|
2019-03-12 12:45:32 +00:00
|
|
|
Common.Gateway.on('setactionlink', function (url) {
|
|
|
|
console.log('url with actions: ' + url);
|
|
|
|
}.bind(this));
|
2017-12-23 08:33:49 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
setApi: function (api) {
|
|
|
|
if (api) {
|
|
|
|
this.api = api;
|
|
|
|
this.api.asc_registerCallback('asc_onFocusObject', this.onApiFocusObject.bind(this));
|
2017-12-26 07:32:52 +00:00
|
|
|
this.api.asc_registerCallback('asc_onCanAddHyperlink', _.bind(this.onApiCanAddHyperlink, this));
|
2017-12-23 08:33:49 +00:00
|
|
|
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this));
|
|
|
|
Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this));
|
2019-11-20 11:56:32 +00:00
|
|
|
this.api.asc_registerCallback('asc_onShowContentControlsActions',_.bind(this.onShowContentControlsActions, this));
|
|
|
|
this.api.asc_registerCallback('asc_onHideContentControlsActions',_.bind(this.onHideContentControlsActions, this));
|
2020-10-15 07:32:46 +00:00
|
|
|
this.api.asc_registerCallback('asc_onAscReplaceCurrentTOF',_.bind(this.onAscReplaceCurrentTOF, this));
|
|
|
|
this.api.asc_registerCallback('asc_onAscTOFUpdate',_.bind(this.onAscTOFUpdate, this));
|
2017-12-23 08:33:49 +00:00
|
|
|
}
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
setConfig: function(config) {
|
|
|
|
this.toolbar = config.toolbar;
|
|
|
|
this.view = this.createView('Links', {
|
2017-12-26 07:32:52 +00:00
|
|
|
toolbar: this.toolbar.toolbar
|
2017-12-23 08:33:49 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
SetDisabled: function(state) {
|
|
|
|
this.view && this.view.SetDisabled(state);
|
|
|
|
},
|
|
|
|
|
|
|
|
getView: function(name) {
|
|
|
|
return !name && this.view ?
|
|
|
|
this.view : Backbone.Controller.prototype.getView.call(this, name);
|
|
|
|
},
|
|
|
|
|
|
|
|
onCoAuthoringDisconnect: function() {
|
|
|
|
this.SetDisabled(true);
|
|
|
|
},
|
|
|
|
|
|
|
|
onApiFocusObject: function(selectedObjects) {
|
2017-12-26 07:32:52 +00:00
|
|
|
if (!this.toolbar.editMode) return;
|
2017-12-23 08:33:49 +00:00
|
|
|
|
2017-12-25 12:55:26 +00:00
|
|
|
var pr, i = -1, type,
|
2017-12-23 08:33:49 +00:00
|
|
|
paragraph_locked = false,
|
2017-12-25 12:55:26 +00:00
|
|
|
header_locked = false,
|
|
|
|
in_header = false,
|
|
|
|
in_equation = false,
|
2019-09-12 09:20:50 +00:00
|
|
|
in_image = false,
|
2019-11-21 14:29:39 +00:00
|
|
|
in_table = false,
|
2021-01-13 15:39:39 +00:00
|
|
|
frame_pr = null,
|
|
|
|
object_type;
|
2017-12-23 08:33:49 +00:00
|
|
|
|
|
|
|
while (++i < selectedObjects.length) {
|
|
|
|
type = selectedObjects[i].get_ObjectType();
|
|
|
|
pr = selectedObjects[i].get_ObjectValue();
|
|
|
|
|
|
|
|
if (type === Asc.c_oAscTypeSelectElement.Paragraph) {
|
|
|
|
paragraph_locked = pr.get_Locked();
|
2019-11-21 14:29:39 +00:00
|
|
|
frame_pr = pr;
|
2017-12-23 08:33:49 +00:00
|
|
|
} else if (type === Asc.c_oAscTypeSelectElement.Header) {
|
|
|
|
header_locked = pr.get_Locked();
|
2017-12-25 12:55:26 +00:00
|
|
|
in_header = true;
|
|
|
|
} else if (type === Asc.c_oAscTypeSelectElement.Image) {
|
|
|
|
in_image = true;
|
2021-01-13 15:39:39 +00:00
|
|
|
object_type = type;
|
2017-12-25 12:55:26 +00:00
|
|
|
} else if (type === Asc.c_oAscTypeSelectElement.Math) {
|
|
|
|
in_equation = true;
|
2021-01-13 15:39:39 +00:00
|
|
|
object_type = type;
|
2019-09-12 09:20:50 +00:00
|
|
|
} else if (type === Asc.c_oAscTypeSelectElement.Table) {
|
|
|
|
in_table = true;
|
2021-01-13 15:39:39 +00:00
|
|
|
object_type = type;
|
2017-12-23 08:33:49 +00:00
|
|
|
}
|
|
|
|
}
|
2021-01-13 15:39:39 +00:00
|
|
|
this._state.in_object = object_type;
|
2017-12-26 07:32:52 +00:00
|
|
|
|
2018-05-25 12:12:38 +00:00
|
|
|
var control_props = this.api.asc_IsContentControl() ? this.api.asc_GetContentControlProperties() : null,
|
2020-09-23 14:36:27 +00:00
|
|
|
control_plain = (control_props) ? (control_props.get_ContentControlType()==Asc.c_oAscSdtLevelType.Inline) : false,
|
|
|
|
lock_type = control_props ? control_props.get_Lock() : Asc.c_oAscSdtLockType.Unlocked,
|
|
|
|
content_locked = lock_type==Asc.c_oAscSdtLockType.SdtContentLocked || lock_type==Asc.c_oAscSdtLockType.ContentLocked;
|
2019-12-24 10:49:18 +00:00
|
|
|
var rich_del_lock = (frame_pr) ? !frame_pr.can_DeleteBlockContentControl() : false,
|
|
|
|
rich_edit_lock = (frame_pr) ? !frame_pr.can_EditBlockContentControl() : false,
|
|
|
|
plain_del_lock = (frame_pr) ? !frame_pr.can_DeleteInlineContentControl() : false,
|
|
|
|
plain_edit_lock = (frame_pr) ? !frame_pr.can_EditInlineContentControl() : false;
|
2018-05-25 12:12:38 +00:00
|
|
|
|
2021-12-29 16:32:43 +00:00
|
|
|
this.lockToolbar(Common.enumLock.paragraphLock, paragraph_locked, {array: this.view.btnsNotes.concat(this.view.btnsHyperlink).concat([this.view.btnBookmarks, this.view.btnTableFiguresUpdate, this.view.btnCrossRef])});
|
|
|
|
this.lockToolbar(Common.enumLock.inHeader, in_header, {array: this.view.btnsNotes.concat(this.view.btnsContents).concat([this.view.btnBookmarks, this.view.btnTableFigures,
|
2021-12-29 10:14:42 +00:00
|
|
|
this.view.btnTableFiguresUpdate, this.view.btnCaption])});
|
2021-12-29 16:32:43 +00:00
|
|
|
this.lockToolbar(Common.enumLock.controlPlain, control_plain, {array: this.view.btnsNotes.concat([this.view.btnBookmarks, this.view.btnCrossRef])});
|
|
|
|
this.lockToolbar(Common.enumLock.richEditLock, rich_edit_lock, {array: this.view.btnsNotes.concat(this.view.btnsContents).concat([this.view.btnTableFigures, this.view.btnTableFiguresUpdate,
|
2021-12-29 10:14:42 +00:00
|
|
|
this.view.btnCrossRef])});
|
2021-12-29 16:32:43 +00:00
|
|
|
this.lockToolbar(Common.enumLock.plainEditLock, plain_edit_lock, {array: this.view.btnsNotes.concat(this.view.btnsContents).concat([this.view.btnTableFigures, this.view.btnTableFiguresUpdate,
|
2021-12-29 10:14:42 +00:00
|
|
|
this.view.btnCrossRef])});
|
2021-12-29 16:32:43 +00:00
|
|
|
this.lockToolbar(Common.enumLock.headerLock, header_locked, {array: this.view.btnsHyperlink.concat([this.view.btnBookmarks, this.view.btnCrossRef])});
|
|
|
|
this.lockToolbar(Common.enumLock.inEquation, in_equation, {array: this.view.btnsNotes});
|
|
|
|
this.lockToolbar(Common.enumLock.inImage, in_image, {array: this.view.btnsNotes});
|
|
|
|
this.lockToolbar(Common.enumLock.richDelLock, rich_del_lock, {array: this.view.btnsContents.concat([this.view.btnTableFigures, this.view.btnTableFiguresUpdate])});
|
|
|
|
this.lockToolbar(Common.enumLock.plainDelLock, plain_del_lock, {array: this.view.btnsContents.concat([this.view.btnTableFigures, this.view.btnTableFiguresUpdate])});
|
|
|
|
this.lockToolbar(Common.enumLock.contentLock, content_locked, {array: [this.view.btnCrossRef]});
|
|
|
|
this.lockToolbar(Common.enumLock.cantUpdateTOF, !this.api.asc_CanUpdateTablesOfFigures(), {array: [this.view.btnTableFiguresUpdate]});
|
2022-03-14 17:19:17 +00:00
|
|
|
this.lockToolbar(Common.enumLock.inFootnote, this.api.asc_IsCursorInFootnote() || this.api.asc_IsCursorInEndnote(), {array: [this.view.btnAddText]});
|
|
|
|
this.lockToolbar(Common.enumLock.inHeader, in_header, {array: [this.view.btnAddText]});
|
2021-12-29 10:14:42 +00:00
|
|
|
|
|
|
|
this.dlgCrossRefDialog && this.dlgCrossRefDialog.isVisible() && this.dlgCrossRefDialog.setLocked(this.view.btnCrossRef.isDisabled());
|
|
|
|
},
|
2020-09-23 14:36:27 +00:00
|
|
|
|
2021-12-29 10:14:42 +00:00
|
|
|
lockToolbar: function (causes, lock, opts) {
|
|
|
|
Common.Utils.lockControls(causes, lock, opts, this.view.getButtons());
|
2017-12-26 07:32:52 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onApiCanAddHyperlink: function(value) {
|
2021-12-29 16:32:43 +00:00
|
|
|
this.toolbar.editMode && this.lockToolbar(Common.enumLock.hyperlinkLock, !value, {array: this.view.btnsHyperlink});
|
2017-12-26 07:32:52 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onHyperlinkClick: function(btn) {
|
|
|
|
var me = this,
|
|
|
|
win, props, text;
|
|
|
|
|
|
|
|
if (me.api){
|
|
|
|
|
|
|
|
var handlerDlg = function(dlg, result) {
|
|
|
|
if (result == 'ok') {
|
|
|
|
props = dlg.getSettings();
|
|
|
|
(text!==false)
|
|
|
|
? me.api.add_Hyperlink(props)
|
|
|
|
: me.api.change_Hyperlink(props);
|
|
|
|
}
|
|
|
|
|
|
|
|
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
|
|
|
|
};
|
|
|
|
|
|
|
|
text = me.api.can_AddHyperlink();
|
|
|
|
|
|
|
|
if (text !== false) {
|
|
|
|
win = new DE.Views.HyperlinkSettingsDialog({
|
|
|
|
api: me.api,
|
|
|
|
handler: handlerDlg
|
|
|
|
});
|
|
|
|
|
|
|
|
props = new Asc.CHyperlinkProperty();
|
|
|
|
props.put_Text(text);
|
|
|
|
|
|
|
|
win.show();
|
|
|
|
win.setSettings(props);
|
|
|
|
} else {
|
|
|
|
var selectedElements = me.api.getSelectedElements();
|
|
|
|
if (selectedElements && _.isArray(selectedElements)){
|
|
|
|
_.each(selectedElements, function(el, i) {
|
|
|
|
if (selectedElements[i].get_ObjectType() == Asc.c_oAscTypeSelectElement.Hyperlink)
|
|
|
|
props = selectedElements[i].get_ObjectValue();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (props) {
|
|
|
|
win = new DE.Views.HyperlinkSettingsDialog({
|
|
|
|
api: me.api,
|
|
|
|
handler: handlerDlg
|
|
|
|
});
|
|
|
|
win.show();
|
|
|
|
win.setSettings(props);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-12-25 12:55:26 +00:00
|
|
|
|
2017-12-26 07:32:52 +00:00
|
|
|
Common.component.Analytics.trackEvent('ToolBar', 'Add Hyperlink');
|
2017-12-23 08:33:49 +00:00
|
|
|
},
|
|
|
|
|
2018-02-08 13:03:10 +00:00
|
|
|
onTableContents: function(type, currentTOC){
|
2018-03-15 13:05:38 +00:00
|
|
|
currentTOC = !!currentTOC;
|
|
|
|
var props = this.api.asc_GetTableOfContentsPr(currentTOC);
|
2017-12-23 08:33:49 +00:00
|
|
|
switch (type) {
|
|
|
|
case 0:
|
2018-01-19 12:20:45 +00:00
|
|
|
if (!props) {
|
|
|
|
props = new Asc.CTableOfContentsPr();
|
|
|
|
props.put_OutlineRange(1, 9);
|
|
|
|
}
|
2018-01-18 08:58:24 +00:00
|
|
|
props.put_Hyperlink(true);
|
|
|
|
props.put_ShowPageNumbers(true);
|
|
|
|
props.put_RightAlignTab(true);
|
|
|
|
props.put_TabLeader( Asc.c_oAscTabLeader.Dot);
|
2018-03-15 13:05:38 +00:00
|
|
|
(currentTOC) ? this.api.asc_SetTableOfContentsPr(props) : this.api.asc_AddTableOfContents(null, props);
|
2018-01-19 12:20:45 +00:00
|
|
|
break;
|
2017-12-23 08:33:49 +00:00
|
|
|
case 1:
|
2018-01-19 12:20:45 +00:00
|
|
|
if (!props) {
|
|
|
|
props = new Asc.CTableOfContentsPr();
|
|
|
|
props.put_OutlineRange(1, 9);
|
|
|
|
}
|
2018-01-18 08:58:24 +00:00
|
|
|
props.put_Hyperlink(true);
|
|
|
|
props.put_ShowPageNumbers(false);
|
|
|
|
props.put_TabLeader( Asc.c_oAscTabLeader.None);
|
2020-02-11 12:22:30 +00:00
|
|
|
props.put_StylesType(Asc.c_oAscTOCStylesType.Web);
|
2018-03-15 13:05:38 +00:00
|
|
|
(currentTOC) ? this.api.asc_SetTableOfContentsPr(props) : this.api.asc_AddTableOfContents(null, props);
|
2018-01-19 12:20:45 +00:00
|
|
|
break;
|
2017-12-26 14:31:14 +00:00
|
|
|
case 'settings':
|
2018-03-15 13:05:38 +00:00
|
|
|
var me = this,
|
|
|
|
win = new DE.Views.TableOfContentsSettings({
|
2017-12-26 14:31:14 +00:00
|
|
|
api: this.api,
|
2018-01-18 08:58:24 +00:00
|
|
|
props: props,
|
2020-10-15 07:32:46 +00:00
|
|
|
type: 0,
|
2018-01-18 08:58:24 +00:00
|
|
|
handler: function(result, value) {
|
2017-12-26 14:31:14 +00:00
|
|
|
if (result == 'ok') {
|
2018-01-19 13:41:40 +00:00
|
|
|
(props) ? me.api.asc_SetTableOfContentsPr(value) : me.api.asc_AddTableOfContents(null, value);
|
2017-12-26 14:31:14 +00:00
|
|
|
}
|
|
|
|
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
win.show();
|
2017-12-23 08:33:49 +00:00
|
|
|
break;
|
|
|
|
case 'remove':
|
2018-08-17 08:01:54 +00:00
|
|
|
currentTOC = (currentTOC && props) ? props.get_InternalClass() : undefined;
|
2018-03-15 13:05:38 +00:00
|
|
|
this.api.asc_RemoveTableOfContents(currentTOC);
|
2017-12-23 08:33:49 +00:00
|
|
|
break;
|
|
|
|
}
|
2018-03-14 10:19:41 +00:00
|
|
|
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
|
2017-12-23 08:33:49 +00:00
|
|
|
},
|
|
|
|
|
2018-02-08 13:03:10 +00:00
|
|
|
onTableContentsUpdate: function(type, currentTOC){
|
2018-08-10 08:17:21 +00:00
|
|
|
var props = this.api.asc_GetTableOfContentsPr(currentTOC);
|
2022-03-14 13:36:33 +00:00
|
|
|
if (currentTOC && props)
|
|
|
|
currentTOC = props.get_InternalClass();
|
|
|
|
this.api.asc_UpdateTableOfContents(type == 'pages', currentTOC);
|
2018-03-14 10:19:41 +00:00
|
|
|
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
|
2017-12-25 12:55:26 +00:00
|
|
|
},
|
|
|
|
|
2021-04-13 09:14:15 +00:00
|
|
|
onTableContentsOpen: function(menu) {
|
2021-04-13 09:52:19 +00:00
|
|
|
this.api.asc_getButtonsTOC(menu.items[0].options.previewId, menu.items[1].options.previewId);
|
2021-04-13 09:14:15 +00:00
|
|
|
},
|
|
|
|
|
2022-03-14 17:19:17 +00:00
|
|
|
onAddTextOpen: function(menu) {
|
|
|
|
var props = this.api.asc_GetTableOfContentsPr(),
|
|
|
|
end = props ? props.get_OutlineEnd() : 3;
|
|
|
|
(end<0) && (end = 9);
|
|
|
|
this.view.fillAddTextMenu(menu, end, this.api.asc_GetCurrentLevelTOC());
|
|
|
|
},
|
|
|
|
|
|
|
|
onAddText: function(value) {
|
|
|
|
this.api.asc_AddParagraphToTOC(value);
|
|
|
|
},
|
|
|
|
|
2017-12-25 12:55:26 +00:00
|
|
|
onNotesClick: function(type) {
|
|
|
|
var me = this;
|
|
|
|
switch (type) {
|
|
|
|
case 'ins_footnote':
|
|
|
|
this.api.asc_AddFootnote();
|
|
|
|
break;
|
2020-07-29 11:50:24 +00:00
|
|
|
case 'ins_endnote':
|
|
|
|
this.api.asc_AddEndnote();
|
|
|
|
break;
|
2017-12-25 12:55:26 +00:00
|
|
|
case 'delele':
|
2020-07-29 11:50:24 +00:00
|
|
|
(new DE.Views.NotesRemoveDialog({
|
|
|
|
handler: function (dlg, result) {
|
|
|
|
if (result=='ok') {
|
|
|
|
var settings = dlg.getSettings();
|
|
|
|
(settings.footnote || settings.endnote) && me.api.asc_RemoveAllFootnotes(settings.footnote, settings.endnote);
|
2017-12-25 12:55:26 +00:00
|
|
|
}
|
2020-07-29 11:50:24 +00:00
|
|
|
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
|
|
|
|
}
|
|
|
|
})).show();
|
2017-12-25 12:55:26 +00:00
|
|
|
break;
|
|
|
|
case 'settings':
|
2020-11-21 11:49:59 +00:00
|
|
|
var isEndNote = me.api.asc_IsCursorInEndnote(),
|
|
|
|
isFootNote = me.api.asc_IsCursorInFootnote();
|
|
|
|
isEndNote = (isEndNote || isFootNote) ? isEndNote : Common.Utils.InternalSettings.get("de-settings-note-last") || false;
|
2017-12-25 12:55:26 +00:00
|
|
|
(new DE.Views.NoteSettingsDialog({
|
|
|
|
api: me.api,
|
|
|
|
handler: function (result, settings) {
|
|
|
|
if (settings) {
|
2020-07-29 11:50:24 +00:00
|
|
|
settings.isEndNote ? me.api.asc_SetEndnoteProps(settings.props, settings.applyToAll) :
|
|
|
|
me.api.asc_SetFootnoteProps(settings.props, settings.applyToAll);
|
2017-12-25 12:55:26 +00:00
|
|
|
if (result == 'insert')
|
2019-07-08 10:56:26 +00:00
|
|
|
setTimeout(function() {
|
2020-07-29 11:50:24 +00:00
|
|
|
settings.isEndNote ? me.api.asc_AddEndnote(settings.custom) : me.api.asc_AddFootnote(settings.custom);
|
2019-07-08 10:56:26 +00:00
|
|
|
}, 1);
|
2020-11-21 11:49:59 +00:00
|
|
|
if (result == 'insert' || result == 'apply') {
|
|
|
|
Common.Utils.InternalSettings.set("de-settings-note-last", settings.isEndNote);
|
|
|
|
}
|
2017-12-25 12:55:26 +00:00
|
|
|
}
|
|
|
|
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
|
|
|
|
},
|
2020-07-29 11:50:24 +00:00
|
|
|
isEndNote: isEndNote,
|
2020-11-23 18:37:56 +00:00
|
|
|
hasSections: me.api.asc_GetSectionsCount()>1,
|
2020-07-29 11:50:24 +00:00
|
|
|
props: isEndNote ? me.api.asc_GetEndnoteProps() : me.api.asc_GetFootnoteProps()
|
2017-12-25 12:55:26 +00:00
|
|
|
})).show();
|
|
|
|
break;
|
|
|
|
case 'prev':
|
|
|
|
this.api.asc_GotoFootnote(false);
|
|
|
|
setTimeout(function() {
|
|
|
|
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
|
|
|
|
}, 50);
|
|
|
|
break;
|
|
|
|
case 'next':
|
|
|
|
this.api.asc_GotoFootnote(true);
|
|
|
|
setTimeout(function() {
|
|
|
|
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
|
|
|
|
}, 50);
|
|
|
|
break;
|
2020-07-29 11:50:24 +00:00
|
|
|
case 'prev-end':
|
|
|
|
this.api.asc_GotoEndnote(false);
|
|
|
|
setTimeout(function() {
|
|
|
|
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
|
|
|
|
}, 50);
|
|
|
|
break;
|
|
|
|
case 'next-end':
|
|
|
|
this.api.asc_GotoEndnote(true);
|
|
|
|
setTimeout(function() {
|
|
|
|
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
|
|
|
|
}, 50);
|
|
|
|
break;
|
2020-08-02 16:39:37 +00:00
|
|
|
case 'to-endnotes':
|
|
|
|
this.api.asc_ConvertFootnoteType(false, true, false);
|
|
|
|
setTimeout(function() {
|
|
|
|
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
|
|
|
|
}, 50);
|
|
|
|
break;
|
|
|
|
case 'to-footnotes':
|
|
|
|
this.api.asc_ConvertFootnoteType(false, false, true);
|
|
|
|
setTimeout(function() {
|
|
|
|
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
|
|
|
|
}, 50);
|
|
|
|
break;
|
|
|
|
case 'swap':
|
|
|
|
this.api.asc_ConvertFootnoteType(false, true, true);
|
|
|
|
setTimeout(function() {
|
|
|
|
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
|
|
|
|
}, 50);
|
|
|
|
break;
|
2017-12-25 12:55:26 +00:00
|
|
|
}
|
2018-02-19 11:56:44 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onBookmarksClick: function(btn) {
|
|
|
|
var me = this;
|
|
|
|
(new DE.Views.BookmarksDialog({
|
2018-03-27 12:21:15 +00:00
|
|
|
api: me.api,
|
2019-03-18 13:03:26 +00:00
|
|
|
appOptions: me.toolbar.appOptions,
|
2018-03-27 12:21:15 +00:00
|
|
|
props: me.api.asc_GetBookmarksManager(),
|
2018-02-19 11:56:44 +00:00
|
|
|
handler: function (result, settings) {
|
|
|
|
if (settings) {
|
|
|
|
}
|
2019-09-11 14:26:20 +00:00
|
|
|
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
|
|
|
|
}
|
|
|
|
})).show();
|
|
|
|
},
|
|
|
|
|
|
|
|
onCaptionClick: function(btn) {
|
|
|
|
var me = this;
|
|
|
|
(new DE.Views.CaptionDialog({
|
2021-01-13 15:39:39 +00:00
|
|
|
objectType: this._state.in_object,
|
2019-09-11 14:26:20 +00:00
|
|
|
handler: function (result, settings) {
|
|
|
|
if (result == 'ok') {
|
|
|
|
me.api.asc_AddObjectCaption(settings);
|
|
|
|
}
|
2018-02-19 11:56:44 +00:00
|
|
|
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
|
2018-03-27 12:21:15 +00:00
|
|
|
}
|
2018-02-19 11:56:44 +00:00
|
|
|
})).show();
|
2018-03-19 09:10:49 +00:00
|
|
|
},
|
|
|
|
|
2019-11-20 11:56:32 +00:00
|
|
|
onShowTOCActions: function(obj, x, y) {
|
|
|
|
var action = obj.button,
|
|
|
|
menu = (action==AscCommon.CCButtonType.Toc) ? this.view.contentsUpdateMenu : this.view.contentsMenu,
|
2018-03-14 10:19:41 +00:00
|
|
|
documentHolderView = this.getApplication().getController('DocumentHolder').documentHolder,
|
2018-03-14 11:55:53 +00:00
|
|
|
menuContainer = documentHolderView.cmpEl.find(Common.Utils.String.format('#menu-container-{0}', menu.id)),
|
|
|
|
me = this;
|
2018-03-14 10:19:41 +00:00
|
|
|
|
|
|
|
if (!menu) return;
|
2018-03-14 11:55:53 +00:00
|
|
|
this._fromShowContentControls = true;
|
2018-03-14 10:19:41 +00:00
|
|
|
Common.UI.Menu.Manager.hideAll();
|
|
|
|
|
|
|
|
if (!menu.rendered) {
|
|
|
|
// Prepare menu container
|
|
|
|
if (menuContainer.length < 1) {
|
|
|
|
menuContainer = $(Common.Utils.String.format('<div id="menu-container-{0}" style="position: absolute; z-index: 10000;"><div class="dropdown-toggle" data-toggle="dropdown"></div></div>', menu.id));
|
|
|
|
documentHolderView.cmpEl.append(menuContainer);
|
|
|
|
}
|
|
|
|
|
|
|
|
menu.render(menuContainer);
|
|
|
|
menu.cmpEl.attr({tabindex: "-1"});
|
2018-03-14 11:55:53 +00:00
|
|
|
menu.on('hide:after', function(){
|
|
|
|
if (!me._fromShowContentControls)
|
|
|
|
me.api.asc_UncheckContentControlButtons();
|
|
|
|
});
|
2018-03-14 10:19:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
menuContainer.css({left: x, top : y});
|
|
|
|
menuContainer.attr('data-value', 'prevent-canvas-click');
|
|
|
|
documentHolderView._preventClick = true;
|
|
|
|
menu.show();
|
|
|
|
|
|
|
|
menu.alignPosition();
|
|
|
|
_.delay(function() {
|
|
|
|
menu.cmpEl.focus();
|
|
|
|
}, 10);
|
2018-03-14 11:55:53 +00:00
|
|
|
this._fromShowContentControls = false;
|
2018-03-14 10:19:41 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onHideContentControlsActions: function() {
|
|
|
|
this.view.contentsMenu && this.view.contentsMenu.hide();
|
|
|
|
this.view.contentsUpdateMenu && this.view.contentsUpdateMenu.hide();
|
2019-11-20 13:04:32 +00:00
|
|
|
},
|
|
|
|
|
2019-11-20 11:56:32 +00:00
|
|
|
onShowContentControlsActions: function(obj, x, y) {
|
2019-12-05 10:48:48 +00:00
|
|
|
(obj.type == Asc.c_oAscContentControlSpecificType.TOC) && this.onShowTOCActions(obj, x, y);
|
2020-09-22 13:48:45 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onCrossRefClick: function(btn) {
|
2020-09-23 14:36:27 +00:00
|
|
|
if (this.dlgCrossRefDialog && this.dlgCrossRefDialog.isVisible()) return;
|
|
|
|
|
2020-09-22 13:48:45 +00:00
|
|
|
var me = this;
|
2020-09-23 14:36:27 +00:00
|
|
|
me.dlgCrossRefDialog = new DE.Views.CrossReferenceDialog({
|
2020-09-22 13:48:45 +00:00
|
|
|
api: me.api,
|
2020-09-24 14:03:46 +00:00
|
|
|
crossRefProps: me.crossRefProps,
|
2020-09-22 13:48:45 +00:00
|
|
|
handler: function (result, settings) {
|
2020-09-23 14:36:27 +00:00
|
|
|
if (result != 'ok')
|
|
|
|
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
|
2020-09-22 13:48:45 +00:00
|
|
|
}
|
2020-09-23 14:36:27 +00:00
|
|
|
});
|
2020-09-24 14:03:46 +00:00
|
|
|
me.dlgCrossRefDialog.on('close', function(obj){
|
|
|
|
me.crossRefProps = me.dlgCrossRefDialog.getSettings();
|
|
|
|
});
|
2020-09-23 14:36:27 +00:00
|
|
|
me.dlgCrossRefDialog.show();
|
2020-10-15 07:32:46 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onTableFigures: function(){
|
|
|
|
var props = this.api.asc_GetTableOfFiguresPr();
|
|
|
|
var me = this,
|
|
|
|
win = new DE.Views.TableOfContentsSettings({
|
|
|
|
api: this.api,
|
|
|
|
props: props,
|
|
|
|
type: 1,
|
|
|
|
handler: function(result, value) {
|
|
|
|
if (result == 'ok') {
|
|
|
|
me.api.asc_AddTableOfFigures(value);
|
|
|
|
}
|
|
|
|
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
win.show();
|
|
|
|
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
|
|
|
|
},
|
|
|
|
|
|
|
|
onTableFiguresUpdate: function(){
|
|
|
|
this.api.asc_UpdateTablesOfFigures();
|
|
|
|
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
|
|
|
|
},
|
|
|
|
|
|
|
|
onAscReplaceCurrentTOF: function(apiCallback) {
|
|
|
|
Common.UI.warning({
|
|
|
|
msg: this.view.confirmReplaceTOF,
|
2020-10-15 11:39:44 +00:00
|
|
|
buttons: ['yes', 'no', 'cancel'],
|
|
|
|
primary: 'yes',
|
2020-10-15 07:32:46 +00:00
|
|
|
callback: _.bind(function(btn) {
|
2020-10-15 11:39:44 +00:00
|
|
|
if (btn=='yes' || btn=='no') {
|
|
|
|
apiCallback && apiCallback(btn === 'yes');
|
|
|
|
}
|
2020-10-15 07:32:46 +00:00
|
|
|
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
|
|
|
|
}, this)
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
onAscTOFUpdate: function(apiCallback) {
|
2020-10-15 11:39:44 +00:00
|
|
|
var me = this;
|
|
|
|
(new Common.Views.OptionsDialog({
|
|
|
|
width: 300,
|
|
|
|
title: this.view.titleUpdateTOF,
|
|
|
|
items: [
|
|
|
|
{caption: this.view.textUpdatePages, value: true, checked: true},
|
|
|
|
{caption: this.view.textUpdateAll, value: false, checked: false}
|
|
|
|
],
|
|
|
|
handler: function (dlg, result) {
|
|
|
|
if (result=='ok') {
|
|
|
|
apiCallback && apiCallback(dlg.getSettings());
|
|
|
|
}
|
|
|
|
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
|
|
|
|
}
|
|
|
|
})).show();
|
2017-12-23 08:33:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}, DE.Controllers.Links || {}));
|
|
|
|
});
|