From 73f182069ea28d7bc2da68c3fe28642737817f6c Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 22 Jan 2017 11:01:10 -0500 Subject: [PATCH] Auto-focus first input field of modal when shown Fixes #3101 --- view/theme/frio/templates/jot-header.tpl | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/view/theme/frio/templates/jot-header.tpl b/view/theme/frio/templates/jot-header.tpl index 145667be9b..af9951528c 100644 --- a/view/theme/frio/templates/jot-header.tpl +++ b/view/theme/frio/templates/jot-header.tpl @@ -29,7 +29,7 @@ $('#character-counter').text(textlen); }); return; - } + } tinyMCE.init({ theme : "advanced", mode : "specific_textareas", @@ -82,7 +82,7 @@ } else { $('#profile-jot-desc').html(' '); - } + } //Character count @@ -120,7 +120,7 @@ $("a#jot-perms-icon").colorbox({ 'inline' : true, 'transition' : 'elastic' - }); + }); } else { if (typeof cb!="undefined") cb(); @@ -397,13 +397,18 @@ var modal = $('#jot-modal').modal(); 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 .find('#jot-modal-content') .append(jotcache) .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 function aclActive() { $(".modal-body #profile-jot-wrapper, .modal-body #jot-preview-content, .modal-body #jot-fbrowser-wrapper").hide();