Skip to content
This repository has been archived by the owner on Dec 25, 2023. It is now read-only.

Commit

Permalink
Sharing (#134)
Browse files Browse the repository at this point in the history
* Use a contemporary share icon
* Fix the most recent breakage in standalone view
* Fix photo sharing display in the info sidebar
* Add colors to the visibility button
* Support split visibility/share buttons
* Move all visibility options under one dialog box
* New photo visibility settings dialog
* Make loading bar notifications easier to see
* Dialog boxes for image direct links and downloads
* Images in hidden public albums are not hidden
* Avoid red for public
* Fix issues with v3
  • Loading branch information
kamil4 authored and ildyria committed Aug 27, 2019
1 parent c0ec8f4 commit a024ef3
Show file tree
Hide file tree
Showing 17 changed files with 772 additions and 242 deletions.
2 changes: 1 addition & 1 deletion images/ionicons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
220 changes: 113 additions & 107 deletions scripts/main/album.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ album.hasSub = function (albumID) {

};

// noinspection DuplicatedCode
album.deleteByID = function (photoID) {

if (photoID == null || !album.json || !album.json.photos) {
Expand All @@ -132,6 +133,7 @@ album.deleteByID = function (photoID) {

};

// noinspection DuplicatedCode
album.deleteSubByID = function (albumID) {

if (albumID == null || !album.json || !album.json.albums) {
Expand Down Expand Up @@ -296,7 +298,7 @@ album.setTitle = function (albumIDs) {
let msg = '';

if (!albumIDs) return false;
if (albumIDs instanceof Array === false) albumIDs = [albumIDs];
if (!albumIDs instanceof Array) albumIDs = [albumIDs];

if (albumIDs.length === 1) {

Expand Down Expand Up @@ -493,82 +495,65 @@ album.setLicense = function (albumID) {

};

album.setPublic = function (albumID, modal, e) {
album.setPublic = function (albumID, e) {

let password = '';

albums.refresh();

if (modal === true) {

let text = '';
let action = {};

action.fn = () => {

// Call setPublic function without showing the modal
album.setPublic(album.getID(), false, e)

};

// Album public = Editing a shared album
if (album.json.public === '1') {

action.title = lychee.locale['EDIT_SHARING_TITLE'];
text = lychee.locale['EDIT_SHARING_TEXT']

} else {

action.title = lychee.locale['SHARE_ALBUM'];
text = lychee.locale['SHARE_ALBUM_TEXT']

}
if (!basicModal.visible()) {

let msg = `
<p class='less'>${text}</p>
<form>
<div class='choice'>
<label>
<input type='checkbox' name='full_photo'>
<span class='checkbox'>${build.iconic('check')}</span>
<span class='label'>${lychee.locale['ALBUM_FULL']}</span>
</label>
<p>${lychee.locale['ALBUM_FULL_EXPL']}</p>
</div>
<div class='choice'>
<label>
<input type='checkbox' name='hidden'>
<span class='checkbox'>${build.iconic('check')}</span>
<span class='label'>${lychee.locale['ALBUM_HIDDEN']}</span>
</label>
<p>${lychee.locale['ALBUM_HIDDEN_EXPL']}</p>
</div>
<div class='choice'>
<label>
<input type='checkbox' name='downloadable'>
<span class='checkbox'>${build.iconic('check')}</span>
<span class='label'>${lychee.locale['ALBUM_DOWNLOADABLE']}</span>
</label>
<p>${lychee.locale['ALBUM_DOWNLOADABLE_EXPL']}</p>
</div>
<div class='choice'>
<label>
<input type='checkbox' name='password'>
<span class='checkbox'>${build.iconic('check')}</span>
<span class='label'>${lychee.locale['ALBUM_PASSWORD_PROT']}</span>
</label>
<p>${lychee.locale['ALBUM_PASSWORD_PROT_EXPL']}</p>
<input class='text' name='passwordtext' type='text' placeholder='password' value=''>
</div>
</form>
`;
<form>
<div class='switch'>
<label>
${lychee.locale['ALBUM_PUBLIC']}:&nbsp;
<input type='checkbox' name='public'>
<span class='slider round'></span>
</label>
<p>${lychee.locale['ALBUM_PUBLIC_EXPL']}</p>
</div>
<div class='choice'>
<label>
<input type='checkbox' name='full_photo'>
<span class='checkbox'>${build.iconic('check')}</span>
<span class='label'>${lychee.locale['ALBUM_FULL']}</span>
</label>
<p>${lychee.locale['ALBUM_FULL_EXPL']}</p>
</div>
<div class='choice'>
<label>
<input type='checkbox' name='hidden'>
<span class='checkbox'>${build.iconic('check')}</span>
<span class='label'>${lychee.locale['ALBUM_HIDDEN']}</span>
</label>
<p>${lychee.locale['ALBUM_HIDDEN_EXPL']}</p>
</div>
<div class='choice'>
<label>
<input type='checkbox' name='downloadable'>
<span class='checkbox'>${build.iconic('check')}</span>
<span class='label'>${lychee.locale['ALBUM_DOWNLOADABLE']}</span>
</label>
<p>${lychee.locale['ALBUM_DOWNLOADABLE_EXPL']}</p>
</div>
<div class='choice'>
<label>
<input type='checkbox' name='password'>
<span class='checkbox'>${build.iconic('check')}</span>
<span class='label'>${lychee.locale['ALBUM_PASSWORD_PROT']}</span>
</label>
<p>${lychee.locale['ALBUM_PASSWORD_PROT_EXPL']}</p>
<input class='text' name='passwordtext' type='text' placeholder='${ lychee.locale['PASSWORD'] }' value=''>
</div>
</form>
`;

basicModal.show({
body: msg,
buttons: {
action: {
title: action.title,
fn: action.fn
title: lychee.locale['ALBUM_SHARING_CONFIRM'],
// Call setPublic function without showing the modal
fn: () => album.setPublic(albumID, e)
},
cancel: {
title: lychee.locale['CANCEL'],
Expand All @@ -577,9 +562,39 @@ album.setPublic = function (albumID, modal, e) {
}
});

if (album.json.full_photo !== null && album.json.full_photo === '1') $('.basicModal .choice input[name="full_photo"]').click();
if (album.json.public === '1' && album.json.visible === '0') $('.basicModal .choice input[name="hidden"]').click();
if (album.json.downloadable === '1') $('.basicModal .choice input[name="downloadable"]').click();
$('.basicModal .switch input[name="public"]').on('click', function () {
if ($(this).prop('checked') === true) {
$('.basicModal .choice input').attr('disabled', false);

if (album.json.public === '1') {
// Initialize options based on album settings.
if (album.json.full_photo !== null && album.json.full_photo === '1') $('.basicModal .choice input[name="full_photo"]').prop('checked', true);
if (album.json.visible === '0') $('.basicModal .choice input[name="hidden"]').prop('checked', true);
if (album.json.downloadable === '1') $('.basicModal .choice input[name="downloadable"]').prop('checked', true);
if (album.json.password === '1') {
$('.basicModal .choice input[name="password"]').prop('checked', true);
$('.basicModal .choice input[name="passwordtext"]').show()
}
} else {
// Initialize options based on global settings.
if (lychee.full_photo) {
$('.basicModal .choice input[name="full_photo"]').prop('checked', true)
}
if (lychee.downloadable) {
$('.basicModal .choice input[name="downloadable"]').prop('checked', true)
}
}
} else {
$('.basicModal .choice input').prop('checked', false).attr('disabled', true);
$('.basicModal .choice input[name="passwordtext"]').hide()
}
});

if (album.json.public === '1') {
$('.basicModal .switch input[name="public"]').click()
} else {
$('.basicModal .choice input').attr('disabled', true)
}

$('.basicModal .choice input[name="password"]').on('change', function () {

Expand All @@ -592,68 +607,59 @@ album.setPublic = function (albumID, modal, e) {

}

// Set data
if (basicModal.visible()) {

// Visible modal => Set album public
album.json.public = '1';

// Set visible
if ($('.basicModal .choice input[name="full_photo"]:checked').length === 1) album.json.full_photo= '1';
else album.json.full_photo = '0';
albums.refresh();

// Set visible
if ($('.basicModal .choice input[name="hidden"]:checked').length === 1) album.json.visible = '0';
else album.json.visible = '1';
// Set public
if ($('.basicModal .switch input[name="public"]:checked').length === 1) album.json.public = '1';
else album.json.public = '0';

// Set downloadable
if ($('.basicModal .choice input[name="downloadable"]:checked').length === 1) album.json.downloadable = '1';
else album.json.downloadable = '0';
// Set full photo
if ($('.basicModal .choice input[name="full_photo"]:checked').length === 1) album.json.full_photo = '1';
else album.json.full_photo = '0';

// Set password
if ($('.basicModal .choice input[name="password"]:checked').length === 1) {
password = $('.basicModal .choice input[name="passwordtext"]').val();
album.json.password = '1'
} else {
password = '';
album.json.password = '0'
}
// Set visible
if ($('.basicModal .choice input[name="hidden"]:checked').length === 1) album.json.visible = '0';
else album.json.visible = '1';

// Modal input has been processed, now it can be closed
basicModal.close()
// Set downloadable
if ($('.basicModal .choice input[name="downloadable"]:checked').length === 1) album.json.downloadable = '1';
else album.json.downloadable = '0';

// Set password
let oldPassword = album.json.password;
if ($('.basicModal .choice input[name="password"]:checked').length === 1) {
password = $('.basicModal .choice input[name="passwordtext"]').val();
album.json.password = '1'
} else {

// Modal not visible => Set album private
album.json.public = '0'

password = '';
album.json.password = '0'
}

// Modal input has been processed, now it can be closed
basicModal.close();

// Set data and refresh view
if (visible.album()) {

album.json.full_photo = (album.json.full_photo === '0') ? '0' : album.json.full_photo;
album.json.visible = (album.json.public === '0') ? '1' : album.json.visible;
album.json.downloadable = (album.json.public === '0') ? '0' : album.json.downloadable;
album.json.password = (album.json.public === '0') ? '0' : album.json.password;

view.album.public();
view.album.hidden();
view.album.downloadable();
view.album.password();

if (album.json.public === '1') contextMenu.shareAlbum(albumID, e)

}

let params = {
albumID,
full_photo: album.json.full_photo,
public: album.json.public,
password: password,
visible: album.json.visible,
downloadable: album.json.downloadable
};
if (oldPassword !== album.json.password || password.length > 0) {
// We send the password only if there's been a change; that way the
// server will keep the current password if it wasn't changed.
params.password = password
}

api.post('Album::setPublic', params, function (data) {

Expand Down
2 changes: 1 addition & 1 deletion scripts/main/albums.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ albums._createSmartAlbums = function (data) {
public: '1',
thumbs: data.public.thumbs,
thumbs2x: data.public.thumbs2x ? data.public.thumbs2x : null,
hidden: '1',
visible: '0',
types: data.public.types
}
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/main/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ build.album = function (data, disabled = false) {
html += lychee.html`
<div class='badges'>
<a class='badge ${(data.star === '1' ? 'badge--star' : '')} icn-star'>${build.iconic('star')}</a>
<a class='badge ${(data.public === '1' ? 'badge--visible' : '')} ${(data.hidden === '1' ? 'badge--not--hidden' : 'badge--hidden')} icn-share'>${build.iconic('eye')}</a>
<a class='badge ${(data.public === '1' ? 'badge--visible' : '')} ${(data.visible === '1' ? 'badge--not--hidden' : 'badge--hidden')} icn-share'>${build.iconic('eye')}</a>
<a class='badge ${(data.unsorted === '1' ? 'badge--visible' : '')}'>${build.iconic('list')}</a>
<a class='badge ${(data.recent === '1' ? 'badge--visible badge--list' : '')}'>${build.iconic('clock')}</a>
<a class='badge ${(data.password === '1' ? 'badge--visible' : '')}'>${build.iconic('lock-locked')}</a>
Expand Down Expand Up @@ -206,7 +206,7 @@ build.photo = function (data, disabled = false) {
html += lychee.html`
<div class='badges'>
<a class='badge ${(data.star === '1' ? 'badge--star' : '')} icn-star'>${build.iconic('star')}</a>
<a class='badge ${((data.public === '1' && album.json.public !== '1') ? 'badge--visible' : '')} icn-share'>${build.iconic('eye')}</a>
<a class='badge ${((data.public === '1' && album.json.public !== '1') ? 'badge--visible badge--hidden' : '')} icn-share'>${build.iconic('eye')}</a>
</div>
`

Expand Down
Loading

0 comments on commit a024ef3

Please sign in to comment.