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([
|
|
|
|
'common/main/lib/util/utils',
|
|
|
|
'common/main/lib/component/BaseView',
|
|
|
|
'common/main/lib/component/Layout'
|
|
|
|
], function () {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
DE.Views.Links = Common.UI.BaseView.extend(_.extend((function(){
|
|
|
|
function setEvents() {
|
|
|
|
var me = this;
|
|
|
|
this.btnsContents.forEach(function(button) {
|
|
|
|
button.menu.on('item:click', function (menu, item, e) {
|
|
|
|
me.fireEvent('links:contents', [item.value]);
|
|
|
|
});
|
|
|
|
button.on('click', function (b, e) {
|
|
|
|
me.fireEvent('links:contents', [0]);
|
|
|
|
});
|
|
|
|
});
|
2018-03-14 10:19:41 +00:00
|
|
|
this.contentsMenu.on('item:click', function (menu, item, e) {
|
|
|
|
setTimeout(function(){
|
|
|
|
me.fireEvent('links:contents', [item.value, true]);
|
|
|
|
}, 10);
|
|
|
|
});
|
2017-12-23 08:33:49 +00:00
|
|
|
|
|
|
|
this.btnContentsUpdate.menu.on('item:click', function (menu, item, e) {
|
|
|
|
me.fireEvent('links:update', [item.value]);
|
|
|
|
});
|
|
|
|
this.btnContentsUpdate.on('click', function (b, e) {
|
|
|
|
me.fireEvent('links:update', ['all']);
|
|
|
|
});
|
2018-03-14 10:19:41 +00:00
|
|
|
this.contentsUpdateMenu.on('item:click', function (menu, item, e) {
|
|
|
|
setTimeout(function(){
|
|
|
|
me.fireEvent('links:update', [item.value, true]);
|
|
|
|
}, 10);
|
|
|
|
});
|
2017-12-25 12:55:26 +00:00
|
|
|
|
|
|
|
this.btnsNotes.forEach(function(button) {
|
|
|
|
button.menu.on('item:click', function (menu, item, e) {
|
|
|
|
me.fireEvent('links:notes', [item.value]);
|
|
|
|
});
|
|
|
|
button.on('click', function (b, e) {
|
|
|
|
me.fireEvent('links:notes', ['ins_footnote']);
|
|
|
|
});
|
2020-08-02 16:39:37 +00:00
|
|
|
button.menu.items[7].menu.on('item:click', function (menu, item, e) {//convert
|
|
|
|
me.fireEvent('links:notes', [item.value]);
|
|
|
|
});
|
2017-12-25 12:55:26 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
this.btnsPrevNote.forEach(function(button) {
|
|
|
|
button.on('click', function (b, e) {
|
|
|
|
me.fireEvent('links:notes', ['prev']);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
this.btnsNextNote.forEach(function(button) {
|
|
|
|
button.on('click', function (b, e) {
|
|
|
|
me.fireEvent('links:notes', ['next']);
|
|
|
|
});
|
|
|
|
});
|
2017-12-26 07:32:52 +00:00
|
|
|
|
2020-07-29 11:50:24 +00:00
|
|
|
this.btnsPrevEndNote.forEach(function(button) {
|
|
|
|
button.on('click', function (b, e) {
|
|
|
|
me.fireEvent('links:notes', ['prev-end']);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
this.btnsNextEndNote.forEach(function(button) {
|
|
|
|
button.on('click', function (b, e) {
|
|
|
|
me.fireEvent('links:notes', ['next-end']);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-12-26 07:32:52 +00:00
|
|
|
this.btnsHyperlink.forEach(function(button) {
|
|
|
|
button.on('click', function (b, e) {
|
|
|
|
me.fireEvent('links:hyperlink');
|
|
|
|
});
|
|
|
|
});
|
2018-02-19 11:56:44 +00:00
|
|
|
|
|
|
|
this.btnBookmarks.on('click', function (b, e) {
|
|
|
|
me.fireEvent('links:bookmarks');
|
|
|
|
});
|
2019-09-11 14:26:20 +00:00
|
|
|
|
|
|
|
this.btnCaption.on('click', function (b, e) {
|
|
|
|
me.fireEvent('links:caption');
|
|
|
|
});
|
2017-12-23 08:33:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
options: {},
|
|
|
|
|
|
|
|
initialize: function (options) {
|
|
|
|
Common.UI.BaseView.prototype.initialize.call(this);
|
|
|
|
this.toolbar = options.toolbar;
|
|
|
|
|
2017-12-25 12:55:26 +00:00
|
|
|
this.btnsPrevNote = [];
|
|
|
|
this.btnsNextNote = [];
|
2020-07-29 11:50:24 +00:00
|
|
|
this.btnsPrevEndNote = [];
|
|
|
|
this.btnsNextEndNote = [];
|
2017-12-26 07:32:52 +00:00
|
|
|
this.paragraphControls = [];
|
2017-12-23 08:33:49 +00:00
|
|
|
|
|
|
|
var me = this,
|
|
|
|
$host = me.toolbar.$el;
|
|
|
|
|
2019-11-21 07:58:05 +00:00
|
|
|
this.btnsContents = Common.Utils.injectButtons($host.find('.btn-slot.btn-contents'), '', 'toolbar__icon btn-contents', me.capBtnInsContents, undefined, true, true );
|
|
|
|
this.btnsNotes = Common.Utils.injectButtons($host.find('.btn-slot.slot-notes'), '', 'toolbar__icon btn-notes', me.capBtnInsFootnote, undefined, true, true);
|
|
|
|
this.btnsHyperlink = Common.Utils.injectButtons($host.find('.btn-slot.slot-inshyperlink'), '', 'toolbar__icon btn-inserthyperlink', me.capBtnInsLink);
|
2019-06-11 11:27:25 +00:00
|
|
|
Array.prototype.push.apply(this.paragraphControls, this.btnsContents.concat(this.btnsNotes, this.btnsHyperlink));
|
2017-12-23 08:33:49 +00:00
|
|
|
|
|
|
|
this.btnContentsUpdate = new Common.UI.Button({
|
2020-04-29 07:36:53 +00:00
|
|
|
parentEl: $host.find('#slot-btn-contents-update'),
|
2017-12-23 08:33:49 +00:00
|
|
|
cls: 'btn-toolbar x-huge icon-top',
|
2020-04-21 17:35:58 +00:00
|
|
|
iconCls: 'toolbar__icon btn-update',
|
2017-12-23 08:33:49 +00:00
|
|
|
caption: this.capBtnContentsUpdate,
|
|
|
|
split: true,
|
|
|
|
menu: true,
|
|
|
|
disabled: true
|
|
|
|
});
|
2017-12-26 07:32:52 +00:00
|
|
|
this.paragraphControls.push(this.btnContentsUpdate);
|
2017-12-25 12:55:26 +00:00
|
|
|
|
2018-02-19 11:56:44 +00:00
|
|
|
this.btnBookmarks = new Common.UI.Button({
|
2020-04-29 07:36:53 +00:00
|
|
|
parentEl: $host.find('#slot-btn-bookmarks'),
|
2018-02-19 11:56:44 +00:00
|
|
|
cls: 'btn-toolbar x-huge icon-top',
|
2019-11-21 07:58:05 +00:00
|
|
|
iconCls: 'toolbar__icon btn-bookmarks',
|
2018-02-19 11:56:44 +00:00
|
|
|
caption: this.capBtnBookmarks,
|
|
|
|
disabled: true
|
|
|
|
});
|
|
|
|
this.paragraphControls.push(this.btnBookmarks);
|
|
|
|
|
2019-09-11 14:26:20 +00:00
|
|
|
this.btnCaption = new Common.UI.Button({
|
2020-04-29 07:36:53 +00:00
|
|
|
parentEl: $host.find('#slot-btn-caption'),
|
2019-09-11 14:26:20 +00:00
|
|
|
cls: 'btn-toolbar x-huge icon-top',
|
2019-11-21 07:58:05 +00:00
|
|
|
iconCls: 'toolbar__icon btn-caption',
|
2019-09-11 14:26:20 +00:00
|
|
|
caption: this.capBtnCaption,
|
|
|
|
disabled: true
|
|
|
|
});
|
|
|
|
this.paragraphControls.push(this.btnCaption);
|
|
|
|
|
2017-12-25 12:55:26 +00:00
|
|
|
this._state = {disabled: false};
|
2017-12-23 08:33:49 +00:00
|
|
|
Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this));
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function (el) {
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
onAppReady: function (config) {
|
|
|
|
var me = this;
|
|
|
|
(new Promise(function (accept, reject) {
|
|
|
|
accept();
|
|
|
|
})).then(function(){
|
2019-09-25 13:25:57 +00:00
|
|
|
var contentsTemplate = _.template('<a id="<%= id %>" tabindex="-1" type="menuitem" class="item-contents"><div></div></a>');
|
2017-12-23 08:33:49 +00:00
|
|
|
me.btnsContents.forEach( function(btn) {
|
|
|
|
btn.updateHint( me.tipContents );
|
|
|
|
|
|
|
|
var _menu = new Common.UI.Menu({
|
2019-09-25 13:25:57 +00:00
|
|
|
cls: 'toc-menu',
|
2017-12-23 08:33:49 +00:00
|
|
|
items: [
|
|
|
|
{template: contentsTemplate, offsety: 0, value: 0},
|
|
|
|
{template: contentsTemplate, offsety: 72, value: 1},
|
|
|
|
{caption: me.textContentsSettings, value: 'settings'},
|
|
|
|
{caption: me.textContentsRemove, value: 'remove'}
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
|
|
|
btn.setMenu(_menu);
|
|
|
|
});
|
|
|
|
|
2018-03-14 10:19:41 +00:00
|
|
|
me.contentsMenu = new Common.UI.Menu({
|
2019-09-25 13:25:57 +00:00
|
|
|
cls: 'toc-menu',
|
2018-03-14 10:19:41 +00:00
|
|
|
items: [
|
|
|
|
{template: contentsTemplate, offsety: 0, value: 0},
|
|
|
|
{template: contentsTemplate, offsety: 72, value: 1},
|
|
|
|
{caption: me.textContentsSettings, value: 'settings'},
|
|
|
|
{caption: me.textContentsRemove, value: 'remove'}
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
2018-03-15 14:57:36 +00:00
|
|
|
me.btnContentsUpdate.updateHint([me.textUpdateAll, me.tipContentsUpdate]);
|
2017-12-26 07:32:52 +00:00
|
|
|
me.btnContentsUpdate.setMenu(new Common.UI.Menu({
|
2017-12-23 08:33:49 +00:00
|
|
|
items: [
|
|
|
|
{caption: me.textUpdateAll, value: 'all'},
|
|
|
|
{caption: me.textUpdatePages, value: 'pages'}
|
|
|
|
]
|
2017-12-26 07:32:52 +00:00
|
|
|
}));
|
2017-12-23 08:33:49 +00:00
|
|
|
|
2018-03-14 10:19:41 +00:00
|
|
|
me.contentsUpdateMenu = new Common.UI.Menu({
|
|
|
|
items: [
|
|
|
|
{caption: me.textUpdateAll, value: 'all'},
|
|
|
|
{caption: me.textUpdatePages, value: 'pages'}
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
2017-12-25 12:55:26 +00:00
|
|
|
me.btnsNotes.forEach( function(btn, index) {
|
|
|
|
btn.updateHint( me.tipNotes );
|
|
|
|
|
|
|
|
var _menu = new Common.UI.Menu({
|
|
|
|
items: [
|
|
|
|
{caption: me.mniInsFootnote, value: 'ins_footnote'},
|
2020-07-29 11:50:24 +00:00
|
|
|
{caption: me.mniInsEndnote, value: 'ins_endnote'},
|
2017-12-25 12:55:26 +00:00
|
|
|
{caption: '--'},
|
|
|
|
new Common.UI.MenuItem({
|
|
|
|
template: _.template([
|
|
|
|
'<div class="menu-zoom" style="height: 25px;" ',
|
|
|
|
'<% if(!_.isUndefined(options.stopPropagation)) { %>',
|
|
|
|
'data-stopPropagation="true"',
|
|
|
|
'<% } %>', '>',
|
|
|
|
'<label class="title">' + me.textGotoFootnote + '</label>',
|
2019-11-21 07:58:05 +00:00
|
|
|
'<button id="id-menu-goto-footnote-next-' + index + '" type="button" style="float:right; margin: 2px 5px 0 0;" class="btn small btn-toolbar"><i class="icon menu__icon btn-nextitem"> </i></button>',
|
|
|
|
'<button id="id-menu-goto-footnote-prev-' + index + '" type="button" style="float:right; margin-top: 2px;" class="btn small btn-toolbar"><i class="icon menu__icon btn-previtem"> </i></button>',
|
2017-12-25 12:55:26 +00:00
|
|
|
'</div>'
|
|
|
|
].join('')),
|
|
|
|
stopPropagation: true
|
|
|
|
}),
|
2020-07-29 11:50:24 +00:00
|
|
|
new Common.UI.MenuItem({
|
|
|
|
template: _.template([
|
|
|
|
'<div class="menu-zoom" style="height: 25px;" ',
|
|
|
|
'<% if(!_.isUndefined(options.stopPropagation)) { %>',
|
|
|
|
'data-stopPropagation="true"',
|
|
|
|
'<% } %>', '>',
|
|
|
|
'<label class="title">' + me.textGotoEndnote + '</label>',
|
|
|
|
'<button id="id-menu-goto-endnote-next-' + index + '" type="button" style="float:right; margin: 2px 5px 0 0;" class="btn small btn-toolbar"><i class="icon menu__icon btn-nextitem"> </i></button>',
|
|
|
|
'<button id="id-menu-goto-endnote-prev-' + index + '" type="button" style="float:right; margin-top: 2px;" class="btn small btn-toolbar"><i class="icon menu__icon btn-previtem"> </i></button>',
|
|
|
|
'</div>'
|
|
|
|
].join('')),
|
|
|
|
stopPropagation: true
|
|
|
|
}),
|
2017-12-25 12:55:26 +00:00
|
|
|
{caption: '--'},
|
|
|
|
{caption: me.mniDelFootnote, value: 'delele'},
|
2020-08-02 16:39:37 +00:00
|
|
|
{
|
|
|
|
caption: me.mniConvertNote, value: 'convert',
|
|
|
|
menu: new Common.UI.Menu({
|
|
|
|
menuAlign : 'tl-tr',
|
|
|
|
items: [
|
|
|
|
{caption: me.textConvertToEndnotes, value: 'to-endnotes'},
|
|
|
|
{caption: me.textConvertToFootnotes, value: 'to-footnotes'},
|
|
|
|
{caption: me.textSwapNotes, value: 'swap'}
|
|
|
|
]
|
|
|
|
})
|
|
|
|
},
|
2017-12-25 12:55:26 +00:00
|
|
|
{caption: me.mniNoteSettings, value: 'settings'}
|
|
|
|
]
|
|
|
|
});
|
|
|
|
btn.setMenu(_menu);
|
|
|
|
|
|
|
|
me.btnsPrevNote.push(new Common.UI.Button({
|
|
|
|
el: $('#id-menu-goto-footnote-prev-'+index),
|
|
|
|
cls: 'btn-toolbar'
|
|
|
|
}));
|
2019-06-10 10:45:38 +00:00
|
|
|
me.btnsNextNote.push(new Common.UI.Button({
|
2017-12-25 12:55:26 +00:00
|
|
|
el: $('#id-menu-goto-footnote-next-'+index),
|
|
|
|
cls: 'btn-toolbar'
|
|
|
|
}));
|
2020-07-29 11:50:24 +00:00
|
|
|
me.btnsPrevEndNote.push(new Common.UI.Button({
|
|
|
|
el: $('#id-menu-goto-endnote-prev-'+index),
|
|
|
|
cls: 'btn-toolbar'
|
|
|
|
}));
|
|
|
|
me.btnsNextEndNote.push(new Common.UI.Button({
|
|
|
|
el: $('#id-menu-goto-endnote-next-'+index),
|
|
|
|
cls: 'btn-toolbar'
|
|
|
|
}));
|
2017-12-26 07:32:52 +00:00
|
|
|
});
|
2017-12-25 12:55:26 +00:00
|
|
|
|
2017-12-26 07:32:52 +00:00
|
|
|
me.btnsHyperlink.forEach( function(btn) {
|
|
|
|
btn.updateHint(me.tipInsertHyperlink + Common.Utils.String.platformKey('Ctrl+K'));
|
2017-12-25 12:55:26 +00:00
|
|
|
});
|
|
|
|
|
2018-02-19 11:56:44 +00:00
|
|
|
me.btnBookmarks.updateHint(me.tipBookmarks);
|
2019-09-11 14:26:20 +00:00
|
|
|
me.btnCaption.updateHint(me.tipCaption);
|
2018-02-19 11:56:44 +00:00
|
|
|
|
2017-12-23 08:33:49 +00:00
|
|
|
setEvents.call(me);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
show: function () {
|
|
|
|
Common.UI.BaseView.prototype.show.call(this);
|
|
|
|
this.fireEvent('show', this);
|
|
|
|
},
|
|
|
|
|
|
|
|
getButtons: function() {
|
2017-12-26 07:32:52 +00:00
|
|
|
return this.paragraphControls;
|
2017-12-23 08:33:49 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
SetDisabled: function (state) {
|
|
|
|
this._state.disabled = state;
|
2017-12-26 07:32:52 +00:00
|
|
|
this.paragraphControls.forEach(function(button) {
|
2017-12-23 08:33:49 +00:00
|
|
|
if ( button ) {
|
|
|
|
button.setDisabled(state);
|
|
|
|
}
|
|
|
|
}, this);
|
|
|
|
},
|
|
|
|
|
|
|
|
capBtnInsContents: 'Table of Contents',
|
|
|
|
tipContents: 'Insert table of contents',
|
|
|
|
textContentsSettings: 'Settings',
|
|
|
|
textContentsRemove: 'Remove table of contents',
|
2018-02-08 13:03:10 +00:00
|
|
|
capBtnContentsUpdate: 'Refresh',
|
|
|
|
tipContentsUpdate: 'Refresh table of contents',
|
|
|
|
textUpdateAll: 'Refresh entire table',
|
|
|
|
textUpdatePages: 'Refresh page numbers only',
|
2017-12-25 12:55:26 +00:00
|
|
|
tipNotes: 'Footnotes',
|
|
|
|
mniInsFootnote: 'Insert Footnote',
|
2020-07-29 11:50:24 +00:00
|
|
|
mniDelFootnote: 'Delete All Notes',
|
2017-12-25 12:55:26 +00:00
|
|
|
mniNoteSettings: 'Notes Settings',
|
2020-08-03 13:12:33 +00:00
|
|
|
textGotoFootnote: 'Go to Footnotes',
|
2017-12-25 12:55:26 +00:00
|
|
|
capBtnInsFootnote: 'Footnotes',
|
2017-12-26 07:32:52 +00:00
|
|
|
confirmDeleteFootnotes: 'Do you want to delete all footnotes?',
|
|
|
|
capBtnInsLink: 'Hyperlink',
|
2018-02-19 11:56:44 +00:00
|
|
|
tipInsertHyperlink: 'Add Hyperlink',
|
|
|
|
capBtnBookmarks: 'Bookmark',
|
2019-09-11 14:26:20 +00:00
|
|
|
tipBookmarks: 'Create a bookmark',
|
|
|
|
capBtnCaption: 'Caption',
|
2020-07-29 11:50:24 +00:00
|
|
|
tipCaption: 'Insert caption',
|
|
|
|
mniConvertNote: 'Convert All Notes',
|
2020-08-03 13:12:33 +00:00
|
|
|
textGotoEndnote: 'Go to Endnotes',
|
2020-08-02 16:39:37 +00:00
|
|
|
mniInsEndnote: 'Insert Endnote',
|
|
|
|
textConvertToEndnotes: 'Convert All Footnotes to Endnotes',
|
|
|
|
textConvertToFootnotes: 'Convert All Endnotes to Footnotes',
|
|
|
|
textSwapNotes: 'Swap Footnotes and Endnotes'
|
2017-12-23 08:33:49 +00:00
|
|
|
}
|
|
|
|
}()), DE.Views.Links || {}));
|
|
|
|
});
|