Patch #29395 » 0003-adds-file-preview-prev-next-navigation-with-arrow-ke.patch
app/views/layouts/_file.html.erb | ||
---|---|---|
12 | 12 |
</div> |
13 | 13 |
<%= yield %> |
14 | 14 | |
15 |
<span class="pagination"> |
|
15 |
<span class="pagination filepreview">
|
|
16 | 16 |
<%= render_pagination %> |
17 | 17 |
</span> |
18 | 18 |
app/views/repositories/entry.html.erb | ||
---|---|---|
35 | 35 |
:class => 'icon icon-download') : nil } %> |
36 | 36 |
<% end %> |
37 | 37 | |
38 |
<span class="pagination"> |
|
38 |
<span class="pagination filepreview">
|
|
39 | 39 |
<%= render_pagination %> |
40 | 40 |
</span> |
41 | 41 |
public/javascripts/application.js | ||
---|---|---|
756 | 756 |
} |
757 | 757 |
} |
758 | 758 | |
759 |
function setupFilePreviewNavigation() { |
|
760 |
// only bind arrow keys when preview navigation is present |
|
761 |
const element = $('.pagination.filepreview').first(); |
|
762 |
if (element) { |
|
763 | ||
764 |
const handleArrowKey = function(selector, e){ |
|
765 |
const href = $(element).find(selector).attr('href'); |
|
766 |
if (href) { |
|
767 |
window.location = href; |
|
768 |
e.preventDefault(); |
|
769 |
} |
|
770 |
}; |
|
771 | ||
772 |
$(document).keydown(function(e) { |
|
773 |
if(e.shiftKey || e.metaKey || e.ctrlKey || e.altKey) return; |
|
774 |
switch(e.key) { |
|
775 |
case 'ArrowLeft': |
|
776 |
handleArrowKey('.previous a', e); |
|
777 |
break; |
|
778 | ||
779 |
case 'ArrowRight': |
|
780 |
handleArrowKey('.next a', e); |
|
781 |
break; |
|
782 |
} |
|
783 |
}); |
|
784 |
} |
|
785 |
} |
|
786 | ||
787 | ||
788 | ||
759 | 789 |
function hideOnLoad() { |
760 | 790 |
$('.hol').hide(); |
761 | 791 |
} |
... | ... | |
879 | 909 |
$(document).ready(addFormObserversForDoubleSubmit); |
880 | 910 |
$(document).ready(defaultFocus); |
881 | 911 |
$(document).ready(setupTabs); |
912 |
$(document).ready(setupFilePreviewNavigation); |
- « Previous
- 1
- …
- 4
- 5
- 6
- Next »