[DE] Refactoring line numbers
This commit is contained in:
parent
2bbd1e5937
commit
9140de31ef
|
@ -387,6 +387,7 @@ define([
|
||||||
this.api.asc_registerCallback('asc_onMathTypes', _.bind(this.onApiMathTypes, this));
|
this.api.asc_registerCallback('asc_onMathTypes', _.bind(this.onApiMathTypes, this));
|
||||||
this.api.asc_registerCallback('asc_onColumnsProps', _.bind(this.onColumnsProps, this));
|
this.api.asc_registerCallback('asc_onColumnsProps', _.bind(this.onColumnsProps, this));
|
||||||
this.api.asc_registerCallback('asc_onSectionProps', _.bind(this.onSectionProps, this));
|
this.api.asc_registerCallback('asc_onSectionProps', _.bind(this.onSectionProps, this));
|
||||||
|
this.api.asc_registerCallback('asc_onLineNumbersProps', _.bind(this.onLineNumbersProps, this));
|
||||||
this.api.asc_registerCallback('asc_onContextMenu', _.bind(this.onContextMenu, this));
|
this.api.asc_registerCallback('asc_onContextMenu', _.bind(this.onContextMenu, this));
|
||||||
this.api.asc_registerCallback('asc_onShowParaMarks', _.bind(this.onShowParaMarks, this));
|
this.api.asc_registerCallback('asc_onShowParaMarks', _.bind(this.onShowParaMarks, this));
|
||||||
this.api.asc_registerCallback('asc_onChangeSdtGlobalSettings', _.bind(this.onChangeSdtGlobalSettings, this));
|
this.api.asc_registerCallback('asc_onChangeSdtGlobalSettings', _.bind(this.onChangeSdtGlobalSettings, this));
|
||||||
|
@ -1677,16 +1678,21 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
onLineNumbersSelect: function(menu, item) {
|
onLineNumbersSelect: function(menu, item) {
|
||||||
|
if (_.isUndefined(item.value))
|
||||||
|
return;
|
||||||
|
|
||||||
switch (item.value) {
|
switch (item.value) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
|
||||||
case 1:
|
case 1:
|
||||||
break;
|
|
||||||
case 2:
|
case 2:
|
||||||
break;
|
|
||||||
case 3:
|
case 3:
|
||||||
|
this._state.linenum = undefined;
|
||||||
|
if (this.api && item.checked) {
|
||||||
|
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
|
this.api && this.api.put_ParagraphSuppressLineNumbers(item.checked);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
var win,
|
var win,
|
||||||
|
@ -1694,15 +1700,39 @@ define([
|
||||||
win = new DE.Views.LineNumbersDialog({
|
win = new DE.Views.LineNumbersDialog({
|
||||||
handler: function(dlg, result) {
|
handler: function(dlg, result) {
|
||||||
if (result == 'ok') {
|
if (result == 'ok') {
|
||||||
|
// var props = dlg.getSettings();
|
||||||
|
// me.api.asc_SetLineNumbersProps(props);
|
||||||
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
|
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
win.show();
|
win.show();
|
||||||
|
// win.setSettings(me.api.asc_GetLineNumbersProps());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onLineNumbersProps: function(props) {
|
||||||
|
if (props) {
|
||||||
|
// var type = props.asc_getType();
|
||||||
|
var index = -1;
|
||||||
|
// switch (type) {
|
||||||
|
// case Asc.None: index = 0; break;
|
||||||
|
// case Asc.Continuous: index = 1; break;
|
||||||
|
// case Asc.Page: index = 2; break;
|
||||||
|
// case Asc.Section: index = 3; break;
|
||||||
|
// }
|
||||||
|
if (this._state.linenum === index)
|
||||||
|
return;
|
||||||
|
if (index < 0)
|
||||||
|
this.toolbar.btnLineNumbers.menu.clearAll();
|
||||||
|
else
|
||||||
|
this.toolbar.btnLineNumbers.menu.items[index].setChecked(true);
|
||||||
|
|
||||||
|
this._state.linenum = index;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
onColorSchemaClick: function(menu, item) {
|
onColorSchemaClick: function(menu, item) {
|
||||||
if (this.api) {
|
if (this.api) {
|
||||||
this.api.asc_ChangeColorSchemeByIdx(item.value);
|
this.api.asc_ChangeColorSchemeByIdx(item.value);
|
||||||
|
|
|
@ -47,9 +47,11 @@ define([
|
||||||
DE.Views.LineNumbersDialog = Common.UI.Window.extend(_.extend({
|
DE.Views.LineNumbersDialog = Common.UI.Window.extend(_.extend({
|
||||||
options: {
|
options: {
|
||||||
width: 290,
|
width: 290,
|
||||||
|
height: 273,
|
||||||
header: true,
|
header: true,
|
||||||
style: 'min-width: 290px;',
|
style: 'min-width: 290px;',
|
||||||
cls: 'modal-dlg'
|
cls: 'modal-dlg',
|
||||||
|
buttons: ['ok', 'cancel']
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize : function(options) {
|
initialize : function(options) {
|
||||||
|
@ -69,10 +71,6 @@ define([
|
||||||
'<div id="line-numbers-restart-each-page" style="margin-bottom: 8px;"></div>',
|
'<div id="line-numbers-restart-each-page" style="margin-bottom: 8px;"></div>',
|
||||||
'<div id="line-numbers-restart-each-section" style="margin-bottom: 8px;"></div>',
|
'<div id="line-numbers-restart-each-section" style="margin-bottom: 8px;"></div>',
|
||||||
'<div id="line-numbers-continuous" style="margin-bottom: 5px;"></div>',
|
'<div id="line-numbers-continuous" style="margin-bottom: 5px;"></div>',
|
||||||
'</div>',
|
|
||||||
'<div class="footer center">',
|
|
||||||
'<button class="btn normal dlg-btn primary" result="ok" style="margin-right: 10px;">' + this.okButtonText + '</button>',
|
|
||||||
'<button class="btn normal dlg-btn" result="cancel">' + this.cancelButtonText + '</button>',
|
|
||||||
'</div>'
|
'</div>'
|
||||||
].join('');
|
].join('');
|
||||||
|
|
||||||
|
@ -107,7 +105,8 @@ define([
|
||||||
defaultUnit : '',
|
defaultUnit : '',
|
||||||
value: 1,
|
value: 1,
|
||||||
maxValue: 32767,
|
maxValue: 32767,
|
||||||
minValue: 1
|
minValue: 1,
|
||||||
|
disabled: true
|
||||||
});
|
});
|
||||||
|
|
||||||
this.spnFromText = new Common.UI.MetricSpinner({
|
this.spnFromText = new Common.UI.MetricSpinner({
|
||||||
|
@ -118,7 +117,8 @@ define([
|
||||||
value: 'Auto',
|
value: 'Auto',
|
||||||
maxValue: 55.87,
|
maxValue: 55.87,
|
||||||
minValue: 0.1,
|
minValue: 0.1,
|
||||||
allowAuto: true
|
allowAuto: true,
|
||||||
|
disabled: true
|
||||||
});
|
});
|
||||||
this.spinners.push(this.spnFromText);
|
this.spinners.push(this.spnFromText);
|
||||||
|
|
||||||
|
@ -129,25 +129,30 @@ define([
|
||||||
defaultUnit : '',
|
defaultUnit : '',
|
||||||
value: 1,
|
value: 1,
|
||||||
maxValue: 100,
|
maxValue: 100,
|
||||||
minValue: 1
|
minValue: 1,
|
||||||
|
disabled: true
|
||||||
});
|
});
|
||||||
|
|
||||||
this.rbRestartEachPage = new Common.UI.RadioBox({
|
this.rbRestartEachPage = new Common.UI.RadioBox({
|
||||||
el: $('#line-numbers-restart-each-page'),
|
el: $('#line-numbers-restart-each-page'),
|
||||||
labelText: this.textRestartEachPage,
|
labelText: this.textRestartEachPage,
|
||||||
name: 'asc-radio-line-numbers'
|
name: 'asc-radio-line-numbers',
|
||||||
|
disabled: true,
|
||||||
|
checked: true
|
||||||
});
|
});
|
||||||
|
|
||||||
this.rbRestartEachSection = new Common.UI.RadioBox({
|
this.rbRestartEachSection = new Common.UI.RadioBox({
|
||||||
el: $('#line-numbers-restart-each-section'),
|
el: $('#line-numbers-restart-each-section'),
|
||||||
labelText: this.textRestartEachSection,
|
labelText: this.textRestartEachSection,
|
||||||
name: 'asc-radio-line-numbers'
|
name: 'asc-radio-line-numbers',
|
||||||
|
disabled: true
|
||||||
});
|
});
|
||||||
|
|
||||||
this.rbContinuous = new Common.UI.RadioBox({
|
this.rbContinuous = new Common.UI.RadioBox({
|
||||||
el: $('#line-numbers-continuous'),
|
el: $('#line-numbers-continuous'),
|
||||||
labelText: this.textContinuous,
|
labelText: this.textContinuous,
|
||||||
name: 'asc-radio-line-numbers'
|
name: 'asc-radio-line-numbers',
|
||||||
|
disabled: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -157,11 +162,21 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
afterRender: function() {
|
afterRender: function() {
|
||||||
this._setDefaults();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_setDefaults: function() {
|
setSettings: function (props) {
|
||||||
|
if (props) {
|
||||||
|
// var type = props.asc_getType();
|
||||||
|
// this.chAddLineNumbering.setValue(type !== case Asc.None);
|
||||||
|
// switch (type) {
|
||||||
|
// case Asc.Continuous: this.rbContinuous.setValue(true, true); break;
|
||||||
|
// case Asc.Page: this.rbRestartEachPage.setValue(true, true); break;
|
||||||
|
// case Asc.Section: this.rbRestartEachSection.setValue(true, true); break;
|
||||||
|
// }
|
||||||
|
// this.spnStartAt.setValue(props.get_StartAt()!==null ? props.get_StartAt() : '', true);
|
||||||
|
// this.spnFromText.setValue(props.get_FromText()!==null ? (props.get_FromText()<0 ? -1 : Common.Utils.Metric.fnRecalcFromMM(props.get_FromText())) : '', true);
|
||||||
|
// this.spnCountBy.setValue(props.get_Count()!==null ? props.get_Count() : '', true);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_handleInput: function(state) {
|
_handleInput: function(state) {
|
||||||
|
@ -182,7 +197,22 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
getSettings: function() {
|
getSettings: function() {
|
||||||
return this;
|
// var props = new Asc.CDocumentLineNumberProps();
|
||||||
|
// if (this.chAddLineNumbering.getValue()!=='checked') {
|
||||||
|
// props.put_Type(Asc.None);
|
||||||
|
// } else {
|
||||||
|
// if (this.rbContinuous.getValue())
|
||||||
|
// props.put_Type(Asc.Continuous);
|
||||||
|
// else if (this.rbRestartEachPage.getValue())
|
||||||
|
// props.put_Type(Asc.Page);
|
||||||
|
// else if (this.rbRestartEachSection.getValue())
|
||||||
|
// props.put_Type(Asc.Section);
|
||||||
|
// props.put_StartAt(this.spnStartAt.getNumberValue());
|
||||||
|
// var value = this.spnFromText.getNumberValue();
|
||||||
|
// props.put_FromText(value<0 ? -1 : Common.Utils.Metric.fnRecalcToMM());
|
||||||
|
// props.put_Count(this.spnCountBy.getNumberValue());
|
||||||
|
// }
|
||||||
|
// return props;
|
||||||
},
|
},
|
||||||
|
|
||||||
updateMetricUnit: function() {
|
updateMetricUnit: function() {
|
||||||
|
@ -196,9 +226,7 @@ define([
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
textTitle: 'Line Numbers Settings',
|
textTitle: 'Line Numbers',
|
||||||
cancelButtonText: 'Cancel',
|
|
||||||
okButtonText: 'Ok',
|
|
||||||
textAddLineNumbering: 'Add line numbering',
|
textAddLineNumbering: 'Add line numbering',
|
||||||
textStartAt: 'Start at',
|
textStartAt: 'Start at',
|
||||||
textFromText: 'From text',
|
textFromText: 'From text',
|
||||||
|
|
|
@ -350,6 +350,11 @@ define([ 'text!documenteditor/main/app/template/ParagraphSettingsAdvanced.tem
|
||||||
el: $('#paragraphadv-checkbox-suppress-line-numbers'),
|
el: $('#paragraphadv-checkbox-suppress-line-numbers'),
|
||||||
labelText: this.strSuppressLineNumbers
|
labelText: this.strSuppressLineNumbers
|
||||||
});
|
});
|
||||||
|
this.chLineNumbers.on('change', _.bind(function(field, newValue, oldValue, eOpts){
|
||||||
|
if (this._changedProps) {
|
||||||
|
// this._changedProps.put_SuppressLineNumbers(field.getValue()=='checked');
|
||||||
|
}
|
||||||
|
}, this));
|
||||||
|
|
||||||
// Borders
|
// Borders
|
||||||
|
|
||||||
|
@ -779,6 +784,8 @@ define([ 'text!documenteditor/main/app/template/ParagraphSettingsAdvanced.tem
|
||||||
this.chKeepNext.setValue((props.get_KeepNext() !== null && props.get_KeepNext() !== undefined) ? props.get_KeepNext() : 'indeterminate', true);
|
this.chKeepNext.setValue((props.get_KeepNext() !== null && props.get_KeepNext() !== undefined) ? props.get_KeepNext() : 'indeterminate', true);
|
||||||
this.chOrphan.setValue((props.get_WidowControl() !== null && props.get_WidowControl() !== undefined) ? props.get_WidowControl() : 'indeterminate', true);
|
this.chOrphan.setValue((props.get_WidowControl() !== null && props.get_WidowControl() !== undefined) ? props.get_WidowControl() : 'indeterminate', true);
|
||||||
|
|
||||||
|
// this.chLineNumbers.setValue((props.get_SuppressLineNumbers() !== null && props.get_SuppressLineNumbers() !== undefined) ? props.get_SuppressLineNumbers() : 'indeterminate', true);
|
||||||
|
|
||||||
this.Borders = new Asc.asc_CParagraphBorders(props.get_Borders());
|
this.Borders = new Asc.asc_CParagraphBorders(props.get_Borders());
|
||||||
|
|
||||||
// Margins
|
// Margins
|
||||||
|
|
|
@ -1009,15 +1009,13 @@ define([
|
||||||
{
|
{
|
||||||
caption: this.textSuppressForCurrentParagraph,
|
caption: this.textSuppressForCurrentParagraph,
|
||||||
checkable: true,
|
checkable: true,
|
||||||
toggleGroup: 'menuLineNumbers',
|
allowDepress: true,
|
||||||
value: 4
|
value: 4
|
||||||
},
|
},
|
||||||
{caption: '--'},
|
{caption: '--'},
|
||||||
{
|
{
|
||||||
caption: this.textCustomLineNumbers,
|
caption: this.textCustomLineNumbers,
|
||||||
value: 5,
|
value: 5
|
||||||
checkable: true,
|
|
||||||
toggleGroup: 'menuLineNumbers'
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
@ -2420,8 +2418,8 @@ define([
|
||||||
textRestartEachPage: 'Restart Each Page',
|
textRestartEachPage: 'Restart Each Page',
|
||||||
textRestartEachSection: 'Restart Each Section',
|
textRestartEachSection: 'Restart Each Section',
|
||||||
textSuppressForCurrentParagraph: 'Suppress for Current Paragraph',
|
textSuppressForCurrentParagraph: 'Suppress for Current Paragraph',
|
||||||
textCustomLineNumbers: 'Custom Line Numbers',
|
textCustomLineNumbers: 'Line Numbering Options',
|
||||||
tipLineNumbers: 'Line Numbers'
|
tipLineNumbers: 'Show line numbers'
|
||||||
}
|
}
|
||||||
})(), DE.Views.Toolbar || {}));
|
})(), DE.Views.Toolbar || {}));
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue