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 /js | |
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
Diffstat (limited to 'js')
-rw-r--r-- | js/gallery.js | 13 | ||||
-rw-r--r-- | js/gallerybutton.js | 76 | ||||
-rw-r--r-- | js/public.js | 47 |
3 files changed, 85 insertions, 51 deletions
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); - } - } -); |