From 298b54c0e71ea2cdd91a7808e69a8ba16625b0f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Fri, 29 Nov 2013 20:03:39 +0100 Subject: [PATCH] add download link in lightbox --- app/assets/javascripts/discourse/lib/lightbox.js | 12 +++++++++++- config/locales/client.en.yml | 3 +++ lib/cooked_post_processor.rb | 2 ++ spec/components/cooked_post_processor_spec.rb | 2 +- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/lib/lightbox.js b/app/assets/javascripts/discourse/lib/lightbox.js index 65947d05f16..8f6cb58aa73 100644 --- a/app/assets/javascripts/discourse/lib/lightbox.js +++ b/app/assets/javascripts/discourse/lib/lightbox.js @@ -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') + ' · ' + I18n.t("lightbox.download") + ''; + } + } + + }); }); }); } diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index c2e693b7099..23130ac75f1 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -1438,3 +1438,6 @@ en: rate_limits: 'Rate Limits' developer: 'Developer' uncategorized: 'Uncategorized' + + lightbox: + download: "download" diff --git a/lib/cooked_post_processor.rb b/lib/cooked_post_processor.rb index 62f268bcaa6..ae940e6fb5d 100644 --- a/lib/cooked_post_processor.rb +++ b/lib/cooked_post_processor.rb @@ -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") diff --git a/spec/components/cooked_post_processor_spec.rb b/spec/components/cooked_post_processor_spec.rb index 02cc21f28f5..683c6adfb20 100644 --- a/spec/components/cooked_post_processor_spec.rb +++ b/spec/components/cooked_post_processor_spec.rb @@ -94,7 +94,7 @@ describe CookedPostProcessor do it "generates overlay information" do cpp.post_process_images - cpp.html.should match_html '