diff options
Diffstat (limited to 'js/gallerybutton.js')
-rw-r--r-- | js/gallerybutton.js | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/js/gallerybutton.js b/js/gallerybutton.js index 351facb6..4fc071dd 100644 --- a/js/gallerybutton.js +++ b/js/gallerybutton.js @@ -3,7 +3,7 @@ var GalleryButton = {}; GalleryButton.isPublic = false; GalleryButton.button = {}; GalleryButton.url = null; - +GalleryButton.appName = 'galleryplus'; GalleryButton.onFileListUpdated = function () { var hasImages = false; @@ -29,6 +29,7 @@ GalleryButton.onFileListUpdated = function () { if (hasImages) { GalleryButton.button.toggleClass('hidden', false); GalleryButton.buildUrl(fileList.getCurrentDirectory().replace(/^\//, '')); + GalleryButton.hijackShare(); } else { GalleryButton.button.toggleClass('hidden', true); } @@ -45,6 +46,39 @@ GalleryButton.buildUrl = function (dir) { GalleryButton.url = OC.generateUrl('apps/galleryplus/' + tokenPath, params) + '#' + dir; }; +GalleryButton.hijackShare = function () { + var target = OC.Share.showLink; + OC.Share.showLink = function () { + var r = target.apply(this, arguments); + + if (!$('#linkSwitchButton').length) { + var linkSwitchButton = '<a class="button" id="linkSwitchButton">' + + t(GalleryButton.appName, 'Show Gallery link') + '</a>'; + $('#linkCheckbox+label').after(linkSwitchButton); + } + + $("#linkSwitchButton").toggle(function () { + $(this).text("Show Files link"); + $('#linkText').val($('#linkText').val().replace('index.php/s/', 'index.php/apps/' + + GalleryButton.appName + '/s/')); + }, function () { + $(this).text("Show Gallery link"); + $('#linkText').val($('#linkText').val().replace('index.php/apps/' + + GalleryButton.appName + '/s/', 'index.php/s/')); + + }); + + $('#linkCheckbox').change(function () { + if (this.checked) { + $('#linkSwitchButton').show(); + } else { + $('#linkSwitchButton').hide(); + } + }); + + return r; + }; +}; $(document).ready(function () { |