diff --git a/apps/common/main/lib/component/ComboBox.js b/apps/common/main/lib/component/ComboBox.js index 7d6af572cb..76fd8af98b 100644 --- a/apps/common/main/lib/component/ComboBox.js +++ b/apps/common/main/lib/component/ComboBox.js @@ -638,6 +638,11 @@ define([ $('#' + this._selectedItem.get('id'), $(this.el)).addClass('selected'); }, + clearSelection: function (){ + $('.selected', $(this.el)).removeClass('selected'); + this._selectedItem = null; + }, + itemClicked: function (e) { var el = $(e.target).closest('li'); diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index 648f5d8213..a5f0947a80 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -4164,21 +4164,15 @@ define([ info.asc_setType(Asc.c_oAscNumFormatType.None); info.asc_setSymbol(this._state.langId); var arr = this.api.asc_getFormatCells(info); // all formats - var disp=0 for (var i=0; i Asc.c_oAscNumFormatType.Date)|0; - this.toolbar.cmbNumberFormat.setRawValue( - (numformattype === Asc.c_oAscNumFormatType.Date) ? this.toolbar.txtDate : this.toolbar.numFormatData[indexNFD].displayValue - ); - }, - onDecrement: function(btn) { if (this.api) this.api.asc_decreaseCellDigitNumbers(); @@ -3200,8 +3190,8 @@ define([ this._state.numformatinfo = val; val = val.asc_getType(); if (this._state.numformattype !== val) { - this._state.numformattype = val; - this.cmbNumberFormatSetValue(); + toolbar.cmbNumberFormat.setValue(val, toolbar.txtCustom); + this._state.numformattype = val; } } @@ -3358,8 +3348,8 @@ define([ this._state.numformatinfo = val; val = val.asc_getType(); if (this._state.numformattype !== val) { + me.toolbar.cmbNumberFormat.setValue(val, me.toolbar.txtCustom); this._state.numformattype = val; - this.cmbNumberFormatSetValue(); } } }, @@ -3729,8 +3719,8 @@ define([ this._state.numformatinfo = val; val = val.asc_getType(); if (this._state.numformattype !== val) { + me.toolbar.cmbNumberFormat.setValue(val, me.toolbar.txtCustom); this._state.numformattype = val; - this.cmbNumberFormatSetValue(); } } }, diff --git a/apps/spreadsheeteditor/main/app/view/DocumentHolder.js b/apps/spreadsheeteditor/main/app/view/DocumentHolder.js index 0fb83d9417..f5bd57defa 100644 --- a/apps/spreadsheeteditor/main/app/view/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/view/DocumentHolder.js @@ -472,7 +472,6 @@ define([ { caption: this.txtGeneral, template: numFormatTemplate, - checkable: true, format: 'General', exampleval: '100', value: Asc.c_oAscNumFormatType.General @@ -480,7 +479,6 @@ define([ { caption: this.txtNumber, template: numFormatTemplate, - checkable: true, format: '0.00', exampleval: '100,00', value: Asc.c_oAscNumFormatType.Number @@ -488,7 +486,6 @@ define([ { caption: this.txtScientific, template: numFormatTemplate, - checkable: true, format: '0.00E+00', exampleval: '1,00E+02', value: Asc.c_oAscNumFormatType.Scientific @@ -496,7 +493,6 @@ define([ { caption: this.txtAccounting, template: numFormatTemplate, - checkable: true, format: '_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)', exampleval: '100,00 $', value: Asc.c_oAscNumFormatType.Accounting @@ -504,23 +500,27 @@ define([ { caption: this.txtCurrency, template: numFormatTemplate, - checkable: true, format: '$#,##0.00', exampleval: '100,00 $', value: Asc.c_oAscNumFormatType.Currency }, { - caption: this.txtDate, + caption: this.txtDateShort, template: numFormatTemplate, - checkable: true, format: 'MM-dd-yyyy', exampleval: '04-09-1900', value: Asc.c_oAscNumFormatType.Date }, + { + caption: this.txtDateLong, + template: numFormatTemplate, + format: 'MMMM d yyyy', + exampleval: 'April 9 1900', + value: Asc.c_oAscNumFormatType.Date + }, { caption: this.txtTime, template: numFormatTemplate, - checkable: true, format: 'HH:MM:ss', exampleval: '00:00:00', value: Asc.c_oAscNumFormatType.Time @@ -528,7 +528,6 @@ define([ { caption: this.txtPercentage, template: numFormatTemplate, - checkable: true, format: '0.00%', exampleval: '100,00%', value: Asc.c_oAscNumFormatType.Percent @@ -536,7 +535,6 @@ define([ { caption: this.txtFraction, template: numFormatTemplate, - checkable: true, format: '# ?/?', exampleval: '100', value: Asc.c_oAscNumFormatType.Fraction @@ -544,7 +542,6 @@ define([ { caption: this.txtText, template: numFormatTemplate, - checkable: true, format: '@', exampleval: '100', value: Asc.c_oAscNumFormatType.Text @@ -1329,7 +1326,8 @@ define([ txtScientific: 'Scientific', txtAccounting: 'Accounting', txtCurrency: 'Currency', - txtDate: 'Date', + txtDateShort: 'Short Date', + txtDateLong: 'Long Date', txtTime: 'Time', txtPercentage: 'Percentage', txtFraction: 'Fraction', diff --git a/apps/spreadsheeteditor/main/app/view/FormatRulesEditDlg.js b/apps/spreadsheeteditor/main/app/view/FormatRulesEditDlg.js index 6a2ad9e2bf..07b1400878 100644 --- a/apps/spreadsheeteditor/main/app/view/FormatRulesEditDlg.js +++ b/apps/spreadsheeteditor/main/app/view/FormatRulesEditDlg.js @@ -579,8 +579,8 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesEditDlg.template', { value: Asc.c_oAscNumFormatType.Scientific,format: this.ascFormatOptions.Scientific, displayValue: this.txtScientific, exampleval: '1,00E+02' }, { value: Asc.c_oAscNumFormatType.Accounting,format: this.ascFormatOptions.Accounting, displayValue: this.txtAccounting, exampleval: '100,00 $' }, { value: Asc.c_oAscNumFormatType.Currency, format: this.ascFormatOptions.Currency, displayValue: this.txtCurrency, exampleval: '100,00 $' }, - { value: Asc.c_oAscNumFormatType.Date, format: 'MM-dd-yyyy', displayValue: this.txtDateShort, exampleval: '04-09-1900' }, - { value: Asc.c_oAscNumFormatType.Date, format: 'MMMM d yyyy', displayValue: this.txtDateLong, exampleval: 'April-09-1900' }, + { value: Asc.c_oAscNumFormatType.Date, format: 'MM-dd-yyyy', displayValue: this.txtDateShort, exampleval: '04-09-1900', customDisplayValue: this.txtDate}, + { value: Asc.c_oAscNumFormatType.Date, format: 'MMMM d yyyy', displayValue: this.txtDateLong, exampleval: 'April-09-1900', customDisplayValue: this.txtDate}, { value: Asc.c_oAscNumFormatType.Time, format: 'HH:MM:ss', displayValue: this.txtTime, exampleval: '00:00:00' }, { value: Asc.c_oAscNumFormatType.Percent, format: this.ascFormatOptions.Percentage, displayValue: this.txtPercentage, exampleval: '100,00%' }, { value: Asc.c_oAscNumFormatType.Fraction, format: this.ascFormatOptions.Fraction, displayValue: this.txtFraction, exampleval: '100' }, @@ -610,7 +610,7 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesEditDlg.template', // '
  • ' + me.textMoreFormats + '
  • ' ].join('')); - this.cmbNumberFormat = new Common.UI.ComboBox({ + this.cmbNumberFormat = new Common.UI.ComboBoxCustom({ el : $('#format-rules-edit-combo-num-format'), cls : 'input-group-nr', style : 'width: 113px;', @@ -619,11 +619,14 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesEditDlg.template', itemsTemplate: formatTemplate, editable : false, data : this.numFormatData, - takeFocusOnClose: true + takeFocusOnClose: true, + updateFormControl: function (record){ + this.clearSelection(); + record && this.setRawValue(record.get('customDisplayValue')||record.get('displayValue')); + } }); this.cmbNumberFormat.setRawValue(this.numFormatData[Asc.c_oAscNumFormatType.General].displayValue); this.cmbNumberFormat.on('selected', _.bind(this.onNumberFormatSelect, this)); - this.cmbNumberFormat.on('show:before', _.bind(this.onNumberFormatShowBefore, this)); Common.UI.FocusManager.add(this, this.cmbNumberFormat); this.btnClear = new Common.UI.Button({ @@ -1315,13 +1318,7 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesEditDlg.template', color = this.setColor(xfs.asc_getFillColor(), this.btnFillColor, this.mnuFillColorPicker); var val = xfs.asc_getNumFormatInfo(); - if (val) { - val = val.asc_getType(); - var indexNFD = val + (val > Asc.c_oAscNumFormatType.Date)|0; - this.cmbNumberFormat.setRawValue( - (val === Asc.c_oAscNumFormatType.Date) ? this.txtDate : this.numFormatData[indexNFD].displayValue - ); - } + val && this.cmbNumberFormat.setValue(val.asc_getType(), this.textCustom); } }, @@ -1746,13 +1743,6 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesEditDlg.template', !this.xfsFormat && (this.xfsFormat = new Asc.asc_CellXfs()); this.xfsFormat.asc_setNumFormatInfo(record.format); this.previewFormat(); - this.cmbNumberFormat.setRawValue( - (record.value === Asc.c_oAscNumFormatType.Date) ? this.txtDate : record.displayValue); - }, - - onNumberFormatShowBefore: function (){ - var rec = $('.selected', $(this.cmbNumberFormat.el)); - rec && rec.removeClass('selected');; }, previewFormat: function() { diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 07af40c093..3ee4605a9b 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -167,8 +167,8 @@ define([ { value: Asc.c_oAscNumFormatType.Scientific,format: this.ascFormatOptions.Scientific, displayValue: this.txtScientific, exampleval: '1,00E+02' }, { value: Asc.c_oAscNumFormatType.Accounting,format: this.ascFormatOptions.Accounting, displayValue: this.txtAccounting, exampleval: '100,00 $' }, { value: Asc.c_oAscNumFormatType.Currency, format: this.ascFormatOptions.Currency, displayValue: this.txtCurrency, exampleval: '100,00 $' }, - { value: Asc.c_oAscNumFormatType.Date, format: 'MM-dd-yyyy', displayValue: this.txtDateShort, exampleval: '04-09-1900' }, - { value: Asc.c_oAscNumFormatType.Date, format: 'MMMM d yyyy', displayValue: this.txtDateLong, exampleval: 'April 9 1900' }, + { value: Asc.c_oAscNumFormatType.Date, format: 'MM-dd-yyyy', displayValue: this.txtDateShort, exampleval: '04-09-1900', customDisplayValue: this.txtDate}, + { value: Asc.c_oAscNumFormatType.Date, format: 'MMMM d yyyy', displayValue: this.txtDateLong, exampleval: 'April 9 1900', customDisplayValue: this.txtDate }, { value: Asc.c_oAscNumFormatType.Time, format: 'HH:MM:ss', displayValue: this.txtTime, exampleval: '00:00:00' }, { value: Asc.c_oAscNumFormatType.Percent, format: this.ascFormatOptions.Percentage, displayValue: this.txtPercentage, exampleval: '100,00%' }, { value: Asc.c_oAscNumFormatType.Fraction, format: this.ascFormatOptions.Fraction, displayValue: this.txtFraction, exampleval: '100' }, @@ -278,7 +278,7 @@ define([ '
  • ' + me.textMoreFormats + '
  • ' ].join('')); - me.cmbNumberFormat = new Common.UI.ComboBox({ + me.cmbNumberFormat = new Common.UI.ComboBoxCustom({ cls : 'input-group-nr', menuStyle : 'min-width: 180px;', hint : me.tipNumFormat, @@ -287,7 +287,11 @@ define([ editable : false, data : me.numFormatData, dataHint : '1', - dataHintDirection: 'bottom' + dataHintDirection: 'bottom', + updateFormControl: function (record){ + this.clearSelection(); + record && this.setRawValue(record.get('customDisplayValue')||record.get('displayValue')); + } }); } if ( config.isEditMailMerge || config.isEditOle ) { @@ -1393,7 +1397,7 @@ define([ '
  • ' + me.textMoreFormats + '
  • ' ].join('')); - me.cmbNumberFormat = new Common.UI.ComboBox({ + me.cmbNumberFormat = new Common.UI.ComboBoxCustom({ cls : 'input-group-nr', style : 'width: 113px;', menuStyle : 'min-width: 180px;', @@ -1403,7 +1407,12 @@ define([ editable : false, data : me.numFormatData, dataHint : '1', - dataHintDirection: 'top' + dataHintDirection: 'top', + updateFormControl: function (record){ + this.clearSelection(); + record && this.setRawValue(record.get('customDisplayValue')||record.get('displayValue')); + } + }); me.btnPercentStyle = new Common.UI.Button({ diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index a4f3b5e9dc..c60365a1a5 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -2249,7 +2249,9 @@ "SSE.Views.DocumentHolder.txtCustomRowHeight": "Custom row height", "SSE.Views.DocumentHolder.txtCustomSort": "Custom sort", "SSE.Views.DocumentHolder.txtCut": "Cut", - "SSE.Views.DocumentHolder.txtDate": "Date", + "del_SSE.Views.DocumentHolder.txtDate": "Date", + "SSE.Views.DocumentHolder.txtDateShort": "Short Date", + "SSE.Views.DocumentHolder.txtDateLong": "Long Date", "SSE.Views.DocumentHolder.txtDelete": "Delete", "SSE.Views.DocumentHolder.txtDescending": "Descending", "SSE.Views.DocumentHolder.txtDistribHor": "Distribute horizontally", @@ -3849,7 +3851,7 @@ "SSE.Views.Toolbar.txtCustom": "Custom", "SSE.Views.Toolbar.txtDate": "Date", "SSE.Views.Toolbar.txtDateLong": "Long Date", - "SSE.Views.Toolbar.txtDateShort": "Date Short", + "SSE.Views.Toolbar.txtDateShort": "Short Date", "SSE.Views.Toolbar.txtDateTime": "Date & Time", "SSE.Views.Toolbar.txtDescending": "Descending", "SSE.Views.Toolbar.txtDollar": "$ Dollar",