Skip to content

Commit

Permalink
added lightbox image and pdf preview to issue list attachment column //
Browse files Browse the repository at this point in the history
  • Loading branch information
tofi86 committed Apr 17, 2020
1 parent edf80d2 commit dd5f80b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions assets/javascripts/lightbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,24 @@ $(document).ready(function() {
});


// #76 support for issue list attachment column
$("table.list.issues td.attachments a").each(function(i, obj) {
var href = $(this).attr('href');
var filename = $(this).text();
// Also support PDF preview in lightbox
var isPdf = filename.match(/\.pdf$/i);
// only apply thumbnail class to image and pdf links
if(filename.match(extensionRegexAll)) {
$(this)
.attr('href', href.replace(/\/attachments\/(\d+)/g,'/attachments/download/$1/' + filename))
.addClass(isPdf ? 'lightbox pdf' : 'lightbox')
.attr('data-type', isPdf ? 'iframe' : 'image')
.attr('data-fancybox', 'issue-list-attachments-' + $(this).closest('tr').attr('id'))
.attr('data-caption', filename);
}
});


// DMSF support
var dmsf_link_selector = "a[data-downloadurl][href^='/dmsf/files/'][href$='/view']";

Expand Down

0 comments on commit dd5f80b

Please sign in to comment.