diff --git a/apps/common/main/lib/component/InputField.js b/apps/common/main/lib/component/InputField.js index 5bfea7578..00fc916a6 100644 --- a/apps/common/main/lib/component/InputField.js +++ b/apps/common/main/lib/component/InputField.js @@ -155,6 +155,7 @@ define([ if (this.editable) { this._input.on('blur', _.bind(this.onInputChanged, this)); this._input.on('keypress', _.bind(this.onKeyPress, this)); + this._input.on('keydown', _.bind(this.onKeyDown, this)); this._input.on('keyup', _.bind(this.onKeyUp, this)); if (this.validateOnChange) this._input.on('input', _.bind(this.onInputChanging, this)); if (this.maxLength) this._input.attr('maxlength', this.maxLength); @@ -225,13 +226,11 @@ define([ if (e.isDefaultPrevented()) return; - if (e.keyCode === Common.UI.Keys.RETURN) { - this._doChange(e); - } else if (this.options.maskExp && !_.isEmpty(this.options.maskExp.source)){ + if (this.options.maskExp && !_.isEmpty(this.options.maskExp.source)){ var charCode = String.fromCharCode(e.which); if(!this.options.maskExp.test(charCode) && !e.ctrlKey && e.keyCode !== Common.UI.Keys.DELETE && e.keyCode !== Common.UI.Keys.BACKSPACE && e.keyCode !== Common.UI.Keys.LEFT && e.keyCode !== Common.UI.Keys.RIGHT && e.keyCode !== Common.UI.Keys.HOME && - e.keyCode !== Common.UI.Keys.END && e.keyCode !== Common.UI.Keys.ESC && e.keyCode !== Common.UI.Keys.INSERT ){ + e.keyCode !== Common.UI.Keys.END && e.keyCode !== Common.UI.Keys.ESC && e.keyCode !== Common.UI.Keys.INSERT && e.keyCode !== Common.UI.Keys.RETURN){ e.preventDefault(); e.stopPropagation(); } @@ -240,6 +239,14 @@ define([ this.trigger('keypress:after', this, e); }, + onKeyDown: function(e) { + if (e.isDefaultPrevented()) + return; + + if (e.keyCode === Common.UI.Keys.RETURN) + this._doChange(e); + }, + onKeyUp: function(e) { this.trigger('keyup:before', this, e); diff --git a/apps/common/main/lib/view/ExtendedColorDialog.js b/apps/common/main/lib/view/ExtendedColorDialog.js index ff6e6e86d..541124f4d 100644 --- a/apps/common/main/lib/view/ExtendedColorDialog.js +++ b/apps/common/main/lib/view/ExtendedColorDialog.js @@ -280,6 +280,12 @@ define([ },50); }, + onPrimary: function() { + this.trigger('onmodalresult', 1); + this.close(true); + return false; + }, + cancelButtonText: 'Cancel', addButtonText: 'Add', textNew: 'New', diff --git a/apps/common/main/lib/view/ImageFromUrlDialog.js b/apps/common/main/lib/view/ImageFromUrlDialog.js index 5f92912fc..8cfb3d3d9 100644 --- a/apps/common/main/lib/view/ImageFromUrlDialog.js +++ b/apps/common/main/lib/view/ImageFromUrlDialog.js @@ -87,7 +87,6 @@ define([ var $window = this.getChild(); $window.find('.btn').on('click', _.bind(this.onBtnClick, this)); - $window.find('input').on('keypress', _.bind(this.onKeyPress, this)); }, show: function() { @@ -99,10 +98,9 @@ define([ },500); }, - onKeyPress: function(event) { - if (event.keyCode == Common.UI.Keys.RETURN) { - this._handleInput('ok'); - } + onPrimary: function(event) { + this._handleInput('ok'); + return false; }, onBtnClick: function(event) { diff --git a/apps/common/main/lib/view/LanguageDialog.js b/apps/common/main/lib/view/LanguageDialog.js index 26f87e7c3..c9fa28635 100644 --- a/apps/common/main/lib/view/LanguageDialog.js +++ b/apps/common/main/lib/view/LanguageDialog.js @@ -136,6 +136,15 @@ define([ icon.addClass(rec.value).attr('lang',rec.value); }, + onPrimary: function() { + if (this.options.handler) { + this.options.handler.call(this, 'ok', this.cmbLanguage.getValue()); + } + + this.close(); + return false; + }, + labelSelect : 'Select document language', btnCancel : 'Cancel', btnOk : 'Ok' diff --git a/apps/common/main/lib/view/OpenDialog.js b/apps/common/main/lib/view/OpenDialog.js index 1157b7184..d854ec693 100644 --- a/apps/common/main/lib/view/OpenDialog.js +++ b/apps/common/main/lib/view/OpenDialog.js @@ -162,7 +162,7 @@ define([ return me.txtIncorrectPwd; } }); - this.$window.find('input').on('keypress', _.bind(this.onKeyPress, this)); + this.$window.find('input').on('input', function(){ if ($(this).val() !== '') { ($(this).attr('type') !== 'password') && $(this).attr('type', 'password'); @@ -174,11 +174,11 @@ define([ this.initCodePages(); if (this.preview) this.updatePreview(); - this.onPrimary = function() { - me._handleInput('ok'); - return false; - }; } + this.onPrimary = function() { + me._handleInput('ok'); + return false; + }; } }, @@ -195,13 +195,6 @@ define([ } }, - onKeyPress: function(event) { - if (event.keyCode == Common.UI.Keys.RETURN) { - this._handleInput('ok'); - } else if (this.closable && event.keyCode == Common.UI.Keys.ESC) - this._handleInput('cancel'); - }, - onBtnClick: function(event) { this._handleInput(event.currentTarget.attributes['result'].value); }, diff --git a/apps/common/main/lib/view/PasswordDialog.js b/apps/common/main/lib/view/PasswordDialog.js index 02ab68cf1..cc2302195 100644 --- a/apps/common/main/lib/view/PasswordDialog.js +++ b/apps/common/main/lib/view/PasswordDialog.js @@ -114,7 +114,6 @@ define([ return me.txtIncorrectPwd; } }); - this.$window.find('input').on('keypress', _.bind(this.onKeyPress, this)); } }, @@ -127,10 +126,9 @@ define([ }, 500); }, - onKeyPress: function(event) { - if (event.keyCode == Common.UI.Keys.RETURN) { - this._handleInput('ok'); - } + onPrimary: function(event) { + this._handleInput('ok'); + return false; }, onBtnClick: function(event) { diff --git a/apps/common/main/lib/view/RenameDialog.js b/apps/common/main/lib/view/RenameDialog.js index 241b8c589..671e0ed79 100644 --- a/apps/common/main/lib/view/RenameDialog.js +++ b/apps/common/main/lib/view/RenameDialog.js @@ -88,7 +88,6 @@ define([ $window.find('.btn').on('click', _.bind(this.onBtnClick, this)); me.inputNameEl = $window.find('input'); - me.inputNameEl.on('keypress', _.bind(this.onKeyPress, this)); }, show: function() { @@ -101,10 +100,9 @@ define([ },100); }, - onKeyPress: function(event) { - if (event.keyCode == Common.UI.Keys.RETURN) { - this._handleInput('ok'); - } + onPrimary: function(event) { + this._handleInput('ok'); + return false; }, onBtnClick: function(event) { diff --git a/apps/common/main/lib/view/SignDialog.js b/apps/common/main/lib/view/SignDialog.js index 0745e8da1..4916818b2 100644 --- a/apps/common/main/lib/view/SignDialog.js +++ b/apps/common/main/lib/view/SignDialog.js @@ -239,7 +239,6 @@ define([ (me.signType == 'visible') ? me.cntInvisibleSign.addClass('hidden') : me.cntVisibleSign.addClass('hidden'); $window.find('.dlg-btn').on('click', _.bind(me.onBtnClick, me)); - $window.find('input').on('keypress', _.bind(me.onKeyPress, me)); me.afterRender(); }, @@ -297,11 +296,9 @@ define([ this._handleInput(event.currentTarget.attributes['result'].value); }, - onKeyPress: function(event) { - if (event.keyCode == Common.UI.Keys.RETURN) { - this._handleInput('ok'); - return false; - } + onPrimary: function(event) { + this._handleInput('ok'); + return false; }, _handleInput: function(state) { diff --git a/apps/common/main/lib/view/SignSettingsDialog.js b/apps/common/main/lib/view/SignSettingsDialog.js index 4d284c8cd..59a1c25c3 100644 --- a/apps/common/main/lib/view/SignSettingsDialog.js +++ b/apps/common/main/lib/view/SignSettingsDialog.js @@ -140,7 +140,6 @@ define([ }); $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); - $window.find('input').on('keypress', _.bind(this.onKeyPress, this)); }, show: function() { @@ -185,11 +184,9 @@ define([ this._handleInput(event.currentTarget.attributes['result'].value); }, - onKeyPress: function(event) { - if (event.keyCode == Common.UI.Keys.RETURN) { - this._handleInput('ok'); - return false; - } + onPrimary: function(event) { + this._handleInput('ok'); + return false; }, _handleInput: function(state) { diff --git a/apps/documenteditor/main/app/view/ControlSettingsDialog.js b/apps/documenteditor/main/app/view/ControlSettingsDialog.js index b0eba142a..9d4fd65d2 100644 --- a/apps/documenteditor/main/app/view/ControlSettingsDialog.js +++ b/apps/documenteditor/main/app/view/ControlSettingsDialog.js @@ -195,10 +195,6 @@ define([ this.close(); }, - onPrimary: function() { - return true; - }, - textTitle: 'Content Control Settings', textName: 'Title', textTag: 'Tag', diff --git a/apps/documenteditor/main/app/view/HyperlinkSettingsDialog.js b/apps/documenteditor/main/app/view/HyperlinkSettingsDialog.js index d8a782461..4d7c87cbb 100644 --- a/apps/documenteditor/main/app/view/HyperlinkSettingsDialog.js +++ b/apps/documenteditor/main/app/view/HyperlinkSettingsDialog.js @@ -165,7 +165,7 @@ define([ }); $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); - $window.find('input').on('keypress', _.bind(this.onKeyPress, this)); + me.internalList.on('entervalue', _.bind(me.onPrimary, me)); me.externalPanel = $window.find('#id-external-link'); me.internalPanel = $window.find('#id-internal-link'); }, @@ -367,11 +367,9 @@ define([ this._handleInput(event.currentTarget.attributes['result'].value); }, - onKeyPress: function(event) { - if (event.keyCode == Common.UI.Keys.RETURN) { - this._handleInput('ok'); - return false; - } + onPrimary: function(event) { + this._handleInput('ok'); + return false; }, _handleInput: function(state) { diff --git a/apps/documenteditor/main/app/view/PageMarginsDialog.js b/apps/documenteditor/main/app/view/PageMarginsDialog.js index 891381e50..fe97fb7b2 100644 --- a/apps/documenteditor/main/app/view/PageMarginsDialog.js +++ b/apps/documenteditor/main/app/view/PageMarginsDialog.js @@ -147,7 +147,6 @@ define([ var $window = this.getChild(); $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); - $window.find('input').on('keypress', _.bind(this.onKeyPress, this)); this.updateMetricUnit(); }, @@ -178,10 +177,9 @@ define([ this._handleInput(event.currentTarget.attributes['result'].value); }, - onKeyPress: function(event) { - if (event.keyCode == Common.UI.Keys.RETURN) { - this._handleInput('ok'); - } + onPrimary: function(event) { + this._handleInput('ok'); + return false; }, setSettings: function (props) { diff --git a/apps/documenteditor/main/app/view/PageSizeDialog.js b/apps/documenteditor/main/app/view/PageSizeDialog.js index f438431e9..e883605ec 100644 --- a/apps/documenteditor/main/app/view/PageSizeDialog.js +++ b/apps/documenteditor/main/app/view/PageSizeDialog.js @@ -167,7 +167,6 @@ define([ var $window = this.getChild(); $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); - $window.find('input').on('keypress', _.bind(this.onKeyPress, this)); this.updateMetricUnit(); }, @@ -184,10 +183,9 @@ define([ this._handleInput(event.currentTarget.attributes['result'].value); }, - onKeyPress: function(event) { - if (event.keyCode == Common.UI.Keys.RETURN) { - this._handleInput('ok'); - } + onPrimary: function(event) { + this._handleInput('ok'); + return false; }, setSettings: function (props) { diff --git a/apps/documenteditor/main/app/view/StyleTitleDialog.js b/apps/documenteditor/main/app/view/StyleTitleDialog.js index 1779b986b..d227cdc77 100644 --- a/apps/documenteditor/main/app/view/StyleTitleDialog.js +++ b/apps/documenteditor/main/app/view/StyleTitleDialog.js @@ -99,7 +99,6 @@ define([ }); $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); - $window.find('input').on('keypress', _.bind(this.onKeyPress, this)); this.cmbNextStyle = new Common.UI.ComboBox({ el : $('#id-dlg-style-next-par'), @@ -137,11 +136,9 @@ define([ this._handleInput(event.currentTarget.attributes['result'].value); }, - onKeyPress: function(event) { - if (event.keyCode == Common.UI.Keys.RETURN) { - this._handleInput('ok'); - return false; - } + onPrimary: function(event) { + this._handleInput('ok'); + return false; }, _handleInput: function(state) { diff --git a/apps/presentationeditor/main/app/view/HyperlinkSettingsDialog.js b/apps/presentationeditor/main/app/view/HyperlinkSettingsDialog.js index 3c222d5f6..f88c9c372 100644 --- a/apps/presentationeditor/main/app/view/HyperlinkSettingsDialog.js +++ b/apps/presentationeditor/main/app/view/HyperlinkSettingsDialog.js @@ -214,7 +214,6 @@ define([ }, me)); $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); - $window.find('input').on('keypress', _.bind(this.onKeyPress, this)); me.externalPanel = $window.find('#id-external-link'); me.internalPanel = $window.find('#id-internal-link'); }, @@ -295,11 +294,9 @@ define([ this._handleInput(event.currentTarget.attributes['result'].value); }, - onKeyPress: function(event) { - if (event.keyCode == Common.UI.Keys.RETURN) { - this._handleInput('ok'); - return false; - } + onPrimary: function(event) { + this._handleInput('ok'); + return false; }, _handleInput: function(state) { diff --git a/apps/presentationeditor/main/app/view/SlideSizeSettings.js b/apps/presentationeditor/main/app/view/SlideSizeSettings.js index 8e2837b2e..28326a2ff 100644 --- a/apps/presentationeditor/main/app/view/SlideSizeSettings.js +++ b/apps/presentationeditor/main/app/view/SlideSizeSettings.js @@ -201,7 +201,6 @@ define([ var $window = this.getChild(); $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); - $window.find('input').on('keypress', _.bind(this.onKeyPress, this)); this.updateMetricUnit(); }, @@ -218,12 +217,6 @@ define([ this._handleInput(event.currentTarget.attributes['result'].value); }, - onKeyPress: function(event) { - if (event.keyCode == Common.UI.Keys.RETURN) { - this._handleInput('ok'); - } - }, - onPrimary: function() { this._handleInput('ok'); return false; diff --git a/apps/presentationeditor/main/app/view/SlideshowSettings.js b/apps/presentationeditor/main/app/view/SlideshowSettings.js index 173b8fcd6..603171bcf 100644 --- a/apps/presentationeditor/main/app/view/SlideshowSettings.js +++ b/apps/presentationeditor/main/app/view/SlideshowSettings.js @@ -86,7 +86,6 @@ define([ var $window = this.getChild(); $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); - $window.find('input').on('keypress', _.bind(this.onKeyPress, this)); }, _handleInput: function(state) { @@ -101,12 +100,6 @@ define([ this._handleInput(event.currentTarget.attributes['result'].value); }, - onKeyPress: function(event) { - if (event.keyCode == Common.UI.Keys.RETURN) { - this._handleInput('ok'); - } - }, - onPrimary: function() { this._handleInput('ok'); return false; diff --git a/apps/spreadsheeteditor/main/app/view/CellRangeDialog.js b/apps/spreadsheeteditor/main/app/view/CellRangeDialog.js index 8fd7f5347..0f38550f1 100644 --- a/apps/spreadsheeteditor/main/app/view/CellRangeDialog.js +++ b/apps/spreadsheeteditor/main/app/view/CellRangeDialog.js @@ -90,7 +90,6 @@ define([ }); $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); - me.inputRange.cmpEl.find('input').on('keypress', _.bind(this.onKeyPress, this)); this.on('close', _.bind(this.onClose, this)); @@ -153,12 +152,6 @@ define([ SSE.getController('RightMenu').SetDisabled(false); }, - onKeyPress: function(event) { - if (event.keyCode == Common.UI.Keys.RETURN) { - this._handleInput('ok'); - } - }, - _handleInput: function(state) { if (this.options.handler) { if (state == 'ok') { diff --git a/apps/spreadsheeteditor/main/app/view/HyperlinkSettingsDialog.js b/apps/spreadsheeteditor/main/app/view/HyperlinkSettingsDialog.js index 8fb87634e..eae907f2f 100644 --- a/apps/spreadsheeteditor/main/app/view/HyperlinkSettingsDialog.js +++ b/apps/spreadsheeteditor/main/app/view/HyperlinkSettingsDialog.js @@ -182,7 +182,6 @@ define([ }); $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); - $window.find('input').on('keypress', _.bind(this.onKeyPress, this)); me.externalPanel = $window.find('#id-external-link'); me.internalPanel = $window.find('#id-internal-link'); @@ -265,11 +264,9 @@ define([ this._handleInput(event.currentTarget.attributes['result'].value); }, - onKeyPress: function(event) { - if (event.keyCode == Common.UI.Keys.RETURN) { - this._handleInput('ok'); - return false; - } + onPrimary: function(event) { + this._handleInput('ok'); + return false; }, _handleInput: function(state) { diff --git a/apps/spreadsheeteditor/main/app/view/NamedRangeEditDlg.js b/apps/spreadsheeteditor/main/app/view/NamedRangeEditDlg.js index 5fe5fef46..8156f089e 100644 --- a/apps/spreadsheeteditor/main/app/view/NamedRangeEditDlg.js +++ b/apps/spreadsheeteditor/main/app/view/NamedRangeEditDlg.js @@ -145,12 +145,7 @@ define([ } } } - }).on('keypress:after', function(input, e) { - if (e.keyCode === Common.UI.Keys.RETURN) { - me.onDlgBtnClick('ok'); - } - } - ); + }); this.cmbScope = new Common.UI.ComboBox({ el : $('#named-range-combo-scope'), @@ -175,12 +170,7 @@ define([ var isvalid = me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Chart, value, false); return (isvalid!==Asc.c_oAscError.ID.DataRangeError || (me.isEdit && me.props.asc_getRef().toLowerCase() == value.toLowerCase())) ? true : me.textInvalidRange; } - }).on('keypress:after', function(input, e) { - if (e.keyCode === Common.UI.Keys.RETURN) { - me.onDlgBtnClick('ok'); - } - } - ); + }); this.btnSelectData = new Common.UI.Button({ el: $('#named-range-btn-data') @@ -262,7 +252,8 @@ define([ }, onPrimary: function() { - return true; + this.onDlgBtnClick('ok'); + return false; }, onDlgBtnClick: function(event) { diff --git a/apps/spreadsheeteditor/main/app/view/Statusbar.js b/apps/spreadsheeteditor/main/app/view/Statusbar.js index b09161acc..b18681e4d 100644 --- a/apps/spreadsheeteditor/main/app/view/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/view/Statusbar.js @@ -596,10 +596,6 @@ define([ maxLength: 31, validation: _.bind(this.nameValidator, this) }); - - if (this.txtName) { - this.txtName.$el.on('keypress', 'input[type=text]', _.bind(this.onNameKeyPress, this)); - } }, show: function(x,y) { @@ -632,10 +628,9 @@ define([ this.close(); }, - onNameKeyPress: function(e) { - if (e.keyCode == Common.UI.Keys.RETURN) { - this.doClose('ok'); - } + onPrimary: function(e) { + this.doClose('ok'); + return false; }, nameValidator: function(value) { diff --git a/apps/spreadsheeteditor/main/app/view/TableOptionsDialog.js b/apps/spreadsheeteditor/main/app/view/TableOptionsDialog.js index e583d1944..3daed28c0 100644 --- a/apps/spreadsheeteditor/main/app/view/TableOptionsDialog.js +++ b/apps/spreadsheeteditor/main/app/view/TableOptionsDialog.js @@ -100,7 +100,6 @@ define([ }); $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); - me.inputRange.cmpEl.find('input').on('keypress', _.bind(this.onKeyPress, this)); this.on('close', _.bind(this.onClose, this)); }, @@ -189,12 +188,6 @@ define([ SSE.getController('RightMenu').SetDisabled(false); }, - onKeyPress: function(event) { - if (event.keyCode == Common.UI.Keys.RETURN) { - this._handleInput('ok'); - } - }, - _handleInput: function(state) { if (this.options.handler) { if (state == 'ok') {