aboutsummaryrefslogtreecommitdiffstats
path: root/apps/gallery/js/album_cover.js
diff options
context:
space:
mode:
authorBartek Przybylski <bart.p.pl@gmail.com>2011-09-25 22:32:08 +0200
committerBartek Przybylski <bart.p.pl@gmail.com>2011-09-25 22:32:08 +0200
commitbc43851d74e8fceea1c914e98a8cd571b84610d5 (patch)
tree171216b960b26719fe124db95a20520c9a3d0081 /apps/gallery/js/album_cover.js
parentfb01a7269304fe38369f01293f8f7fb707061363 (diff)
downloadnextcloud-server-bc43851d74e8fceea1c914e98a8cd571b84610d5.tar.gz
nextcloud-server-bc43851d74e8fceea1c914e98a8cd571b84610d5.zip
initial commit for gallery app
Diffstat (limited to 'apps/gallery/js/album_cover.js')
-rw-r--r--apps/gallery/js/album_cover.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/apps/gallery/js/album_cover.js b/apps/gallery/js/album_cover.js
new file mode 100644
index 00000000000..d4fb1f0475e
--- /dev/null
+++ b/apps/gallery/js/album_cover.js
@@ -0,0 +1,48 @@
+var actual_cover;
+$('body').ready(function() {
+ $('div[class=gallery_album_box]').each(function(i, e) {
+ $.getJSON('ajax/getCovers.php', { album: $(e).children('h1:last').text() }, function(a) {
+ if (a.status == "success") {
+ e.ic = a.imageCount;
+ e.images = a.images;
+ if (e.ic > 0) {
+ $(e).find('img[class=gallery_album_cover]').attr('src', 'ajax/thumbnail.php?img=' + e.images[0]);
+ actual_cover = 0;
+ }
+ }
+ });
+ });
+ $('img[class=gallery_album_cover]').each(function(i, e) {
+ $(e).mousemove(function(a) {
+ if (e.parentNode.parentNode.ic!=0) {
+ var x = Math.min(Math.floor((a.clientX - this.offsetLeft)/(200/e.parentNode.parentNode.ic)), e.parentNode.parentNode.ic-1);
+ if (actual_cover != x) {
+ $(e).attr('src', 'ajax/thumbnail.php?img=' + e.parentNode.parentNode.images[x]);
+ actual_cover = x;
+ }
+ }
+ });
+ });
+});
+
+function createNewAlbum() {
+ var name = prompt("album name", "");
+ if (name != null && name != "") {
+ $.getJSON("ajax/createAlbum.php", {album_name: name}, function(r) {
+ if (r.status == "success") {
+ var v = '<div class="gallery_album_box"><a href="?view='+r.name+'"><img class="gallery_album_cover"/></a><h1>'+r.name+'</h1></div>';
+ $('div#gallery_list').append(v);
+ }
+ });
+ }
+}
+
+function scanForAlbums() {
+ $.getJSON('ajax/scanForAlbums.php', function(r) {
+ if (r.status == 'success') {
+ window.location.reload(true);
+ } else {
+ alert('Error occured: ' + r.message);
+ }
+ });
+}