lychee/src/scripts/albums.js

115 lines
2.5 KiB
JavaScript
Raw Normal View History

/**
* @description Takes care of every action albums can handle and execute.
* @copyright 2014 by Tobias Reich
*/
2014-11-20 22:27:41 +00:00
albums = {
2014-11-20 21:28:30 +00:00
2014-11-20 22:27:41 +00:00
json: null
}
2014-11-20 21:28:30 +00:00
albums.load = function() {
var startTime,
durationTime,
waitTime;
2014-12-04 21:11:03 +00:00
lychee.animate('.album, .photo', 'contentZoomOut');
2014-11-20 21:28:30 +00:00
lychee.animate('.divider', 'fadeOut');
startTime = new Date().getTime();
if (albums.json===null) {
lychee.api('getAlbums', function(data) {
/* Smart Albums */
data.unsortedAlbum = {
id: 0,
title: 'Unsorted',
sysdate: data.unsortedNum + ' photos',
unsorted: '1',
thumb0: data.unsortedThumb0,
thumb1: data.unsortedThumb1,
thumb2: data.unsortedThumb2
};
data.starredAlbum = {
id: 'f',
title: 'Starred',
sysdate: data.starredNum + ' photos',
star: '1',
thumb0: data.starredThumb0,
thumb1: data.starredThumb1,
thumb2: data.starredThumb2
};
data.publicAlbum = {
id: 's',
title: 'Public',
sysdate: data.publicNum + ' photos',
public: '1',
thumb0: data.publicThumb0,
thumb1: data.publicThumb1,
thumb2: data.publicThumb2
};
data.recentAlbum = {
id: 'r',
title: 'Recent',
sysdate: data.recentNum + ' photos',
recent: '1',
thumb0: data.recentThumb0,
thumb1: data.recentThumb1,
thumb2: data.recentThumb2
};
albums.json = data;
// Calculate delay
durationTime = (new Date().getTime() - startTime);
if (durationTime>300) waitTime = 0;
else waitTime = 300 - durationTime;
// Skip delay when opening a blank Lychee
if (!visible.albums()&&!visible.photo()&&!visible.album()) waitTime = 0;
if (visible.album()&&lychee.content.html()==='') waitTime = 0;
2014-09-17 21:11:02 +00:00
setTimeout(function() {
2015-01-04 21:27:34 +00:00
header.setMode('albums');
view.albums.init();
2014-12-04 21:11:03 +00:00
lychee.animate('.album, .photo', 'contentZoomIn');
2014-11-20 21:28:30 +00:00
}, waitTime);
});
2014-09-17 21:11:02 +00:00
2014-11-20 21:28:30 +00:00
} else {
2014-11-20 21:28:30 +00:00
setTimeout(function() {
2015-01-04 21:27:34 +00:00
header.setMode('albums');
2014-11-20 21:28:30 +00:00
view.albums.init();
2014-12-04 21:11:03 +00:00
lychee.animate('.album, .photo', 'contentZoomIn');
2014-11-20 21:28:30 +00:00
}, 300);
2014-11-20 21:28:30 +00:00
}
}
albums.parse = function(album) {
if (album.password&&lychee.publicMode) {
album.thumb0 = 'src/images/password.svg';
album.thumb1 = 'src/images/password.svg';
album.thumb2 = 'src/images/password.svg';
} else {
if (!album.thumb0) album.thumb0 = 'src/images/no_images.svg';
if (!album.thumb1) album.thumb1 = 'src/images/no_images.svg';
if (!album.thumb2) album.thumb2 = 'src/images/no_images.svg';
}
2014-09-17 21:11:02 +00:00
2014-11-20 21:28:30 +00:00
}
2014-09-17 21:11:02 +00:00
2014-11-20 21:28:30 +00:00
albums.refresh = function() {
2014-09-17 21:11:02 +00:00
2014-11-20 21:28:30 +00:00
albums.json = null;
2014-11-20 21:28:30 +00:00
}