Add Note editing button to the Links tab.

This commit is contained in:
Julia Radzhabova 2017-12-25 15:55:26 +03:00
parent ec02d0695e
commit be416c5ed2
6 changed files with 181 additions and 140 deletions

View file

@ -41,7 +41,8 @@
define([
'core',
'documenteditor/main/app/view/Links'
'documenteditor/main/app/view/Links',
'documenteditor/main/app/view/NoteSettingsDialog'
], function () {
'use strict';
@ -59,7 +60,8 @@ define([
this.addListeners({
'Links': {
'links:contents': this.onTableContents,
'links:update': this.onTableContentsUpdate
'links:update': this.onTableContentsUpdate,
'links:notes': this.onNotesClick
}
});
},
@ -102,9 +104,12 @@ define([
onApiFocusObject: function(selectedObjects) {
if (!this.editMode) return;
var i = -1, type, pr,
var pr, i = -1, type,
paragraph_locked = false,
header_locked = false;
header_locked = false,
in_header = false,
in_equation = false,
in_image = false;
while (++i < selectedObjects.length) {
type = selectedObjects[i].get_ObjectType();
@ -114,9 +119,19 @@ define([
paragraph_locked = pr.get_Locked();
} else if (type === Asc.c_oAscTypeSelectElement.Header) {
header_locked = pr.get_Locked();
in_header = true;
} else if (type === Asc.c_oAscTypeSelectElement.Image) {
in_image = true;
} else if (type === Asc.c_oAscTypeSelectElement.Math) {
in_equation = true;
}
}
var need_disable = paragraph_locked || in_equation || in_image || in_header;
_.each (this.view.btnsNotes, function(item){
item.setDisabled(need_disable);
}, this);
// var need_disable = paragraph_locked || header_locked;
// _.each (this.view.btnsContents, function(item){
// item.setDisabled(need_disable);
@ -141,6 +156,54 @@ define([
this.api.asc_updateTableOfContents();
else
this.api.asc_updateaddTableOfContents();
},
onNotesClick: function(type) {
var me = this;
switch (type) {
case 'ins_footnote':
this.api.asc_AddFootnote();
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();
}
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
}, this)
});
break;
case 'settings':
(new DE.Views.NoteSettingsDialog({
api: me.api,
handler: function (result, settings) {
if (settings) {
me.api.asc_SetFootnoteProps(settings.props, settings.applyToAll);
if (result == 'insert')
me.api.asc_AddFootnote(settings.custom);
}
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
},
props: me.api.asc_GetFootnoteProps()
})).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;
}
}
}, DE.Controllers.Links || {}));

View file

@ -54,7 +54,6 @@ define([
'documenteditor/main/app/view/StyleTitleDialog',
'documenteditor/main/app/view/PageMarginsDialog',
'documenteditor/main/app/view/PageSizeDialog',
'documenteditor/main/app/view/NoteSettingsDialog',
'documenteditor/main/app/controller/PageLayout',
'documenteditor/main/app/view/CustomColumnsDialog'
], function () {
@ -309,10 +308,6 @@ define([
toolbar.mnuZoomIn.on('click', _.bind(this.onZoomInClick, this));
toolbar.mnuZoomOut.on('click', _.bind(this.onZoomOutClick, this));
toolbar.btnInsertEquation.on('click', _.bind(this.onInsertEquationClick, this));
toolbar.btnNotes.on('click', _.bind(this.onNotesClick, this));
toolbar.btnNotes.menu.on('item:click', _.bind(this.onNotesMenuClick, this));
toolbar.mnuGotoFootPrev.on('click', _.bind(this.onFootnotePrevClick, this));
toolbar.mnuGotoFootNext.on('click', _.bind(this.onFootnoteNextClick, this));
$('#id-save-style-plus, #id-save-style-link', toolbar.$el).on('click', this.onMenuSaveStyle.bind(this));
@ -754,9 +749,6 @@ define([
toolbar.btnEditHeader.setDisabled(in_equation);
need_disable = paragraph_locked || in_equation || in_image || in_header;
if (need_disable !== toolbar.btnNotes.isDisabled())
toolbar.btnNotes.setDisabled(need_disable);
need_disable = paragraph_locked || header_locked || in_image;
if (need_disable != toolbar.btnColumns.isDisabled())
@ -2060,68 +2052,6 @@ define([
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
},
onNotesClick: function() {
if (this.api)
this.api.asc_AddFootnote();
},
onNotesMenuClick: function(menu, item) {
if (this.api) {
if (item.value == 'ins_footnote')
this.api.asc_AddFootnote();
else if (item.value == 'delele')
Common.UI.warning({
msg: this.confirmDeleteFootnotes,
buttons: ['yes', 'no'],
primary: 'yes',
callback: _.bind(function(btn) {
if (btn == 'yes') {
this.api.asc_RemoveAllFootnotes();
}
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
}, this)
});
else if (item.value == 'settings') {
var me = this;
(new DE.Views.NoteSettingsDialog({
api: me.api,
handler: function(result, settings) {
if (settings) {
me.api.asc_SetFootnoteProps(settings.props, settings.applyToAll);
if (result == 'insert')
me.api.asc_AddFootnote(settings.custom);
}
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
},
props : me.api.asc_GetFootnoteProps()
})).show();
} else
return;
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
}
},
onFootnotePrevClick: function(btn) {
if (this.api)
this.api.asc_GotoFootnote(false);
var me = this;
setTimeout(function() {
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
}, 50);
},
onFootnoteNextClick: function(btn) {
if (this.api)
this.api.asc_GotoFootnote(true);
var me = this;
setTimeout(function() {
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
}, 50);
},
_clearBullets: function() {
this.toolbar.btnMarkers.toggle(false, true);
this.toolbar.btnNumbers.toggle(false, true);
@ -3264,8 +3194,7 @@ define([
confirmAddFontName: 'The font you are going to save is not available on the current device.<br>The text style will be displayed using one of the device fonts, the saved font will be used when it is available.<br>Do you want to continue?',
notcriticalErrorTitle: 'Warning',
txtMarginsW: 'Left and right margins are too high for a given page wight',
txtMarginsH: 'Top and bottom margins are too high for a given page height',
confirmDeleteFootnotes: 'Do you want to delete all footnotes?'
txtMarginsH: 'Top and bottom margins are too high for a given page height'
}, DE.Controllers.Toolbar || {}));
});

View file

@ -123,7 +123,7 @@
<div class="separator long"></div>
<div class="group">
<span class="btn-slot text x-huge" id="slot-btn-inshyperlink"></span>
<span class="btn-slot text x-huge" id="slot-btn-notes"></span>
<span class="btn-slot text x-huge slot-notes"></span>
<span class="btn-slot text x-huge slot-comment"></span>
</div>
<div class="separator long"></div>

View file

@ -64,6 +64,27 @@ define([
this.btnContentsUpdate.on('click', function (b, e) {
me.fireEvent('links:update', ['all']);
});
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']);
});
});
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']);
});
});
}
return {
@ -75,6 +96,9 @@ define([
this.toolbar = options.toolbar;
this.btnsContents = [];
this.btnsNotes = [];
this.btnsPrevNote = [];
this.btnsNextNote = [];
var me = this,
$host = me.toolbar.$el;
@ -111,7 +135,24 @@ define([
});
_injectComponent('#slot-btn-contents-update', this.btnContentsUpdate);
this._state = {disabled: false, hasPassword: false};
$slots = $host.find('.btn-slot.slot-notes');
$slots.each(function(index, el) {
var _cls = 'btn-toolbar';
/x-huge/.test(el.className) && (_cls += ' x-huge icon-top');
var button = new Common.UI.Button({
cls: _cls,
iconCls: 'btn-notes',
caption: me.capBtnInsFootnote,
split: true,
menu: true,
disabled: true
}).render( $slots.eq(index) );
me.btnsNotes.push(button);
});
this._state = {disabled: false};
Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this));
},
@ -149,6 +190,44 @@ define([
});
me.btnContentsUpdate.setMenu(_menu);
me.btnsNotes.forEach( function(btn, index) {
btn.updateHint( me.tipNotes );
var _menu = new Common.UI.Menu({
items: [
{caption: me.mniInsFootnote, value: 'ins_footnote'},
{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>',
'<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 mmerge-next">&nbsp;</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 mmerge-prev">&nbsp;</i></button>',
'</div>'
].join('')),
stopPropagation: true
}),
{caption: '--'},
{caption: me.mniDelFootnote, value: 'delele'},
{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'
}));
me.btnsNextNote.push(me.mnuGotoFootNext = new Common.UI.Button({
el: $('#id-menu-goto-footnote-next-'+index),
cls: 'btn-toolbar'
}));
});
setEvents.call(me);
});
},
@ -159,12 +238,12 @@ define([
},
getButtons: function() {
return this.btnsContents.concat(this.btnContentsUpdate);
return this.btnsContents.concat(this.btnContentsUpdate).concat(this.btnsNotes);
},
SetDisabled: function (state) {
this._state.disabled = state;
this.btnsContents.forEach(function(button) {
this.btnsContents.concat(this.btnsNotes).forEach(function(button) {
if ( button ) {
button.setDisabled(state);
}
@ -179,7 +258,14 @@ define([
capBtnContentsUpdate: 'Update',
tipContentsUpdate: 'Update table of contents',
textUpdateAll: 'Update entire table',
textUpdatePages: 'Update page numbers only'
textUpdatePages: 'Update page numbers only',
tipNotes: 'Footnotes',
mniInsFootnote: 'Insert Footnote',
mniDelFootnote: 'Delete All Footnotes',
mniNoteSettings: 'Notes Settings',
textGotoFootnote: 'Go to Footnotes',
capBtnInsFootnote: 'Footnotes',
confirmDeleteFootnotes: 'Do you want to delete all footnotes?'
}
}()), DE.Views.Links || {}));
});

View file

@ -909,16 +909,6 @@ define([
});
this.toolbarControls.push(this.btnColorSchemas);
this.btnNotes = new Common.UI.Button({
id: 'id-toolbar-btn-notes',
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'btn-notes',
caption: me.capBtnInsFootnote,
split: true,
menu: true
});
this.paragraphControls.push(this.btnNotes);
this.btnMailRecepients = new Common.UI.Button({
id: 'id-toolbar-btn-mailrecepients',
cls: 'btn-toolbar',
@ -1275,7 +1265,6 @@ define([
_injectComponent('#slot-field-styles', this.listStyles);
_injectComponent('#slot-btn-halign', this.btnHorizontalAlign);
_injectComponent('#slot-btn-mailrecepients', this.btnMailRecepients);
_injectComponent('#slot-btn-notes', this.btnNotes);
_injectComponent('#slot-img-align', this.btnImgAlign);
_injectComponent('#slot-img-group', this.btnImgGroup);
_injectComponent('#slot-img-movefrwd', this.btnImgForward);
@ -1525,7 +1514,6 @@ define([
this.btnMailRecepients.updateHint(this.tipMailRecepients);
this.btnHide.updateHint(this.tipViewSettings);
this.btnAdvSettings.updateHint(this.tipAdvSettings);
this.btnNotes.updateHint(this.tipNotes);
// set menus
@ -1650,40 +1638,6 @@ define([
cls: 'btn-toolbar'
});
this.btnNotes.setMenu(
new Common.UI.Menu({
items: [
{caption: this.mniInsFootnote, value: 'ins_footnote'},
{caption: '--'},
this.mnuGotoFootnote = new Common.UI.MenuItem({
template: _.template([
'<div id="id-toolbar-menu-goto-footnote" class="menu-zoom" style="height: 25px;" ',
'<% if(!_.isUndefined(options.stopPropagation)) { %>',
'data-stopPropagation="true"',
'<% } %>', '>',
'<label class="title">' + this.textGotoFootnote + '</label>',
'<button id="id-menu-goto-footnote-next" type="button" style="float:right; margin: 2px 5px 0 0;" class="btn small btn-toolbar"><i class="icon mmerge-next">&nbsp;</i></button>',
'<button id="id-menu-goto-footnote-prev" type="button" style="float:right; margin-top: 2px;" class="btn small btn-toolbar"><i class="icon mmerge-prev">&nbsp;</i></button>',
'</div>'
].join('')),
stopPropagation: true
}),
{caption: '--'},
{caption: this.mniDelFootnote, value: 'delele'},
{caption: this.mniNoteSettings, value: 'settings'}
]
})
);
this.mnuGotoFootPrev = new Common.UI.Button({
el: $('#id-menu-goto-footnote-prev'),
cls: 'btn-toolbar'
});
this.mnuGotoFootNext = new Common.UI.Button({
el: $('#id-menu-goto-footnote-next'),
cls: 'btn-toolbar'
});
// set dataviews
var _conf = this.mnuMarkersPicker.conf;
@ -2418,11 +2372,6 @@ define([
textLandscape: 'Landscape',
textInsertPageCount: 'Insert number of pages',
textCharts: 'Charts',
tipNotes: 'Footnotes',
mniInsFootnote: 'Insert Footnote',
mniDelFootnote: 'Delete All Footnotes',
mniNoteSettings: 'Notes Settings',
textGotoFootnote: 'Go to Footnotes',
tipChangeChart: 'Change Chart Type',
capBtnInsPagebreak: 'Page Break',
capBtnInsImage: 'Picture',
@ -2438,7 +2387,6 @@ define([
capBtnInsTextbox: 'Text Box',
capBtnInsTextart: 'Text Art',
capBtnInsDropcap: 'Drop Cap',
capBtnInsFootnote: 'Footnotes',
capBtnInsEquation: 'Equation',
capBtnInsHeader: 'Headers/Footers',
capBtnColumns: 'Columns',

View file

@ -436,7 +436,7 @@
"DE.Controllers.Statusbar.tipReview": "Track changes",
"DE.Controllers.Statusbar.zoomText": "Zoom {0}%",
"DE.Controllers.Toolbar.confirmAddFontName": "The font you are going to save is not available on the current device.<br>The text style will be displayed using one of the system fonts, the saved font will be used when it is available.<br>Do you want to continue?",
"DE.Controllers.Toolbar.confirmDeleteFootnotes": "Do you want to delete all footnotes?",
"del_DE.Controllers.Toolbar.confirmDeleteFootnotes": "Do you want to delete all footnotes?",
"DE.Controllers.Toolbar.notcriticalErrorTitle": "Warning",
"DE.Controllers.Toolbar.textAccent": "Accents",
"DE.Controllers.Toolbar.textBracket": "Brackets",
@ -1233,6 +1233,21 @@
"DE.Views.LeftMenu.tipTitles": "Titles",
"DE.Views.LeftMenu.txtDeveloper": "DEVELOPER MODE",
"DE.Views.LeftMenu.txtTrial": "TRIAL MODE",
"DE.Views.Links.capBtnContentsUpdate": "Update",
"DE.Views.Links.capBtnInsContents": "Table of Contents",
"DE.Views.Links.capBtnInsFootnote": "Footnote",
"DE.Views.Links.confirmDeleteFootnotes": "Do you want to delete all footnotes?",
"DE.Views.Links.mniDelFootnote": "Delete All Footnotes",
"DE.Views.Links.mniInsFootnote": "Insert Footnote",
"DE.Views.Links.mniNoteSettings": "Notes Settings",
"DE.Views.Links.textContentsRemove": "Remove table of contents",
"DE.Views.Links.textContentsSettings": "Settings",
"DE.Views.Links.textGotoFootnote": "Go to Footnotes",
"DE.Views.Links.textUpdateAll": "Update entire table",
"DE.Views.Links.textUpdatePages": "Update page numbers only",
"DE.Views.Links.tipContents": "Insert table of contents",
"DE.Views.Links.tipContentsUpdate": "Update table of contents",
"DE.Views.Links.tipNotes": "Insert or edit footnotes",
"DE.Views.MailMergeEmailDlg.cancelButtonText": "Cancel",
"DE.Views.MailMergeEmailDlg.filePlaceholder": "PDF",
"DE.Views.MailMergeEmailDlg.okButtonText": "Send",
@ -1622,7 +1637,7 @@
"DE.Views.Toolbar.capBtnInsChart": "Chart",
"DE.Views.Toolbar.capBtnInsDropcap": "Drop Cap",
"DE.Views.Toolbar.capBtnInsEquation": "Equation",
"DE.Views.Toolbar.capBtnInsFootnote": "Footnote",
"del_DE.Views.Toolbar.capBtnInsFootnote": "Footnote",
"DE.Views.Toolbar.capBtnInsHeader": "Header/Footer",
"DE.Views.Toolbar.capBtnInsImage": "Picture",
"DE.Views.Toolbar.capBtnInsLink": "Hyperlink",
@ -1640,7 +1655,7 @@
"DE.Views.Toolbar.capImgGroup": "Group",
"DE.Views.Toolbar.capImgWrapping": "Wrapping",
"DE.Views.Toolbar.mniCustomTable": "Insert Custom Table",
"DE.Views.Toolbar.mniDelFootnote": "Delete All Footnotes",
"del_DE.Views.Toolbar.mniDelFootnote": "Delete All Footnotes",
"DE.Views.Toolbar.mniEditDropCap": "Drop Cap Settings",
"DE.Views.Toolbar.mniEditFooter": "Edit Footer",
"DE.Views.Toolbar.mniEditHeader": "Edit Header",
@ -1648,8 +1663,8 @@
"DE.Views.Toolbar.mniHiddenChars": "Nonprinting Characters",
"DE.Views.Toolbar.mniImageFromFile": "Picture from File",
"DE.Views.Toolbar.mniImageFromUrl": "Picture from URL",
"DE.Views.Toolbar.mniInsFootnote": "Insert Footnote",
"DE.Views.Toolbar.mniNoteSettings": "Notes Settings",
"del_DE.Views.Toolbar.mniInsFootnote": "Insert Footnote",
"del_DE.Views.Toolbar.mniNoteSettings": "Notes Settings",
"DE.Views.Toolbar.strMenuNoFill": "No Fill",
"DE.Views.Toolbar.textArea": "Area",
"DE.Views.Toolbar.textAutoColor": "Automatic",
@ -1669,7 +1684,7 @@
"DE.Views.Toolbar.textEvenPage": "Even Page",
"DE.Views.Toolbar.textFitPage": "Fit to Page",
"DE.Views.Toolbar.textFitWidth": "Fit to Width",
"DE.Views.Toolbar.textGotoFootnote": "Go to Footnotes",
"del_DE.Views.Toolbar.textGotoFootnote": "Go to Footnotes",
"DE.Views.Toolbar.textHideLines": "Hide Rulers",
"DE.Views.Toolbar.textHideStatusBar": "Hide Status Bar",
"DE.Views.Toolbar.textHideTitleBar": "Hide Title Bar",
@ -1762,7 +1777,7 @@
"DE.Views.Toolbar.tipMailRecepients": "Mail merge",
"DE.Views.Toolbar.tipMarkers": "Bullets",
"DE.Views.Toolbar.tipMultilevels": "Multilevel list",
"DE.Views.Toolbar.tipNotes": "Insert or edit footnotes",
"del_DE.Views.Toolbar.tipNotes": "Insert or edit footnotes",
"DE.Views.Toolbar.tipNumbers": "Numbering",
"DE.Views.Toolbar.tipPageBreak": "Insert page or section break",
"DE.Views.Toolbar.tipPageMargins": "Page margins",