mirror of
https://github.com/meineerde/redmine.git
synced 2026-02-11 13:15:20 +00:00
Adds file preview prev/next navigation with arrow keys (#29395).
Patch by Jens Krämer. git-svn-id: http://svn.redmine.org/redmine/trunk@17569 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
7d615fd516
commit
7516823617
@ -12,7 +12,7 @@
|
||||
</div>
|
||||
<%= yield %>
|
||||
|
||||
<span class="pagination">
|
||||
<span class="pagination filepreview">
|
||||
<%= render_pagination %>
|
||||
</span>
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
:class => 'icon icon-download') : nil } %>
|
||||
<% end %>
|
||||
|
||||
<span class="pagination">
|
||||
<span class="pagination filepreview">
|
||||
<%= render_pagination %>
|
||||
</span>
|
||||
|
||||
|
||||
@ -756,6 +756,36 @@ function setupTabs() {
|
||||
}
|
||||
}
|
||||
|
||||
function setupFilePreviewNavigation() {
|
||||
// only bind arrow keys when preview navigation is present
|
||||
const element = $('.pagination.filepreview').first();
|
||||
if (element) {
|
||||
|
||||
const handleArrowKey = function(selector, e){
|
||||
const href = $(element).find(selector).attr('href');
|
||||
if (href) {
|
||||
window.location = href;
|
||||
e.preventDefault();
|
||||
}
|
||||
};
|
||||
|
||||
$(document).keydown(function(e) {
|
||||
if(e.shiftKey || e.metaKey || e.ctrlKey || e.altKey) return;
|
||||
switch(e.key) {
|
||||
case 'ArrowLeft':
|
||||
handleArrowKey('.previous a', e);
|
||||
break;
|
||||
|
||||
case 'ArrowRight':
|
||||
handleArrowKey('.next a', e);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function hideOnLoad() {
|
||||
$('.hol').hide();
|
||||
}
|
||||
@ -879,3 +909,4 @@ $(document).ready(hideOnLoad);
|
||||
$(document).ready(addFormObserversForDoubleSubmit);
|
||||
$(document).ready(defaultFocus);
|
||||
$(document).ready(setupTabs);
|
||||
$(document).ready(setupFilePreviewNavigation);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user