[DE] Change caption settings

This commit is contained in:
Julia Radzhabova 2019-09-12 12:20:50 +03:00
parent a21cb5c6ac
commit cf59eb8895
2 changed files with 40 additions and 26 deletions

View file

@ -78,7 +78,8 @@ define([
}, },
onLaunch: function () { onLaunch: function () {
this._state = { this._state = {
prcontrolsdisable:undefined prcontrolsdisable:undefined,
in_object: false
}; };
Common.Gateway.on('setactionlink', function (url) { Common.Gateway.on('setactionlink', function (url) {
console.log('url with actions: ' + url); console.log('url with actions: ' + url);
@ -127,7 +128,8 @@ define([
header_locked = false, header_locked = false,
in_header = false, in_header = false,
in_equation = false, in_equation = false,
in_image = false; in_image = false,
in_table = false;
while (++i < selectedObjects.length) { while (++i < selectedObjects.length) {
type = selectedObjects[i].get_ObjectType(); type = selectedObjects[i].get_ObjectType();
@ -142,10 +144,12 @@ define([
in_image = true; in_image = true;
} else if (type === Asc.c_oAscTypeSelectElement.Math) { } else if (type === Asc.c_oAscTypeSelectElement.Math) {
in_equation = true; in_equation = true;
} else if (type === Asc.c_oAscTypeSelectElement.Table) {
in_table = true;
} }
} }
this._state.prcontrolsdisable = paragraph_locked || header_locked; this._state.prcontrolsdisable = paragraph_locked || header_locked;
this._state.in_object = in_image || in_table || in_equation;
var control_props = this.api.asc_IsContentControl() ? this.api.asc_GetContentControlProperties() : null, var control_props = this.api.asc_IsContentControl() ? this.api.asc_GetContentControlProperties() : null,
control_plain = (control_props) ? (control_props.get_ContentControlType()==Asc.c_oAscSdtLevelType.Inline) : false; control_plain = (control_props) ? (control_props.get_ContentControlType()==Asc.c_oAscSdtLevelType.Inline) : false;
@ -337,7 +341,7 @@ define([
onCaptionClick: function(btn) { onCaptionClick: function(btn) {
var me = this; var me = this;
(new DE.Views.CaptionDialog({ (new DE.Views.CaptionDialog({
api: me.api, isObject: this._state.in_object,
handler: function (result, settings) { handler: function (result, settings) {
if (result == 'ok') { if (result == 'ok') {
me.api.asc_AddObjectCaption(settings); me.api.asc_AddObjectCaption(settings);

View file

@ -48,7 +48,7 @@ define([
DE.Views.CaptionDialog = Common.Views.AdvancedSettingsWindow.extend(_.extend({ DE.Views.CaptionDialog = Common.Views.AdvancedSettingsWindow.extend(_.extend({
options: { options: {
contentWidth: 351, contentWidth: 351,
height: 330 height: 350
}, },
initialize : function(options) { initialize : function(options) {
@ -83,6 +83,11 @@ define([
'<button type="button" result="add" class="btn btn-text-default" id="caption-btn-delete">', me.textDelete,'</button>', '<button type="button" result="add" class="btn btn-text-default" id="caption-btn-delete">', me.textDelete,'</button>',
'</td>', '</td>',
'</tr>', '</tr>',
'<tr>',
'<td colspan="4" class="padding-small">',
'<div id="caption-checkbox-exclude"></div>',
'</td>',
'</tr>',
'<tr>', '<tr>',
'<td colspan="2" class="padding-large">', '<td colspan="2" class="padding-large">',
'<label class="input-label" >', me.textNumbering,'</label>', '<label class="input-label" >', me.textNumbering,'</label>',
@ -124,7 +129,7 @@ define([
].join('') ].join('')
}, options); }, options);
this.api = options.api; this.isObject = options.isObject;
this.handler = options.handler; this.handler = options.handler;
this.props = options.props; this.props = options.props;
@ -146,6 +151,7 @@ define([
cls: 'input-group-nr', cls: 'input-group-nr',
menuStyle: 'min-width: 75px;', menuStyle: 'min-width: 75px;',
editable: false, editable: false,
disabled: !this.isObject,
data: [ data: [
{ displayValue: this.textBefore, value: 1 }, { displayValue: this.textBefore, value: 1 },
{ displayValue: this.textAfter, value: 0 } { displayValue: this.textAfter, value: 0 }
@ -162,13 +168,12 @@ define([
Common.Utils.InternalSettings.set("de-settings-captions", arr); Common.Utils.InternalSettings.set("de-settings-captions", arr);
} }
arr = arr ? arr.split(';') : []; arr = arr ? arr.split(';') : [];
arr = _.map(arr, function(str){ return { displayValue: str, value: 1 }; }); arr = _.map(arr, function(str){ return { displayValue: str, value: str, type: 1 }; });
// 0, -1 - not removable // 0 - not removable
this.arrLabel = [{ displayValue: this.textNone, value: -1 }].concat(arr) this.arrLabel = arr.concat([{ displayValue: this.textEquation, value: this.textEquation, type: 0 },
.concat([{ displayValue: this.textEquation, value: 0 }, { displayValue: this.textFigure, value: this.textFigure, type: 0 },
{ displayValue: this.textFigure, value: 0 }, { displayValue: this.textTable, value: this.textTable, type: 0 }
{ displayValue: this.textTable, value: 0 }
]); ]);
this.cmbLabel = new Common.UI.ComboBox({ this.cmbLabel = new Common.UI.ComboBox({
@ -179,12 +184,10 @@ define([
data: this.arrLabel data: this.arrLabel
}); });
this.cmbLabel.on('selected', function(combo, record) { this.cmbLabel.on('selected', function(combo, record) {
me.props.put_ExcludeLabel(record.value==-1); me.props.put_Label(record.value);
if (record.value>=0)
me.props.put_Label(record.displayValue);
me.props.updateName(); me.props.updateName();
me.txtCaption.setValue(me.props.get_Name()); me.txtCaption.setValue(me.props.get_Name());
var custom = (record.value==1); var custom = (record.type==1);
me.btnAdd.setDisabled(true); me.btnAdd.setDisabled(true);
me.btnDelete.setDisabled(!custom); me.btnDelete.setDisabled(!custom);
}); });
@ -203,6 +206,16 @@ define([
this.btnDelete.on('click', function() { this.btnDelete.on('click', function() {
}); });
this.chExclude = new Common.UI.CheckBox({
el: $('#caption-checkbox-exclude'),
labelText: this.textExclude
});
this.chExclude.on('change', function(field, newValue, oldValue) {
me.props.put_ExcludeLabel(newValue=='checked');
me.props.updateName();
me.txtCaption.setValue(me.props.get_Name());
});
this.cmbNumbering = new Common.UI.ComboBox({ this.cmbNumbering = new Common.UI.ComboBox({
el: $('#caption-combo-numbering'), el: $('#caption-combo-numbering'),
cls: 'input-group-nr', cls: 'input-group-nr',
@ -300,13 +313,10 @@ define([
_setDefaults: function (props) { _setDefaults: function (props) {
this.props = new Asc.CAscCaptionProperties(); this.props = new Asc.CAscCaptionProperties();
this.props.put_Before(!!this.cmbPosition.getValue()); this.props.put_Before(!!this.cmbPosition.getValue());
var value = this.cmbLabel.getValue(); this.props.put_Label(this.cmbLabel.getValue());
this.props.put_ExcludeLabel(value==-1); var value = this.cmbLabel.getSelectedRecord();
if (value>=0) this.btnDelete.setDisabled(!value || value.type==0);
this.props.put_Label(this.cmbLabel.getDisplayValue(this.cmbLabel.getSelectedRecord())); this.props.put_ExcludeLabel(this.chExclude.getValue()=='checked');
this.btnDelete.setDisabled(value!=1);
this.props.put_ExcludeLabel = prot["put_ExcludeLabel"] = function(v){this.ExcludeLabel = v;};
this.props.put_Format(this.cmbNumbering.getValue()); this.props.put_Format(this.cmbNumbering.getValue());
this.props.put_IncludeChapterNumber(this.chChapter.getValue()=='checked'); this.props.put_IncludeChapterNumber(this.chChapter.getValue()=='checked');
this.props.put_HeadingLvl(this.cmbChapter.getValue()); this.props.put_HeadingLvl(this.cmbChapter.getValue());
@ -351,10 +361,10 @@ define([
textColon: 'colon', textColon: 'colon',
textLongDash: 'long dash', textLongDash: 'long dash',
textDash: 'dash', textDash: 'dash',
textNone: 'None',
textEquation: 'Equation', textEquation: 'Equation',
textFigure: 'Figure', textFigure: 'Figure',
textTable: 'Table' textTable: 'Table',
textExclude: 'Exclude label from caption'
}, DE.Views.CaptionDialog || {})) }, DE.Views.CaptionDialog || {}))
}); });