diff options
author | Robin Appelman <icewind@owncloud.com> | 2012-01-24 00:24:09 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2012-01-24 00:24:09 +0100 |
commit | cdfb252ceda6a9a97dd6473c472ed21a9948c8cf (patch) | |
tree | 099c7ecf348cb7360c2eb32a449249129399efcc /apps/gallery | |
parent | 7ea2923fa8805d91ee7d69dd19d10d450792bafe (diff) | |
parent | 456394d3ec03e2e0d582ded9db1c92d037d13d36 (diff) | |
download | nextcloud-server-cdfb252ceda6a9a97dd6473c472ed21a9948c8cf.tar.gz nextcloud-server-cdfb252ceda6a9a97dd6473c472ed21a9948c8cf.zip |
Merge branch 'master' of gitorious.org:owncloud/owncloud
Diffstat (limited to 'apps/gallery')
-rw-r--r-- | apps/gallery/css/styles.css | 19 | ||||
-rw-r--r-- | apps/gallery/js/album_cover.js | 17 | ||||
-rw-r--r-- | apps/gallery/js/albums.js | 34 | ||||
-rw-r--r-- | apps/gallery/lib/album.php | 4 | ||||
-rw-r--r-- | apps/gallery/lib/hooks_handlers.php | 6 | ||||
-rw-r--r-- | apps/gallery/lib/scanner.php | 5 |
6 files changed, 47 insertions, 38 deletions
diff --git a/apps/gallery/css/styles.css b/apps/gallery/css/styles.css index 4ada23b0b06..bb8d0607f8c 100644 --- a/apps/gallery/css/styles.css +++ b/apps/gallery/css/styles.css @@ -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; } -#gallery_images.rightcontent { padding:10px 5px; position:absolute; bottom: 0px; overflow: scroll; } +div#gallery_list.leftcontent { padding-top: 15pt; margin: 0; position: absolute; bottom:0px; text-align: center; overflow: auto; } +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; bottom: 0px; overflow: auto; right:0px} diff --git a/apps/gallery/js/album_cover.js b/apps/gallery/js/album_cover.js index 38b5815775c..513dd47d351 100644 --- a/apps/gallery/js/album_cover.js +++ b/apps/gallery/js/album_cover.js @@ -44,7 +44,11 @@ function scanForAlbums() { if (r.status == 'success') { totalAlbums = r.paths.length; - $('#notification').text(t('gallery',"Creating thumbnails")+' ... ' + Math.floor((albumCounter/totalAlbums)*100) + "%"); + if (totalAlbums == 0) { + $('#notification').text(t('gallery', "No photos found")).fadeIn().slideDown().delay(3000).fadeOut().slideUp(); + return; + } + $('#notification').text(t('gallery',"Creating thumbnails")+' ... ' + Math.floor((albumCounter/totalAlbums)*100) + "%"); for(var a in r.paths) { $.getJSON('ajax/galleryOp.php?operation=partial_create&path='+r.paths[a], function(r) { @@ -77,8 +81,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); } @@ -88,6 +92,9 @@ function galleryRemove(albumName) { function galleryRename(name) { var result = window.prompt(t('gallery',"Input new gallery name"), name); + if(result=='' || result==name){ + return; + } if (result) { if (Albums.find(result)) { alert("Album named '" + result + "' already exists"); @@ -95,14 +102,12 @@ 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',name), result); } else { alert("Error: " + r.cause); } }); - } else { - alert(t('gallery',"Album name can't be empty")) } } diff --git a/apps/gallery/js/albums.js b/apps/gallery/js/albums.js index 546aadba49f..6150b0daa1e 100644 --- a/apps/gallery/js/albums.js +++ b/apps/gallery/js/albums.js @@ -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) { @@ -69,8 +75,8 @@ Albums={ }, rename: function(element, new_name) { if (new_name) { - $(element).attr("title", new_name); - $("a", element).attr("href", "?view="+new_name); + $(element).attr("data-album", new_name); + $("a.view", element).attr("href", "?view="+new_name); $("h1", element).text(new_name); } } diff --git a/apps/gallery/lib/album.php b/apps/gallery/lib/album.php index d2c420eb9ef..4eb12cc0b81 100644 --- a/apps/gallery/lib/album.php +++ b/apps/gallery/lib/album.php @@ -28,7 +28,7 @@ class OC_Gallery_Album { } public static function rename($oldname, $newname, $owner) { - $stmt = OC_DB::prepare('UPDATE OR IGNORE *PREFIX*gallery_albums SET album_name=? WHERE uid_owner=? AND album_name=?'); + $stmt = OC_DB::prepare('UPDATE *PREFIX*gallery_albums SET album_name=? WHERE uid_owner=? AND album_name=?'); $stmt->execute(array($newname, $owner, $oldname)); } @@ -76,7 +76,7 @@ class OC_Gallery_Album { } public static function changePath($oldname, $newname, $owner) { - $stmt = OC_DB::prepare('UPDATE OR IGNORE *PREFIX*gallery_albums SET album_path=? WHERE uid_owner=? AND album_path=?'); + $stmt = OC_DB::prepare('UPDATE *PREFIX*gallery_albums SET album_path=? WHERE uid_owner=? AND album_path=?'); $stmt->execute(array($newname, $owner, $oldname)); } diff --git a/apps/gallery/lib/hooks_handlers.php b/apps/gallery/lib/hooks_handlers.php index 7248e67f0a2..53a924ff40a 100644 --- a/apps/gallery/lib/hooks_handlers.php +++ b/apps/gallery/lib/hooks_handlers.php @@ -32,10 +32,8 @@ class OC_Gallery_Hooks_Handlers { private static $APP_TAG = "Gallery"; private static function isPhoto($filename) { - OC_Log::write(self::$APP_TAG, "Checking file ".$filename." with mimetype ".OC_Filesystem::getMimeType($filename), OC_Log::DEBUG); - if (substr(OC_Filesystem::getMimeType($filename), 0, 6) == "image/") - return true; - return false; + $ext = strtolower(substr($filename, strrpos($filename, '.')+1)); + return $ext=='png' || $ext=='jpeg' || $ext=='jpg' || $ext=='gif'; } private static function directoryContainsPhotos($dirpath) { diff --git a/apps/gallery/lib/scanner.php b/apps/gallery/lib/scanner.php index df33369b93b..447174e84c0 100644 --- a/apps/gallery/lib/scanner.php +++ b/apps/gallery/lib/scanner.php @@ -88,9 +88,8 @@ class OC_Gallery_Scanner { } public static function isPhoto($filename) { - if (substr(OC_Filesystem::getMimeType($filename), 0, 6) == "image/") - return 1; - return 0; + $ext = strtolower(substr($filename, strrpos($filename, '.')+1)); + return $ext=='png' || $ext=='jpeg' || $ext=='jpg' || $ext=='gif'; } public static function find_paths($path) { |