From 0888240a7a0ce5dcd44259b8ca6f079649edd271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Sch=C3=A4fer?= Date: Sun, 25 Sep 2016 11:04:50 +0200 Subject: [PATCH 1/2] Use global method to detect PDFs --- app/views/attachments/_links.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/attachments/_links.html.erb b/app/views/attachments/_links.html.erb index 8254367..ab36708 100644 --- a/app/views/attachments/_links.html.erb +++ b/app/views/attachments/_links.html.erb @@ -22,7 +22,7 @@ :class => 'icon-only icon-magnifier lightbox_preview ' + attachment.filename.split('.').last.downcase, :rel => 'attachments', :title => "#{attachment.filename}#{ (' - ' + attachment.description) unless attachment.description.blank? }" %> <% end %> - <% if( attachment.filename =~ /.(pdf|swf)$/i ) %> + <% if attachment.is_pdf? %> <%= link_to l(:button_view), { :controller => 'attachments', :action => 'download_inline', :id => attachment, :filename => attachment.filename }, From cd64560c9dae3a3aba314c3f9af20791084cc2d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Sch=C3=A4fer?= Date: Sun, 25 Sep 2016 16:24:10 +0200 Subject: [PATCH 2/2] Make the lightbox work with all pdf thumbnails --- app/views/attachments/_links.html.erb | 2 +- assets/javascripts/lightbox.js | 7 ++++++- init.rb | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/views/attachments/_links.html.erb b/app/views/attachments/_links.html.erb index ab36708..4d90b3b 100644 --- a/app/views/attachments/_links.html.erb +++ b/app/views/attachments/_links.html.erb @@ -54,7 +54,7 @@ <%= link_to image_tag(url_for(:controller => 'attachments', :action => 'thumbnail', :id => attachment)), {:controller => 'attachments', :action => 'download', :id => attachment, :filename => attachment.filename}, - :class => 'lightbox', :rel => 'thumbnails', :title => "#{attachment.filename}#{ ('-' + attachment.description) unless attachment.description.blank? }" + :class => ('lightbox' + (attachment.is_pdf? ? ' pdf' : '')) , :rel => 'thumbnails', :title => "#{attachment.filename}#{ ('-' + attachment.description) unless attachment.description.blank? }" %> <% end %> diff --git a/assets/javascripts/lightbox.js b/assets/javascripts/lightbox.js index 1b7b3ea..860d9ca 100644 --- a/assets/javascripts/lightbox.js +++ b/assets/javascripts/lightbox.js @@ -40,7 +40,12 @@ $(document).ready(function() { closeSpeed : 150 }); - $("div.attachments a.pdf").fancybox({ + $("div.attachments a.pdf," + + "div.journal ul.details a[href$='.pdf']," + + "div.journal ul.details a[href$='.PDF']," + + "div.journal div.thumbnails a[href$='.pdf']," + + "div.journal div.thumbnails a[href$='.PDF']").fancybox({ + type : 'iframe', prevEffect : 'none', nextEffect : 'none', openSpeed : 300, diff --git a/init.rb b/init.rb index f3f5ebb..dc79395 100644 --- a/init.rb +++ b/init.rb @@ -9,7 +9,7 @@ description 'This plugin lets you preview image, pdf and swf attachments in a lightbox.' version '0.3.2' url 'https://github.com/paginagmbh/redmine_lightbox2' - requires_redmine :version_or_higher => '3.3.0' + requires_redmine :version_or_higher => '3.2.0' end