mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
add download link in lightbox
This commit is contained in:
parent
008151e90d
commit
298b54c0e7
4 changed files with 17 additions and 2 deletions
|
@ -9,7 +9,17 @@ Discourse.Lightbox = {
|
|||
apply: function($elem) {
|
||||
$LAB.script("/javascripts/jquery.magnific-popup-min.js").wait(function() {
|
||||
$('a.lightbox', $elem).each(function(i, e) {
|
||||
$(e).magnificPopup({ type: 'image', closeOnContentClick: true });
|
||||
$(e).magnificPopup({
|
||||
type: 'image',
|
||||
closeOnContentClick: true,
|
||||
|
||||
image: {
|
||||
titleSrc: function(item) {
|
||||
return item.el.attr('title') + ' · <a class="image-source-link" href="' + item.src + '" target="_blank">' + I18n.t("lightbox.download") + '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1438,3 +1438,6 @@ en:
|
|||
rate_limits: 'Rate Limits'
|
||||
developer: 'Developer'
|
||||
uncategorized: 'Uncategorized'
|
||||
|
||||
lightbox:
|
||||
download: "download"
|
||||
|
|
|
@ -170,6 +170,8 @@ class CookedPostProcessor
|
|||
informations = "#{original_width}x#{original_height}"
|
||||
informations << " #{number_to_human_size(upload.filesize)}" if upload
|
||||
|
||||
a["title"] = filename
|
||||
|
||||
meta.add_child create_span_node("filename", filename)
|
||||
meta.add_child create_span_node("informations", informations)
|
||||
meta.add_child create_span_node("expand")
|
||||
|
|
|
@ -94,7 +94,7 @@ describe CookedPostProcessor do
|
|||
|
||||
it "generates overlay information" do
|
||||
cpp.post_process_images
|
||||
cpp.html.should match_html '<div><a href="/uploads/default/1/1234567890123456.jpg" class="lightbox"><img src="/uploads/default/_optimized/da3/9a3/ee5e6b4b0d_690x1380.jpg" width="690" height="1380"><div class="meta">
|
||||
cpp.html.should match_html '<div><a href="/uploads/default/1/1234567890123456.jpg" class="lightbox" title="uploaded.jpg"><img src="/uploads/default/_optimized/da3/9a3/ee5e6b4b0d_690x1380.jpg" width="690" height="1380"><div class="meta">
|
||||
<span class="filename">uploaded.jpg</span><span class="informations">1000x2000 1.21 KB</span><span class="expand"></span>
|
||||
</div></a></div>'
|
||||
cpp.should be_dirty
|
||||
|
|
Loading…
Reference in a new issue