function setFileViewAreaHeight() { var $fileView = $('#file-view'); var $arrow = $('#img-prev, #img-next'); $arrow.css({'top': ($fileView.outerHeight() - $arrow.height())/2}); } setFileViewAreaHeight(); $(window).on('resize', setFileViewAreaHeight); $('#image-view').on('load', function() { $('.image-file-view .loading-icon').hide(); $(this).show(); }); {% if img_prev or img_next %} {# for view_file_image & view_file_via_shared_dir #} var input_focus = false; $('input, textarea').on('focus', function() { input_focus = true; }).on('blur', function() { input_focus = false; }); $('body').on('keydown', function(e) { if (!input_focus) { // so cursor move in form input element can work normally {% if img_prev %} if (e.keyCode == 37) { // press '<-' location.href = $('#img-prev').attr('href'); } {% endif %} {% if img_next %} if (e.keyCode == 39) { // press '->' location.href = $('#img-next').attr('href'); } {% endif %} } }) {% endif %}