diff options
author | Olivier Paroz <github@oparoz.com> | 2015-01-28 00:56:09 +0300 |
---|---|---|
committer | Olivier Paroz <github@oparoz.com> | 2015-01-28 00:56:09 +0300 |
commit | 9ffac93a1609705daede7be9b98c6c82f6d6893e (patch) | |
tree | eb7ff3adc1ab2bba659f9fae826697258a7093c3 | |
parent | 25af5a16f34ff244225c2fd53e56cd68d28ed96f (diff) |
The Gallery button is now available to logged in users
The button which allows users to switch back and forth between the Files and Gallery app without losing the current folder/album was only available in public shares.
Not anymore.
### Fixes
https://github.com/interfasys/galleryplus/issues/15
https://github.com/owncloud/gallery/issues/116
-rw-r--r-- | appinfo/app.php | 4 | ||||
-rw-r--r-- | css/gallerybutton.css | 14 | ||||
-rw-r--r-- | css/public.css | 25 | ||||
-rw-r--r-- | js/gallery.js | 13 | ||||
-rw-r--r-- | js/gallerybutton.js | 76 | ||||
-rw-r--r-- | js/public.js | 47 | ||||
-rw-r--r-- | templates/part.content.php | 7 | ||||
-rw-r--r-- | templates/public.php | 3 |
8 files changed, 111 insertions, 78 deletions
diff --git a/appinfo/app.php b/appinfo/app.php index 99f6794f..ad16a714 100644 --- a/appinfo/app.php +++ b/appinfo/app.php @@ -62,10 +62,12 @@ $c->query('API') $c->query('API') ->addScript('slideshow', $appName); $c->query('API') - ->addScript('public', $appName); + ->addScript('gallerybutton', $appName); /** * Styles for the Files app */ $c->query('API') ->addStyle('slideshow', $appName); +$c->query('API') + ->addStyle('gallerybutton', $appName); diff --git a/css/gallerybutton.css b/css/gallerybutton.css new file mode 100644 index 00000000..80f3c753 --- /dev/null +++ b/css/gallerybutton.css @@ -0,0 +1,14 @@ +/* toggle for opening shared picture view as file list */ +#openAsFileListButton { + float: left; + margin-top: 5px; + margin-right: 0; + font-weight: normal; +} + +#openAsFileListButton img { + vertical-align: text-top; + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; + filter: alpha(opacity=50); + opacity: .5; +} diff --git a/css/public.css b/css/public.css index 8a7bb452..8f594ec1 100644 --- a/css/public.css +++ b/css/public.css @@ -2,16 +2,6 @@ margin-top: 45px; } -#public_upload, -#download { - font-weight: 700; - margin: 0 0.4em 0 0; - padding: 0 5px; - height: 32px; - float: left; - -} - #displayName { margin: 0 0.4em 0 0; padding: 0 5px; @@ -25,21 +15,6 @@ body { text-align: center; } -/* toggle for opening shared picture view as file list */ -#openAsFileListButton { - position: absolute; - right: 0; - top: 0; - font-weight: normal; -} - -#openAsFileListButton img { - vertical-align: text-top; - -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; - filter: alpha(opacity=50); - opacity: .5; -} - /* transfer to core after body has the id #body-public / #body-public-dark */ footer { diff --git a/js/gallery.js b/js/gallery.js index 1af9f877..d7b93e75 100644 --- a/js/gallery.js +++ b/js/gallery.js @@ -315,10 +315,15 @@ $(document).ready(function () { }); $('#openAsFileListButton').click(function () { - window.location.href = OC.generateUrl('s/{token}?path={path}', { - token: Gallery.token, - path: '/' + Gallery.currentAlbum - }); + var subUrl = ''; + var params = {path: '/' + Gallery.currentAlbum}; + if (Gallery.token) { + params.token = Gallery.token; + subUrl = 's/{token}?path={path}'; + } else { + subUrl = 'apps/files?dir={path}'; + } + window.location.href = OC.generateUrl(subUrl, params); }); $('#download').click(function (e) { e.preventDefault(); diff --git a/js/gallerybutton.js b/js/gallerybutton.js new file mode 100644 index 00000000..351facb6 --- /dev/null +++ b/js/gallerybutton.js @@ -0,0 +1,76 @@ +/* global OC, OCA, FileList, $, t */ +var GalleryButton = {}; +GalleryButton.isPublic = false; +GalleryButton.button = {}; +GalleryButton.url = null; + + +GalleryButton.onFileListUpdated = function () { + var hasImages = false; + var fileList; + var files; + + if (GalleryButton.isPublic) { + fileList = OCA.Sharing.PublicApp.fileList; + files = fileList.files; + } else { + fileList = FileList; + files = fileList.files; + } + + for (var i = 0; i < files.length; i++) { + var file = files[i]; + if (file.isPreviewAvailable) { + hasImages = true; + break; + } + } + + if (hasImages) { + GalleryButton.button.toggleClass('hidden', false); + GalleryButton.buildUrl(fileList.getCurrentDirectory().replace(/^\//, '')); + } else { + GalleryButton.button.toggleClass('hidden', true); + } +}; + +GalleryButton.buildUrl = function (dir) { + var params = {}; + var tokenPath = ''; + var token = ($('#sharingToken').val()) ? $('#sharingToken').val() : false; + if (token) { + params.token = token; + tokenPath = 's/{token}'; + } + GalleryButton.url = OC.generateUrl('apps/galleryplus/' + tokenPath, params) + '#' + dir; +}; + + +$(document).ready(function () { + + if ($('#body-login').length > 0) { + return true; //deactivate on login page + } + + if ($('#isPublic').val()) { + GalleryButton.isPublic = true; + } + + if ($('#filesApp').val()) { + + $('#fileList').on('updated', GalleryButton.onFileListUpdated); + + // toggle for opening shared file list as picture view + GalleryButton.button = $('<div id="openAsFileListButton" class="button hidden">' + + '<img class="svg" src="' + OC.imagePath('core', 'actions/toggle-pictures.svg') + '"' + + 'alt="' + t('gallery', 'Picture view') + '"/>' + + '</div>'); + + GalleryButton.button.click(function () { + window.location.href = GalleryButton.url; + }); + + $('#controls').prepend(GalleryButton.button); + } + } +); diff --git a/js/public.js b/js/public.js deleted file mode 100644 index 556704ad..00000000 --- a/js/public.js +++ /dev/null @@ -1,47 +0,0 @@ -/* global OC, OCA, $, t */ -$(document).ready(function () { - var button; - - if ($('#body-login').length > 0) { - return true; //deactivate on login page - } - - function onFileListUpdated () { - var hasImages = false; - var files = OCA.Sharing.PublicApp.fileList.files; - - for (var i = 0; i < files.length; i++) { - var file = files[i]; - if (file.isPreviewAvailable) { - hasImages = true; - break; - } - } - - button.toggleClass('hidden', !hasImages); - } - - if ($('#filesApp').val() && $('#isPublic').val()) { - - $('#fileList').on('updated', onFileListUpdated); - - // toggle for opening shared file list as picture view - // TODO find a way to not need to use inline CSS - button = $('<div class="button hidden"' + - 'style="position: absolute; right: 0; top: 0; font-weight: normal;">' + - '<img class="svg" src="' + OC.imagePath('core', 'actions/toggle-pictures.svg') + '"' + - 'alt="' + t('gallery', 'Picture view') + '"' + - 'style="vertical-align: text-top; ' + - '-ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=50); ' + - 'filter: alpha(opacity=50); opacity: .5;" />' + - '</div>'); - button.click(function () { - window.location.href = OC.generateUrl('apps/galleryplus/s/{token}', { - token: $('#sharingToken').val() - }) + '#' + OCA.Sharing.PublicApp.fileList.getCurrentDirectory().replace(/^\//, ''); - }); - - $('#controls').append(button); - } - } -); diff --git a/templates/part.content.php b/templates/part.content.php index 7e1fc07d..3f677789 100644 --- a/templates/part.content.php +++ b/templates/part.content.php @@ -18,11 +18,18 @@ style( [ 'styles', 'mobile', + 'gallerybutton' ] ); ?> <div id="controls"> <div id='breadcrumbs'></div> + <!-- toggle for opening shared picture view as file list --> + <div id="openAsFileListButton" class="button"> + <img class="svg" src="<?php print_unescaped( + image_path('core', 'actions/toggle-filelist.svg') + ); ?>" alt="<?php p($l->t('File list')); ?>"/> + </div> <span class="right"> <button class="share"><?php p($l->t("Share")); ?></button> <a class="share" data-item-type="folder" data-item="" diff --git a/templates/public.php b/templates/public.php index 41e2b51c..fea3bd6a 100644 --- a/templates/public.php +++ b/templates/public.php @@ -18,7 +18,8 @@ style( [ 'styles', 'mobile', - 'public' + 'public', + 'gallerybutton' ] ); |