Small code adjustments #232
This commit is contained in:
parent
a0d11ca6b2
commit
582a8a3f93
9
README
9
README
@ -1,9 +0,0 @@
|
|||||||
Experimental fork of Lychee, a photo management system, that features a number of improvements, including:
|
|
||||||
|
|
||||||
* Faster photo browsing thanks to caching.
|
|
||||||
* Default sort order of albums is changed from new to old.
|
|
||||||
* Preserves scroll position when changing from albums to album and vice versa
|
|
||||||
* Better Unicode support for values read from the database
|
|
||||||
|
|
||||||
|
|
||||||
See http://github.com/electerious/Lychee for more details on Lychee
|
|
@ -116,8 +116,9 @@ album = {
|
|||||||
if (data!==false&&isNumber(data)) {
|
if (data!==false&&isNumber(data)) {
|
||||||
albums.refresh();
|
albums.refresh();
|
||||||
lychee.goto(data);
|
lychee.goto(data);
|
||||||
|
} else {
|
||||||
|
lychee.error(null, params, data);
|
||||||
}
|
}
|
||||||
else lychee.error(null, params, data);
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -149,7 +150,7 @@ album = {
|
|||||||
albumIDs.forEach(function(id) {
|
albumIDs.forEach(function(id) {
|
||||||
albums.json.num--;
|
albums.json.num--;
|
||||||
view.albums.content.delete(id);
|
view.albums.content.delete(id);
|
||||||
delete albums.json.content[id]
|
delete albums.json.content[id];
|
||||||
});
|
});
|
||||||
|
|
||||||
} else lychee.goto("");
|
} else lychee.goto("");
|
||||||
|
@ -20,8 +20,8 @@ albums = {
|
|||||||
|
|
||||||
startTime = new Date().getTime();
|
startTime = new Date().getTime();
|
||||||
|
|
||||||
|
if(albums.json===null) {
|
||||||
|
|
||||||
if(albums.json == null) {
|
|
||||||
lychee.api("getAlbums", function(data) {
|
lychee.api("getAlbums", function(data) {
|
||||||
|
|
||||||
/* Smart Albums */
|
/* Smart Albums */
|
||||||
@ -76,13 +76,17 @@ albums = {
|
|||||||
view.header.mode("albums");
|
view.header.mode("albums");
|
||||||
view.albums.init();
|
view.albums.init();
|
||||||
lychee.animate(".album:nth-child(-n+50), .photo:nth-child(-n+50)", "contentZoomIn");
|
lychee.animate(".album:nth-child(-n+50), .photo:nth-child(-n+50)", "contentZoomIn");
|
||||||
|
|
||||||
}, waitTime);
|
}, waitTime);
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
setTimeout(function() {
|
||||||
view.header.mode("albums");
|
view.header.mode("albums");
|
||||||
view.albums.init();
|
view.albums.init();
|
||||||
lychee.animate(".album:nth-child(-n+50), .photo:nth-child(-n+50)", "contentZoomIn");
|
lychee.animate(".album:nth-child(-n+50), .photo:nth-child(-n+50)", "contentZoomIn");
|
||||||
|
}, 300);
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -101,7 +105,9 @@ albums = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
refresh: function() {
|
refresh: function() {
|
||||||
|
|
||||||
albums.json = null;
|
albums.json = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
@ -34,7 +34,7 @@ build = {
|
|||||||
title = albumJSON.title,
|
title = albumJSON.title,
|
||||||
typeThumb = "";
|
typeThumb = "";
|
||||||
|
|
||||||
if (title != null && title.length>18) {
|
if (title!==null&&title.length>18) {
|
||||||
title = albumJSON.title.substr(0, 18) + "...";
|
title = albumJSON.title.substr(0, 18) + "...";
|
||||||
longTitle = albumJSON.title;
|
longTitle = albumJSON.title;
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ build = {
|
|||||||
longTitle = "",
|
longTitle = "",
|
||||||
title = photoJSON.title;
|
title = photoJSON.title;
|
||||||
|
|
||||||
if (title != null && title.length>18) {
|
if (title!==null&&title.length>18) {
|
||||||
title = photoJSON.title.substr(0, 18) + "...";
|
title = photoJSON.title.substr(0, 18) + "...";
|
||||||
longTitle = photoJSON.title;
|
longTitle = photoJSON.title;
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,6 @@ var lychee = {
|
|||||||
if (albumID&&photoID) {
|
if (albumID&&photoID) {
|
||||||
|
|
||||||
// Trash data
|
// Trash data
|
||||||
//albums.json = null;
|
|
||||||
photo.json = null;
|
photo.json = null;
|
||||||
|
|
||||||
// Show Photo
|
// Show Photo
|
||||||
@ -195,7 +194,6 @@ var lychee = {
|
|||||||
} else if (albumID) {
|
} else if (albumID) {
|
||||||
|
|
||||||
// Trash data
|
// Trash data
|
||||||
//albums.json = null;
|
|
||||||
photo.json = null;
|
photo.json = null;
|
||||||
|
|
||||||
// Show Album
|
// Show Album
|
||||||
@ -206,7 +204,6 @@ var lychee = {
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Trash data
|
// Trash data
|
||||||
//albums.json = null;
|
|
||||||
album.json = null;
|
album.json = null;
|
||||||
photo.json = null;
|
photo.json = null;
|
||||||
search.code = "";
|
search.code = "";
|
||||||
|
@ -5,10 +5,10 @@
|
|||||||
* @copyright 2014 by Tobias Reich
|
* @copyright 2014 by Tobias Reich
|
||||||
*/
|
*/
|
||||||
|
|
||||||
cache = null;
|
|
||||||
photo = {
|
photo = {
|
||||||
|
|
||||||
json: null,
|
json: null,
|
||||||
|
cache: null,
|
||||||
|
|
||||||
getID: function() {
|
getID: function() {
|
||||||
|
|
||||||
@ -52,16 +52,23 @@ photo = {
|
|||||||
|
|
||||||
//preload the next photo for better response time
|
//preload the next photo for better response time
|
||||||
preloadNext: function(photoID) {
|
preloadNext: function(photoID) {
|
||||||
if(album.json &&
|
|
||||||
|
var nextPhoto,
|
||||||
|
url;
|
||||||
|
|
||||||
|
if (album.json &&
|
||||||
album.json.content &&
|
album.json.content &&
|
||||||
album.json.content[photoID] &&
|
album.json.content[photoID] &&
|
||||||
album.json.content[photoID].nextPhoto!="") {
|
album.json.content[photoID].nextPhoto!="") {
|
||||||
|
|
||||||
var nextPhoto = album.json.content[photoID].nextPhoto;
|
nextPhoto = album.json.content[photoID].nextPhoto;
|
||||||
var url = album.json.content[nextPhoto].url;
|
url = album.json.content[nextPhoto].url;
|
||||||
cache = new Image();
|
|
||||||
cache.src = url;
|
photo.cache = new Image();
|
||||||
|
photo.cache.src = url;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
parse: function() {
|
parse: function() {
|
||||||
@ -341,14 +348,12 @@ photo = {
|
|||||||
var params;
|
var params;
|
||||||
|
|
||||||
if (photo.json.public==2) {
|
if (photo.json.public==2) {
|
||||||
|
|
||||||
modal.show("Public Album", "This photo is located in a public album. To make this photo private or public, edit the visibility of the associated album.", [["Show Album", function() { lychee.goto(photo.json.original_album) }], ["Close", function() {}]]);
|
modal.show("Public Album", "This photo is located in a public album. To make this photo private or public, edit the visibility of the associated album.", [["Show Album", function() { lychee.goto(photo.json.original_album) }], ["Close", function() {}]]);
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
albums.refresh();
|
|
||||||
|
|
||||||
|
|
||||||
if (visible.photo()) {
|
if (visible.photo()) {
|
||||||
|
|
||||||
photo.json.public = (photo.json.public==0) ? 1 : 0;
|
photo.json.public = (photo.json.public==0) ? 1 : 0;
|
||||||
@ -367,6 +372,8 @@ photo = {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
albums.refresh();
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setDescription: function(photoID) {
|
setDescription: function(photoID) {
|
||||||
|
@ -122,7 +122,7 @@ view = {
|
|||||||
|
|
||||||
content: {
|
content: {
|
||||||
|
|
||||||
scroll_pos: 0,
|
scrollPosition: 0,
|
||||||
|
|
||||||
init: function() {
|
init: function() {
|
||||||
|
|
||||||
@ -137,8 +137,8 @@ view = {
|
|||||||
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) 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);
|
||||||
|
|
||||||
/* Albums */
|
/* Albums */
|
||||||
|
|
||||||
if (albums.json.content) {
|
if (albums.json.content) {
|
||||||
|
|
||||||
$.each(albums.json.content, function() {
|
$.each(albums.json.content, function() {
|
||||||
albums.parse(this);
|
albums.parse(this);
|
||||||
|
|
||||||
@ -147,6 +147,7 @@ view = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!lychee.publicMode) albumsData = build.divider("Albums") + albumsData;
|
if (!lychee.publicMode) albumsData = build.divider("Albums") + albumsData;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (smartData===""&&albumsData==="") {
|
if (smartData===""&&albumsData==="") {
|
||||||
@ -158,9 +159,9 @@ view = {
|
|||||||
|
|
||||||
$("img[data-type!='nonretina']").retina();
|
$("img[data-type!='nonretina']").retina();
|
||||||
|
|
||||||
//restore scroll
|
/* Restore scroll position */
|
||||||
if (view.albums.content.scroll_pos != null) {
|
if (view.albums.content.scrollPosition!==null) {
|
||||||
$("html, body").scrollTop(view.albums.content.scroll_pos);
|
$("html, body").scrollTop(view.albums.content.scrollPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -172,7 +173,7 @@ view = {
|
|||||||
title = albums.json.content[albumID].title;
|
title = albums.json.content[albumID].title;
|
||||||
|
|
||||||
if (albums.json.content[albumID].password) prefix = "<span class='icon-lock'></span> ";
|
if (albums.json.content[albumID].password) prefix = "<span class='icon-lock'></span> ";
|
||||||
if (title != null && title.length>18) {
|
if (title!==null&&title.length>18) {
|
||||||
longTitle = title;
|
longTitle = title;
|
||||||
title = title.substr(0, 18) + "...";
|
title = title.substr(0, 18) + "...";
|
||||||
}
|
}
|
||||||
@ -260,9 +261,10 @@ view = {
|
|||||||
|
|
||||||
$("img[data-type!='svg']").retina();
|
$("img[data-type!='svg']").retina();
|
||||||
|
|
||||||
view.albums.content.scroll_pos = $(document).scrollTop();
|
/* Save and reset scroll position */
|
||||||
//scroll to top
|
view.albums.content.scrollPosition = $(document).scrollTop();
|
||||||
$("html, body").scrollTop(0);
|
$("html, body").scrollTop(0);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
title: function(photoID) {
|
title: function(photoID) {
|
||||||
@ -270,7 +272,7 @@ view = {
|
|||||||
var longTitle = "",
|
var longTitle = "",
|
||||||
title = album.json.content[photoID].title;
|
title = album.json.content[photoID].title;
|
||||||
|
|
||||||
if (title != null && title.length>18) {
|
if (title!==null&&title.length>18) {
|
||||||
longTitle = title;
|
longTitle = title;
|
||||||
title = title.substr(0, 18) + "...";
|
title = title.substr(0, 18) + "...";
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
4411
assets/min/main.js
4411
assets/min/main.js
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -31,7 +31,7 @@ gulp.task('view', function () {
|
|||||||
.pipe(gulp.dest('../assets/min/'));
|
.pipe(gulp.dest('../assets/min/'));
|
||||||
|
|
||||||
});
|
});
|
||||||
/*
|
|
||||||
gulp.task('js', function () {
|
gulp.task('js', function () {
|
||||||
|
|
||||||
gulp.src(paths.js)
|
gulp.src(paths.js)
|
||||||
@ -39,15 +39,6 @@ gulp.task('js', function () {
|
|||||||
.pipe(plugins.uglify())
|
.pipe(plugins.uglify())
|
||||||
.pipe(gulp.dest('../assets/min/'));
|
.pipe(gulp.dest('../assets/min/'));
|
||||||
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
|
|
||||||
gulp.task('js', function () {
|
|
||||||
|
|
||||||
gulp.src(paths.js)
|
|
||||||
.pipe(plugins.concat('main.js', {newLine: "\n"}))
|
|
||||||
.pipe(gulp.dest('../assets/min/'));
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('css', function () {
|
gulp.task('css', function () {
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"gulp": "^3.8.8",
|
"gulp": "^3.8.8",
|
||||||
"gulp-autoprefixer": "1.0.0",
|
"gulp-autoprefixer": "1.0.0",
|
||||||
"gulp-concat": "^2.4.0",
|
"gulp-concat": "^2.4.1",
|
||||||
"gulp-load-plugins": "^0.6.0",
|
"gulp-load-plugins": "^0.6.0",
|
||||||
"gulp-minify-css": "^0.3.8",
|
"gulp-minify-css": "^0.3.8",
|
||||||
"gulp-sass": "^0.7.3",
|
"gulp-sass": "^0.7.3",
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
||||||
if (!defined('LYCHEE_ACCESS_ADMIN')) exit('Error: You are not allowed to access this area!');
|
if (!defined('LYCHEE_ACCESS_ADMIN')) exit('Error: You are not allowed to access this area!');
|
||||||
|
|
||||||
|
|
||||||
class Admin extends Access {
|
class Admin extends Access {
|
||||||
|
|
||||||
public function check($fn) {
|
public function check($fn) {
|
||||||
@ -74,6 +73,7 @@ class Admin extends Access {
|
|||||||
|
|
||||||
$album = new Album($this->database, $this->plugins, $this->settings, null);
|
$album = new Album($this->database, $this->plugins, $this->settings, null);
|
||||||
echo json_encode($album->getAll(false));
|
echo json_encode($album->getAll(false));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getAlbum() {
|
private function getAlbum() {
|
||||||
|
@ -8,17 +8,6 @@
|
|||||||
|
|
||||||
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
||||||
|
|
||||||
|
|
||||||
function debug_to_console( $data ) {
|
|
||||||
|
|
||||||
if ( is_array( $data ) )
|
|
||||||
$output = "<script>console.log( 'Debug Objects: " . implode( ',', $data) . "' );</script>";
|
|
||||||
else
|
|
||||||
$output = "<script>console.log( 'Debug Objects: " . $data . "' );</script>";
|
|
||||||
|
|
||||||
echo $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Album extends Module {
|
class Album extends Module {
|
||||||
|
|
||||||
private $database = null;
|
private $database = null;
|
||||||
@ -96,7 +85,6 @@ class Album extends Module {
|
|||||||
$return = $albums->fetch_assoc();
|
$return = $albums->fetch_assoc();
|
||||||
$return['sysdate'] = date('d M. Y', $return['sysstamp']);
|
$return['sysdate'] = date('d M. Y', $return['sysstamp']);
|
||||||
$return['password'] = ($return['password']=='' ? false : true);
|
$return['password'] = ($return['password']=='' ? false : true);
|
||||||
|
|
||||||
$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));
|
$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;
|
break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user