Project

General

Profile

Patch #29395 » 0003-adds-file-preview-prev-next-navigation-with-arrow-ke.patch

Jens Krämer, 2018-10-04 09:05

View differences:

app/views/layouts/_file.html.erb
</div>
<%= yield %>
<span class="pagination">
<span class="pagination filepreview">
<%= render_pagination %>
</span>
app/views/repositories/entry.html.erb
:class => 'icon icon-download') : nil } %>
<% end %>
<span class="pagination">
<span class="pagination filepreview">
<%= render_pagination %>
</span>
public/javascripts/application.js
}
}
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();
}
......
$(document).ready(addFormObserversForDoubleSubmit);
$(document).ready(defaultFocus);
$(document).ready(setupTabs);
$(document).ready(setupFilePreviewNavigation);
(6-6/6)