From 3c8d3c8e5ce188efd1c6f1156fb75cf87af79425 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 23 Jul 2019 13:43:10 +0300 Subject: [PATCH] [PE] Header/Footer: apply font size by pressing enter --- .../main/app/view/HeaderFooterDialog.js | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/apps/spreadsheeteditor/main/app/view/HeaderFooterDialog.js b/apps/spreadsheeteditor/main/app/view/HeaderFooterDialog.js index 8ee3b5d13..29dbae752 100644 --- a/apps/spreadsheeteditor/main/app/view/HeaderFooterDialog.js +++ b/apps/spreadsheeteditor/main/app/view/HeaderFooterDialog.js @@ -372,6 +372,9 @@ define([ data: data })); this.cmbFontSize[0].on('selected', _.bind(this.onFontSizeSelect, this)); + this.cmbFontSize[0].on('changed:before', _.bind(this.onFontSizeChanged, this, true)); + this.cmbFontSize[0].on('changed:after', _.bind(this.onFontSizeChanged, this, false)); + this.cmbFontSize[0].setValue(this._state.fontsize); this.headerControls.push(this.cmbFontSize[0]); @@ -385,6 +388,8 @@ define([ data: data })); this.cmbFontSize[1].on('selected', _.bind(this.onFontSizeSelect, this)); + this.cmbFontSize[1].on('changed:before', _.bind(this.onFontSizeChanged, this, true)); + this.cmbFontSize[1].on('changed:after', _.bind(this.onFontSizeChanged, this, false)); this.cmbFontSize[1].setValue(this._state.fontsize); this.footerControls.push(this.cmbFontSize[1]); @@ -782,6 +787,36 @@ define([ this.onCanvasClick(this.currentCanvas); }, + onFontSizeChanged: function(before, combo, record, e) { + var value, + me = this; + + if (before) { + var item = combo.store.findWhere({ + displayValue: record.value + }); + + if (!item) { + value = /^\+?(\d*\.?\d+)$|^\+?(\d+\.?\d*)$/.exec(record.value); + + if (!value) { + value = combo.getValue(); + combo.setRawValue(value); + e.preventDefault(); + return false; + } + } + } else { + value = parseFloat(record.value); + value = value > 409 ? 409 : + value < 1 ? 1 : Math.floor((value+0.4)*2)/2; + + combo.setRawValue(value); + if (this.HFObject) + this.HFObject.setFontSize(value); + } + }, + onBoldClick: function(btn, e) { if (this.HFObject) { this.HFObject.setBold(btn.pressed);