Skip to content

Commit

Permalink
Download picture from gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
rawbertp committed Nov 5, 2019
1 parent 31eb98d commit 5dd808c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
17 changes: 8 additions & 9 deletions resources/js/photoinit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
function initPhotoSwipeFromDOM (gallerySelector) {

let gallery;
let img;

const parseThumbnailElements = function (container) {
return $(container).find('>a').map(function () {
Expand Down Expand Up @@ -132,6 +133,8 @@ function initPhotoSwipeFromDOM (gallerySelector) {
gallery.listen('close', resetMailForm);

gallery.init();

img = gallery.currItem.src.split('/').pop();
};

// QR in gallery
Expand All @@ -144,8 +147,6 @@ function initPhotoSwipeFromDOM (gallerySelector) {
pswpQR.removeClass('qr-active').fadeOut('fast');
} else {
pswpQR.empty();
let img = gallery.currItem.src;
img = img.split('/').pop();

$('<img>').attr('src', 'api/qrcode.php?filename=' + img).appendTo(pswpQR);

Expand All @@ -157,8 +158,6 @@ function initPhotoSwipeFromDOM (gallerySelector) {
$('.pswp__button--print').on('click', function (e) {
e.preventDefault();

const img = gallery.currItem.src.split('/').pop();

photoBooth.printImage(img, () => {
gallery.close();
});
Expand All @@ -168,8 +167,6 @@ function initPhotoSwipeFromDOM (gallerySelector) {
$('.pswp__button--print-chroma-keying').on('click', function (e) {
e.preventDefault();

const img = gallery.currItem.src.split('/').pop();

if (config.chroma_keying) {
location = 'chromakeying.php?filename=' + encodeURI(img);
}
Expand All @@ -178,12 +175,14 @@ function initPhotoSwipeFromDOM (gallerySelector) {
$('.pswp__button--mail').on('click touchstart', function (e) {
e.preventDefault();
e.stopPropagation();

const img = gallery.currItem.src.split('/').pop();

photoBooth.toggleMailDialog(img);
});

$('.pswp__button--download').on('click touchstart', function (e) {
e.preventDefault();
location = 'api/download.php?image=' + img;
});

$(gallerySelector).on('click', onThumbnailClick);
}

1 change: 1 addition & 0 deletions resources/sass/vendor/_photoswipe.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.pswp__button--qrcode,
.pswp__button--print,
.pswp__button--print-chroma-keying,
.pswp__button--download,
.pswp__button--mail {
color: #fff;
background: transparent !important;
Expand Down
2 changes: 2 additions & 0 deletions template/pswp.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class="fa fa-times"></i></button>
<button class="pswp__button pswp__button--qrcode" title="QR Code"><i class="fa fa-qrcode"></i></button>
<?php endif; ?>

<button class="pswp__button pswp__button--download" title="Download"><i class="fa fa-download"></i></button>

<?php if ($config['chroma_keying']): ?>
<button class="pswp__button pswp__button--print-chroma-keying" title="Chroma Key"><i class="fa fa-paint-brush"></i></button>
<?php endif; ?>
Expand Down

0 comments on commit 5dd808c

Please sign in to comment.