Bug 38988. Refactoring of window closing.

This commit is contained in:
Julia Radzhabova 2018-09-21 16:01:09 +03:00
parent 955cb9c5bb
commit 544e17e96f
22 changed files with 72 additions and 130 deletions

View file

@ -155,6 +155,7 @@ define([
if (this.editable) { if (this.editable) {
this._input.on('blur', _.bind(this.onInputChanged, this)); this._input.on('blur', _.bind(this.onInputChanged, this));
this._input.on('keypress', _.bind(this.onKeyPress, 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)); this._input.on('keyup', _.bind(this.onKeyUp, this));
if (this.validateOnChange) this._input.on('input', _.bind(this.onInputChanging, this)); if (this.validateOnChange) this._input.on('input', _.bind(this.onInputChanging, this));
if (this.maxLength) this._input.attr('maxlength', this.maxLength); if (this.maxLength) this._input.attr('maxlength', this.maxLength);
@ -225,13 +226,11 @@ define([
if (e.isDefaultPrevented()) if (e.isDefaultPrevented())
return; return;
if (e.keyCode === Common.UI.Keys.RETURN) { if (this.options.maskExp && !_.isEmpty(this.options.maskExp.source)){
this._doChange(e);
} else if (this.options.maskExp && !_.isEmpty(this.options.maskExp.source)){
var charCode = String.fromCharCode(e.which); 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 && 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.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.preventDefault();
e.stopPropagation(); e.stopPropagation();
} }
@ -240,6 +239,14 @@ define([
this.trigger('keypress:after', this, e); 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) { onKeyUp: function(e) {
this.trigger('keyup:before', this, e); this.trigger('keyup:before', this, e);

View file

@ -280,6 +280,12 @@ define([
},50); },50);
}, },
onPrimary: function() {
this.trigger('onmodalresult', 1);
this.close(true);
return false;
},
cancelButtonText: 'Cancel', cancelButtonText: 'Cancel',
addButtonText: 'Add', addButtonText: 'Add',
textNew: 'New', textNew: 'New',

View file

@ -87,7 +87,6 @@ define([
var $window = this.getChild(); var $window = this.getChild();
$window.find('.btn').on('click', _.bind(this.onBtnClick, this)); $window.find('.btn').on('click', _.bind(this.onBtnClick, this));
$window.find('input').on('keypress', _.bind(this.onKeyPress, this));
}, },
show: function() { show: function() {
@ -99,10 +98,9 @@ define([
},500); },500);
}, },
onKeyPress: function(event) { onPrimary: function(event) {
if (event.keyCode == Common.UI.Keys.RETURN) { this._handleInput('ok');
this._handleInput('ok'); return false;
}
}, },
onBtnClick: function(event) { onBtnClick: function(event) {

View file

@ -136,6 +136,15 @@ define([
icon.addClass(rec.value).attr('lang',rec.value); 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', labelSelect : 'Select document language',
btnCancel : 'Cancel', btnCancel : 'Cancel',
btnOk : 'Ok' btnOk : 'Ok'

View file

@ -162,7 +162,7 @@ define([
return me.txtIncorrectPwd; return me.txtIncorrectPwd;
} }
}); });
this.$window.find('input').on('keypress', _.bind(this.onKeyPress, this));
this.$window.find('input').on('input', function(){ this.$window.find('input').on('input', function(){
if ($(this).val() !== '') { if ($(this).val() !== '') {
($(this).attr('type') !== 'password') && $(this).attr('type', 'password'); ($(this).attr('type') !== 'password') && $(this).attr('type', 'password');
@ -174,11 +174,11 @@ define([
this.initCodePages(); this.initCodePages();
if (this.preview) if (this.preview)
this.updatePreview(); 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) { onBtnClick: function(event) {
this._handleInput(event.currentTarget.attributes['result'].value); this._handleInput(event.currentTarget.attributes['result'].value);
}, },

View file

@ -114,7 +114,6 @@ define([
return me.txtIncorrectPwd; return me.txtIncorrectPwd;
} }
}); });
this.$window.find('input').on('keypress', _.bind(this.onKeyPress, this));
} }
}, },
@ -127,10 +126,9 @@ define([
}, 500); }, 500);
}, },
onKeyPress: function(event) { onPrimary: function(event) {
if (event.keyCode == Common.UI.Keys.RETURN) { this._handleInput('ok');
this._handleInput('ok'); return false;
}
}, },
onBtnClick: function(event) { onBtnClick: function(event) {

View file

@ -88,7 +88,6 @@ define([
$window.find('.btn').on('click', _.bind(this.onBtnClick, this)); $window.find('.btn').on('click', _.bind(this.onBtnClick, this));
me.inputNameEl = $window.find('input'); me.inputNameEl = $window.find('input');
me.inputNameEl.on('keypress', _.bind(this.onKeyPress, this));
}, },
show: function() { show: function() {
@ -101,10 +100,9 @@ define([
},100); },100);
}, },
onKeyPress: function(event) { onPrimary: function(event) {
if (event.keyCode == Common.UI.Keys.RETURN) { this._handleInput('ok');
this._handleInput('ok'); return false;
}
}, },
onBtnClick: function(event) { onBtnClick: function(event) {

View file

@ -239,7 +239,6 @@ define([
(me.signType == 'visible') ? me.cntInvisibleSign.addClass('hidden') : me.cntVisibleSign.addClass('hidden'); (me.signType == 'visible') ? me.cntInvisibleSign.addClass('hidden') : me.cntVisibleSign.addClass('hidden');
$window.find('.dlg-btn').on('click', _.bind(me.onBtnClick, me)); $window.find('.dlg-btn').on('click', _.bind(me.onBtnClick, me));
$window.find('input').on('keypress', _.bind(me.onKeyPress, me));
me.afterRender(); me.afterRender();
}, },
@ -297,11 +296,9 @@ define([
this._handleInput(event.currentTarget.attributes['result'].value); this._handleInput(event.currentTarget.attributes['result'].value);
}, },
onKeyPress: function(event) { onPrimary: function(event) {
if (event.keyCode == Common.UI.Keys.RETURN) { this._handleInput('ok');
this._handleInput('ok'); return false;
return false;
}
}, },
_handleInput: function(state) { _handleInput: function(state) {

View file

@ -140,7 +140,6 @@ define([
}); });
$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
$window.find('input').on('keypress', _.bind(this.onKeyPress, this));
}, },
show: function() { show: function() {
@ -185,11 +184,9 @@ define([
this._handleInput(event.currentTarget.attributes['result'].value); this._handleInput(event.currentTarget.attributes['result'].value);
}, },
onKeyPress: function(event) { onPrimary: function(event) {
if (event.keyCode == Common.UI.Keys.RETURN) { this._handleInput('ok');
this._handleInput('ok'); return false;
return false;
}
}, },
_handleInput: function(state) { _handleInput: function(state) {

View file

@ -195,10 +195,6 @@ define([
this.close(); this.close();
}, },
onPrimary: function() {
return true;
},
textTitle: 'Content Control Settings', textTitle: 'Content Control Settings',
textName: 'Title', textName: 'Title',
textTag: 'Tag', textTag: 'Tag',

View file

@ -165,7 +165,7 @@ define([
}); });
$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); $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.externalPanel = $window.find('#id-external-link');
me.internalPanel = $window.find('#id-internal-link'); me.internalPanel = $window.find('#id-internal-link');
}, },
@ -367,11 +367,9 @@ define([
this._handleInput(event.currentTarget.attributes['result'].value); this._handleInput(event.currentTarget.attributes['result'].value);
}, },
onKeyPress: function(event) { onPrimary: function(event) {
if (event.keyCode == Common.UI.Keys.RETURN) { this._handleInput('ok');
this._handleInput('ok'); return false;
return false;
}
}, },
_handleInput: function(state) { _handleInput: function(state) {

View file

@ -147,7 +147,6 @@ define([
var $window = this.getChild(); var $window = this.getChild();
$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
$window.find('input').on('keypress', _.bind(this.onKeyPress, this));
this.updateMetricUnit(); this.updateMetricUnit();
}, },
@ -178,10 +177,9 @@ define([
this._handleInput(event.currentTarget.attributes['result'].value); this._handleInput(event.currentTarget.attributes['result'].value);
}, },
onKeyPress: function(event) { onPrimary: function(event) {
if (event.keyCode == Common.UI.Keys.RETURN) { this._handleInput('ok');
this._handleInput('ok'); return false;
}
}, },
setSettings: function (props) { setSettings: function (props) {

View file

@ -167,7 +167,6 @@ define([
var $window = this.getChild(); var $window = this.getChild();
$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
$window.find('input').on('keypress', _.bind(this.onKeyPress, this));
this.updateMetricUnit(); this.updateMetricUnit();
}, },
@ -184,10 +183,9 @@ define([
this._handleInput(event.currentTarget.attributes['result'].value); this._handleInput(event.currentTarget.attributes['result'].value);
}, },
onKeyPress: function(event) { onPrimary: function(event) {
if (event.keyCode == Common.UI.Keys.RETURN) { this._handleInput('ok');
this._handleInput('ok'); return false;
}
}, },
setSettings: function (props) { setSettings: function (props) {

View file

@ -99,7 +99,6 @@ define([
}); });
$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); $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({ this.cmbNextStyle = new Common.UI.ComboBox({
el : $('#id-dlg-style-next-par'), el : $('#id-dlg-style-next-par'),
@ -137,11 +136,9 @@ define([
this._handleInput(event.currentTarget.attributes['result'].value); this._handleInput(event.currentTarget.attributes['result'].value);
}, },
onKeyPress: function(event) { onPrimary: function(event) {
if (event.keyCode == Common.UI.Keys.RETURN) { this._handleInput('ok');
this._handleInput('ok'); return false;
return false;
}
}, },
_handleInput: function(state) { _handleInput: function(state) {

View file

@ -214,7 +214,6 @@ define([
}, me)); }, me));
$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); $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.externalPanel = $window.find('#id-external-link');
me.internalPanel = $window.find('#id-internal-link'); me.internalPanel = $window.find('#id-internal-link');
}, },
@ -295,11 +294,9 @@ define([
this._handleInput(event.currentTarget.attributes['result'].value); this._handleInput(event.currentTarget.attributes['result'].value);
}, },
onKeyPress: function(event) { onPrimary: function(event) {
if (event.keyCode == Common.UI.Keys.RETURN) { this._handleInput('ok');
this._handleInput('ok'); return false;
return false;
}
}, },
_handleInput: function(state) { _handleInput: function(state) {

View file

@ -201,7 +201,6 @@ define([
var $window = this.getChild(); var $window = this.getChild();
$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
$window.find('input').on('keypress', _.bind(this.onKeyPress, this));
this.updateMetricUnit(); this.updateMetricUnit();
}, },
@ -218,12 +217,6 @@ define([
this._handleInput(event.currentTarget.attributes['result'].value); this._handleInput(event.currentTarget.attributes['result'].value);
}, },
onKeyPress: function(event) {
if (event.keyCode == Common.UI.Keys.RETURN) {
this._handleInput('ok');
}
},
onPrimary: function() { onPrimary: function() {
this._handleInput('ok'); this._handleInput('ok');
return false; return false;

View file

@ -86,7 +86,6 @@ define([
var $window = this.getChild(); var $window = this.getChild();
$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
$window.find('input').on('keypress', _.bind(this.onKeyPress, this));
}, },
_handleInput: function(state) { _handleInput: function(state) {
@ -101,12 +100,6 @@ define([
this._handleInput(event.currentTarget.attributes['result'].value); this._handleInput(event.currentTarget.attributes['result'].value);
}, },
onKeyPress: function(event) {
if (event.keyCode == Common.UI.Keys.RETURN) {
this._handleInput('ok');
}
},
onPrimary: function() { onPrimary: function() {
this._handleInput('ok'); this._handleInput('ok');
return false; return false;

View file

@ -90,7 +90,6 @@ define([
}); });
$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); $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)); this.on('close', _.bind(this.onClose, this));
@ -153,12 +152,6 @@ define([
SSE.getController('RightMenu').SetDisabled(false); SSE.getController('RightMenu').SetDisabled(false);
}, },
onKeyPress: function(event) {
if (event.keyCode == Common.UI.Keys.RETURN) {
this._handleInput('ok');
}
},
_handleInput: function(state) { _handleInput: function(state) {
if (this.options.handler) { if (this.options.handler) {
if (state == 'ok') { if (state == 'ok') {

View file

@ -182,7 +182,6 @@ define([
}); });
$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); $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.externalPanel = $window.find('#id-external-link');
me.internalPanel = $window.find('#id-internal-link'); me.internalPanel = $window.find('#id-internal-link');
@ -265,11 +264,9 @@ define([
this._handleInput(event.currentTarget.attributes['result'].value); this._handleInput(event.currentTarget.attributes['result'].value);
}, },
onKeyPress: function(event) { onPrimary: function(event) {
if (event.keyCode == Common.UI.Keys.RETURN) { this._handleInput('ok');
this._handleInput('ok'); return false;
return false;
}
}, },
_handleInput: function(state) { _handleInput: function(state) {

View file

@ -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({ this.cmbScope = new Common.UI.ComboBox({
el : $('#named-range-combo-scope'), el : $('#named-range-combo-scope'),
@ -175,12 +170,7 @@ define([
var isvalid = me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Chart, value, false); 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; 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({ this.btnSelectData = new Common.UI.Button({
el: $('#named-range-btn-data') el: $('#named-range-btn-data')
@ -262,7 +252,8 @@ define([
}, },
onPrimary: function() { onPrimary: function() {
return true; this.onDlgBtnClick('ok');
return false;
}, },
onDlgBtnClick: function(event) { onDlgBtnClick: function(event) {

View file

@ -596,10 +596,6 @@ define([
maxLength: 31, maxLength: 31,
validation: _.bind(this.nameValidator, this) validation: _.bind(this.nameValidator, this)
}); });
if (this.txtName) {
this.txtName.$el.on('keypress', 'input[type=text]', _.bind(this.onNameKeyPress, this));
}
}, },
show: function(x,y) { show: function(x,y) {
@ -632,10 +628,9 @@ define([
this.close(); this.close();
}, },
onNameKeyPress: function(e) { onPrimary: function(e) {
if (e.keyCode == Common.UI.Keys.RETURN) { this.doClose('ok');
this.doClose('ok'); return false;
}
}, },
nameValidator: function(value) { nameValidator: function(value) {

View file

@ -100,7 +100,6 @@ define([
}); });
$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); $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)); this.on('close', _.bind(this.onClose, this));
}, },
@ -189,12 +188,6 @@ define([
SSE.getController('RightMenu').SetDisabled(false); SSE.getController('RightMenu').SetDisabled(false);
}, },
onKeyPress: function(event) {
if (event.keyCode == Common.UI.Keys.RETURN) {
this._handleInput('ok');
}
},
_handleInput: function(state) { _handleInput: function(state) {
if (this.options.handler) { if (this.options.handler) {
if (state == 'ok') { if (state == 'ok') {