Merge branch 'feature/api' into release/v3.0.0
This commit is contained in:
commit
761042d033
BIN
dist/main.css
vendored
BIN
dist/main.css
vendored
Binary file not shown.
BIN
dist/main.js
vendored
BIN
dist/main.js
vendored
Binary file not shown.
BIN
dist/view.js
vendored
BIN
dist/view.js
vendored
Binary file not shown.
@ -83,7 +83,7 @@ class Album extends Module {
|
||||
$albums = $this->database->query($query);
|
||||
$return = $albums->fetch_assoc();
|
||||
$return['sysdate'] = date('d M. Y', $return['sysstamp']);
|
||||
$return['password'] = ($return['password']=='' ? false : true);
|
||||
$return['password'] = ($return['password']=='' ? '0' : '1');
|
||||
$query = Database::prepare($this->database, "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url FROM ? WHERE album = '?' " . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS, $this->albumIDs));
|
||||
break;
|
||||
|
||||
@ -154,8 +154,15 @@ class Album extends Module {
|
||||
# Call plugins
|
||||
$this->plugins(__METHOD__, 0, func_get_args());
|
||||
|
||||
# Initialize return var
|
||||
$return = array(
|
||||
'smartalbums' => null,
|
||||
'albums' => null,
|
||||
'num' => 0
|
||||
);
|
||||
|
||||
# Get SmartAlbums
|
||||
if ($public===false) $return = $this->getSmartInfo();
|
||||
if ($public===false) $return['smartalbums'] = $this->getSmartInfo();
|
||||
|
||||
# Albums query
|
||||
$query = Database::prepare($this->database, 'SELECT id, title, public, sysstamp, password FROM ? WHERE public = 1 AND visible <> 0', array(LYCHEE_TABLE_ALBUMS));
|
||||
@ -173,7 +180,7 @@ class Album extends Module {
|
||||
|
||||
# Parse info
|
||||
$album['sysdate'] = date('F Y', $album['sysstamp']);
|
||||
$album['password'] = ($album['password'] != '');
|
||||
$album['password'] = ($album['password']=='' ? '0' : '1');
|
||||
|
||||
# Thumbs
|
||||
if (($public===true&&$album['password']===false)||($public===false)) {
|
||||
@ -192,7 +199,7 @@ class Album extends Module {
|
||||
}
|
||||
|
||||
# Add to return
|
||||
$return['content'][$album['id']] = $album;
|
||||
$return['albums'][$album['id']] = $album;
|
||||
|
||||
}
|
||||
|
||||
@ -211,29 +218,25 @@ class Album extends Module {
|
||||
# Check dependencies
|
||||
self::dependencies(isset($this->database, $this->settings));
|
||||
|
||||
# Initialize return var
|
||||
$return = array(
|
||||
'unsorted' => null,
|
||||
'public' => null,
|
||||
'starred' => null,
|
||||
'recent' => null
|
||||
);
|
||||
|
||||
# Unsorted
|
||||
$query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE album = 0 ' . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS));
|
||||
$unsorted = $this->database->query($query);
|
||||
$i = 0;
|
||||
while($row = $unsorted->fetch_object()) {
|
||||
if ($i<3) {
|
||||
$return["unsortedThumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row->thumbUrl;
|
||||
$return['unsorted']["thumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row->thumbUrl;
|
||||
$i++;
|
||||
} else break;
|
||||
}
|
||||
$return['unsortedNum'] = $unsorted->num_rows;
|
||||
|
||||
# Public
|
||||
$query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE public = 1 ' . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS));
|
||||
$public = $this->database->query($query);
|
||||
$i = 0;
|
||||
while($row2 = $public->fetch_object()) {
|
||||
if ($i<3) {
|
||||
$return["publicThumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row2->thumbUrl;
|
||||
$i++;
|
||||
} else break;
|
||||
}
|
||||
$return['publicNum'] = $public->num_rows;
|
||||
$return['unsorted']['num'] = $unsorted->num_rows;
|
||||
|
||||
# Starred
|
||||
$query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE star = 1 ' . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS));
|
||||
@ -241,11 +244,23 @@ class Album extends Module {
|
||||
$i = 0;
|
||||
while($row3 = $starred->fetch_object()) {
|
||||
if ($i<3) {
|
||||
$return["starredThumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row3->thumbUrl;
|
||||
$return['starred']["thumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row3->thumbUrl;
|
||||
$i++;
|
||||
} else break;
|
||||
}
|
||||
$return['starredNum'] = $starred->num_rows;
|
||||
$return['starred']['num'] = $starred->num_rows;
|
||||
|
||||
# Public
|
||||
$query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE public = 1 ' . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS));
|
||||
$public = $this->database->query($query);
|
||||
$i = 0;
|
||||
while($row2 = $public->fetch_object()) {
|
||||
if ($i<3) {
|
||||
$return['public']["thumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row2->thumbUrl;
|
||||
$i++;
|
||||
} else break;
|
||||
}
|
||||
$return['public']['num'] = $public->num_rows;
|
||||
|
||||
# Recent
|
||||
$query = Database::prepare($this->database, 'SELECT thumbUrl FROM ? WHERE LEFT(id, 10) >= unix_timestamp(DATE_SUB(NOW(), INTERVAL 1 DAY)) ' . $this->settings['sorting'], array(LYCHEE_TABLE_PHOTOS));
|
||||
@ -253,11 +268,11 @@ class Album extends Module {
|
||||
$i = 0;
|
||||
while($row3 = $recent->fetch_object()) {
|
||||
if ($i<3) {
|
||||
$return["recentThumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row3->thumbUrl;
|
||||
$return['recent']["thumb$i"] = LYCHEE_URL_UPLOADS_THUMB . $row3->thumbUrl;
|
||||
$i++;
|
||||
} else break;
|
||||
}
|
||||
$return['recentNum'] = $recent->num_rows;
|
||||
$return['recent']['num'] = $recent->num_rows;
|
||||
|
||||
return $return;
|
||||
|
||||
|
@ -13,6 +13,13 @@ function search($database, $settings, $term) {
|
||||
|
||||
$return['albums'] = '';
|
||||
|
||||
# Initialize return var
|
||||
$return = array(
|
||||
'photos' => null,
|
||||
'albums' => null,
|
||||
'hash' => ''
|
||||
);
|
||||
|
||||
# Photos
|
||||
$query = Database::prepare($database, "SELECT id, title, tags, public, star, album, thumbUrl FROM ? WHERE title LIKE '%?%' OR description LIKE '%?%' OR tags LIKE '%?%'", array(LYCHEE_TABLE_PHOTOS, $term, $term, $term));
|
||||
$result = $database->query($query);
|
||||
@ -48,6 +55,9 @@ function search($database, $settings, $term) {
|
||||
|
||||
}
|
||||
|
||||
# Hash
|
||||
$return['hash'] = md5(json_encode($return));
|
||||
|
||||
return $return;
|
||||
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"jQuery": "~2.1.3",
|
||||
"js-md5": "~1.1.0",
|
||||
"mousetrap": "~1.4.6",
|
||||
"basicContext": "~2.0.2",
|
||||
"basicModal": "~2.0.3"
|
||||
|
@ -59,7 +59,6 @@ paths.main = {
|
||||
],
|
||||
scripts: [
|
||||
'bower_components/jQuery/dist/jquery.min.js',
|
||||
'bower_components/js-md5/js/md5.min.js',
|
||||
'bower_components/mousetrap/mousetrap.min.js',
|
||||
'bower_components/mousetrap/plugins/global-bind/mousetrap-global-bind.min.js',
|
||||
'bower_components/basicContext/dist/basicContext.min.js',
|
||||
|
@ -179,7 +179,7 @@ album.delete = function(albumIDs) {
|
||||
albumIDs.forEach(function(id) {
|
||||
albums.json.num--;
|
||||
view.albums.content.delete(id);
|
||||
delete albums.json.content[id];
|
||||
delete albums.json.albums[id];
|
||||
});
|
||||
|
||||
} else {
|
||||
@ -209,7 +209,7 @@ album.delete = function(albumIDs) {
|
||||
|
||||
// Get title
|
||||
if (album.json) albumTitle = album.json.title;
|
||||
else if (albums.json) albumTitle = albums.json.content[albumIDs].title;
|
||||
else if (albums.json) albumTitle = albums.json.albums[albumIDs].title;
|
||||
|
||||
msg = "<p>Are you sure you want to delete the album '" + albumTitle + "' and all of the photos it contains? This action can't be undone!</p>";
|
||||
|
||||
@ -253,7 +253,7 @@ album.setTitle = function(albumIDs) {
|
||||
|
||||
// Get old title if only one album is selected
|
||||
if (album.json) oldTitle = album.json.title;
|
||||
else if (albums.json) oldTitle = albums.json.content[albumIDs].title;
|
||||
else if (albums.json) oldTitle = albums.json.albums[albumIDs].title;
|
||||
|
||||
if (!oldTitle) oldTitle = '';
|
||||
oldTitle = oldTitle.replace("'", ''');
|
||||
@ -280,13 +280,13 @@ album.setTitle = function(albumIDs) {
|
||||
|
||||
if (albums.json) {
|
||||
var id = albumIDs[0];
|
||||
albums.json.content[id].title = newTitle;
|
||||
albums.json.albums[id].title = newTitle;
|
||||
}
|
||||
|
||||
} else if (visible.albums()) {
|
||||
|
||||
albumIDs.forEach(function(id) {
|
||||
albums.json.content[id].title = newTitle;
|
||||
albums.json.albums[id].title = newTitle;
|
||||
view.albums.content.title(id);
|
||||
});
|
||||
|
||||
@ -384,7 +384,7 @@ album.setPublic = function(albumID, e) {
|
||||
|
||||
albums.refresh();
|
||||
|
||||
if (!basicModal.visible()&&album.json.public==0) {
|
||||
if (!basicModal.visible()&&album.json.public==='0') {
|
||||
|
||||
var msg = '',
|
||||
action;
|
||||
@ -456,10 +456,10 @@ album.setPublic = function(albumID, e) {
|
||||
|
||||
if ($('.basicModal .choice input[name="password"]:checked').length===1) {
|
||||
password = $('.basicModal .choice input[data-name="password"]').val();
|
||||
album.json.password = 1;
|
||||
album.json.password = '1';
|
||||
} else {
|
||||
password = '';
|
||||
album.json.password = 0;
|
||||
album.json.password = '0';
|
||||
}
|
||||
|
||||
if ($('.basicModal .choice input[name="listed"]:checked').length===1) listed = true;
|
||||
@ -469,13 +469,13 @@ album.setPublic = function(albumID, e) {
|
||||
|
||||
if (visible.album()) {
|
||||
|
||||
album.json.public = (album.json.public==0) ? 1 : 0;
|
||||
album.json.password = (album.json.public==0) ? 0 : album.json.password;
|
||||
album.json.public = (album.json.public==='0') ? '1' : '0';
|
||||
album.json.password = (album.json.public==='0') ? '0' : album.json.password;
|
||||
|
||||
view.album.public();
|
||||
view.album.password();
|
||||
|
||||
if (album.json.public==1) contextMenu.shareAlbum(albumID, e);
|
||||
if (album.json.public==='1') contextMenu.shareAlbum(albumID, e);
|
||||
|
||||
}
|
||||
|
||||
@ -526,7 +526,7 @@ album.getArchive = function(albumID) {
|
||||
if (location.href.indexOf('index.html')>0) link = location.href.replace(location.hash, '').replace('index.html', url);
|
||||
else link = location.href.replace(location.hash, '') + url;
|
||||
|
||||
if (lychee.publicMode) link += '&password=' + password.value;
|
||||
if (lychee.publicMode===true) link += '&password=' + password.value;
|
||||
|
||||
location.href = link;
|
||||
|
||||
|
@ -25,45 +25,7 @@ albums.load = function() {
|
||||
api.post('Album::getAll', {}, 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
|
||||
};
|
||||
if (lychee.publicMode===false) albums._createSmartAlbums(data.smartalbums);
|
||||
|
||||
albums.json = data;
|
||||
|
||||
@ -79,7 +41,7 @@ albums.load = function() {
|
||||
setTimeout(function() {
|
||||
header.setMode('albums');
|
||||
view.albums.init();
|
||||
lychee.animate('.album, .photo', 'contentZoomIn');
|
||||
lychee.animate('.album', 'contentZoomIn');
|
||||
}, waitTime);
|
||||
});
|
||||
|
||||
@ -96,7 +58,7 @@ albums.load = function() {
|
||||
|
||||
albums.parse = function(album) {
|
||||
|
||||
if (album.password&&lychee.publicMode) {
|
||||
if (album.password==='1'&&lychee.publicMode===true) {
|
||||
album.thumb0 = 'src/images/password.svg';
|
||||
album.thumb1 = 'src/images/password.svg';
|
||||
album.thumb2 = 'src/images/password.svg';
|
||||
@ -108,6 +70,50 @@ albums.parse = function(album) {
|
||||
|
||||
}
|
||||
|
||||
albums._createSmartAlbums = function(data) {
|
||||
|
||||
data.unsorted = {
|
||||
id: 0,
|
||||
title: 'Unsorted',
|
||||
sysdate: data.unsorted.num + ' photos',
|
||||
unsorted: '1',
|
||||
thumb0: data.unsorted.thumb0,
|
||||
thumb1: data.unsorted.thumb1,
|
||||
thumb2: data.unsorted.thumb2
|
||||
};
|
||||
|
||||
data.starred = {
|
||||
id: 'f',
|
||||
title: 'Starred',
|
||||
sysdate: data.starred.num + ' photos',
|
||||
star: '1',
|
||||
thumb0: data.starred.thumb0,
|
||||
thumb1: data.starred.thumb1,
|
||||
thumb2: data.starred.thumb2
|
||||
};
|
||||
|
||||
data.public = {
|
||||
id: 's',
|
||||
title: 'Public',
|
||||
sysdate: data.public.num + ' photos',
|
||||
public: '1',
|
||||
thumb0: data.public.thumb0,
|
||||
thumb1: data.public.thumb1,
|
||||
thumb2: data.public.thumb2
|
||||
};
|
||||
|
||||
data.recent = {
|
||||
id: 'r',
|
||||
title: 'Recent',
|
||||
sysdate: data.recent.num + ' photos',
|
||||
recent: '1',
|
||||
thumb0: data.recent.thumb0,
|
||||
thumb1: data.recent.thumb1,
|
||||
thumb2: data.recent.thumb2
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
albums.refresh = function() {
|
||||
|
||||
albums.json = null;
|
||||
|
@ -92,7 +92,7 @@ build.album = function(data) {
|
||||
if (data.public==='1') html += `<a class='badge icn-share'>${ build.iconic('eye') }</a>`;
|
||||
if (data.unsorted==='1') html += `<a class='badge'>${ build.iconic('list') }</a>`;
|
||||
if (data.recent==='1') html += `<a class='badge'>${ build.iconic('clock') }</a>`;
|
||||
if (data.password===true) html += `<a class='badge'>${ build.iconic('lock-locked') }</a>`;
|
||||
if (data.password==='1') html += `<a class='badge'>${ build.iconic('lock-locked') }</a>`;
|
||||
|
||||
}
|
||||
|
||||
@ -244,12 +244,12 @@ build.uploadModal = function(title, files) {
|
||||
|
||||
}
|
||||
|
||||
build.tags = function(tags, forView) {
|
||||
build.tags = function(tags, forView = false) {
|
||||
|
||||
var html = '',
|
||||
editTagsHTML = '';
|
||||
|
||||
if (forView!==true&&lychee.publicMode!==true) editTagsHTML = ' ' + build.editIcon('edit_tags');
|
||||
if (forView===false&&lychee.publicMode===false) editTagsHTML = ' ' + build.editIcon('edit_tags');
|
||||
|
||||
if (tags!=='') {
|
||||
|
||||
@ -271,7 +271,7 @@ build.tags = function(tags, forView) {
|
||||
|
||||
}
|
||||
|
||||
build.infoboxPhoto = function(data, forView) {
|
||||
build.infoboxPhoto = function(data, forView = false) {
|
||||
|
||||
var html = '',
|
||||
visible = '',
|
||||
@ -293,7 +293,7 @@ build.infoboxPhoto = function(data, forView) {
|
||||
|
||||
}
|
||||
|
||||
if (forView!==true&&lychee.publicMode!==true) {
|
||||
if (forView===false&&lychee.publicMode===false) {
|
||||
editTitleHTML = ' ' + build.editIcon('edit_title');
|
||||
editDescriptionHTML = ' ' + build.editIcon('edit_description');
|
||||
}
|
||||
@ -355,7 +355,7 @@ build.infoboxPhoto = function(data, forView) {
|
||||
case 'Tags':
|
||||
|
||||
// Tags
|
||||
if (forView!==true&&lychee.publicMode===false) {
|
||||
if (forView===false&&lychee.publicMode===false) {
|
||||
|
||||
html += `
|
||||
</table>
|
||||
@ -395,7 +395,7 @@ build.infoboxPhoto = function(data, forView) {
|
||||
|
||||
}
|
||||
|
||||
build.infoboxAlbum = function(data, forView) {
|
||||
build.infoboxAlbum = function(data, forView = false) {
|
||||
|
||||
var html = '',
|
||||
visible = '',
|
||||
@ -418,9 +418,9 @@ build.infoboxAlbum = function(data, forView) {
|
||||
|
||||
switch (data.password) {
|
||||
|
||||
case false: password = 'No';
|
||||
case '0': password = 'No';
|
||||
break;
|
||||
case true: password = 'Yes';
|
||||
case '1': password = 'Yes';
|
||||
break;
|
||||
default: password = '-';
|
||||
break;
|
||||
@ -438,7 +438,7 @@ build.infoboxAlbum = function(data, forView) {
|
||||
|
||||
}
|
||||
|
||||
if (forView!==true&&lychee.publicMode!==true) {
|
||||
if (forView===false&&lychee.publicMode===false) {
|
||||
editTitleHTML = ' ' + build.editIcon('edit_title_album');
|
||||
editDescriptionHTML = ' ' + build.editIcon('edit_description_album');
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ contextMenu.albumTitle = function(albumID, e) {
|
||||
items.push({ type: 'separator' });
|
||||
|
||||
// Generate list of albums
|
||||
$.each(data.content, function(index) {
|
||||
$.each(data.albums, function(index) {
|
||||
|
||||
var that = this,
|
||||
title = '';
|
||||
@ -220,12 +220,12 @@ contextMenu.move = function(photoIDs, e) {
|
||||
} else {
|
||||
|
||||
// Generate list of albums
|
||||
$.each(data.content, function(index) {
|
||||
$.each(data.albums, function(index) {
|
||||
|
||||
var that = this;
|
||||
|
||||
if (!that.thumb0) that.thumb0 = 'src/images/no_cover.svg';
|
||||
that.title = "<img class='albumCover' width='16' height='16' src='" + that.thumb0 + "'><div class='albumTitle'>" + that.title + "</div>";
|
||||
that.title = "<img class='cover' width='16' height='16' src='" + that.thumb0 + "'><div class='title'>" + that.title + "</div>";
|
||||
|
||||
if (that.id!=album.getID()) items.push({ type: 'item', title: that.title, fn: function() { photo.setAlbum(photoIDs, that.id) } });
|
||||
|
||||
|
@ -91,7 +91,7 @@ header.setMode = function(mode) {
|
||||
album.json.content === false ? $('#button_archive').hide() : $('#button_archive').show();
|
||||
|
||||
// Hide download button when not logged in and album not downloadable
|
||||
if (lychee.publicMode&&album.json.downloadable==='0') $('#button_archive').hide();
|
||||
if (lychee.publicMode===true&&album.json.downloadable==='0') $('#button_archive').hide();
|
||||
|
||||
if (albumID==='s'||albumID==='f'||albumID==='r') {
|
||||
$('#button_info_album, #button_trash_album, #button_share_album').hide();
|
||||
|
@ -201,9 +201,9 @@ lychee.load = function() {
|
||||
} else {
|
||||
|
||||
// Trash albums.json when filled with search results
|
||||
if (search.code!=='') {
|
||||
if (search.hash!==null) {
|
||||
albums.json = null;
|
||||
search.code = '';
|
||||
search.hash = null;
|
||||
}
|
||||
|
||||
// Trash data
|
||||
|
@ -14,9 +14,9 @@ password.get = function(albumID, callback) {
|
||||
var passwd = $('.basicModal input.text').val(),
|
||||
params;
|
||||
|
||||
if (!lychee.publicMode) callback();
|
||||
else if (album.json&&album.json.password==false) callback();
|
||||
else if (albums.json&&albums.json.content[albumID].password==false) callback();
|
||||
if (lychee.publicMode===false) callback();
|
||||
else if (album.json&&album.json.password==='0') callback();
|
||||
else if (albums.json&&albums.json.albums[albumID].password==='0') callback();
|
||||
else if (!albums.json&&!album.json) {
|
||||
|
||||
// Continue without password
|
||||
|
@ -393,12 +393,12 @@ photo.setStar = function(photoIDs) {
|
||||
|
||||
if (!photoIDs) return false;
|
||||
if (visible.photo()) {
|
||||
photo.json.star = (photo.json.star==0) ? 1 : 0;
|
||||
photo.json.star = (photo.json.star==='0') ? '1' : '0';
|
||||
view.photo.star();
|
||||
}
|
||||
|
||||
photoIDs.forEach(function(id, index, array) {
|
||||
album.json.content[id].star = (album.json.content[id].star==0) ? 1 : 0;
|
||||
album.json.content[id].star = (album.json.content[id].star==='0') ? '1' : '0';
|
||||
view.album.content.star(id);
|
||||
});
|
||||
|
||||
@ -449,13 +449,13 @@ photo.setPublic = function(photoID, e) {
|
||||
|
||||
if (visible.photo()) {
|
||||
|
||||
photo.json.public = (photo.json.public==0) ? 1 : 0;
|
||||
photo.json.public = (photo.json.public==='0') ? '1' : '0';
|
||||
view.photo.public();
|
||||
if (photo.json.public==1) contextMenu.sharePhoto(photoID, e);
|
||||
if (photo.json.public==='1') contextMenu.sharePhoto(photoID, e);
|
||||
|
||||
}
|
||||
|
||||
album.json.content[photoID].public = (album.json.content[photoID].public==0) ? 1 : 0;
|
||||
album.json.content[photoID].public = (album.json.content[photoID].public==='0') ? '1' : '0';
|
||||
view.album.content.public(photoID);
|
||||
|
||||
albums.refresh();
|
||||
@ -698,7 +698,7 @@ photo.getArchive = function(photoID) {
|
||||
if (location.href.indexOf('index.html')>0) link = location.href.replace(location.hash, '').replace('index.html', url);
|
||||
else link = location.href.replace(location.hash, '') + url;
|
||||
|
||||
if (lychee.publicMode) link += '&password=' + password.value;
|
||||
if (lychee.publicMode===true) link += '&password=' + password.value;
|
||||
|
||||
location.href = link;
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
search = {
|
||||
|
||||
code: null
|
||||
hash: null
|
||||
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ search.find = function(term) {
|
||||
|
||||
var albumsData = '',
|
||||
photosData = '',
|
||||
code;
|
||||
html = '';
|
||||
|
||||
clearTimeout($(window).data('timeout'));
|
||||
$(window).data('timeout', setTimeout(function() {
|
||||
@ -24,8 +24,8 @@ search.find = function(term) {
|
||||
|
||||
// Build albums
|
||||
if (data&&data.albums) {
|
||||
albums.json = { content: data.albums };
|
||||
$.each(albums.json.content, function() {
|
||||
albums.json = { albums: data.albums };
|
||||
$.each(albums.json.albums, function() {
|
||||
albums.parse(this);
|
||||
albumsData += build.album(this);
|
||||
});
|
||||
@ -43,28 +43,28 @@ search.find = function(term) {
|
||||
// 2. Only photos found
|
||||
// 3. Only albums found
|
||||
// 4. Albums and photos found
|
||||
if (albumsData===''&&photosData==='') code = 'error';
|
||||
else if (albumsData==='') code = build.divider('Photos') + photosData;
|
||||
else if (photosData==='') code = build.divider('Albums') + albumsData;
|
||||
else code = build.divider('Photos') + photosData + build.divider('Albums') + albumsData;
|
||||
if (albumsData===''&&photosData==='') html = 'error';
|
||||
else if (albumsData==='') html = build.divider('Photos') + photosData;
|
||||
else if (photosData==='') html = build.divider('Albums') + albumsData;
|
||||
else html = build.divider('Photos') + photosData + build.divider('Albums') + albumsData;
|
||||
|
||||
// Only refresh view when search results are different
|
||||
if (search.code!==md5(code)) {
|
||||
if (search.hash!==data.hash) {
|
||||
|
||||
$('.no_content').remove();
|
||||
|
||||
lychee.animate('.album, .photo', 'contentZoomOut');
|
||||
lychee.animate('.divider', 'fadeOut');
|
||||
|
||||
search.code = md5(code);
|
||||
search.hash = data.hash;
|
||||
|
||||
setTimeout(function() {
|
||||
|
||||
if (code==='error') {
|
||||
if (html==='error') {
|
||||
lychee.content.html('');
|
||||
$('body').append(build.no_content('magnifying-glass'));
|
||||
} else {
|
||||
lychee.content.html(code);
|
||||
lychee.content.html(html);
|
||||
lychee.animate('.album, .photo', 'contentZoomIn');
|
||||
$('img[data-type!="svg"]').retina();
|
||||
}
|
||||
@ -86,13 +86,13 @@ search.reset = function() {
|
||||
$('#search').val('');
|
||||
$('.no_content').remove();
|
||||
|
||||
if (search.code!=='') {
|
||||
if (search.hash!==null) {
|
||||
|
||||
// Trash data
|
||||
albums.json = null;
|
||||
album.json = null;
|
||||
photo.json = null;
|
||||
search.code = '';
|
||||
search.hash = null;
|
||||
|
||||
lychee.animate('.divider', 'fadeOut');
|
||||
albums.load();
|
||||
|
@ -49,23 +49,29 @@ view.albums = {
|
||||
albumsData = '';
|
||||
|
||||
/* Smart Albums */
|
||||
albums.parse(albums.json.unsortedAlbum);
|
||||
albums.parse(albums.json.publicAlbum);
|
||||
albums.parse(albums.json.starredAlbum);
|
||||
albums.parse(albums.json.recentAlbum);
|
||||
if (!lychee.publicMode) smartData = build.divider('Smart Albums') + build.album(albums.json.unsortedAlbum) + build.album(albums.json.starredAlbum) + build.album(albums.json.publicAlbum) + build.album(albums.json.recentAlbum);
|
||||
if (lychee.publicMode===false) {
|
||||
|
||||
albums.parse(albums.json.smartalbums.unsorted);
|
||||
albums.parse(albums.json.smartalbums.public);
|
||||
albums.parse(albums.json.smartalbums.starred);
|
||||
albums.parse(albums.json.smartalbums.recent);
|
||||
|
||||
smartData = build.divider('Smart Albums') + build.album(albums.json.smartalbums.unsorted) + build.album(albums.json.smartalbums.public) + build.album(albums.json.smartalbums.starred) + build.album(albums.json.smartalbums.recent);
|
||||
|
||||
}
|
||||
|
||||
/* Albums */
|
||||
if (albums.json.content&&albums.json.num!==0) {
|
||||
if (albums.json.albums&&albums.json.num!==0) {
|
||||
|
||||
$.each(albums.json.content, function() {
|
||||
$.each(albums.json.albums, function() {
|
||||
albums.parse(this);
|
||||
|
||||
// Display albums in reverse order
|
||||
albumsData = build.album(this) + albumsData;
|
||||
});
|
||||
|
||||
if (!lychee.publicMode) albumsData = build.divider('Albums') + albumsData;
|
||||
// Add divider
|
||||
if (lychee.publicMode===false) albumsData = build.divider('Albums') + albumsData;
|
||||
|
||||
}
|
||||
|
||||
@ -88,7 +94,7 @@ view.albums = {
|
||||
title: function(albumID) {
|
||||
|
||||
var longTitle = '',
|
||||
title = albums.json.content[albumID].title;
|
||||
title = albums.json.albums[albumID].title;
|
||||
|
||||
if (title!==null&&title.length>18) {
|
||||
longTitle = title;
|
||||
@ -203,14 +209,14 @@ view.album = {
|
||||
star: function(photoID) {
|
||||
|
||||
$('.photo[data-id="' + photoID + '"] .iconic-star').remove();
|
||||
if (album.json.content[photoID].star==1) $('.photo[data-id="' + photoID + '"]').append("<a class='badge iconic-star'>" + build.iconic('star') + "</a>");
|
||||
if (album.json.content[photoID].star==='1') $('.photo[data-id="' + photoID + '"]').append("<a class='badge iconic-star'>" + build.iconic('star') + "</a>");
|
||||
|
||||
},
|
||||
|
||||
public: function(photoID) {
|
||||
|
||||
$('.photo[data-id="' + photoID + '"] .iconic-share').remove();
|
||||
if (album.json.content[photoID].public==1) $('.photo[data-id="' + photoID + '"]').append("<a class='badge iconic-share'>" + build.iconic('eye') + "</a>");
|
||||
if (album.json.content[photoID].public==='1') $('.photo[data-id="' + photoID + '"]').append("<a class='badge iconic-share'>" + build.iconic('eye') + "</a>");
|
||||
|
||||
},
|
||||
|
||||
@ -247,7 +253,7 @@ view.album = {
|
||||
|
||||
public: function() {
|
||||
|
||||
if (album.json.public==1) {
|
||||
if (album.json.public==='1') {
|
||||
|
||||
$('#button_share_album')
|
||||
.addClass('active')
|
||||
@ -270,7 +276,7 @@ view.album = {
|
||||
|
||||
password: function() {
|
||||
|
||||
if (album.json.password==1) $('#infobox .attr_password').html('Yes');
|
||||
if (album.json.password==='1') $('#infobox .attr_password').html('Yes');
|
||||
else $('#infobox .attr_password').html('No');
|
||||
|
||||
},
|
||||
@ -372,7 +378,7 @@ view.photo = {
|
||||
|
||||
public: function() {
|
||||
|
||||
if (photo.json.public==1||photo.json.public==2) {
|
||||
if (photo.json.public==='1'||photo.json.public==='2') {
|
||||
// Photo public
|
||||
$('#button_share')
|
||||
.addClass('active')
|
||||
|
@ -21,7 +21,7 @@ visible.photo = function() {
|
||||
}
|
||||
|
||||
visible.search = function() {
|
||||
if (search.code!==null&&search.code!=='') return true;
|
||||
if (search.hash!==null) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user