blob: 24d3a40f77a56a35de8c0ad1031fadd4a14bd92e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
/* global OC, OCA, FileList, $, t */
var GalleryButton = {};
GalleryButton.isPublic = false;
GalleryButton.button = {};
GalleryButton.url = null;
/**
* Rebuilds the Gallery URL every time the files list has changed
*/
GalleryButton.onFileListUpdated = function () {
"use strict";
var fileList;
if (GalleryButton.isPublic) {
fileList = OCA.Sharing.PublicApp.fileList;
} else {
fileList = FileList;
}
GalleryButton.buildGalleryUrl(fileList.getCurrentDirectory().replace(/^\//, ''));
};
/**
* Builds the URL which will load the exact same folder in Gallery
*
* @param dir
*/
GalleryButton.buildGalleryUrl = function (dir) {
"use strict";
var params = {};
var tokenPath = '';
var sharingTokenElement = $('#sharingToken');
var token = (sharingTokenElement.val()) ? sharingTokenElement.val() : false;
if (token) {
params.token = token;
tokenPath = 's/{token}';
}
GalleryButton.url =
OC.generateUrl('apps/gallery/' + tokenPath, params) + '#' + encodeURIComponent(dir);
};
$(document).ready(function () {
"use strict";
if ($('#body-login').length > 0) {
return true; //deactivate on login page
}
if ($('html').is('.ie8')) {
return true; //deactivate in IE8
}
if ($('#isPublic').val()) {
GalleryButton.isPublic = true;
}
if ($('#filesApp').val()) {
$('#fileList').on('updated', GalleryButton.onFileListUpdated);
// Toggle for opening files list as gallery view
GalleryButton.button =
$('<div id="gallery-button" class="button view-switcher right-switch-button inactive-button">' +
'<img class="svg" src="' + OC.imagePath('core', 'actions/toggle-pictures.svg') +
'"' +
'alt="' + t('gallery', 'Picture view') + '"/>' +
'</div>' +
'<div class="button view-switcher left-switch-button disabled-button">' +
'<img class="svg" src="' + OC.imagePath('core', 'actions/toggle-filelist.svg') +
'"' +
'alt="' + t('gallery', 'Picture view') + '"/>' +
'</div>');
GalleryButton.button.click(function () {
$(this).addClass('loading');
window.location.href = GalleryButton.url;
});
$('#controls').prepend(GalleryButton.button);
}
}
);
|