From: Will Budicm Date: Thu, 24 Dec 2020 19:24:59 +0000 (+1100) Subject: Fixed on enter key not showing category dropdown. X-Git-Url: https://lifelog.hopto.org/gitweb/?a=commitdiff_plain;h=fa14122e014c3447c421ddd63870c96392c1146c;p=LifeLog.git Fixed on enter key not showing category dropdown. --- diff --git a/htdocs/cgi-bin/wsrc/main.js b/htdocs/cgi-bin/wsrc/main.js index 910e8c3..214989a 100644 --- a/htdocs/cgi-bin/wsrc/main.js +++ b/htdocs/cgi-bin/wsrc/main.js @@ -43,6 +43,13 @@ function onBodyLoad(toggle, locale, tz, today, expires, rs_cur, log_limit) { _show_all = false;//toggle type switch showAll(); } + + $(function() { + $( "#rs_keys, #rs_keys2" ).autocomplete({ + source: AUTOWORDS + }); + }); + $('#ed').datetimepicker({ dateFormat: 'yy-mm-dd', timeFormat: 'HH:mm:ss', @@ -262,7 +269,7 @@ function onBodyLoad(toggle, locale, tz, today, expires, rs_cur, log_limit) { lbl = lbl + " ".repeat(16-lbl.length); $("#lcat_x").html(lbl); $("#xc").val(ci); - $("#cat_desc").show(); + $("#cat_desc").show(); }).mouseenter(function(e){ var pr = $(event.target).parent(); pr = pr.attr('id'); if(pr){ @@ -282,17 +289,32 @@ function onBodyLoad(toggle, locale, tz, today, expires, rs_cur, log_limit) { } } ] - }); + }); + //Following is needed as the dropdown registers somewhere in lib. to show on when enter key is hit. + $.fn.enterKey = function (fnc) { + return this.each(function () { + $(this).keypress(function (ev) { + var keycode = (ev.keyCode ? ev.keyCode : ev.which); + if (keycode == 13) { + fnc.call(this, ev); + ev.preventDefault(); + } + }) + }) + } + $("#rs_keys").enterKey(function (ev) {}); + + $('#rs_keys').bind('keypress', function(event) { + if(event.which === 13) { + $(this).next().focus(); + } + }); + setPageSessionTimer(expires); - $(function() { - $( "#rs_keys, #rs_keys2" ).autocomplete({ - source: AUTOWORDS - }); - }); var CHK_PREV; $("#frm_log td").mouseover(function(e){