]> git.mxchange.org Git - friendica.git/commitdiff
Auto-focus first input field of modal when shown
authorHypolite Petovan <ben.lort@gmail.com>
Sun, 22 Jan 2017 16:01:10 +0000 (11:01 -0500)
committerHypolite Petovan <ben.lort@gmail.com>
Sun, 22 Jan 2017 16:01:10 +0000 (11:01 -0500)
Fixes #3101

view/theme/frio/templates/jot-header.tpl

index 145667be9b412ef0a53fa43de827e7e3d9e518da..af9951528cbb1cc427b6b50ad32bd3698518df7d 100644 (file)
@@ -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('&nbsp;');
-                                               }        
+                                               }
 
                                         //Character count
 
                        $("a#jot-perms-icon").colorbox({
                                'inline' : true,
                                'transition' : 'elastic'
-                       }); 
+                       });
 
                } else {
                        if (typeof cb!="undefined") cb();
                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();