diff options
author | Bartek Przybylski <bart.p.pl@gmail.com> | 2011-12-21 21:55:52 +0100 |
---|---|---|
committer | Bartek Przybylski <bart.p.pl@gmail.com> | 2011-12-21 21:55:52 +0100 |
commit | 1383cb51e7672b422732a1d20379baaa4f3f7b62 (patch) | |
tree | 555a4c11f738b30dbacf20fc5866f34fc6eb1276 /apps/gallery/js | |
parent | 6a1a7fcd268e90a3b6c33f9568403a441ce983da (diff) | |
download | nextcloud-server-1383cb51e7672b422732a1d20379baaa4f3f7b62.tar.gz nextcloud-server-1383cb51e7672b422732a1d20379baaa4f3f7b62.zip |
removing and renaming albums
Diffstat (limited to 'apps/gallery/js')
-rw-r--r-- | apps/gallery/js/album_cover.js | 34 | ||||
-rw-r--r-- | apps/gallery/js/albums.js | 10 |
2 files changed, 42 insertions, 2 deletions
diff --git a/apps/gallery/js/album_cover.js b/apps/gallery/js/album_cover.js index c475c60d5da..619aa391c56 100644 --- a/apps/gallery/js/album_cover.js +++ b/apps/gallery/js/album_cover.js @@ -39,3 +39,37 @@ function scanForAlbums() { } }); } + +function galleryRemove(albumName) { + if (confirm("Do you wan't to remove album " + albumName + "?")) { + $.getJSON("ajax/galleryOp.php", {operation: "remove", name: albumName}, function(r) { + if (r.status == "success") { + $("#gallery_album_box[title='"+albumName+"']").remove(); + Albums.remove(albumName); + } else { + alert("Error: " + r.cause); + } + }); + } +} + +function galleryRename(name) { + var result = window.prompt("Input new gallery name", ""); + if (result) { + if (Albums.find(result)) { + alert("Album named '" + result + "' already exists"); + return; + } + $.getJSON("ajax/galleryOp.php", {operation: "rename", oldname: name, newname: result}, function(r) { + if (r.status == "success") { + Albums.rename($("#gallery_album_box[title='"+name+"']"), result); + } else { + alert("Error: " + r.cause); + } + }); + + } else { + alert("Album name can't be empty") + } +} + diff --git a/apps/gallery/js/albums.js b/apps/gallery/js/albums.js index 7ffa2cf891d..ae7d1fac500 100644 --- a/apps/gallery/js/albums.js +++ b/apps/gallery/js/albums.js @@ -57,13 +57,19 @@ Albums={ // displays gallery in linear representation // on given element, and apply default styles for gallery display: function(element) { - var displayTemplate = '<div id="gallery_album_box" title="*NAME*"><a href="#?view=*NAME*"><div id="#gallery_control_overlay"><div id="gallery_album_cover" title="*NAME*"></div></div></a><h1>*NAME*</h1></div></div>'; + var displayTemplate = '<div id="gallery_album_box" title="*NAME*"><div id="gallery_control_overlay"><a href="#" onclick="galleryRename(\'*NAME*\');return false;">rename</a> | <a href="#" onclick="galleryRemove(\'*NAME*\');">remove</a></div><a href="?view=*NAME*"><div id="gallery_album_cover" title="*NAME*"></div></a><h1>*NAME*</h1></div></div>'; for (var i in Albums.albums) { var a = Albums.albums[i]; var local = $(displayTemplate.replace(/\*NAME\*/g, a.name)); $("#gallery_album_cover", local).css('background-repeat', 'no-repeat'); $("#gallery_album_cover", local).css('background-position', '0'); $("#gallery_album_cover", local).css('background-image','url("ajax/getCovers.php?album_name='+a.name+'")'); + local.mouseover(function(e) { + $("#gallery_control_overlay", this).css('visibility','visible'); + }); + local.mouseout(function(e) { + $("#gallery_control_overlay", this).css('visibility','hidden'); + }); $("#gallery_album_cover", local).mousemove(function(e) { var albumMetadata = Albums.find(this.title); @@ -71,7 +77,7 @@ Albums={ return; } var x = Math.min(Math.floor((e.layerX - this.offsetLeft)/(this.offsetWidth/albumMetadata.numOfCovers)), albumMetadata.numOfCovers-1); - x *= this.offsetWidth; + x *= this.offsetWidth-1; $(this).css('background-position', -x+'px 0'); }); $(element).append(local); |