Fix Bug 49948

This commit is contained in:
OVSharova 2021-10-08 15:24:41 +03:00
parent 65171005ae
commit 63232779e9
3 changed files with 66 additions and 32 deletions

View file

@ -191,6 +191,7 @@ define([
}, },
checkPasswordType: function(){ checkPasswordType: function(){
if(this.type == 'text') return;
if (this._input.val() !== '') { if (this._input.val() !== '') {
(this._input.attr('type') !== 'password') && this._input.attr('type', 'password'); (this._input.attr('type') !== 'password') && this._input.attr('type', 'password');
} else { } else {
@ -439,7 +440,7 @@ define([
template: _.template([ template: _.template([
'<div class="input-field input-field-btn" style="<%= style %>">', '<div class="input-field input-field-btn" style="<%= style %>">',
'<input ', '<input ',
'type="<%= type %>" ', 'type="text" ',
'name="<%= name %>" ', 'name="<%= name %>" ',
'spellcheck="<%= spellcheck %>" ', 'spellcheck="<%= spellcheck %>" ',
'class="form-control <%= cls %>" ', 'class="form-control <%= cls %>" ',
@ -487,17 +488,7 @@ define([
el: this.cmpEl.find('button'), el: this.cmpEl.find('button'),
hint: this.options.btnHint || '' hint: this.options.btnHint || ''
}); });
this._button.on('click', _.bind(this.onButtonClick, this)); (this.type === 'text') && this._button.on('click', _.bind(this.onButtonClick, this));
if((this.type == 'password')&&(this.options.btnForPwdShow))
{
this._btnElm = this._button.$el;
this._button.setIconCls('hide-password');
if(this.options.showPwdOnClick)
this._button.on('click', _.bind(this.passwordShow, this));
else
this._btnElm.on('mousedown', _.bind(this.passwordShow, this));
}
this._input = this.cmpEl.find('input').addBack().filter('input'); this._input = this.cmpEl.find('input').addBack().filter('input');
@ -509,6 +500,21 @@ define([
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);
} }
if((this.type == 'password')&&(this.options.btnForPwdShow))
{
this.hidePwd = true;
this.repeatInput= this.options.repeatInput;
this.currentType = 'password';
this._btnElm = this._button.$el;
this._button.setIconCls('btn-sheet-view');
this._input.on('input', _.bind(this.checkPasswordType, this));
this._button.updateHint(this.textHintShowPwd);
if(this.options.showPwdOnClick)
this._button.on('click', _.bind(this.passwordClick, this));
else
this._btnElm.on('mousedown', _.bind(this.passwordShow, this));
}
this.setEditable(this.editable); this.setEditable(this.editable);
@ -525,6 +531,8 @@ define([
} }
me.rendered = true; me.rendered = true;
if (me.value)
me.setValue(me.value);
return this; return this;
}, },
@ -553,38 +561,63 @@ define([
this._button.updateHint(this.options.hint); this._button.updateHint(this.options.hint);
}, },
checkPasswordType: function(){
if (this._input.val() != '') {
(this._input.attr('type') !== this.currentType) && this._input.attr('type', this.currentType);
} else {
this._input.attr('type', 'text');
}
},
passwordClick: function (e)
{
if(this.hidePwd) {
this.passwordShow(e);
this.hidePwd = false;
}
else {
this.passwordHide(e);
this.hidePwd = true;
}
},
passwordShow: function (e) { passwordShow: function (e) {
if (this.disabled) return; if (this.disabled) return;
this._button.setIconCls('btn-sheet-view'); this._button.setIconCls('hide-password');
this._input.attr('type', 'text'); this.currentType = 'text';
if(this.options.repeatInput) this._input.attr('type', this.currentType);
this.options.repeatInput.attr('type', 'text'); if(this.repeatInput) {
this.repeatInput.type = this.currentType;
this.repeatInput._input.attr('type', this.currentType);
}
if(this.options.showPwdOnClick) if(this.options.showPwdOnClick) {
{ this._button.updateHint(this.textHintHidePwd);
this._button.off('click', _.bind(this.passwordShow, this));
this._button.on('click', _.bind(this.passwordHide, this));
} }
else else
this._btnElm.on('mouseup', _.bind(this.passwordHide,this)); this._btnElm.on('mouseup', _.bind(this.passwordHide,this));
}, },
passwordHide: function (e) { passwordHide: function (e) {
this._button.setIconCls('hide-password'); this._button.setIconCls('btn-sheet-view');
this._input.attr('type', 'password'); this.currentType = 'password';
if(this.options.repeatInput)
this.options.repeatInput.attr('type', 'password');
if(this.options.showPwdOnClick) (this._input.val() !== '') && this._input.attr('type', this.currentType);
{ if(this.repeatInput) {
this._button.off('click', _.bind(this.passwordHide, this)); this.repeatInput.type = this.currentType;
this._button.on('click', _.bind(this.passwordShow, this)); (this.repeatInput._input.val() !== '') && this.repeatInput._input.attr('type', this.currentType);
}
if(this.options.showPwdOnClick) {
this._button.updateHint(this.textHintShowPwd);
} }
else else
this._btnElm.off('mouseup', this.passwordHide); this._btnElm.off('mouseup', this.passwordHide);
} },
textHintShowPwd: 'show password',
textHintHidePwd: 'hide password'
} }
})()); })());
}); });

View file

@ -112,7 +112,7 @@ define([
style : 'width: 100%;', style : 'width: 100%;',
maxLength: 255, maxLength: 255,
validateOnBlur: false, validateOnBlur: false,
repeatInput: this.repeatPwd._input, repeatInput: this.repeatPwd,
showPwdOnClick: true, showPwdOnClick: true,
btnForPwdShow: true btnForPwdShow: true
}); });

View file

@ -123,6 +123,7 @@ define([
return me.txtIncorrectPwd; return me.txtIncorrectPwd;
} }
}); });
this.inputPwd = new Common.UI.InputFieldBtn({ this.inputPwd = new Common.UI.InputFieldBtn({
el: $('#id-password-txt'), el: $('#id-password-txt'),
type: 'password', type: 'password',
@ -130,7 +131,7 @@ define([
style : 'width: 100%;', style : 'width: 100%;',
maxLength: 255, maxLength: 255,
validateOnBlur: false, validateOnBlur: false,
repeatInput: this.repeatPwd._input, repeatInput: this.repeatPwd,
btnForPwdShow: true btnForPwdShow: true
}); });