Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/gallery.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Paroz <github@oparoz.com>2015-01-28 20:40:48 +0300
committerOlivier Paroz <github@oparoz.com>2015-01-28 20:40:48 +0300
commite334693b2059d4c9c69c319a81977425748dd2be (patch)
treea46f65ffceea64275eb6bd311d7b91a3fe8dc30d /js/gallerybutton.js
parent9ffac93a1609705daede7be9b98c6c82f6d6893e (diff)
Add a way to dynamically modify the share link
There is now a button next to "Share link" which allows a user to switch between the Files and Gallery public link ### Fixes https://github.com/interfasys/galleryplus/issues/16 https://github.com/owncloud/core/issues/8268#issuecomment-41960633
Diffstat (limited to 'js/gallerybutton.js')
-rw-r--r--js/gallerybutton.js36
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 () {