Fix Bug 49948

This commit is contained in:
OVSharova 2021-10-07 06:24:47 +03:00
parent 0bd401884e
commit 289556cee3

View file

@ -541,4 +541,106 @@ define([
}
}
})());
Common.UI.InputFieldBtnPassword = Common.UI.InputFieldBtn.extend((function() {
return {
options : {
id : null,
cls : '',
style : '',
value : '',
name : '',
validation : null,
allowBlank : true,
placeHolder : '',
blankError : null,
spellcheck : false,
maskExp : '',
validateOnChange: false,
validateOnBlur: true,
disabled: false,
editable: true,
iconCls: 'btn-select-range',
btnHint: ''
},
render : function(parentEl) {
if (!this.rendered) {
this.cmpEl = $(this.template({
id : this.id,
cls : this.cls,
style : this.style,
value : this.value,
type : 'password',
name : this.name,
placeHolder : this.placeHolder,
spellcheck : this.spellcheck,
iconCls : this.options.iconCls,
scope : this
}));
if (parentEl) {
this.setElement(parentEl, false);
parentEl.html(this.cmpEl);
} else {
this.$el.html(this.cmpEl);
}
} else {
this.cmpEl = this.$el;
}
if (!this.rendered) {
var el = this.cmpEl;
this._button = this.cmpEl.find('button');
var button = new Common.UI.Button({
el: this._button,
hint: this.options.btnHint || ''
});
button.on('click', _.bind(this.onButtonClick, this));
this._button.on('mousedown', _.bind(this.onMouseDown, this));
this._input = this.cmpEl.find('input').addBack().filter('input');
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);
}
this.setEditable(this.editable);
if (this.disabled)
this.setDisabled(this.disabled);
if (this._input.closest('.asc-window').length>0)
var onModalClose = function() {
var errorTip = el.find('.input-error').data('bs.tooltip');
if (errorTip) errorTip.tip().remove();
Common.NotificationCenter.off({'modal:close': onModalClose});
};
Common.NotificationCenter.on({'modal:close': onModalClose});
}
this.rendered = true;
return this;
},
onMouseDown: function (e) {
if ((this._input.val() == '')||(this.disabled)) return;
this._button.on('mouseup', _.bind(this.onMouseUp,this));
this._input.attr('type', 'text');
},
onMouseUp: function (e) {
this._input.attr('type', 'password');
this._button.off('mouseup', this.onMouseUp);
}
}
})());
});