[DE] Show settings for table of contents.

This commit is contained in:
Julia Radzhabova 2018-01-17 12:32:12 +03:00
parent dc2475af7a
commit 5f3d992f12
2 changed files with 49 additions and 28 deletions

View file

@ -204,17 +204,18 @@ define([
onTableContents: function(type){ onTableContents: function(type){
switch (type) { switch (type) {
case 0: case 0:
this.api.asc_addTableOfContents(); break; this.api.asc_AddTableOfContents(); break;
case 1: case 1:
this.api.asc_addTableOfContents(); break; this.api.asc_AddTableOfContents(); break;
case 'settings': case 'settings':
var props, me = this; var props, me = this;
var win = new DE.Views.TableOfContentsSettings({ var win = new DE.Views.TableOfContentsSettings({
api: this.api, api: this.api,
props: props, props: this.api.asc_GetTableOfContentsPr(),
handler: function(dlg, result) { handler: function(dlg, result) {
if (result == 'ok') { if (result == 'ok') {
props = dlg.getSettings(); props = dlg.getSettings();
me.api.asc_SetTableOfContentsPr(props);
} }
Common.NotificationCenter.trigger('edit:complete', me.toolbar); Common.NotificationCenter.trigger('edit:complete', me.toolbar);
@ -223,6 +224,7 @@ define([
win.show(); win.show();
break; break;
case 'remove': case 'remove':
this.api.asc_RemoveTableOfContents();
break; break;
} }
}, },

View file

@ -49,7 +49,7 @@ define([
DE.Views.TableOfContentsSettings = Common.Views.AdvancedSettingsWindow.extend(_.extend({ DE.Views.TableOfContentsSettings = Common.Views.AdvancedSettingsWindow.extend(_.extend({
options: { options: {
contentWidth: 500, contentWidth: 500,
height: 430 height: 455
}, },
initialize : function(options) { initialize : function(options) {
@ -106,8 +106,8 @@ define([
'<label class="input-label" style="width: 144px; margin-left: 23px;">' + me.textStyle + '</label>', '<label class="input-label" style="width: 144px; margin-left: 23px;">' + me.textStyle + '</label>',
'<label class="input-label" style="">' + me.textLevel + '</label>', '<label class="input-label" style="">' + me.textLevel + '</label>',
'</td></tr>', '</td></tr>',
'<tr><td class="padding-small">', '<tr><td>',
'<div id="tableofcontents-styles-list" class="header-styles-tableview" style="width:100%; height: 91px;"></div>', '<div id="tableofcontents-styles-list" class="header-styles-tableview" style="width:100%; height: 122px;"></div>',
'</td></tr></table>', '</td></tr></table>',
'</div>', '</div>',
'</td>', '</td>',
@ -171,7 +171,7 @@ define([
{ value: Asc.c_oAscTabLeader.Underscore,displayValue: '__________' } { value: Asc.c_oAscTabLeader.Underscore,displayValue: '__________' }
] ]
}); });
this.cmbLeader.setValue(Asc.c_oAscTabLeader.None); this.cmbLeader.setValue(Asc.c_oAscTabLeader.Dot);
this.chLinks = new Common.UI.CheckBox({ this.chLinks = new Common.UI.CheckBox({
el: $('#tableofcontents-chb-links'), el: $('#tableofcontents-chb-links'),
@ -275,30 +275,49 @@ define([
}, },
_setDefaults: function (props) { _setDefaults: function (props) {
var styles = [];
_.each(window.styles.get_MergedStyles(), function (style) {
styles.push(new Common.UI.DataViewModel({
name: style.get_Name(),
allowSelected: false,
checked: false,
value: ''
}));
});
if (props) { if (props) {
var value = props.get_Hyperlink();
this.chLinks.setValue((value !== null && value !== undefined) ? value : 'indeterminate', true);
var start = props.get_OutlineStart(),
end = props.get_OutlineEnd();
this.spnLevels.setValue((start<0 || end<0) ? 0 : end);
this.spnLevels.setDisabled(start>1);
var count = props.get_StylesCount();
for (var i=0; i<count; i++) {
var style = props.get_StyleName(i),
level = props.get_StyleLevel(i),
rec = _.findWhere(styles, {name: style});
if (rec) {
rec.set('checked', true);
rec.set('value', level);
} else {
styles.push(new Common.UI.DataViewModel({
name: style,
allowSelected: false,
checked: true,
value: level
}));
}
}
} }
this.stylesLevels.reset(styles);
// this.api.SetDrawImagePlaceContents('tableofcontents-img', props);
this.stylesLevels.reset([ this._changedProps = new Asc.CTableOfContentsPr();
(new Common.UI.DataViewModel({
name: 'header1',
allowSelected: false,
checked: true,
value: 1
})),
(new Common.UI.DataViewModel({
name: 'header2',
allowSelected: false,
checked: false,
value: ''
})),
(new Common.UI.DataViewModel({
name: 'header3',
allowSelected: false,
checked: false,
value: ''
}))]);
// this._changedProps = new Asc.asc_CParagraphProperty();
}, },
getSettings: function () { getSettings: function () {