[SSE] Header/Footer settings: change buttons for presets and inserted objects

This commit is contained in:
Julia Radzhabova 2019-10-01 15:44:04 +03:00
parent 84796a03a6
commit 69715fc18f

View file

@ -273,62 +273,58 @@ define([
});
this.btnFirst.on('toggle', _.bind(this.onPageTypeToggle, this, Asc.c_oAscHeaderFooterType.first));
this.cmbPresetsH = new Common.UI.ComboBox({
el : $('#id-dlg-h-presets'),
cls : 'input-group-nr',
style : 'width: 110px;',
menuStyle : 'min-width: 100%; max-height: 200px;',
editable : false,
scrollAlwaysVisible: true,
data: []
this.btnPresetsH = new Common.UI.Button({
cls: 'btn-text-menu-default',
caption: this.textPresets,
style: 'width: 110px;',
menu: true
});
this.cmbPresetsH.on('selected', _.bind(this.onPresetSelect, this, false));
this.cmbPresetsH.setValue(this.textPresets);
this.btnPresetsH.render( $('#id-dlg-h-presets')) ;
this.cmbPresetsF = new Common.UI.ComboBox({
el : $('#id-dlg-f-presets'),
cls : 'input-group-nr',
style : 'width: 110px;',
menuStyle : 'min-width: 100%; max-height: 200px;',
editable : false,
scrollAlwaysVisible: true,
data: []
this.btnPresetsF = new Common.UI.Button({
cls: 'btn-text-menu-default',
caption: this.textPresets,
style: 'width: 110px;',
menu: true
});
this.cmbPresetsF.on('selected', _.bind(this.onPresetSelect, this, true));
this.cmbPresetsF.setValue(this.textPresets);
this.btnPresetsF.render( $('#id-dlg-f-presets')) ;
var data = [
{displayValue: this.textPageNum, value: Asc.c_oAscHeaderFooterField.pageNumber},
{displayValue: this.textPageCount, value: Asc.c_oAscHeaderFooterField.pageCount},
{displayValue: this.textDate, value: Asc.c_oAscHeaderFooterField.date},
{displayValue: this.textTime, value: Asc.c_oAscHeaderFooterField.time},
{displayValue: this.textFileName, value: Asc.c_oAscHeaderFooterField.fileName},
{displayValue: this.textSheet, value: Asc.c_oAscHeaderFooterField.sheetName}
{caption: this.textPageNum, value: Asc.c_oAscHeaderFooterField.pageNumber},
{caption: this.textPageCount, value: Asc.c_oAscHeaderFooterField.pageCount},
{caption: this.textDate, value: Asc.c_oAscHeaderFooterField.date},
{caption: this.textTime, value: Asc.c_oAscHeaderFooterField.time},
{caption: this.textFileName, value: Asc.c_oAscHeaderFooterField.fileName},
{caption: this.textSheet, value: Asc.c_oAscHeaderFooterField.sheetName}
];
this.cmbInsertH = new Common.UI.ComboBox({
el : $('#id-dlg-h-insert'),
cls : 'input-group-nr',
style : 'width: 110px;',
menuStyle : 'min-width: 100%; max-heigh: 100px;',
editable : false,
data: data
this.btnInsertH = new Common.UI.Button({
cls: 'btn-text-menu-default',
caption: this.textInsert,
style: 'width: 110px;',
menu: new Common.UI.Menu({
style: 'min-width: 110px;',
maxHeight: 200,
items: data
})
});
this.cmbInsertH.on('selected', _.bind(this.onObjectSelect, this));
this.cmbInsertH.setValue(this.textInsert);
this.headerControls.push(this.cmbInsertH);
this.btnInsertH.render( $('#id-dlg-h-insert')) ;
this.btnInsertH.menu.on('item:click', _.bind(this.onObjectSelect, this));
this.headerControls.push(this.btnInsertH);
this.cmbInsertF = new Common.UI.ComboBox({
el : $('#id-dlg-f-insert'),
cls : 'input-group-nr',
style : 'width: 110px;',
menuStyle : 'min-width: 100%; max-heigh: 100px;',
editable : false,
data: data
this.btnInsertF = new Common.UI.Button({
cls: 'btn-text-menu-default',
caption: this.textInsert,
style: 'width: 110px;',
menu: new Common.UI.Menu({
style: 'min-width: 110px;',
maxHeight: 200,
items: data
})
});
this.cmbInsertF.on('selected', _.bind(this.onObjectSelect, this));
this.cmbInsertF.setValue(this.textInsert);
this.footerControls.push(this.cmbInsertF);
this.btnInsertF.render( $('#id-dlg-f-insert')) ;
this.btnInsertF.menu.on('item:click', _.bind(this.onObjectSelect, this));
this.footerControls.push(this.btnInsertF);
this.cmbFonts = [];
this.cmbFonts.push(new Common.UI.ComboBoxFonts({
@ -664,12 +660,21 @@ define([
_setDefaults: function (props) {
var presets = [];
this.HFObject.getTextPresetsArr().forEach(function(item, index){
presets.push({displayValue: item, value: index});
presets.push({caption: item, value: index});
});
this.cmbPresetsH.setData(presets);
this.cmbPresetsH.setValue(this.textPresets);
this.cmbPresetsF.setData(presets);
this.cmbPresetsF.setValue(this.textPresets);
this.btnPresetsH.setMenu(new Common.UI.Menu({
style: 'min-width: 110px;',
maxHeight: 200,
items: presets
}));
this.btnPresetsH.menu.on('item:click', _.bind(this.onPresetSelect, this, false));
this.btnPresetsF.setMenu(new Common.UI.Menu({
style: 'min-width: 110px;',
maxHeight: 200,
items: presets
}));
this.btnPresetsF.menu.on('item:click', _.bind(this.onPresetSelect, this, true));
this.chOddPage.setValue(this.HFObject.getDifferentOddEven());
this.chFirstPage.setValue(this.HFObject.getDifferentFirst());
@ -794,17 +799,15 @@ define([
}
},
onPresetSelect: function(footer, combo, record) {
combo.setValue(this.textPresets);
onPresetSelect: function(footer, menu, item) {
if (this.HFObject)
this.HFObject.applyPreset(record.value, !!footer);
this.HFObject.applyPreset(item.value, !!footer);
this.onCanvasClick(footer ? '#footer-left-img' : '#header-left-img');
},
onObjectSelect: function(combo, record) {
combo.setValue(this.textInsert);
onObjectSelect: function(menu, item) {
if (this.HFObject)
this.HFObject.addField(record.value);
this.HFObject.addField(item.value);
this.onCanvasClick(this.currentCanvas);
},