From 289556cee30b4d8b0937303869624c7635a6e192 Mon Sep 17 00:00:00 2001 From: OVSharova Date: Thu, 7 Oct 2021 06:24:47 +0300 Subject: [PATCH] Fix Bug 49948 --- apps/common/main/lib/component/InputField.js | 102 +++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/apps/common/main/lib/component/InputField.js b/apps/common/main/lib/component/InputField.js index 8ea0d65a0..bb6857785 100644 --- a/apps/common/main/lib/component/InputField.js +++ b/apps/common/main/lib/component/InputField.js @@ -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); + } + + } + })()); }); \ No newline at end of file