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