Skip to content

Commit 8936cb5

Browse files
committed
support for redmine 3.3 // fixes #25
now using the default magnifier icon from redmine 3.3 instead of our own preview.png asset
1 parent 2dc3586 commit 8936cb5

File tree

6 files changed

+60
-44
lines changed

6 files changed

+60
-44
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ This is a fork of zipme's [redmine_lightbox](https://github.com/zipme/redmine_li
1111
Compatibility
1212
-------------
1313

14-
The latest version only supports redmine 3.x
14+
**The latest version on `master` branch supports Redmine 3.3 only!**
15+
16+
A Redmine 3.0, 3.1, 3.2 compatible version can be found in the [redmine-3.0-3.2](https://github.com/paginagmbh/redmine_lightbox2/tree/redmine-3.0-3.2) branch.
1517

1618
A Redmine 2.6.x compatible version can be found in the [redmine-2.6](https://github.com/paginagmbh/redmine_lightbox2/tree/redmine-2.6) branch.
1719

app/views/attachments/_links.html.erb

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,46 @@
11
<div class="attachments">
22
<div class="contextual">
3-
<%= link_to image_tag('edit.png'),
4-
container_attachments_edit_path(container),
5-
:title => l(:label_edit_attachments) if options[:editable] %>
3+
<%= link_to(l(:label_edit_attachments),
4+
container_attachments_edit_path(container),
5+
:title => l(:label_edit_attachments),
6+
:class => 'icon-only icon-edit'
7+
) if options[:editable] %>
68
</div>
79
<% for attachment in attachments %>
810
<p><%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%>
911
<% if attachment.is_text? %>
10-
<%= link_to image_tag('magnifier.png'),
11-
:controller => 'attachments', :action => 'show',
12-
:id => attachment, :filename => attachment.filename %>
12+
<%= link_to l(:button_view),
13+
{ :controller => 'attachments', :action => 'show',
14+
:id => attachment, :filename => attachment.filename },
15+
:class => 'icon-only icon-magnifier',
16+
:title => l(:button_view) %>
17+
<% end %>
18+
<% if attachment.is_image? %>
19+
<%= link_to l(:button_view),
20+
{ :controller => 'attachments', :action => 'download',
21+
:id => attachment, :filename => attachment.filename },
22+
:class => 'icon-only icon-magnifier lightbox_preview ' + attachment.filename.split('.').last.downcase,
23+
:rel => 'attachments', :title => "#{attachment.filename}#{ (' - ' + attachment.description) unless attachment.description.blank? }" %>
1324
<% end %>
14-
<%= h(" - #{attachment.description}") unless attachment.description.blank? %>
15-
<span class="size">(<%= number_to_human_size attachment.filesize %>)</span>
1625
<% if( attachment.filename =~ /.(pdf|swf)$/i ) %>
17-
<%= link_to image_tag('preview.png', :plugin => :redmine_lightbox2), {
18-
:controller => 'attachments', :action => 'download_inline',
19-
:id => attachment, :filename => attachment.filename
20-
}, :class => $1.downcase + ' lightbox_preview', :rel => 'attachments',
21-
:title => "#{attachment.filename}#{ ('-' + attachment.description) unless attachment.description.blank? }",
26+
<%= link_to l(:button_view),
27+
{ :controller => 'attachments', :action => 'download_inline',
28+
:id => attachment, :filename => attachment.filename },
29+
:class => 'icon-only icon-magnifier lightbox_preview ' + attachment.filename.split('.').last.downcase,
30+
:rel => 'attachments', :title => "#{attachment.filename}#{ (' - ' + attachment.description) unless attachment.description.blank? }",
2231
:data => {:fancybox_type => 'iframe'} %>
23-
<% end -%>
24-
<% if( attachment.filename =~ /.(png|jpg|jpeg|gif)$/i ) %>
25-
<%= link_to image_tag('preview.png', :plugin => :redmine_lightbox2), {
26-
:controller => 'attachments', :action => 'show',
27-
:id => attachment, :filename => attachment.filename
28-
}, :class => $1.downcase + ' lightbox_preview', :rel => 'attachments',
29-
:title => "#{attachment.filename}#{ ('-' + attachment.description) unless attachment.description.blank? }" %>
30-
<% end -%>
32+
<% end %>
33+
<%= attachment.description unless attachment.description.blank? %>
34+
<span class="size">(<%= number_to_human_size attachment.filesize %>)</span>
3135
<% if options[:deletable] %>
32-
<%= link_to image_tag('delete.png'), attachment_path(attachment),
33-
:data => {:confirm => l(:text_are_you_sure)},
34-
:method => :delete,
35-
:class => 'delete',
36-
:title => l(:button_delete) %>
36+
<%= link_to l(:button_delete), attachment_path(attachment),
37+
:data => {:confirm => l(:text_are_you_sure)},
38+
:method => :delete,
39+
:class => 'delete icon-only icon-del',
40+
:title => l(:button_delete) %>
3741
<% end %>
3842
<% if options[:author] %>
39-
<span class="author"><%= h(attachment.author) %>, <%= format_time(attachment.created_on) %></span>
43+
<span class="author"><%= attachment.author %>, <%= format_time(attachment.created_on) %></span>
4044
<% end %>
4145
</p>
4246
<% end %>
@@ -49,7 +53,7 @@
4953
<div>
5054
<%=
5155
link_to image_tag(url_for(:controller => 'attachments', :action => 'thumbnail', :id => attachment)),
52-
{:controller => 'attachments', :action => 'show', :id => attachment, :filename => attachment.filename},
56+
{:controller => 'attachments', :action => 'download', :id => attachment, :filename => attachment.filename},
5357
:class => 'lightbox', :rel => 'thumbnails', :title => "#{attachment.filename}#{ ('-' + attachment.description) unless attachment.description.blank? }"
5458
%>
5559
</div>
@@ -61,8 +65,8 @@
6165
<% unless images.empty? %>
6266
<div class='images'>
6367
<% images.each do |attachment| %>
64-
<%= link_to image_tag(url_for({:controller => 'attachments', :action => 'show', :id => attachment, :filename => attachment.filename }), :width => '180'),
65-
{:controller => 'attachments', :action => 'show', :id => attachment, :filename => attachment.filename }, :class => 'lightbox', :rel => 'thumbnails', :title => "#{attachment.filename}#{ ('-' + attachment.description) unless attachment.description.blank? }" %>
68+
<%= link_to image_tag(url_for({:controller => 'attachments', :action => 'download', :id => attachment, :filename => attachment.filename }), :width => '180'),
69+
{:controller => 'attachments', :action => 'download', :id => attachment, :filename => attachment.filename }, :class => 'lightbox', :rel => 'thumbnails', :title => "#{attachment.filename}#{ ('-' + attachment.description) unless attachment.description.blank? }" %>
6670
<% end -%>
6771
</div>
6872
<% end -%>

assets/images/preview.png

-1.76 KB
Binary file not shown.

assets/javascripts/lightbox.js

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
$(document).ready(function() {
2-
3-
// modify thumbnail links and add filename to url to support fancybox preview
2+
3+
// modify thumbnail links in wiki content -> add filename to url to support fancybox preview
44
$("div.wiki a.thumbnail").attr('href', function(i, v){
5-
return v + '/' + $(this).attr('title');
5+
return v + '/' + $(this).attr('title').replace(/(.*\.[^.]*)\s\(.*\)/g,'$1');
6+
});
7+
8+
// modify thumbnails and magnifier links in journal details -> add filename to url to support fancybox preview
9+
$("div.journal div.thumbnails a, div.journal ul.details li a.icon-magnifier").attr('href', function(i, v){
10+
return v.replace(/\/attachments\/(\d+)/g,'/attachments/download/$1');
611
});
7-
12+
13+
// add rel attribute to detail links of the same journal entry
14+
$("div.journal ul.details li a.icon-magnifier").attr('rel', function(i, v){
15+
return 'image-details-' + $(this).closest('div.journal').attr('id');
16+
});
17+
818
// add rel attribute to thumbnails of the same journal entry
919
$("div.journal div.thumbnails a").attr('rel', function(i, v){
1020
return 'thumbnails-' + $(this).closest('div.journal').attr('id');
1121
});
12-
22+
1323
$("div.attachments a.lightbox," +
1424
"div.attachments a.lightbox_preview," +
1525
"div.journal ul.details a[href$='.png']," +
@@ -26,20 +36,20 @@ $(document).ready(function() {
2636
".avatar a").fancybox({
2737
prevEffect : 'none',
2838
nextEffect : 'none',
29-
openSpeed : 400,
30-
closeSpeed : 200
39+
openSpeed : 300,
40+
closeSpeed : 150
3141
});
3242

3343
$("div.attachments a.pdf").fancybox({
3444
prevEffect : 'none',
3545
nextEffect : 'none',
36-
openSpeed : 400,
37-
closeSpeed : 200,
46+
openSpeed : 300,
47+
closeSpeed : 150,
3848
width : '90%',
3949
height : '90%',
4050
autoSize : true,
4151
iframe : {
4252
preload: false
4353
}
4454
});
45-
});
55+
});

init.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
name 'Redmine Lightbox 2'
88
author 'Tobias Fischer'
99
description 'This plugin lets you preview image, pdf and swf attachments in a lightbox.'
10-
version '0.2.5'
10+
version '0.3.0'
1111
url 'https://github.com/paginagmbh/redmine_lightbox2'
12-
requires_redmine :version_or_higher => '3.0.0'
12+
requires_redmine :version_or_higher => '3.3.0'
1313
end
1414

1515

lib/hooks/view_layouts_base_html_head_hook.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def view_layouts_base_html_head(context={})
1010
context[:controller].is_a?(MessagesController) ||
1111
context[:controller].is_a?(NewsController))
1212
return stylesheet_link_tag("jquery.fancybox-2.1.5.css", :plugin => "redmine_lightbox2", :media => "screen") +
13-
stylesheet_link_tag("lightbox.css", :plugin => "redmine_lightbox2", :media => "screen") +
13+
stylesheet_link_tag("lightbox.css", :plugin => "redmine_lightbox2", :media => "screen") +
1414
javascript_include_tag('jquery.fancybox-2.1.5.pack.js', :plugin => 'redmine_lightbox2') +
1515
javascript_include_tag('lightbox.js', :plugin => 'redmine_lightbox2')
1616
else

0 commit comments

Comments
 (0)