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) {
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);

View file

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

View file

@ -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) {

View file

@ -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'

View file

@ -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);
},

View file

@ -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) {

View file

@ -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) {

View file

@ -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) {

View file

@ -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) {

View file

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

View file

@ -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) {

View file

@ -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) {

View file

@ -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) {

View file

@ -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) {

View file

@ -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) {

View file

@ -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;

View file

@ -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;

View file

@ -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') {

View file

@ -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) {

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({
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) {

View file

@ -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) {

View file

@ -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') {