Browse Source

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
tags/4.0.0
Go MAEDA 5 years ago
parent
commit
7516823617

+ 1
- 1
app/views/layouts/_file.html.erb View File

@@ -12,7 +12,7 @@
</div>
<%= yield %>

<span class="pagination">
<span class="pagination filepreview">
<%= render_pagination %>
</span>


+ 1
- 1
app/views/repositories/entry.html.erb View File

@@ -35,7 +35,7 @@
:class => 'icon icon-download') : nil } %>
<% end %>

<span class="pagination">
<span class="pagination filepreview">
<%= render_pagination %>
</span>


+ 31
- 0
public/javascripts/application.js View File

@@ -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…
Cancel
Save