Skip to content

Commit c035375

Browse files
committed
bugfix for pdf preview
1 parent 0343b8a commit c035375

File tree

3 files changed

+23
-33
lines changed

3 files changed

+23
-33
lines changed

app/views/attachments/_links.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<%= h(" - #{attachment.description}") unless attachment.description.blank? %>
1010
<span class="size">(<%= number_to_human_size attachment.filesize %>)</span>
1111
<% if( attachment.filename =~ /.(pdf|swf)$/i ) %>
12-
<%= link_to image_tag('preview.png', :plugin => :redmine_lightbox2), {:controller => 'attachments', :action => "#{$1 === 'swf' ? 'download_inline' : 'show'}", :id => attachment, :filename => attachment.filename }, :class => $1, :rel => 'attachments', :title => "#{attachment.filename}#{ ('-' + attachment.description) unless attachment.description.blank? }" %>
12+
<%= link_to image_tag('preview.png', :plugin => :redmine_lightbox2), {:controller => 'attachments', :action => "#{$1 === 'swf' ? 'download_inline' : 'show'}", :id => attachment, :filename => attachment.filename }, :class => $1, :rel => 'attachments', :title => "#{attachment.filename}#{ ('-' + attachment.description) unless attachment.description.blank? }", :data => {:fancybox_type => 'iframe'} %>
1313
<% end -%>
1414
<% if options[:deletable] %>
1515
<%= link_to image_tag('delete.png'), attachment_path(attachment),

assets/javascripts/lightbox.js

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,21 @@
1-
(function($) {
2-
3-
$(function() {
4-
var options = {
5-
'transitionIn' : 'elastic',
6-
'transitionOut' : 'elastic',
7-
'speedIn' : 600,
8-
'speedOut' : 200
9-
};
10-
11-
$("div.attachments a.lightbox, div.attachments a.swf").fancybox(options);
12-
$.extend(
13-
options,
14-
{
15-
'width': '100%', // or whatever
16-
'height': '100%',
17-
'autoDimensions': false,
18-
'onClosed': function() {
19-
$("#fancybox-inner").empty();
20-
}
21-
}
22-
);
23-
$("div.attachments a.pdf").each(function() {
24-
options.content = '<embed src="' + this.href + '#nameddest=self&page=1&view=FitH, 0&zoom=80,0,0" type="application/pdf" height="100%" width="100%" />';
25-
$(this).fancybox(options);
26-
})
27-
28-
29-
})
30-
31-
})(jQuery);
1+
$(document).ready(function() {
2+
$("div.attachments a.lightbox, div.attachments a.swf").fancybox({
3+
prevEffect : 'none',
4+
nextEffect : 'none',
5+
openSpeed : 400,
6+
closeSpeed : 200
7+
});
8+
9+
$("div.attachments a.pdf").fancybox({
10+
prevEffect : 'none',
11+
nextEffect : 'none',
12+
openSpeed : 400,
13+
closeSpeed : 200,
14+
width : '100%',
15+
height : '100%',
16+
autoSize : true,
17+
iframe : {
18+
preload: false
19+
}
20+
});
21+
});

init.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
name 'Redmine Lightbox 2'
77
author 'G.K. & Tobias Fischer'
88
description 'This plugin lets you preview image, pdf and swf attachments in a lightbox.'
9-
version '0.0.2'
9+
version '0.0.3'
1010
url 'https://github.com/paginagmbh/redmine_lightbox2'
1111
requires_redmine :version_or_higher => '2.6.0'
1212
end

0 commit comments

Comments
 (0)