Skip to content

Small improvement- Focus #2

@tapaccos

Description

@tapaccos

Hi there thanks for a great tool.
May I suggest a small improvement. I have changed prompt code so that first input element in prompt will receive focus automatically and scroll into view.

Popup.prototype.prompt = function (p, c) {
    this.type = 'prompt';
    this.setParams(p, c);
    
    var inputsHtml = '', tabIndex = 0;
	var first=true;
	var firstId="";
    for (var i in this.params.inputs){ inputsHtml += '<label for="purePopupInputs_'+i+'">'+this.params.inputs[i]+'</label><input id="purePopupInputs_'+i+'" name="'+i+'" type="text" tabindex="'+(tabIndex++)+'">';
		if (first){
			first=false;
			firstId='purePopupInputs_'+i;
		}
	}
    var buttonsHtml = '';
    for (var i in this.params.buttons) buttonsHtml += '<span class="purePopupButton _'+i+'_">'+this.params.buttons[i]+'</span>';

    this.wrap.innerHTML = '<div>'+
                            '<div>'+
                                '<div class="purePopupTitle">'+this.params.title+'</div>'+
                                inputsHtml+
                                buttonsHtml+
                            '</div>'+
                           '</div>';
    this.show();
		
	var textbox = document.getElementById(firstId);
	textbox.focus();
	textbox.scrollIntoView();

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions