Skip to content

Commit

Permalink
bugfix for pdf preview
Browse files Browse the repository at this point in the history
  • Loading branch information
tofi86 committed Oct 28, 2014
1 parent 0343b8a commit c035375
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 33 deletions.
2 changes: 1 addition & 1 deletion app/views/attachments/_links.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<%= h(" - #{attachment.description}") unless attachment.description.blank? %>
<span class="size">(<%= number_to_human_size attachment.filesize %>)</span>
<% if( attachment.filename =~ /.(pdf|swf)$/i ) %>
<%= 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? }" %>
<%= 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'} %>
<% end -%>
<% if options[:deletable] %>
<%= link_to image_tag('delete.png'), attachment_path(attachment),
Expand Down
52 changes: 21 additions & 31 deletions assets/javascripts/lightbox.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,21 @@
(function($) {

$(function() {
var options = {
'transitionIn' : 'elastic',
'transitionOut' : 'elastic',
'speedIn' : 600,
'speedOut' : 200
};

$("div.attachments a.lightbox, div.attachments a.swf").fancybox(options);
$.extend(
options,
{
'width': '100%', // or whatever
'height': '100%',
'autoDimensions': false,
'onClosed': function() {
$("#fancybox-inner").empty();
}
}
);
$("div.attachments a.pdf").each(function() {
options.content = '<embed src="' + this.href + '#nameddest=self&page=1&view=FitH, 0&zoom=80,0,0" type="application/pdf" height="100%" width="100%" />';
$(this).fancybox(options);
})


})

})(jQuery);
$(document).ready(function() {
$("div.attachments a.lightbox, div.attachments a.swf").fancybox({
prevEffect : 'none',
nextEffect : 'none',
openSpeed : 400,
closeSpeed : 200
});

$("div.attachments a.pdf").fancybox({
prevEffect : 'none',
nextEffect : 'none',
openSpeed : 400,
closeSpeed : 200,
width : '100%',
height : '100%',
autoSize : true,
iframe : {
preload: false
}
});
});
2 changes: 1 addition & 1 deletion init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
name 'Redmine Lightbox 2'
author 'G.K. & Tobias Fischer'
description 'This plugin lets you preview image, pdf and swf attachments in a lightbox.'
version '0.0.2'
version '0.0.3'
url 'https://github.com/paginagmbh/redmine_lightbox2'
requires_redmine :version_or_higher => '2.6.0'
end

0 comments on commit c035375

Please sign in to comment.