[DE] Add endnotes

This commit is contained in:
Julia Radzhabova 2020-07-29 14:50:24 +03:00
parent a9da5afdd4
commit 11af3400a7
3 changed files with 165 additions and 41 deletions

View file

@ -46,7 +46,8 @@ define([
'documenteditor/main/app/view/HyperlinkSettingsDialog', 'documenteditor/main/app/view/HyperlinkSettingsDialog',
'documenteditor/main/app/view/TableOfContentsSettings', 'documenteditor/main/app/view/TableOfContentsSettings',
'documenteditor/main/app/view/BookmarksDialog', 'documenteditor/main/app/view/BookmarksDialog',
'documenteditor/main/app/view/CaptionDialog' 'documenteditor/main/app/view/CaptionDialog',
'documenteditor/main/app/view/NotesRemoveDialog'
], function () { ], function () {
'use strict'; 'use strict';
@ -292,33 +293,37 @@ define([
case 'ins_footnote': case 'ins_footnote':
this.api.asc_AddFootnote(); this.api.asc_AddFootnote();
break; break;
case 'ins_endnote':
this.api.asc_AddEndnote();
break;
case 'delele': case 'delele':
Common.UI.warning({ (new DE.Views.NotesRemoveDialog({
msg: this.view.confirmDeleteFootnotes, handler: function (dlg, result) {
buttons: ['yes', 'no'], if (result=='ok') {
primary: 'yes', var settings = dlg.getSettings();
callback: _.bind(function (btn) { (settings.footnote || settings.endnote) && me.api.asc_RemoveAllFootnotes(settings.footnote, settings.endnote);
if (btn == 'yes') {
this.api.asc_RemoveAllFootnotes();
} }
Common.NotificationCenter.trigger('edit:complete', this.toolbar); Common.NotificationCenter.trigger('edit:complete', me.toolbar);
}, this) }
}); })).show();
break; break;
case 'settings': case 'settings':
var isEndNote = me.api.asc_IsCursorInEndnote();
(new DE.Views.NoteSettingsDialog({ (new DE.Views.NoteSettingsDialog({
api: me.api, api: me.api,
handler: function (result, settings) { handler: function (result, settings) {
if (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') if (result == 'insert')
setTimeout(function() { setTimeout(function() {
me.api.asc_AddFootnote(settings.custom); settings.isEndNote ? me.api.asc_AddEndnote(settings.custom) : me.api.asc_AddFootnote(settings.custom);
}, 1); }, 1);
} }
Common.NotificationCenter.trigger('edit:complete', me.toolbar); 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(); })).show();
break; break;
case 'prev': case 'prev':
@ -333,6 +338,18 @@ define([
Common.NotificationCenter.trigger('edit:complete', me.toolbar); Common.NotificationCenter.trigger('edit:complete', me.toolbar);
}, 50); }, 50);
break; 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;
} }
}, },

View file

@ -96,6 +96,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) { this.btnsHyperlink.forEach(function(button) {
button.on('click', function (b, e) { button.on('click', function (b, e) {
me.fireEvent('links:hyperlink'); me.fireEvent('links:hyperlink');
@ -121,6 +133,8 @@ define([
this.btnsPrevNote = []; this.btnsPrevNote = [];
this.btnsNextNote = []; this.btnsNextNote = [];
this.btnsPrevEndNote = [];
this.btnsNextEndNote = [];
this.paragraphControls = []; this.paragraphControls = [];
var me = this, var me = this,
@ -221,6 +235,7 @@ define([
var _menu = new Common.UI.Menu({ var _menu = new Common.UI.Menu({
items: [ items: [
{caption: me.mniInsFootnote, value: 'ins_footnote'}, {caption: me.mniInsFootnote, value: 'ins_footnote'},
{caption: me.mniInsEndnote, value: 'ins_endnote'},
{caption: '--'}, {caption: '--'},
new Common.UI.MenuItem({ new Common.UI.MenuItem({
template: _.template([ template: _.template([
@ -235,8 +250,22 @@ define([
].join('')), ].join('')),
stopPropagation: true stopPropagation: true
}), }),
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">&nbsp;</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">&nbsp;</i></button>',
'</div>'
].join('')),
stopPropagation: true
}),
{caption: '--'}, {caption: '--'},
{caption: me.mniDelFootnote, value: 'delele'}, {caption: me.mniDelFootnote, value: 'delele'},
{caption: me.mniConvertNote, value: 'convert'},
{caption: me.mniNoteSettings, value: 'settings'} {caption: me.mniNoteSettings, value: 'settings'}
] ]
}); });
@ -250,6 +279,14 @@ define([
el: $('#id-menu-goto-footnote-next-'+index), el: $('#id-menu-goto-footnote-next-'+index),
cls: 'btn-toolbar' 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) { me.btnsHyperlink.forEach( function(btn) {
@ -291,9 +328,9 @@ define([
textUpdatePages: 'Refresh page numbers only', textUpdatePages: 'Refresh page numbers only',
tipNotes: 'Footnotes', tipNotes: 'Footnotes',
mniInsFootnote: 'Insert Footnote', mniInsFootnote: 'Insert Footnote',
mniDelFootnote: 'Delete All Footnotes', mniDelFootnote: 'Delete All Notes',
mniNoteSettings: 'Notes Settings', mniNoteSettings: 'Notes Settings',
textGotoFootnote: 'Go to Footnotes', textGotoFootnote: 'Go to Footnote',
capBtnInsFootnote: 'Footnotes', capBtnInsFootnote: 'Footnotes',
confirmDeleteFootnotes: 'Do you want to delete all footnotes?', confirmDeleteFootnotes: 'Do you want to delete all footnotes?',
capBtnInsLink: 'Hyperlink', capBtnInsLink: 'Hyperlink',
@ -301,7 +338,10 @@ define([
capBtnBookmarks: 'Bookmark', capBtnBookmarks: 'Bookmark',
tipBookmarks: 'Create a bookmark', tipBookmarks: 'Create a bookmark',
capBtnCaption: 'Caption', capBtnCaption: 'Caption',
tipCaption: 'Insert caption' tipCaption: 'Insert caption',
mniConvertNote: 'Convert All Notes',
textGotoEndnote: 'Go to Endnote',
mniInsEndnote: 'Insert Endnote'
} }
}()), DE.Views.Links || {})); }()), DE.Views.Links || {}));
}); });

View file

@ -65,18 +65,19 @@ define([
'<table cols="1" style="width: 100%;">', '<table cols="1" style="width: 100%;">',
'<tr>', '<tr>',
'<td class="padding-small">', '<td class="padding-small">',
'<label class="header">', me.textLocation,'</label>', '<label class="header">', me.textLocation,'</label>',
'</td>', '</td>',
'</tr>', '</tr>',
'<tr>', '<tr>',
'<td class="padding-large">', '<td class="padding-small">',
'<label class="input-label" style="margin-top: 4px;">', me.textFootnote,'</label>', '<div id="note-settings-radio-foot" style="margin-top: 4px;display: inline-block"></div>',
'<div id="note-settings-combo-footnote" class="input-group-nr" style="display: inline-block; width:150px;float:right;"></div>', '<div id="note-settings-combo-footnote" class="input-group-nr" style="display: inline-block; width:150px;float:right;"></div>',
'</td>', '</td>',
'</tr>', '</tr>',
'<tr>', '<tr>',
'<td>', '<td class="padding-large">',
'<div class="padding-large"></div>', '<div id="note-settings-radio-end" style="margin-top: 4px;display: inline-block"></div>',
'<div id="note-settings-combo-endnote" class="input-group-nr" style="display: inline-block; width:150px;float:right;"></div>',
'</td>', '</td>',
'</tr>', '</tr>',
'<tr>', '<tr>',
@ -107,11 +108,6 @@ define([
'<div id="note-settings-txt-custom"></div>', '<div id="note-settings-txt-custom"></div>',
'</td>', '</td>',
'</tr>', '</tr>',
'<tr>',
'<td>',
'<div class="padding-large"></div>',
'</td>',
'</tr>',
'<tr>', '<tr>',
'<td class="padding-small">', '<td class="padding-small">',
'<label class="header" style="margin-top: 4px;">', me.textApplyTo,'</label>', '<label class="header" style="margin-top: 4px;">', me.textApplyTo,'</label>',
@ -133,17 +129,50 @@ define([
this.api = options.api; this.api = options.api;
this.handler = options.handler; this.handler = options.handler;
this.props = options.props; this.props = options.props;
this.isEndNote = options.isEndNote || false;
Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options); Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options);
this.FormatType = 1; this._state = {
this.StartValue = 1; 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() { render: function() {
Common.Views.AdvancedSettingsWindow.prototype.render.call(this); Common.Views.AdvancedSettingsWindow.prototype.render.call(this);
var me = 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({ this.cmbFootnote = new Common.UI.ComboBox({
el: $('#note-settings-combo-footnote'), el: $('#note-settings-combo-footnote'),
cls: 'input-group-nr', cls: 'input-group-nr',
@ -156,6 +185,18 @@ define([
}); });
this.cmbFootnote.setValue(Asc.c_oAscFootnotePos.PageBottom); 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({ this.cmbFormat = new Common.UI.ComboBox({
el: $('#note-settings-combo-format'), el: $('#note-settings-combo-format'),
cls: 'input-group-nr', cls: 'input-group-nr',
@ -169,10 +210,9 @@ define([
{ displayValue: 'I, II, III,...', value: Asc.c_oAscNumberingFormat.UpperRoman, maskExp: /[IVXLCDM]/, defValue: 'I' } { 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.cmbFormat.on('selected', _.bind(this.onFormatSelect, this));
// this.spnStart = new Common.UI.MetricSpinner({
this.spnStart = new Common.UI.CustomSpinner({ this.spnStart = new Common.UI.CustomSpinner({
el: $('#note-settings-spin-start'), el: $('#note-settings-spin-start'),
step: 1, step: 1,
@ -185,16 +225,17 @@ define([
maskExp: /[0-9]/ 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({ this.cmbNumbering = new Common.UI.ComboBox({
el: $('#note-settings-combo-numbering'), el: $('#note-settings-combo-numbering'),
cls: 'input-group-nr', cls: 'input-group-nr',
menuStyle: 'min-width: 150px;', menuStyle: 'min-width: 150px;',
editable: false, editable: false,
data: [ data: 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.setValue(Asc.c_oAscFootnoteRestart.Continuous); this.cmbNumbering.setValue(Asc.c_oAscFootnoteRestart.Continuous);
@ -239,9 +280,13 @@ define([
}, },
_setDefaults: function (props) { _setDefaults: function (props) {
this.isEndNote ? this.radioEndnote.setValue(true, true) : this.radioFootnote.setValue(true, true);
this.changeNoteType(this.isEndNote);
if (props) { if (props) {
var val = props.get_Pos(); var val = props.get_Pos();
this.cmbFootnote.setValue(val); this.isEndNote ? this.cmbEndnote.setValue(val) : this.cmbFootnote.setValue(val);
val = props.get_NumFormat(); val = props.get_NumFormat();
this.cmbFormat.setValue(val); this.cmbFormat.setValue(val);
@ -258,7 +303,7 @@ define([
getSettings: function () { getSettings: function () {
var props = new Asc.CAscFootnotePr(); 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()); props.put_NumRestart(this.cmbNumbering.getValue());
var val = this.txtCustom.getValue(); var val = this.txtCustom.getValue();
@ -268,7 +313,7 @@ define([
props.put_NumStart(this.spnStart.getNumberValue()); 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) { onDlgBtnClick: function(event) {
@ -315,7 +360,7 @@ define([
} }
this.spnStart.setValue(this.spnStart.getValue()); this.spnStart.setValue(this.spnStart.getValue());
this.FormatType = record.value; this._state[this.isEndNote ? 'endnote' : 'footnote'].format = record.value;
}, },
_10toS: function(value) { _10toS: function(value) {
@ -411,6 +456,26 @@ define([
return result; 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', textTitle: 'Notes Settings',
textLocation: 'Location', textLocation: 'Location',
textFootnote: 'Footnote', textFootnote: 'Footnote',
@ -428,7 +493,9 @@ define([
textSection: 'Current section', textSection: 'Current section',
textApply: 'Apply', textApply: 'Apply',
textInsert: 'Insert', textInsert: 'Insert',
textCustom: 'Custom Mark' textCustom: 'Custom Mark',
textSectEnd: 'End of section',
textEndnote: 'Endnote'
}, DE.Views.NoteSettingsDialog || {})) }, DE.Views.NoteSettingsDialog || {}))
}); });