Skip to content

Commit

Permalink
! Add sidebar bbc share link for albums
Browse files Browse the repository at this point in the history
  • Loading branch information
Spuds committed Jan 1, 2024
1 parent 0f5b359 commit 82c8ba3
Showing 1 changed file with 67 additions and 3 deletions.
70 changes: 67 additions & 3 deletions levgal_tpl/LevGal-Album.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ function template_main_album_display()

function template_main_album_sidebar()
{
global $context, $txt, $modSettings, $memberContext, $scripturl;
global $context, $txt, $modSettings, $memberContext, $scripturl, $settings;

// Start the sidebar container.
echo '
Expand Down Expand Up @@ -553,12 +553,61 @@ function template_main_album_sidebar()
template_sidebar_action_list($txt['lgal_album_actions'], $context['album_actions']);
}

// Sidebar Sharing.
template_main_item_sidebar_share();

// Sorting albums.
template_main_item_sidebar_sorting();

// And end the sidebar container.
echo '
</div>';

// Now we need the JavaScript for our copy to clipboard buttons.
echo '
<script src="', $settings['default_theme_url'], '/levgal_res/clipboard/clipboard.min.js"></script>
<script>
let items = ["lgal_share_simple_bbc"],
parentEl,
el;
for (let i = 0, n = items.length; i < n; i++)
{
parentEl = document.querySelector("#" + items[i] + "_container");
el = document.querySelector("#" + items[i] + "_container span.i-clipboard");
el.setAttribute("data-clipboard-target", "#" + items[i]);
parentEl.addEventListener("mouseleave", lgalClearTooltip);
parentEl.addEventListener("blur", lgalClearTooltip);
}
let clipboardSnippets = new ClipboardJS(".i-clipboard", {});
clipboardSnippets.on("success", function(e) {
let clip = e.trigger.parentElement;
lgalShowTooltip(clip, "', $txt['lgal_copyied_to_clipboard'], '");
});
</script>';
}

function template_main_item_sidebar_share()
{
global $context, $txt, $scripturl;

echo '
<h3 class="lgal_secondary_header secondary_header">
', $txt['lgal_share'], '
</h3>
<div class="content" style="overflow: visible;">
<dl class="album_details" style="overflow: visible;">
<dt>', $txt['lgal_share_simple_bbc'], '
<a href="', $scripturl, '?action=quickhelp;help=media_bbc" onclick="return reqOverlayDiv(this.href);" class="helpicon i-help"><s>', $txt['help'], '</s></a>
</dt>
<dd id="lgal_share_simple_bbc_container" class="lgal_share">
<input type="text" class="input_text" id="lgal_share_simple_bbc" value="[media type=album]', $context['album_details']['id_album'], '[/media]" readonly="readonly" />
<span class="lgalicon i-clipboard" title="', $txt['lgal_copy_to_clipboard'], '"></span>
</dd>
</dl>
</div>';
}

function template_main_item_sidebar_sorting()
Expand Down Expand Up @@ -832,6 +881,7 @@ function transLitSlug()
lgal_quota: ' . (empty($context['quota_data']) ? '{}' : json_encode($context['quota_data'])) . ',
lgal_enable_resize: ' . (empty($context['lgal_enable_resize']) ? 'false' : 'true') . ',
maxFiles: 1,
maxThumbnailFilesize: defaults.maxThumbnailFilesize,
paramName: defaults.paramName,
chunking: defaults.chunking,
retryChunks: defaults.retryChunks,
Expand Down Expand Up @@ -899,7 +949,7 @@ function transLitSlug()
},
accept: function(file, done) {
// We do not have the width / height until thumbnail completes
this.on("thumbnail", function(file) {
this.on("thumbnail", function(file, dataURL) {
let result = addFileFilter(file, this.options.lgal_quota, this.options.lgal_enable_resize);
if (result !== true)
{
Expand All @@ -909,6 +959,13 @@ function transLitSlug()
}
else
{
// This is for tiff files, maybe others, which fail on creating a client side thumbnail
if (typeof dataURL === "object" && dataURL instanceof Event)
{
let dataURL = get_upload_generic_thumbnail(file, this.options.lgal_quota);
file.previewElement.querySelector("img[data-dz-thumbnail]").src = dataURL;
}
done();
}
});
Expand Down Expand Up @@ -1074,6 +1131,7 @@ function template_add_bulk_items()
lgal_quota: ' . (empty($context['quota_data']) ? '{}' : json_encode($context['quota_data'])) . ',
lgal_enable_resize: ' . (empty($context['lgal_enable_resize']) ? 'false' : 'true') . ',
maxFiles: 250,
maxThumbnailFilesize: defaults.maxThumbnailFilesize,
paramName: defaults.paramName,
chunking: defaults.chunking,
retryChunks: defaults.retryChunks,
Expand Down Expand Up @@ -1180,7 +1238,7 @@ function template_add_bulk_items()
uploader.disable();
}
});
this.on("thumbnail", function(file) {
this.on("thumbnail", function(file, dataURL) {
let result = addFileFilter(file, this.options.lgal_quota, this.options.lgal_enable_resize);
if (result !== true)
{
Expand All @@ -1189,6 +1247,12 @@ function template_add_bulk_items()
}
else
{
// This is for tiff files, maybe others, which fail on creating a client side thumbnail
if (typeof dataURL === "object" && dataURL instanceof Event)
{
let dataURL = get_upload_generic_thumbnail(file, this.options.lgal_quota);
file.previewElement.querySelector("img[data-dz-thumbnail]").src = dataURL;
}
sessionStorage.setItem(file.upload.uuid, file.name);
file.acceptDimensions();
}
Expand Down

0 comments on commit 82c8ba3

Please sign in to comment.