diff --git a/apps/documenteditor/main/app/controller/Links.js b/apps/documenteditor/main/app/controller/Links.js index 4c3a5d09e..5e52e1e46 100644 --- a/apps/documenteditor/main/app/controller/Links.js +++ b/apps/documenteditor/main/app/controller/Links.js @@ -46,7 +46,8 @@ define([ 'documenteditor/main/app/view/HyperlinkSettingsDialog', 'documenteditor/main/app/view/TableOfContentsSettings', 'documenteditor/main/app/view/BookmarksDialog', - 'documenteditor/main/app/view/CaptionDialog' + 'documenteditor/main/app/view/CaptionDialog', + 'documenteditor/main/app/view/NotesRemoveDialog' ], function () { 'use strict'; @@ -292,33 +293,37 @@ define([ case 'ins_footnote': this.api.asc_AddFootnote(); break; + case 'ins_endnote': + this.api.asc_AddEndnote(); + break; case 'delele': - Common.UI.warning({ - msg: this.view.confirmDeleteFootnotes, - buttons: ['yes', 'no'], - primary: 'yes', - callback: _.bind(function (btn) { - if (btn == 'yes') { - this.api.asc_RemoveAllFootnotes(); + (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); } - Common.NotificationCenter.trigger('edit:complete', this.toolbar); - }, this) - }); + Common.NotificationCenter.trigger('edit:complete', me.toolbar); + } + })).show(); break; case 'settings': + var isEndNote = me.api.asc_IsCursorInEndnote(); (new DE.Views.NoteSettingsDialog({ api: me.api, handler: function (result, settings) { if (settings) { - me.api.asc_SetFootnoteProps(settings.props, settings.applyToAll); + settings.isEndNote ? me.api.asc_SetEndnoteProps(settings.props, settings.applyToAll) : + me.api.asc_SetFootnoteProps(settings.props, settings.applyToAll); if (result == 'insert') setTimeout(function() { - me.api.asc_AddFootnote(settings.custom); + settings.isEndNote ? me.api.asc_AddEndnote(settings.custom) : me.api.asc_AddFootnote(settings.custom); }, 1); } Common.NotificationCenter.trigger('edit:complete', me.toolbar); }, - props: me.api.asc_GetFootnoteProps() + isEndNote: isEndNote, + props: isEndNote ? me.api.asc_GetEndnoteProps() : me.api.asc_GetFootnoteProps() })).show(); break; case 'prev': @@ -333,6 +338,36 @@ define([ Common.NotificationCenter.trigger('edit:complete', me.toolbar); }, 50); break; + 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; + 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; } }, diff --git a/apps/documenteditor/main/app/view/Links.js b/apps/documenteditor/main/app/view/Links.js index eb641576a..e8bcc4880 100644 --- a/apps/documenteditor/main/app/view/Links.js +++ b/apps/documenteditor/main/app/view/Links.js @@ -82,6 +82,9 @@ define([ button.on('click', function (b, e) { me.fireEvent('links:notes', ['ins_footnote']); }); + button.menu.items[7].menu.on('item:click', function (menu, item, e) {//convert + me.fireEvent('links:notes', [item.value]); + }); }); this.btnsPrevNote.forEach(function(button) { @@ -96,6 +99,18 @@ define([ }); }); + 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']); + }); + }); + this.btnsHyperlink.forEach(function(button) { button.on('click', function (b, e) { me.fireEvent('links:hyperlink'); @@ -121,6 +136,8 @@ define([ this.btnsPrevNote = []; this.btnsNextNote = []; + this.btnsPrevEndNote = []; + this.btnsNextEndNote = []; this.paragraphControls = []; var me = this, @@ -221,6 +238,7 @@ define([ var _menu = new Common.UI.Menu({ items: [ {caption: me.mniInsFootnote, value: 'ins_footnote'}, + {caption: me.mniInsEndnote, value: 'ins_endnote'}, {caption: '--'}, new Common.UI.MenuItem({ template: _.template([ @@ -235,8 +253,32 @@ define([ ].join('')), stopPropagation: true }), + new Common.UI.MenuItem({ + template: _.template([ + '
' + ].join('')), + stopPropagation: true + }), {caption: '--'}, {caption: me.mniDelFootnote, value: 'delele'}, + { + 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'} + ] + }) + }, {caption: me.mniNoteSettings, value: 'settings'} ] }); @@ -250,6 +292,14 @@ define([ el: $('#id-menu-goto-footnote-next-'+index), cls: 'btn-toolbar' })); + 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' + })); }); me.btnsHyperlink.forEach( function(btn) { @@ -291,7 +341,7 @@ define([ textUpdatePages: 'Refresh page numbers only', tipNotes: 'Footnotes', mniInsFootnote: 'Insert Footnote', - mniDelFootnote: 'Delete All Footnotes', + mniDelFootnote: 'Delete All Notes', mniNoteSettings: 'Notes Settings', textGotoFootnote: 'Go to Footnotes', capBtnInsFootnote: 'Footnotes', @@ -301,7 +351,13 @@ define([ capBtnBookmarks: 'Bookmark', tipBookmarks: 'Create a bookmark', capBtnCaption: 'Caption', - tipCaption: 'Insert caption' + tipCaption: 'Insert caption', + mniConvertNote: 'Convert All Notes', + textGotoEndnote: 'Go to Endnotes', + mniInsEndnote: 'Insert Endnote', + textConvertToEndnotes: 'Convert All Footnotes to Endnotes', + textConvertToFootnotes: 'Convert All Endnotes to Footnotes', + textSwapNotes: 'Swap Footnotes and Endnotes' } }()), DE.Views.Links || {})); }); \ No newline at end of file diff --git a/apps/documenteditor/main/app/view/NoteSettingsDialog.js b/apps/documenteditor/main/app/view/NoteSettingsDialog.js index 2c4bfc099..3f13ac7ef 100644 --- a/apps/documenteditor/main/app/view/NoteSettingsDialog.js +++ b/apps/documenteditor/main/app/view/NoteSettingsDialog.js @@ -65,18 +65,19 @@ define([ '', - '', + '', ' | ', '|
', - '', + ' | ', + '', '', ' | ', '
', - '', + ' | ', + '', + '', ' | ', '
', - '', - ' | ', - '|
',
'',
@@ -133,17 +129,50 @@ define([
this.api = options.api;
this.handler = options.handler;
this.props = options.props;
+ this.isEndNote = options.isEndNote || false;
Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options);
- this.FormatType = 1;
- this.StartValue = 1;
+ this._state = {
+ footnote: {
+ numbering: Asc.c_oAscFootnoteRestart.Continuous,
+ format: Asc.c_oAscNumberingFormat.Decimal,
+ start: 1
+ },
+ endnote: {
+ numbering: Asc.c_oAscFootnoteRestart.Continuous,
+ format: Asc.c_oAscNumberingFormat.LowerRoman,
+ start: 1
+ }};
},
render: function() {
Common.Views.AdvancedSettingsWindow.prototype.render.call(this);
var me = this;
+ this.radioFootnote = new Common.UI.RadioBox({
+ el: $('#note-settings-radio-foot'),
+ name: 'asc-radio-notes',
+ labelText: this.textFootnote,
+ checked: true
+ });
+ this.radioFootnote.on('change', function(field, newValue, eOpts) {
+ if (newValue) {
+ me.changeNoteType(false);
+ }
+ });
+
+ this.radioEndnote = new Common.UI.RadioBox({
+ el: $('#note-settings-radio-end'),
+ labelText: this.textEndnote,
+ name: 'asc-radio-notes'
+ });
+ this.radioEndnote.on('change', function(field, newValue, eOpts) {
+ if (newValue) {
+ me.changeNoteType(true);
+ }
+ });
+
this.cmbFootnote = new Common.UI.ComboBox({
el: $('#note-settings-combo-footnote'),
cls: 'input-group-nr',
@@ -156,6 +185,18 @@ define([
});
this.cmbFootnote.setValue(Asc.c_oAscFootnotePos.PageBottom);
+ this.cmbEndnote = new Common.UI.ComboBox({
+ el: $('#note-settings-combo-endnote'),
+ cls: 'input-group-nr',
+ menuStyle: 'min-width: 150px;',
+ editable: false,
+ data: [
+ { displayValue: this.textSectEnd, value: Asc.c_oAscFootnotePos.SectEnd },
+ { displayValue: this.textPageBottom, value: Asc.c_oAscFootnotePos.PageBottom }
+ ]
+ });
+ this.cmbEndnote.setValue(Asc.c_oAscFootnotePos.PageBottom);
+
this.cmbFormat = new Common.UI.ComboBox({
el: $('#note-settings-combo-format'),
cls: 'input-group-nr',
@@ -169,10 +210,9 @@ define([
{ displayValue: 'I, II, III,...', value: Asc.c_oAscNumberingFormat.UpperRoman, maskExp: /[IVXLCDM]/, defValue: 'I' }
]
});
- this.cmbFormat.setValue(this.FormatType);
+ this.cmbFormat.setValue(this._state.footnote.format);
this.cmbFormat.on('selected', _.bind(this.onFormatSelect, this));
- // this.spnStart = new Common.UI.MetricSpinner({
this.spnStart = new Common.UI.CustomSpinner({
el: $('#note-settings-spin-start'),
step: 1,
@@ -185,16 +225,17 @@ define([
maskExp: /[0-9]/
});
+ this._arrNumbering = [
+ { displayValue: this.textContinue, value: Asc.c_oAscFootnoteRestart.Continuous },
+ { displayValue: this.textEachSection, value: Asc.c_oAscFootnoteRestart.EachSect },
+ { displayValue: this.textEachPage, value: Asc.c_oAscFootnoteRestart.EachPage }
+ ];
this.cmbNumbering = new Common.UI.ComboBox({
el: $('#note-settings-combo-numbering'),
cls: 'input-group-nr',
menuStyle: 'min-width: 150px;',
editable: false,
- data: [
- { displayValue: this.textContinue, value: Asc.c_oAscFootnoteRestart.Continuous },
- { displayValue: this.textEachSection, value: Asc.c_oAscFootnoteRestart.EachSect },
- { displayValue: this.textEachPage, value: Asc.c_oAscFootnoteRestart.EachPage }
- ]
+ data: this._arrNumbering
});
this.cmbNumbering.setValue(Asc.c_oAscFootnoteRestart.Continuous);
@@ -239,9 +280,13 @@ define([
},
_setDefaults: function (props) {
+
+ this.isEndNote ? this.radioEndnote.setValue(true, true) : this.radioFootnote.setValue(true, true);
+ this.changeNoteType(this.isEndNote);
+
if (props) {
var val = props.get_Pos();
- this.cmbFootnote.setValue(val);
+ this.isEndNote ? this.cmbEndnote.setValue(val) : this.cmbFootnote.setValue(val);
val = props.get_NumFormat();
this.cmbFormat.setValue(val);
@@ -258,7 +303,7 @@ define([
getSettings: function () {
var props = new Asc.CAscFootnotePr();
- props.put_Pos(this.cmbFootnote.getValue());
+ props.put_Pos(this.isEndNote ? this.cmbEndnote.getValue() : this.cmbFootnote.getValue());
props.put_NumRestart(this.cmbNumbering.getValue());
var val = this.txtCustom.getValue();
@@ -268,7 +313,7 @@ define([
props.put_NumStart(this.spnStart.getNumberValue());
}
- return {props: props, applyToAll: (this.cmbApply.getValue()==1), custom: _.isEmpty(val) ? undefined : val};
+ return {props: props, applyToAll: (this.cmbApply.getValue()==1), custom: _.isEmpty(val) ? undefined : val, isEndNote: this.isEndNote};
},
onDlgBtnClick: function(event) {
@@ -315,7 +360,7 @@ define([
}
this.spnStart.setValue(this.spnStart.getValue());
- this.FormatType = record.value;
+ this._state[this.isEndNote ? 'endnote' : 'footnote'].format = record.value;
},
_10toS: function(value) {
@@ -411,6 +456,26 @@ define([
return result;
},
+ changeNoteType: function(isEndNote) {
+ this._state[this.isEndNote ? 'endnote' : 'footnote'].start = this.spnStart.getNumberValue(); // save prev start
+ this._state[this.isEndNote ? 'endnote' : 'footnote'].numbering = this.cmbNumbering.getValue(); // save prev numbering
+
+ this.isEndNote = isEndNote;
+
+ this.cmbFootnote.setDisabled(isEndNote);
+ this.cmbEndnote.setDisabled(!isEndNote);
+
+ var state = this._state[isEndNote ? 'endnote' : 'footnote'],
+ arr = isEndNote ? this._arrNumbering.slice(0,2) : this._arrNumbering;
+ this.cmbNumbering.setData(arr);
+ this.cmbNumbering.setValue(state.numbering);
+
+ this.cmbFormat.setValue(state.format);
+ this.onFormatSelect(this.cmbFormat, this.cmbFormat.getSelectedRecord());
+
+ this.spnStart.setValue(state.start);
+ },
+
textTitle: 'Notes Settings',
textLocation: 'Location',
textFootnote: 'Footnote',
@@ -428,7 +493,9 @@ define([
textSection: 'Current section',
textApply: 'Apply',
textInsert: 'Insert',
- textCustom: 'Custom Mark'
+ textCustom: 'Custom Mark',
+ textSectEnd: 'End of section',
+ textEndnote: 'Endnote'
}, DE.Views.NoteSettingsDialog || {}))
});
\ No newline at end of file
diff --git a/apps/documenteditor/main/app/view/NotesRemoveDialog.js b/apps/documenteditor/main/app/view/NotesRemoveDialog.js
new file mode 100644
index 000000000..2782ccddb
--- /dev/null
+++ b/apps/documenteditor/main/app/view/NotesRemoveDialog.js
@@ -0,0 +1,115 @@
+/*
+ *
+ * (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
+ *
+ */
+/**
+ * NotesRemoveDialog.js
+ *
+ * Created by Julia Radzhabova on 29.07.2020
+ * Copyright (c) 2020 Ascensio System SIA. All rights reserved.
+ *
+ */
+define([
+ 'common/main/lib/component/Window',
+ 'common/main/lib/component/RadioBox'
+], function () { 'use strict';
+
+ DE.Views.NotesRemoveDialog = Common.UI.Window.extend(_.extend({
+ options: {
+ width: 214,
+ height: 138,
+ header: true,
+ style: 'min-width: 214px;',
+ cls: 'modal-dlg',
+ buttons: ['ok', 'cancel']
+ },
+
+ initialize : function(options) {
+ _.extend(this.options, {
+ title: this.textTitle
+ }, options);
+
+ this.template = [
+ ' ',
+ '',
+ '',
+ ' '
+ ].join('');
+
+ this.options.tpl = _.template(this.template)(this.options);
+
+ Common.UI.Window.prototype.initialize.call(this, this.options);
+ },
+
+ render: function() {
+ Common.UI.Window.prototype.render.call(this);
+
+ var $window = this.getChild();
+ $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
+
+ this.chFootnote = new Common.UI.CheckBox({
+ el: $window.find('#notes-remove-chk-foot'),
+ labelText: this.textFoot,
+ value: true
+ });
+
+ this.chEndnote = new Common.UI.CheckBox({
+ el: $window.find('#notes-remove-chk-end'),
+ labelText: this.textEnd,
+ value: true
+ });
+ },
+
+ _handleInput: function(state) {
+ if (this.options.handler) {
+ this.options.handler.call(this, this, state);
+ }
+
+ this.close();
+ },
+
+ onBtnClick: function(event) {
+ this._handleInput(event.currentTarget.attributes['result'].value);
+ },
+
+ getSettings: function() {
+ return {footnote: this.chFootnote.isChecked(), endnote: this.chEndnote.isChecked()};
+ },
+
+ onPrimary: function() {
+ this._handleInput('ok');
+ return false;
+ },
+ textTitle: 'Delete Notes',
+ textFoot: 'Delete All Footnotes',
+ textEnd: 'Delete All Endnotes'
+ }, DE.Views.NotesRemoveDialog || {}))
+});
\ No newline at end of file
diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json
index e9c13aa9c..6d7684000 100644
--- a/apps/documenteditor/main/locale/en.json
+++ b/apps/documenteditor/main/locale/en.json
@@ -1750,7 +1750,7 @@
"DE.Views.Links.capBtnInsFootnote": "Footnote",
"DE.Views.Links.capBtnInsLink": "Hyperlink",
"DE.Views.Links.confirmDeleteFootnotes": "Do you want to delete all footnotes?",
- "DE.Views.Links.mniDelFootnote": "Delete All Footnotes",
+ "DE.Views.Links.mniDelFootnote": "Delete All Notes",
"DE.Views.Links.mniInsFootnote": "Insert Footnote",
"DE.Views.Links.mniNoteSettings": "Notes Settings",
"DE.Views.Links.textContentsRemove": "Remove table of contents",
@@ -1764,6 +1764,12 @@
"DE.Views.Links.tipContentsUpdate": "Refresh table of contents",
"DE.Views.Links.tipInsertHyperlink": "Add hyperlink",
"DE.Views.Links.tipNotes": "Insert or edit footnotes",
+ "DE.Views.Links.mniConvertNote": "Convert All Notes",
+ "DE.Views.Links.textGotoEndnote": "Go to Endnotes",
+ "DE.Views.Links.mniInsEndnote": "Insert Endnote",
+ "DE.Views.Links.textConvertToEndnotes": "Convert All Footnotes to Endnotes",
+ "DE.Views.Links.textConvertToFootnotes": "Convert All Endnotes to Footnotes",
+ "DE.Views.Links.textSwapNotes": "Swap Footnotes and Endnotes",
"DE.Views.ListSettingsDialog.textAuto": "Automatic",
"DE.Views.ListSettingsDialog.textCenter": "Center",
"DE.Views.ListSettingsDialog.textLeft": "Left",
@@ -1857,6 +1863,11 @@
"DE.Views.NoteSettingsDialog.textStart": "Start at",
"DE.Views.NoteSettingsDialog.textTextBottom": "Below text",
"DE.Views.NoteSettingsDialog.textTitle": "Notes Settings",
+ "DE.Views.NoteSettingsDialog.textSectEnd": "End of section",
+ "DE.Views.NoteSettingsDialog.textEndnote": "Endnote",
+ "DE.Views.NotesRemoveDialog.textTitle": "Delete Notes",
+ "DE.Views.NotesRemoveDialog.textFoot": "Delete All Footnotes",
+ "DE.Views.NotesRemoveDialog.textEnd": "Delete All Endnotes",
"DE.Views.PageMarginsDialog.notcriticalErrorTitle": "Warning",
"DE.Views.PageMarginsDialog.textBottom": "Bottom",
"DE.Views.PageMarginsDialog.textGutter": "Gutter",
|