2013-05-03 11:57:08 +00:00
|
|
|
/**
|
2015-07-11 12:16:11 +00:00
|
|
|
* @description Takes care of every action albums can handle and execute.
|
|
|
|
* @copyright 2015 by Tobias Reich
|
2013-05-03 11:57:08 +00:00
|
|
|
*/
|
|
|
|
|
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() {
|
|
|
|
|
2015-07-11 11:47:43 +00:00
|
|
|
let startTime = new Date().getTime()
|
2014-11-20 21:28:30 +00:00
|
|
|
|
2015-09-28 16:47:50 +00:00
|
|
|
lychee.animate('.content', 'contentZoomOut')
|
2014-11-20 21:28:30 +00:00
|
|
|
|
|
|
|
if (albums.json===null) {
|
|
|
|
|
Added basic subalbum support.
That is, albums can now contain other albums, which are shown at
the top of the album view. This required some changes to album.js
and the contextMenu.js, because this view contains now both
photos and albums.
The contextMenu on this view has been kept simple by requiring
the user to select either only albums or only photos, but not
a mixture of both.
This feature required a database change, so that the version
has been updated to 3.1.3.
At the moment, album and photo operations (make public, download,
delete, merge) are still "flat", i.e. don't respect the album
hierarchy.
2016-07-28 14:01:36 +00:00
|
|
|
params = {
|
|
|
|
parent: 0
|
|
|
|
}
|
|
|
|
|
|
|
|
api.post('Albums::get', params, function(data) {
|
2014-11-20 21:28:30 +00:00
|
|
|
|
2015-07-11 11:47:43 +00:00
|
|
|
let waitTime = 0
|
|
|
|
|
|
|
|
// Smart Albums
|
|
|
|
if (lychee.publicMode===false) albums._createSmartAlbums(data.smartalbums)
|
2014-11-20 21:28:30 +00:00
|
|
|
|
2015-07-11 11:47:43 +00:00
|
|
|
albums.json = data
|
2014-11-20 21:28:30 +00:00
|
|
|
|
|
|
|
// Calculate delay
|
2015-07-11 11:47:43 +00:00
|
|
|
let durationTime = (new Date().getTime() - startTime)
|
|
|
|
if (durationTime>300) waitTime = 0
|
|
|
|
else waitTime = 300 - durationTime
|
2014-11-20 21:28:30 +00:00
|
|
|
|
|
|
|
// Skip delay when opening a blank Lychee
|
2015-07-11 11:47:43 +00:00
|
|
|
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
|
|
|
|
2015-07-11 11:47:43 +00:00
|
|
|
setTimeout(() => {
|
|
|
|
header.setMode('albums')
|
|
|
|
view.albums.init()
|
2015-09-28 16:47:50 +00:00
|
|
|
lychee.animate(lychee.content, 'contentZoomIn')
|
2015-07-11 11:47:43 +00:00
|
|
|
}, waitTime)
|
2015-06-28 15:47:31 +00:00
|
|
|
|
2015-07-11 11:47:43 +00:00
|
|
|
})
|
2014-09-17 21:11:02 +00:00
|
|
|
|
2014-11-20 21:28:30 +00:00
|
|
|
} else {
|
2013-05-03 11:57:08 +00:00
|
|
|
|
2015-07-11 11:47:43 +00:00
|
|
|
setTimeout(() => {
|
|
|
|
header.setMode('albums')
|
|
|
|
view.albums.init()
|
2015-09-28 16:47:50 +00:00
|
|
|
lychee.animate(lychee.content, 'contentZoomIn')
|
2015-07-11 11:47:43 +00:00
|
|
|
}, 300)
|
2013-05-03 11:57:08 +00:00
|
|
|
|
2014-11-20 21:28:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
albums.parse = function(album) {
|
|
|
|
|
2015-07-11 11:47:43 +00:00
|
|
|
if (album.password==='1' && lychee.publicMode===true) {
|
|
|
|
album.thumbs[0] = 'src/images/password.svg'
|
|
|
|
album.thumbs[1] = 'src/images/password.svg'
|
|
|
|
album.thumbs[2] = 'src/images/password.svg'
|
2014-11-20 21:28:30 +00:00
|
|
|
} else {
|
2015-07-11 11:47:43 +00:00
|
|
|
if (!album.thumbs[0]) album.thumbs[0] = 'src/images/no_images.svg'
|
|
|
|
if (!album.thumbs[1]) album.thumbs[1] = 'src/images/no_images.svg'
|
|
|
|
if (!album.thumbs[2]) album.thumbs[2] = 'src/images/no_images.svg'
|
2014-11-20 21:28:30 +00:00
|
|
|
}
|
2014-09-17 21:11:02 +00:00
|
|
|
|
2014-11-20 21:28:30 +00:00
|
|
|
}
|
2014-09-17 21:11:02 +00:00
|
|
|
|
2015-02-27 21:14:19 +00:00
|
|
|
albums._createSmartAlbums = function(data) {
|
|
|
|
|
|
|
|
data.unsorted = {
|
2015-07-11 11:47:43 +00:00
|
|
|
id : 0,
|
|
|
|
title : 'Unsorted',
|
|
|
|
sysdate : data.unsorted.num + ' photos',
|
|
|
|
unsorted : '1',
|
|
|
|
thumbs : data.unsorted.thumbs
|
|
|
|
}
|
2015-02-27 21:14:19 +00:00
|
|
|
|
|
|
|
data.starred = {
|
2015-07-11 11:47:43 +00:00
|
|
|
id : 'f',
|
|
|
|
title : 'Starred',
|
|
|
|
sysdate : data.starred.num + ' photos',
|
|
|
|
star : '1',
|
|
|
|
thumbs : data.starred.thumbs
|
|
|
|
}
|
2015-02-27 21:14:19 +00:00
|
|
|
|
|
|
|
data.public = {
|
2015-07-11 11:47:43 +00:00
|
|
|
id : 's',
|
|
|
|
title : 'Public',
|
|
|
|
sysdate : data.public.num + ' photos',
|
|
|
|
public : '1',
|
|
|
|
thumbs : data.public.thumbs
|
|
|
|
}
|
2015-02-27 21:14:19 +00:00
|
|
|
|
|
|
|
data.recent = {
|
2015-07-11 11:47:43 +00:00
|
|
|
id : 'r',
|
|
|
|
title : 'Recent',
|
|
|
|
sysdate : data.recent.num + ' photos',
|
|
|
|
recent : '1',
|
|
|
|
thumbs : data.recent.thumbs
|
|
|
|
}
|
2015-02-27 21:14:19 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-05-14 13:42:28 +00:00
|
|
|
albums.getByID = function(albumID) {
|
|
|
|
|
|
|
|
// Function returns the JSON of an album
|
|
|
|
|
2015-07-11 11:47:43 +00:00
|
|
|
if (albumID==null) return undefined
|
Added basic subalbum support.
That is, albums can now contain other albums, which are shown at
the top of the album view. This required some changes to album.js
and the contextMenu.js, because this view contains now both
photos and albums.
The contextMenu on this view has been kept simple by requiring
the user to select either only albums or only photos, but not
a mixture of both.
This feature required a database change, so that the version
has been updated to 3.1.3.
At the moment, album and photo operations (make public, download,
delete, merge) are still "flat", i.e. don't respect the album
hierarchy.
2016-07-28 14:01:36 +00:00
|
|
|
if (albumID instanceof Array)
|
|
|
|
albumID = albumID[0]
|
2015-05-14 13:42:28 +00:00
|
|
|
|
2015-07-11 11:47:43 +00:00
|
|
|
let json = undefined
|
2015-05-14 13:42:28 +00:00
|
|
|
|
Added basic subalbum support.
That is, albums can now contain other albums, which are shown at
the top of the album view. This required some changes to album.js
and the contextMenu.js, because this view contains now both
photos and albums.
The contextMenu on this view has been kept simple by requiring
the user to select either only albums or only photos, but not
a mixture of both.
This feature required a database change, so that the version
has been updated to 3.1.3.
At the moment, album and photo operations (make public, download,
delete, merge) are still "flat", i.e. don't respect the album
hierarchy.
2016-07-28 14:01:36 +00:00
|
|
|
let func = function() {
|
|
|
|
if (this.id==albumID) json = this
|
|
|
|
}
|
2015-05-14 13:42:28 +00:00
|
|
|
|
Added basic subalbum support.
That is, albums can now contain other albums, which are shown at
the top of the album view. This required some changes to album.js
and the contextMenu.js, because this view contains now both
photos and albums.
The contextMenu on this view has been kept simple by requiring
the user to select either only albums or only photos, but not
a mixture of both.
This feature required a database change, so that the version
has been updated to 3.1.3.
At the moment, album and photo operations (make public, download,
delete, merge) are still "flat", i.e. don't respect the album
hierarchy.
2016-07-28 14:01:36 +00:00
|
|
|
if (albums.json && albums.json.albums) {
|
|
|
|
$.each(albums.json.albums, func)
|
|
|
|
}
|
|
|
|
else if (album.subjson && album.subjson.albums) {
|
|
|
|
$.each(album.subjson.albums, func)
|
|
|
|
}
|
2015-05-14 13:42:28 +00:00
|
|
|
|
2015-07-11 11:47:43 +00:00
|
|
|
return json
|
2015-05-14 13:42:28 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
albums.deleteByID = function(albumID) {
|
|
|
|
|
|
|
|
// Function returns the JSON of an album
|
|
|
|
|
2015-07-11 11:47:43 +00:00
|
|
|
if (albumID==null) return false
|
|
|
|
if (!albums.json) return false
|
|
|
|
if (!albums.json.albums) return false
|
2015-05-14 13:42:28 +00:00
|
|
|
|
2016-01-24 14:16:03 +00:00
|
|
|
let deleted = false
|
2015-05-14 13:42:28 +00:00
|
|
|
|
|
|
|
$.each(albums.json.albums, function(i) {
|
|
|
|
|
|
|
|
if (albums.json.albums[i].id==albumID) {
|
2015-07-11 11:47:43 +00:00
|
|
|
albums.json.albums.splice(i, 1)
|
|
|
|
deleted = true
|
|
|
|
return false
|
2015-05-14 13:42:28 +00:00
|
|
|
}
|
|
|
|
|
2015-07-11 11:47:43 +00:00
|
|
|
})
|
2015-05-14 13:42:28 +00:00
|
|
|
|
2015-07-11 11:47:43 +00:00
|
|
|
return deleted
|
2015-05-14 13:42:28 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-11-20 21:28:30 +00:00
|
|
|
albums.refresh = function() {
|
2014-09-17 21:11:02 +00:00
|
|
|
|
2015-07-11 11:47:43 +00:00
|
|
|
albums.json = null
|
2013-05-03 11:57:08 +00:00
|
|
|
|
2014-11-20 21:28:30 +00:00
|
|
|
}
|