FEATURE: don't show the 'download' link to anon when they can't even download the original image

This commit is contained in:
Régis Hanol 2015-03-30 10:57:26 +02:00
parent e9e57f3059
commit 8760f7d817

View File

@ -3,7 +3,7 @@ import loadScript from 'discourse/lib/load-script';
export default function($elem) {
$("a.lightbox", $elem).each(function(i, e) {
loadScript("/javascripts/jquery.magnific-popup-min.js").then(function() {
var $e = $(e);
const $e = $(e);
// do not lightbox spoiled images
if ($e.parents(".spoiler").length > 0 || $e.parents(".spoiled").length > 0) { return; }
@ -14,30 +14,30 @@ export default function($elem) {
mainClass: "mfp-zoom-in",
callbacks: {
open: function() {
var wrap = this.wrap,
img = this.currItem.img,
maxHeight = img.css("max-height");
open() {
const wrap = this.wrap,
img = this.currItem.img,
maxHeight = img.css("max-height");
wrap.on("click.pinhandler", "img", function() {
wrap.toggleClass("mfp-force-scrollbars");
img.css("max-height", wrap.hasClass("mfp-force-scrollbars") ? "none" : maxHeight);
});
},
beforeClose: function() {
beforeClose() {
this.wrap.off("click.pinhandler");
this.wrap.removeClass("mfp-force-scrollbars");
}
},
image: {
titleSrc: function(item) {
var href = item.el.data("download-href") || item.src;
return [
item.el.attr("title"),
$("span.informations", item.el).text().replace('x', '×'),
'<a class="image-source-link" href="' + href + '">' + I18n.t("lightbox.download") + '</a>'
].join(' &middot; ');
titleSrc(item) {
const href = item.el.data("download-href") || item.src;
let src = [item.el.attr("title"), $("span.informations", item.el).text().replace('x', '&times;')];
if (!Discourse.SiteSettings.prevent_anons_from_downloading_files || Discourse.User.current()) {
src.push('<a class="image-source-link" href="' + href + '">' + I18n.t("lightbox.download") + '</a>');
}
return src.join(' &middot; ');
}
}