mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Restore cursor position in TypedInput cred-mode
This commit is contained in:
		| @@ -173,6 +173,7 @@ | ||||
|             valueLabel: function(container,value) { | ||||
|                 var that = this; | ||||
|                 container.css("pointer-events","none"); | ||||
|                 container.css("flex-grow",0); | ||||
|                 this.elementDiv.hide(); | ||||
|                 var buttons = $('<div>').css({ | ||||
|                     position: "absolute", | ||||
| @@ -184,22 +185,25 @@ | ||||
|                     width:"20px" | ||||
|                 }).appendTo(buttons).on("click", function(evt) { | ||||
|                     evt.preventDefault(); | ||||
|                     var cursorPosition = that.input[0].selectionStart; | ||||
|                     var currentType = that.input.attr("type"); | ||||
|                     if (currentType === "text") { | ||||
|                         that.input.attr("type","password"); | ||||
|                         eyeCon.removeClass("fa-eye-slash").addClass("fa-eye"); | ||||
|                         setTimeout(function() { | ||||
|                             that.input.focus(); | ||||
|                             that.input[0].setSelectionRange(cursorPosition, cursorPosition); | ||||
|                         },50); | ||||
|                     } else { | ||||
|                         that.input.attr("type","text"); | ||||
|                         eyeCon.removeClass("fa-eye").addClass("fa-eye-slash"); | ||||
|                         setTimeout(function() { | ||||
|                             that.input.focus(); | ||||
|                             that.input[0].setSelectionRange(cursorPosition, cursorPosition); | ||||
|                         },50); | ||||
|                     } | ||||
|                 }).hide(); | ||||
|                 var eyeCon = $('<i class="fa fa-eye"></i>').css("margin-left","-1px").appendTo(eyeButton); | ||||
|                 var eyeCon = $('<i class="fa fa-eye"></i>').css("margin-left","-2px").appendTo(eyeButton); | ||||
|  | ||||
|                 if (value === "__PWRD__") { | ||||
|                     var innerContainer = $('<div><i class="fa fa-asterisk"></i><i class="fa fa-asterisk"></i><i class="fa fa-asterisk"></i><i class="fa fa-asterisk"></i><i class="fa fa-asterisk"></i></div>').css({ | ||||
| @@ -284,7 +288,7 @@ | ||||
|                 this.input.css('width','100%'); | ||||
|                 this.uiSelect.width(m[1]); | ||||
|                 this.uiWidth = null; | ||||
|             } else { | ||||
|             } else if (this.uiWidth !== 0){ | ||||
|                 this.uiSelect.width(this.uiWidth); | ||||
|             } | ||||
|             ["Right","Left"].forEach(function(d) { | ||||
| @@ -304,7 +308,11 @@ | ||||
|  | ||||
|             this.element.attr('type','hidden'); | ||||
|  | ||||
|             this.options.types = this.options.types||Object.keys(allOptions); | ||||
|             if (!this.options.types && this.options.type) { | ||||
|                 this.options.types = [this.options.type] | ||||
|             } else { | ||||
|                 this.options.types = this.options.types||Object.keys(allOptions); | ||||
|             } | ||||
|  | ||||
|             this.selectTrigger = $('<button class="red-ui-typedInput-type-select" tabindex="0"></button>').prependTo(this.uiSelect); | ||||
|             $('<i class="red-ui-typedInput-icon fa fa-caret-down"></i>').toggle(this.options.types.length > 1).appendTo(this.selectTrigger); | ||||
| @@ -872,6 +880,9 @@ | ||||
|                             this.elementDiv.hide(); | ||||
|                             this.valueLabelContainer.hide(); | ||||
|                         } else if (opt.valueLabel) { | ||||
|                             // Reset any CSS the custom label may have set | ||||
|                             this.valueLabelContainer.css("pointer-events",""); | ||||
|                             this.valueLabelContainer.css("flex-grow",1); | ||||
|                             this.valueLabelContainer.show(); | ||||
|                             this.valueLabelContainer.empty(); | ||||
|                             this.elementDiv.hide(); | ||||
|   | ||||
| @@ -18,6 +18,7 @@ | ||||
|     border: 1px solid $form-input-border-color; | ||||
|     border-radius: 4px; | ||||
|     height: 34px; | ||||
|     line-height: 14px; | ||||
|     display: inline-flex; | ||||
|     padding: 0; | ||||
|     margin: 0; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user