diff --git a/module/bug/js/batchcreate.js b/module/bug/js/batchcreate.js index 19aa152c65..c5cb2073a8 100644 --- a/module/bug/js/batchcreate.js +++ b/module/bug/js/batchcreate.js @@ -120,13 +120,13 @@ $(document).on('mousedown', 'select', function() $(document).keydown(function(event) { - if(event.ctrlKey && event.keyCode == 38) + if((event.ctrlKey || event.altKey) && event.keyCode == 38) { event.stopPropagation(); event.preventDefault(); selectFocusJump('up'); } - else if(event.ctrlKey && event.keyCode == 40) + else if((event.ctrlKey || event.altKey) && event.keyCode == 40) { event.stopPropagation(); event.preventDefault(); diff --git a/www/js/my.full.js b/www/js/my.full.js index 630874d86e..2db9b6a831 100644 --- a/www/js/my.full.js +++ b/www/js/my.full.js @@ -611,46 +611,31 @@ function revertModuleCookie() /** * Focus move up or down for input. * - * @param type up|down + * @param direction up|down */ -function inputFocusJump(type){ - var hasFocus = $('input').is(':focus'); - if(hasFocus) - { - var title = $("input:focus").attr('name').replace(/\[\d]/g, ''); - var $input = $(":input[name^=" + title + "]:text:not(:disabled):not([name*='%'])"); - var num = $input.length; - var index = parseInt($("input:focus").attr('name').replace(/[^0-9]/g, '')); - var nextIndex = type == 'down' ? index + 1 : index - 1; +function inputFocusJump(direction, type){ + var $input = $('#mainContent table').find(type || 'input').filter(':focus').first(); + if(!$input.length) return; - if(nextIndex < num && nextIndex >= 0) - { - $input[nextIndex].focus(); - } - } + var $row = $input.closest('tr'); + var $nextRow = $row[direction === 'up' ? 'prev' : 'next']('tr'); + if(!$nextRow.length) $nextRow = $row.parent().children('tr')[direction === 'up' ? 'last' : 'first'](); + if(!$nextRow.length) return; + + var datetimepicker = $input.data('datetimepicker'); + if(datetimepicker) datetimepicker.hide(); + + return $nextRow.find(':input[name^=' + ($input.attr('name').split('[')[0]) + ']:text:not(:disabled):not([name*="%"])').focus(); } /** * Focus move up or down for select. * - * @param type + * @param direction */ -function selectFocusJump(type) +function selectFocusJump(direction) { - var hasFocus = $('select').is(':focus'); - if(hasFocus) - { - var title = $("select:focus").attr('name').replace(/\[\d]/g, ''); - var $select = $("select[name^=" + title + "]:not([name*='%'])"); - var num = $select.length; - var index = parseInt($("select:focus").attr('name').replace(/[^0-9]/g, '')); - var nextIndex = type == 'down' ? index + 1 : index - 1; - - if(nextIndex < num && nextIndex >= 0) - { - $select[nextIndex].focus(); - } - } + return inputFocusJump(direction, 'select'); } function adjustNoticePosition()