mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 13:01:07 +08:00
add download link in lightbox
This commit is contained in:
@ -9,7 +9,17 @@ Discourse.Lightbox = {
|
|||||||
apply: function($elem) {
|
apply: function($elem) {
|
||||||
$LAB.script("/javascripts/jquery.magnific-popup-min.js").wait(function() {
|
$LAB.script("/javascripts/jquery.magnific-popup-min.js").wait(function() {
|
||||||
$('a.lightbox', $elem).each(function(i, e) {
|
$('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'
|
rate_limits: 'Rate Limits'
|
||||||
developer: 'Developer'
|
developer: 'Developer'
|
||||||
uncategorized: 'Uncategorized'
|
uncategorized: 'Uncategorized'
|
||||||
|
|
||||||
|
lightbox:
|
||||||
|
download: "download"
|
||||||
|
@ -170,6 +170,8 @@ class CookedPostProcessor
|
|||||||
informations = "#{original_width}x#{original_height}"
|
informations = "#{original_width}x#{original_height}"
|
||||||
informations << " #{number_to_human_size(upload.filesize)}" if upload
|
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("filename", filename)
|
||||||
meta.add_child create_span_node("informations", informations)
|
meta.add_child create_span_node("informations", informations)
|
||||||
meta.add_child create_span_node("expand")
|
meta.add_child create_span_node("expand")
|
||||||
|
@ -94,7 +94,7 @@ describe CookedPostProcessor do
|
|||||||
|
|
||||||
it "generates overlay information" do
|
it "generates overlay information" do
|
||||||
cpp.post_process_images
|
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>
|
<span class="filename">uploaded.jpg</span><span class="informations">1000x2000 1.21 KB</span><span class="expand"></span>
|
||||||
</div></a></div>'
|
</div></a></div>'
|
||||||
cpp.should be_dirty
|
cpp.should be_dirty
|
||||||
|
Reference in New Issue
Block a user