]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix deleting/renaming albums with a ' in the name
authorRobin Appelman <icewind@owncloud.com>
Fri, 20 Jan 2012 18:26:09 +0000 (19:26 +0100)
committerRobin Appelman <icewind@owncloud.com>
Fri, 20 Jan 2012 18:26:09 +0000 (19:26 +0100)
apps/gallery/css/styles.css
apps/gallery/js/album_cover.js
apps/gallery/js/albums.js

index 4ada23b0b062aae8ebce749d49cff56f4c306f36..a0822ddec1e0920c6249f165446388b503ad85fe 100644 (file)
@@ -1,11 +1,12 @@
 div#gallery_list { margin: 90pt 20pt; }
-div#gallery_list.leftcontent { padding-top: 15pt; margin: 0; position: absolute; bottom:0px; text-align: center; overflow: scroll; }
-div#gallery_album_box { width: 200px; text-align: center; border: 0; display: inline-block; margin: 5pt; vertical-align: top; padding: 10px; position: relative; overflow: hidden; color: #999; }
-div#gallery_album_box:hover { color: black; }
-.leftcontent div#gallery_album_box { margin: 5px; }
-div#gallery_album_box h1 { font-size: 9pt; font-family: Verdana; }
-div#gallery_album_cover { width: 199px; height: 199px; border: solid 1pt #999; padding: 0; }
-div#gallery_control_overlay { border: 0; position:absolute; right: 10pt; background-color: #333; opacity: 0.5; visibility:hidden; padding: 0 5pt; }
-div#gallery_control_overlay a { color:white; }
+div.gallery_list.leftcontent { padding-top: 15pt; margin: 0; position: absolute; bottom:0px; text-align: center; overflow: scroll; }
+div.gallery_album_box { width: 200px; text-align: center; border: 0; display: inline-block; margin: 5pt; vertical-align: top; padding: 10px; position: relative; overflow: hidden; color: #999; }
+div.gallery_album_box:hover { color: black; }
+.leftcontent div.gallery_album_box { margin: 5px; }
+div.gallery_album_box h1 { font-size: 9pt; font-family: Verdana; }
+div.gallery_album_cover { width: 199px; height: 199px; border: solid 1pt #999; padding: 0; }
+div.gallery_control_overlay { border: 0; position:absolute; right: 10pt; background-color: #333; opacity: 0; padding: 0 5pt; }
+div.gallery_album_box:hover div.gallery_control_overlay { opacity:0.5 }
+div.gallery_control_overlay a { color:white; }
 #gallery_images.rightcontent { padding:10px 5px; position:absolute; bottom: 0px; overflow: scroll; }
 
index 38b5815775c8e4d03200a9e080666360aba7659d..0e791689a1a45033cf008262617c95359afc9667 100644 (file)
@@ -77,8 +77,8 @@ function galleryRemove(albumName) {
   if (confirm(t('gallery',"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);
+               $(".gallery_album_box").filterAttr('data-album',albumName).remove();
+               Albums.remove(albumName);
          } else {
                alert("Error: " + r.cause);
          }
@@ -95,7 +95,7 @@ function galleryRename(name) {
        }
        $.getJSON("ajax/galleryOp.php", {operation: "rename", oldname: name, newname: result}, function(r) {
          if (r.status == "success") {
-        Albums.rename($("#gallery_album_box[title='"+name+"']"), result);
+                 Albums.rename($(".gallery_album_box").filterAttr('data-album',albumName), result);
       } else {
            alert("Error: " + r.cause);
       }
index 546aadba49f1b39564a6de2b208b147981d64c6c..f18d1deca4cca44b2ce8d8b004f0853345f3e4fd 100644 (file)
@@ -41,20 +41,26 @@ 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*"><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>';
+    var displayTemplate = '<div class="gallery_album_box"><div class="gallery_control_overlay"><a href="#" class="rename">rename</a> | <a href="#" class="remove">remove</a></div><a class="view"><div class="gallery_album_cover"></div></a><h1></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/galleryOp.php?operation=get_covers&albumname='+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 local=$(displayTemplate);
+         local.attr('data-album',a.name);
+         $(".gallery_control_overlay a.rename", local).click(function(name,event){
+                       event.preventDefault();
+                       galleryRename(name);
+               }.bind(null,a.name));
+         $(".gallery_control_overlay a.remove", local).click(function(name,event){
+                 event.preventDefault();
+                 galleryRemove(name);
+         }.bind(null,a.name));
+         $("a.view", local).attr('href','?view='+a.name);
+         $('h1',local).text(a.name);
+         $(".gallery_album_cover", local).attr('title',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/galleryOp.php?operation=get_covers&albumname='+a.name+'")');
+      $(".gallery_album_cover", local).mousemove(function(e) {
 
         var albumMetadata = Albums.find(this.title);
         if (albumMetadata == undefined) {