Auto-focus first input field of modal when shown

Fixes #3101
This commit is contained in:
Hypolite Petovan 2017-01-22 11:01:10 -05:00
parent dbf7c7d9ad
commit 73f182069e

View file

@ -29,7 +29,7 @@
$('#character-counter').text(textlen); $('#character-counter').text(textlen);
}); });
return; return;
} }
tinyMCE.init({ tinyMCE.init({
theme : "advanced", theme : "advanced",
mode : "specific_textareas", mode : "specific_textareas",
@ -82,7 +82,7 @@
} }
else { else {
$('#profile-jot-desc').html(' '); $('#profile-jot-desc').html(' ');
} }
//Character count //Character count
@ -120,7 +120,7 @@
$("a#jot-perms-icon").colorbox({ $("a#jot-perms-icon").colorbox({
'inline' : true, 'inline' : true,
'transition' : 'elastic' 'transition' : 'elastic'
}); });
} else { } else {
if (typeof cb!="undefined") cb(); if (typeof cb!="undefined") cb();
@ -397,13 +397,18 @@
var modal = $('#jot-modal').modal(); var modal = $('#jot-modal').modal();
jotcache = $("#jot-sections"); jotcache = $("#jot-sections");
// Auto focus on the first enabled field in the modal
modal.on('shown.bs.modal', function (e) {
$('#jot-modal-content').find('select:not([disabled]), input:not([type=hidden]):not([disabled]), textarea:not([disabled])').first().focus();
})
modal modal
.find('#jot-modal-content') .find('#jot-modal-content')
.append(jotcache) .append(jotcache)
.modal.show; .modal.show;
} }
// the following functions show/hide the specific jot content // the following functions show/hide the specific jot content
// in dependence of the selected nav // in dependence of the selected nav
function aclActive() { function aclActive() {
$(".modal-body #profile-jot-wrapper, .modal-body #jot-preview-content, .modal-body #jot-fbrowser-wrapper").hide(); $(".modal-body #profile-jot-wrapper, .modal-body #jot-preview-content, .modal-body #jot-fbrowser-wrapper").hide();