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:
-rw-r--r--js/app.js29
-rw-r--r--js/eventsource.js3
-rw-r--r--js/gallery.js315
-rw-r--r--js/galleryalbum.js180
-rw-r--r--js/gallerybutton.js10
-rw-r--r--js/galleryconfig.js74
-rw-r--r--js/galleryfileaction.js21
-rw-r--r--js/galleryimage.js4
-rw-r--r--js/galleryinfobox.js12
-rw-r--r--js/galleryrow.js36
-rw-r--r--js/galleryutility.js11
-rw-r--r--js/galleryview.js124
-rw-r--r--js/slideshow.js12
-rw-r--r--js/slideshowcontrols.js19
-rw-r--r--js/slideshowzoomablepreview.js10
15 files changed, 490 insertions, 370 deletions
diff --git a/js/app.js b/js/app.js
index 49af7110..ea391e4d 100644
--- a/js/app.js
+++ b/js/app.js
@@ -7,6 +7,7 @@ $(document).ready(function () {
Gallery.token = Gallery.utility.getRequestToken();
Gallery.ieVersion = Gallery.utility.getIeVersion();
+ // The first thing to do is to detect if we're on IE
if (Gallery.ieVersion === 'unsupportedIe') {
Gallery.utility.showIeWarning(Gallery.ieVersion);
Gallery.showEmpty();
@@ -17,6 +18,8 @@ $(document).ready(function () {
// Needed to centre the spinner in some browsers
Gallery.resetContentHeight();
+
+ // Get the config, the files and initialise the slideshow
Gallery.showLoading();
$.getJSON(Gallery.utility.buildGalleryUrl('config', '', {}))
.then(function (config) {
@@ -48,58 +51,62 @@ $(document).ready(function () {
$('.album-info-content').slideUp();
});
- $(window).scroll(function () {
- Gallery.view.loadVisibleRows(Gallery.albumMap[Gallery.currentAlbum],
- Gallery.currentAlbum);
- });
- $('#content-wrapper').scroll(function () {
+ // This block loads new rows
+ $('html, #content-wrapper').scroll(function () {
Gallery.view.loadVisibleRows(Gallery.albumMap[Gallery.currentAlbum],
Gallery.currentAlbum);
});
- // A shorter delay avoids redrawing the view in the middle of a previous request, but it
- // may kill baby CPUs
+
var windowWidth = $(window).width();
var windowHeight = $(window).height();
$(window).resize(_.throttle(function () {
+ // This section redraws the photowall
if (windowWidth !== $(window).width()) {
if ($('#emptycontent').is(':hidden')) {
Gallery.view.viewAlbum(Gallery.currentAlbum);
}
- // 320 is the width required for the buttons
Gallery.view.breadcrumb.setMaxWidth($(window).width() - Gallery.buttonsWidth);
windowWidth = $(window).width();
}
+ // This makes sure dropdowns will not be hidden after a window resize
if (windowHeight !== $(window).height()) {
Gallery.resetContentHeight();
var infoContentElement = $('.album-info-content');
- // 150 is the space required for the browser toolbar on some mobile OS
infoContentElement.css('max-height',
$(window).height() - Gallery.browserToolbarHeight);
windowHeight = $(window).height();
}
- }, 250));
+ }, 250)); // A shorter delay avoids redrawing the view in the middle of a previous request,
+ // but it may kill baby CPUs
}
});
+/**
+ * Responsible to refresh the view when we detect a change of location via the browser URL
+ */
window.onhashchange = function () {
"use strict";
- // The hash location is ALWAYS encoded
var currentLocation = window.location.href.split('#')[1] || '';
+ // The hash location is ALWAYS encoded, despite what the browser shows
var path = decodeURIComponent(currentLocation);
+
+ // This section tries to determine if the hash location points to a file or a folder
var albumPath = OC.dirname(path);
if (Gallery.albumMap[path]) {
albumPath = path;
} else if (!Gallery.albumMap[albumPath]) {
albumPath = '';
}
+ // We need to get new files if we've assessed that we've changed folder
if (Gallery.currentAlbum !== null && Gallery.currentAlbum !== albumPath) {
Gallery.getFiles(currentLocation).done(function () {
Gallery.refresh(path, albumPath);
});
} else {
+ // When the gallery is first loaded, the files have already been fetched
Gallery.refresh(path, albumPath);
}
}; \ No newline at end of file
diff --git a/js/eventsource.js b/js/eventsource.js
index f2624f67..28297889 100644
--- a/js/eventsource.js
+++ b/js/eventsource.js
@@ -27,8 +27,7 @@
*
* @param {string} src
* @param {object} [data] to be send as GET
- *
- * @constructs Gallery.EventSource
+ * @constructor
*/
var CustomEventSource = function (src, data) {
var dataStr = '';
diff --git a/js/gallery.js b/js/gallery.js
index 9028c778..67cea338 100644
--- a/js/gallery.js
+++ b/js/gallery.js
@@ -64,7 +64,16 @@
};
// Only use the folder as a GET parameter and not as part of the URL
var url = Gallery.utility.buildGalleryUrl('files', '', params);
- return $.getJSON(url).then(function (/**{albuminfo}*/ data) {
+ return $.getJSON(url).then(function (/**{{albuminfo:Object, files:Array}}*/ data) {
+ /**@type {{
+ * fileid: number,
+ * permissions: number,
+ * path: string,
+ * etag: string
+ * information,
+ * sorting,
+ * error: string
+ * }}*/
var albumInfo = data.albuminfo;
Gallery.config.setAlbumConfig(albumInfo);
// Both the folder and the etag have to match
@@ -72,7 +81,7 @@
&& (albumInfo.etag === albumEtag)) {
Gallery.imageMap = albumCache.imageMap;
} else {
- Gallery.mapFiles(data);
+ Gallery._mapFiles(data);
}
// Restore the previous sorting order for this album
@@ -89,114 +98,6 @@
},
/**
- * Builds the album's model
- *
- * @param {{albuminfo:Array, files:Array}} data
- */
- mapFiles: function (data) {
- Gallery.imageMap = {};
- var image = null;
- var path = null;
- var fileId = null;
- var mimeType = null;
- var mTime = null;
- var etag = null;
- var albumInfo = data.albuminfo;
- var currentLocation = albumInfo.path;
- // This adds a new node to the map for each parent album
- Gallery.mapStructure(currentLocation);
- var files = data.files;
- if (files.length > 0) {
- var subAlbumCache = {};
- var albumCache = Gallery.albumMap[currentLocation]
- = new Album(currentLocation, [], [], OC.basename(currentLocation));
- for (var i = 0; i < files.length; i++) {
- path = files[i].path;
- fileId = files[i].fileid;
- mimeType = files[i].mimetype;
- mTime = files[i].mtime;
- etag = files[i].etag;
-
- image = new GalleryImage(path, path, fileId, mimeType, mTime, etag);
-
- // Determines the folder name for the image
- var dir = OC.dirname(path);
- if (dir === path) {
- dir = '';
- }
- if (dir === currentLocation) {
- // The image belongs to the current album, so we can add it directly
- albumCache.images.push(image);
- } else {
- // The image belongs to a sub-album, so we create a sub-album cache if it
- // doesn't exist and add images to it
- if (!subAlbumCache[dir]) {
- subAlbumCache[dir] = new Album(dir, [], [],
- OC.basename(dir));
- }
- subAlbumCache[dir].images.push(image);
-
- // The sub-album also has to be added to the global map
- if (!Gallery.albumMap[dir]) {
- Gallery.albumMap[dir] = {};
- }
- }
- Gallery.imageMap[image.path] = image;
- }
- // Adds the sub-albums to the current album
- Gallery.mapAlbums(albumCache, subAlbumCache);
-
- // Caches the information which is not already cached
- albumCache.etag = albumInfo.etag;
- albumCache.imageMap = Gallery.imageMap;
- }
- },
-
- /**
- * Adds every album leading the current folder to a global album map
- *
- * Per example, if you have Root/Folder1/Folder2/CurrentFolder then the map will contain:
- * * Root
- * * Folder1
- * * Folder2
- * * CurrentFolder
- *
- * Every time a new location is loaded, the map is completed
- *
- *
- * @param {string} path
- *
- * @returns {Album}
- */
- mapStructure: function (path) {
- if (!Gallery.albumMap[path]) {
- Gallery.albumMap[path] = {};
- // Builds relationships between albums
- if (path !== '') {
- var parent = OC.dirname(path);
- if (parent === path) {
- parent = '';
- }
- Gallery.mapStructure(parent);
- }
- }
- return Gallery.albumMap[path];
- },
-
- /**
- * Adds the sub-albums to the current album
- *
- * @param {Album} albumCache
- * @param {{Album}} subAlbumCache
- */
- mapAlbums: function (albumCache, subAlbumCache) {
- for (var j = 0, keys = Object.keys(subAlbumCache); j <
- keys.length; j++) {
- albumCache.subAlbums.push(subAlbumCache[keys[j]]);
- }
- },
-
- /**
* Sorts albums and images based on user preferences
*/
sorter: function () {
@@ -326,47 +227,7 @@
var owner = saveElement.data('owner');
var name = saveElement.data('name');
var isProtected = saveElement.data('protected');
- Gallery.saveToOwnCloud(remote, Gallery.token, owner, name, isProtected);
- },
-
- /**
- * Saves the folder to a remote ownCloud installation
- *
- * Our location is the remote for the other server
- *
- * @param {string} remote
- * @param {string}token
- * @param {string}owner
- * @param {string}name
- * @param {bool} isProtected
- */
- saveToOwnCloud: function (remote, token, owner, name, isProtected) {
- var location = window.location.protocol + '//' + window.location.host + OC.webroot;
- var isProtectedInt = (isProtected) ? 1 : 0;
- var url = remote + '/index.php/apps/files#' + 'remote=' + encodeURIComponent(location)
- + "&token=" + encodeURIComponent(token) + "&owner=" + encodeURIComponent(owner) +
- "&name=" +
- encodeURIComponent(name) + "&protected=" + isProtectedInt;
-
- if (remote.indexOf('://') > 0) {
- OC.redirect(url);
- } else {
- // if no protocol is specified, we automatically detect it by testing https and
- // http
- // this check needs to happen on the server due to the Content Security Policy
- // directive
- $.get(OC.generateUrl('apps/files_sharing/testremote'),
- {remote: remote}).then(function (protocol) {
- if (protocol !== 'http' && protocol !== 'https') {
- OC.dialogs.alert(t('files_sharing',
- 'No ownCloud installation (7 or higher) found at {remote}',
- {remote: remote}),
- t('files_sharing', 'Invalid ownCloud url'));
- } else {
- OC.redirect(protocol + '://' + url);
- }
- });
- }
+ Gallery._saveToOwnCloud(remote, Gallery.token, owner, name, isProtected);
},
/**
@@ -498,6 +359,158 @@
// Resets the last focused element
document.activeElement.blur();
+ },
+
+ /**
+ * Builds the album's model
+ *
+ * @param {{albuminfo:Object, files:Array}} data
+ * @private
+ */
+ _mapFiles: function (data) {
+ Gallery.imageMap = {};
+ var image = null;
+ var path = null;
+ var fileId = null;
+ var mimeType = null;
+ var mTime = null;
+ var etag = null;
+ var albumInfo = data.albuminfo;
+ var currentLocation = albumInfo.path;
+ // This adds a new node to the map for each parent album
+ Gallery._mapStructure(currentLocation);
+ var files = data.files;
+ if (files.length > 0) {
+ var subAlbumCache = {};
+ var albumCache = Gallery.albumMap[currentLocation]
+ = new Album(currentLocation, [], [], OC.basename(currentLocation));
+ for (var i = 0; i < files.length; i++) {
+ path = files[i].path;
+ fileId = files[i].fileid;
+ mimeType = files[i].mimetype;
+ mTime = files[i].mtime;
+ etag = files[i].etag;
+
+ image = new GalleryImage(path, path, fileId, mimeType, mTime, etag);
+
+ // Determines the folder name for the image
+ var dir = OC.dirname(path);
+ if (dir === path) {
+ dir = '';
+ }
+ if (dir === currentLocation) {
+ // The image belongs to the current album, so we can add it directly
+ albumCache.images.push(image);
+ } else {
+ // The image belongs to a sub-album, so we create a sub-album cache if it
+ // doesn't exist and add images to it
+ if (!subAlbumCache[dir]) {
+ subAlbumCache[dir] = new Album(dir, [], [],
+ OC.basename(dir));
+ }
+ subAlbumCache[dir].images.push(image);
+
+ // The sub-album also has to be added to the global map
+ if (!Gallery.albumMap[dir]) {
+ Gallery.albumMap[dir] = {};
+ }
+ }
+ Gallery.imageMap[image.path] = image;
+ }
+ // Adds the sub-albums to the current album
+ Gallery._mapAlbums(albumCache, subAlbumCache);
+
+ // Caches the information which is not already cached
+ albumCache.etag = albumInfo.etag;
+ albumCache.imageMap = Gallery.imageMap;
+ }
+ },
+
+ /**
+ * Adds every album leading the current folder to a global album map
+ *
+ * Per example, if you have Root/Folder1/Folder2/CurrentFolder then the map will contain:
+ * * Root
+ * * Folder1
+ * * Folder2
+ * * CurrentFolder
+ *
+ * Every time a new location is loaded, the map is completed
+ *
+ *
+ * @param {string} path
+ *
+ * @returns {Album}
+ * @private
+ */
+ _mapStructure: function (path) {
+ if (!Gallery.albumMap[path]) {
+ Gallery.albumMap[path] = {};
+ // Builds relationships between albums
+ if (path !== '') {
+ var parent = OC.dirname(path);
+ if (parent === path) {
+ parent = '';
+ }
+ Gallery._mapStructure(parent);
+ }
+ }
+ return Gallery.albumMap[path];
+ },
+
+ /**
+ * Adds the sub-albums to the current album
+ *
+ * @param {Album} albumCache
+ * @param {{Album}} subAlbumCache
+ * @private
+ */
+ _mapAlbums: function (albumCache, subAlbumCache) {
+ for (var j = 0, keys = Object.keys(subAlbumCache); j <
+ keys.length; j++) {
+ albumCache.subAlbums.push(subAlbumCache[keys[j]]);
+ }
+ },
+
+ /**
+ * Saves the folder to a remote ownCloud installation
+ *
+ * Our location is the remote for the other server
+ *
+ * @param {string} remote
+ * @param {string}token
+ * @param {string}owner
+ * @param {string}name
+ * @param {bool} isProtected
+ * @private
+ */
+ _saveToOwnCloud: function (remote, token, owner, name, isProtected) {
+ var location = window.location.protocol + '//' + window.location.host + OC.webroot;
+ var isProtectedInt = (isProtected) ? 1 : 0;
+ var url = remote + '/index.php/apps/files#' + 'remote=' + encodeURIComponent(location)
+ + "&token=" + encodeURIComponent(token) + "&owner=" + encodeURIComponent(owner) +
+ "&name=" +
+ encodeURIComponent(name) + "&protected=" + isProtectedInt;
+
+ if (remote.indexOf('://') > 0) {
+ OC.redirect(url);
+ } else {
+ // if no protocol is specified, we automatically detect it by testing https and
+ // http
+ // this check needs to happen on the server due to the Content Security Policy
+ // directive
+ $.get(OC.generateUrl('apps/files_sharing/testremote'),
+ {remote: remote}).then(function (protocol) {
+ if (protocol !== 'http' && protocol !== 'https') {
+ OC.dialogs.alert(t('files_sharing',
+ 'No ownCloud installation (7 or higher) found at {remote}',
+ {remote: remote}),
+ t('files_sharing', 'Invalid ownCloud url'));
+ } else {
+ OC.redirect(protocol + '://' + url);
+ }
+ });
+ }
}
};
window.Gallery = Gallery;
diff --git a/js/galleryalbum.js b/js/galleryalbum.js
index 2a2a4a34..26ab8c74 100644
--- a/js/galleryalbum.js
+++ b/js/galleryalbum.js
@@ -21,6 +21,98 @@
};
Album.prototype = {
+ /**
+ * Creates the album, which will include between 1 and 4 images
+ *
+ * * Each album is also a link to open that folder
+ * * An album has a natural size of 200x200 and is comprised of 4 thumbnails which have a
+ * natural size of 200x200 The whole thing gets resized to match the targetHeight
+ * * Thumbnails are checked first in order to make sure that we have something to show
+ *
+ * @param {number} targetHeight Each row has a specific height
+ *
+ * @return {a} The album to be placed on the row
+ */
+ getDom: function (targetHeight) {
+ var album = this;
+
+ return this._getThumbnail().then(function () {
+ var a = $('<a/>').addClass('album').attr('href',
+ '#' + encodeURIComponent(album.path));
+
+ a.append($('<span/>').addClass('album-label').text(album.name));
+
+ a.width(targetHeight);
+ a.height(targetHeight);
+
+ album._fillSubAlbum(targetHeight, a);
+
+ return a;
+ });
+ },
+
+ /**
+ * Fills the row with albums and images
+ *
+ * @param {number} width
+ * @returns {$.Deferred<Gallery.Row>}
+ */
+ getNextRow: function (width) {
+ var numberOfThumbnailsToPreload = 6;
+
+ /**
+ * Add images to the row until it's full
+ *
+ * @todo The number of images to preload should be a user setting
+ *
+ * @param {Album} album
+ * @param {Row} row
+ * @param {Array<Album|GalleryImage>} images
+ *
+ * @returns {$.Deferred<Gallery.Row>}
+ */
+ var addRowElements = function (album, row, images) {
+ if ((album.viewedItems + 5) > album.preloadOffset) {
+ album._preload(numberOfThumbnailsToPreload);
+ }
+
+ var image = images[album.viewedItems];
+ return row.addElement(image).then(function (more) {
+ album.viewedItems++;
+ if (more && album.viewedItems < images.length) {
+ return addRowElements(album, row, images);
+ }
+ return row;
+ });
+ };
+ var items = this.subAlbums.concat(this.images);
+ var row = new Gallery.Row(width, this.requestId);
+ return addRowElements(this, row, items);
+ },
+
+ /**
+ * Returns IDs of thumbnails belonging to the album
+ *
+ * @param {number} count
+ *
+ * @return number[]
+ */
+ getThumbnailIds: function (count) {
+ var ids = [];
+ var items = this.images.concat(this.subAlbums);
+ for (var i = 0; i < items.length && i < count; i++) {
+ ids = ids.concat(items[i].getThumbnailIds(count));
+ }
+
+ return ids;
+ },
+
+ /**
+ * Returns the first thumbnail it finds
+ *
+ * @returns {*}
+ * @private
+ */
_getThumbnail: function () {
if (this.images.length) {
return this.images[0].getThumbnail(true);
@@ -127,7 +219,7 @@
* * An album has a natural size of 200x200 and is comprised of 4 thumbnails which have a
* natural size of 200x200 The whole thing gets resized to match the targetHeight
*
- * @param targetHeight
+ * @param {number} targetHeight
* @param a
* @private
*/
@@ -207,92 +299,6 @@
this.preloadOffset = i;
Thumbnails.loadBatch(fileIds, false);
Thumbnails.loadBatch(squareFileIds, true);
- },
-
- /**
- * Creates the album, which will include between 1 and 4 images
- *
- * * Each album is also a link to open that folder
- * * An album has a natural size of 200x200 and is comprised of 4 thumbnails which have a
- * natural size of 200x200 The whole thing gets resized to match the targetHeight
- * * Thumbnails are checked first in order to make sure that we have something to show
- *
- * @param {number} targetHeight Each row has a specific height
- *
- * @return {a} The album to be placed on the row
- */
- getDom: function (targetHeight) {
- var album = this;
-
- return this._getThumbnail().then(function () {
- var a = $('<a/>').addClass('album').attr('href',
- '#' + encodeURIComponent(album.path));
-
- a.append($('<span/>').addClass('album-label').text(album.name));
-
- a.width(targetHeight);
- a.height(targetHeight);
-
- album._fillSubAlbum(targetHeight, a);
-
- return a;
- });
- },
-
- /**
- * Fills the row with albums and images
- *
- * @param {number} width
- * @returns {$.Deferred<Gallery.Row>}
- */
- getNextRow: function (width) {
- var numberOfThumbnailsToPreload = 6;
-
- /**
- * Add images to the row until it's full
- *
- * @todo The number of images to preload should be a user setting
- *
- * @param {Album} album
- * @param {Row} row
- * @param {Array<Album|GalleryImage>} images
- *
- * @returns {$.Deferred<Gallery.Row>}
- */
- var addRowElements = function (album, row, images) {
- if ((album.viewedItems + 5) > album.preloadOffset) {
- album._preload(numberOfThumbnailsToPreload);
- }
-
- var image = images[album.viewedItems];
- return row.addElement(image).then(function (more) {
- album.viewedItems++;
- if (more && album.viewedItems < images.length) {
- return addRowElements(album, row, images);
- }
- return row;
- });
- };
- var items = this.subAlbums.concat(this.images);
- var row = new Gallery.Row(width, this.requestId);
- return addRowElements(this, row, items);
- },
-
- /**
- * Returns IDs of thumbnails belonging to the album
- *
- * @param {number} count
- *
- * @return number[]
- */
- getThumbnailIds: function (count) {
- var ids = [];
- var items = this.images.concat(this.subAlbums);
- for (var i = 0; i < items.length && i < count; i++) {
- ids = ids.concat(items[i].getThumbnailIds(count));
- }
-
- return ids;
}
};
diff --git a/js/gallerybutton.js b/js/gallerybutton.js
index 0c36df13..f131572c 100644
--- a/js/gallerybutton.js
+++ b/js/gallerybutton.js
@@ -4,6 +4,9 @@ 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;
@@ -17,6 +20,11 @@ GalleryButton.onFileListUpdated = function () {
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 = {};
@@ -49,7 +57,7 @@ $(document).ready(function () {
$('#fileList').on('updated', GalleryButton.onFileListUpdated);
- // toggle for opening shared file list as picture view
+ // Toggle for opening files list as gallery view
GalleryButton.button = $('<div id="openAsFileListButton" class="button">' +
'<img class="svg" src="' + OC.imagePath('core', 'actions/toggle-pictures.svg') + '"' +
'alt="' + t('gallery', 'Picture view') + '"/>' +
diff --git a/js/galleryconfig.js b/js/galleryconfig.js
index 509d5442..8b8b5cdc 100644
--- a/js/galleryconfig.js
+++ b/js/galleryconfig.js
@@ -4,7 +4,7 @@
/**
* Stores the gallery configuration
*
- * @param {{features: *}} config
+ * @param {{features: string[], mediatypes: string[]}} config
* @constructor
*/
var Config = function (config) {
@@ -34,7 +34,15 @@
/**
* Stores the configuration about the current album
*
- * @param albumConfig
+ * @param {{
+ * fileid: number,
+ * permissions: number,
+ * path: string,
+ * etag: string
+ * information,
+ * sorting,
+ * error: string
+ * }} albumConfig
*/
setAlbumConfig: function (albumConfig) {
this.albumPermissions = this._setAlbumPermissions(albumConfig);
@@ -57,7 +65,7 @@
/**
* Saves the list of features which have been enabled in the app
*
- * @param configFeatures
+ * @param {string[]} configFeatures
*
* @returns {Array}
* @private
@@ -80,7 +88,7 @@
/**
* Saves the list of supported media types
*
- * @param mediaTypes
+ * @param {string[]} mediaTypes
*
* @returns {Array}
* @private
@@ -104,7 +112,7 @@
/**
* Determines if we can accept the feature in this browser environment
*
- * @param feature
+ * @param {string} feature
*
* @returns {bool}
* @private
@@ -121,7 +129,7 @@
/**
* Determines if we can accept the media type in this browser environment
*
- * @param mediaType
+ * @param {string} mediaType
*
* @returns {bool}
* @private
@@ -138,9 +146,17 @@
/**
* Saves the permissions for the current album
*
- * @param albumConfig
+ * @param {{
+ * fileid: number,
+ * permissions: number,
+ * path: string,
+ * etag: string
+ * information,
+ * sorting,
+ * error: string
+ * }} albumConfig
*
- * @returns {{fileid: *, permissions: *}}
+ * @returns {{fileid: number, permissions: number}}
* @private
*/
_setAlbumPermissions: function (albumConfig) {
@@ -153,15 +169,41 @@
/**
* Saves the description and copyright information for the current album
*
- * @param {{path, information, description_link, copyright_link}} albumConfig
+ * @param {{
+ * fileid: number,
+ * permissions: number,
+ * path: string,
+ * etag: string
+ * information,
+ * sorting,
+ * error: string
+ * }} albumConfig
*
- * @returns {{}}
+ * @returns {null||{
+ * description: string,
+ * descriptionLink: string,
+ * copyright: string,
+ * copyrightLink: string,
+ * filePath: string,
+ * inherit: bool,
+ * level: number
+ * }}
* @private
*/
_setAlbumInfo: function (albumConfig) {
var albumPath = albumConfig.path;
+
+ /**@type {{
+ * description: string,
+ * description_link: string,
+ * copyright: string,
+ * copyright_link: string,
+ * inherit: bool,
+ * level: number
+ * }}
+ */
var albumInfo = albumConfig.information;
- var params = {};
+ var params = null;
if (!$.isEmptyObject(albumInfo)) {
var docPath = albumPath;
var level = albumInfo.level;
@@ -193,7 +235,15 @@
/**
* Saves the sorting configuration for the current album
*
- * @param {{sorting}} albumConfig
+ * @param {{
+ * fileid: number,
+ * permissions: number,
+ * path: string,
+ * etag: string
+ * information,
+ * sorting,
+ * error: string
+ * }} albumConfig
*
* @returns {{type: string, order: string, albumOrder: string}}
* @private
diff --git a/js/galleryfileaction.js b/js/galleryfileaction.js
index d0bfe5c9..cf222a60 100644
--- a/js/galleryfileaction.js
+++ b/js/galleryfileaction.js
@@ -12,7 +12,7 @@
*
* @param {string} endPoint
* @param {undefined|string} path
- * @param params
+ * @param {Object} params
*
* @returns {string}
*/
@@ -32,7 +32,7 @@
/**
* Registers a file action for each media type
*
- * @param mediaTypes
+ * @param {Array} mediaTypes
*/
register: function (mediaTypes) {
//console.log("enabledPreviewProviders: ", mediaTypes);
@@ -55,7 +55,7 @@
* Builds an array containing all the images we can show in the slideshow
*
* @param {string} filename
- * @param context
+ * @param {Object} context
*/
onView: function (filename, context) {
var imageUrl, downloadUrl;
@@ -118,16 +118,19 @@
}
},
+ /**
+ * Launches the slideshow
+ *
+ * @param {{name:string, url: string, path: string, fallBack: string}[]} images
+ * @param {number} start
+ * @private
+ */
_startSlideshow: function (images, start) {
galleryFileAction.slideShow.setImages(images);
var scrollTop = galleryFileAction.scrollContainer.scrollTop();
// This is only called when the slideshow is stopped
galleryFileAction.slideShow.onStop = function () {
- // Adding to the history will add a new URL every time the slideshow is launched
- /*history.pushState('', document.title,
- window.location.pathname + window.location.search + '#');*/
-
FileList.$fileList.one('updated', function () {
galleryFileAction.scrollContainer.scrollTop(scrollTop);
});
@@ -165,8 +168,8 @@ $(document).ready(function () {
window.galleryFileAction.scrollContainer = $(window);
}
- // We're also asking for a list of supported media types.
- // Media files are retrieved through the Files context
+ // Retrieve the config as well as the list of supported media types.
+ // The list of media files is retrieved when the user clicks on a row
var url = window.galleryFileAction.buildGalleryUrl('config', '', {slideshow: 1});
$.getJSON(url).then(function (config) {
if (!$.isEmptyObject(config.features)) {
diff --git a/js/galleryimage.js b/js/galleryimage.js
index 52e2573e..94d67fbf 100644
--- a/js/galleryimage.js
+++ b/js/galleryimage.js
@@ -56,7 +56,6 @@
* @returns {number}
*/
getThumbnailWidth: function () {
-
// img is a Thumbnail.image
return this.getThumbnail(false).then(function (img) {
if (img) {
@@ -71,6 +70,8 @@
*
* Each image is also a link to start the full screen slideshow
*
+ * @param {number} targetHeight
+ *
* @return {a}
*/
getDom: function (targetHeight) {
@@ -113,4 +114,3 @@
window.GalleryImage = GalleryImage;
})(jQuery, Gallery);
-
diff --git a/js/galleryinfobox.js b/js/galleryinfobox.js
index b43ad221..cb4dc879 100644
--- a/js/galleryinfobox.js
+++ b/js/galleryinfobox.js
@@ -1,5 +1,11 @@
-/* global $, t, Gallery, marked */
-(function () {
+/* global Gallery, marked */
+(function ($, t, Gallery) {
+ "use strict";
+ /**
+ * Shows some information about the current album
+ *
+ * @constructor
+ */
var InfoBox = function () {
this.infoContentElement = $('.album-info-content');
};
@@ -133,4 +139,4 @@
};
Gallery.InfoBox = InfoBox;
-})(); \ No newline at end of file
+})(jQuery, t, Gallery); \ No newline at end of file
diff --git a/js/galleryrow.js b/js/galleryrow.js
index 39251edc..d4e8b627 100644
--- a/js/galleryrow.js
+++ b/js/galleryrow.js
@@ -4,8 +4,8 @@
/**
* Creates a row
*
- * @param targetWidth
- * @param requestId
+ * @param {number} targetWidth
+ * @param {number} requestId
* @constructor
*/
var Row = function (targetWidth, requestId) {
@@ -17,16 +17,6 @@
Row.prototype = {
/**
- * Calculates if the row is full
- *
- * @returns {boolean}
- * @private
- */
- _isFull: function () {
- return this.width > this.targetWidth;
- },
-
- /**
* Adds sub-albums and images to the row until it's full
*
* @param {Album|GalleryImage} element
@@ -63,15 +53,21 @@
return def.promise();
},
+ /**
+ * Creates the row element in the DOM
+ *
+ * @returns {*}
+ */
getDom: function () {
var scaleRatio = (this.width > this.targetWidth) ? this.targetWidth / this.width : 1;
var targetHeight = 200 * scaleRatio;
targetHeight = targetHeight.toFixed(3);
var row = $('<div/>').addClass('row loading');
/**
- * @param row
- * @param {Gallery.Image[]} items
- * @param i
+ * @param {*} row
+ * @param {GalleryImage[]|Album[]} items
+ * @param {number} i
+ *
* @returns {*}
*/
var addImageToDom = function (row, items, i) {
@@ -85,6 +81,16 @@
});
};
return addImageToDom(row, this.items, 0);
+ },
+
+ /**
+ * Calculates if the row is full
+ *
+ * @returns {boolean}
+ * @private
+ */
+ _isFull: function () {
+ return this.width > this.targetWidth;
}
};
diff --git a/js/galleryutility.js b/js/galleryutility.js
index 105b0eb6..e51b5ace 100644
--- a/js/galleryutility.js
+++ b/js/galleryutility.js
@@ -1,5 +1,6 @@
-/* global OC, $, t, Gallery, oc_requesttoken */
-(function () {
+/* global Gallery */
+(function ($, OC, t, oc_requesttoken, Gallery) {
+ "use strict";
/**
* Contains utility methods
*
@@ -14,7 +15,7 @@
/**
* Detects if the browser is a recent or an old version of Internet Explorer
*
- * @returns {*}
+ * @returns {string|bool}
*/
getIeVersion: function () {
// Blocking IE8
@@ -70,7 +71,7 @@
},
/**
- * Returns the token alowing access to files
+ * Returns the token allowing access to files
*
* @returns {string}
*/
@@ -209,4 +210,4 @@
};
Gallery.Utility = Utility;
-})();
+})(jQuery, OC, t, oc_requesttoken, Gallery);
diff --git a/js/galleryview.js b/js/galleryview.js
index 75b35b6c..5d3ae12e 100644
--- a/js/galleryview.js
+++ b/js/galleryview.js
@@ -86,7 +86,7 @@
if (albumPath !== Gallery.currentAlbum) {
this.loadVisibleRows.loading = false;
Gallery.currentAlbum = albumPath;
- this.setupButtons(albumPath);
+ this._setupButtons(albumPath);
}
Gallery.albumMap[albumPath].viewedItems = 0;
@@ -105,65 +105,6 @@
},
/**
- * Sets up all the buttons of the interface
- *
- * @param {string} albumPath
- */
- setupButtons: function (albumPath) {
- this.shareButtonSetup(albumPath);
- this.infoButtonSetup();
-
- this.breadcrumb = new Gallery.Breadcrumb(albumPath);
- this.breadcrumb.setMaxWidth($(window).width() - Gallery.buttonsWidth);
-
- var currentSort = Gallery.config.albumSorting;
- this.sortControlsSetup(currentSort.type, currentSort.order);
- Gallery.albumMap[Gallery.currentAlbum].images.sort(Gallery.utility.sortBy(currentSort.type,
- currentSort.order));
- Gallery.albumMap[Gallery.currentAlbum].subAlbums.sort(Gallery.utility.sortBy('name',
- currentSort.albumOrder));
- },
-
- /**
- * Shows or hides the share button depending on if we're in a public gallery or not
- *
- * @param {string} albumPath
- */
- shareButtonSetup: function (albumPath) {
- var shareButton = $('#share-button');
- if (albumPath === '' || Gallery.token) {
- shareButton.hide();
- } else {
- shareButton.show();
- }
- },
-
- /**
- * Shows or hides the info button based on the information we've received from the server
- */
- infoButtonSetup: function () {
- var infoButton = $('#album-info-button');
- infoButton.find('span').hide();
- var infoContentElement = $('.album-info-content');
- infoContentElement.slideUp();
- infoContentElement.css('max-height', $(window).height() - Gallery.browserToolbarHeight);
- var albumInfo = Gallery.config.albumInfo;
- if (Gallery.config.albumError) {
- infoButton.hide();
- var text = '<strong>' + t('gallery', 'Configuration error') + '</strong></br>' +
- Gallery.config.albumError.message + '</br></br>';
- Gallery.utility.showHtmlNotification(text, 7);
- } else if ($.isEmptyObject(albumInfo)) {
- infoButton.hide();
- } else {
- infoButton.show();
- if (albumInfo.inherit !== 'yes' || albumInfo.level === 0) {
- infoButton.find('span').delay(1000).slideDown();
- }
- }
- },
-
- /**
* Manages the sorting interface
*
* @param {string} sortType
@@ -276,6 +217,69 @@
this.loadVisibleRows.loading = showRows(album);
return this.loadVisibleRows.loading;
}
+ },
+
+ /**
+ * Sets up all the buttons of the interface
+ *
+ * @param {string} albumPath
+ * @private
+ */
+ _setupButtons: function (albumPath) {
+ this._shareButtonSetup(albumPath);
+ this._infoButtonSetup();
+
+ this.breadcrumb = new Gallery.Breadcrumb(albumPath);
+ this.breadcrumb.setMaxWidth($(window).width() - Gallery.buttonsWidth);
+
+ var currentSort = Gallery.config.albumSorting;
+ this.sortControlsSetup(currentSort.type, currentSort.order);
+ Gallery.albumMap[Gallery.currentAlbum].images.sort(Gallery.utility.sortBy(currentSort.type,
+ currentSort.order));
+ Gallery.albumMap[Gallery.currentAlbum].subAlbums.sort(Gallery.utility.sortBy('name',
+ currentSort.albumOrder));
+ },
+
+ /**
+ * Shows or hides the share button depending on if we're in a public gallery or not
+ *
+ * @param {string} albumPath
+ * @private
+ */
+ _shareButtonSetup: function (albumPath) {
+ var shareButton = $('#share-button');
+ if (albumPath === '' || Gallery.token) {
+ shareButton.hide();
+ } else {
+ shareButton.show();
+ }
+ },
+
+ /**
+ * Shows or hides the info button based on the information we've received from the server
+ *
+ * @private
+ */
+ _infoButtonSetup: function () {
+ var infoButton = $('#album-info-button');
+ infoButton.find('span').hide();
+ var infoContentElement = $('.album-info-content');
+ infoContentElement.slideUp();
+ infoContentElement.css('max-height', $(window).height() - Gallery.browserToolbarHeight);
+ var albumInfo = Gallery.config.albumInfo;
+ if (Gallery.config.albumError) {
+ infoButton.hide();
+ var text = '<strong>' + t('gallery', 'Configuration error') + '</strong></br>' +
+ Gallery.config.albumError.message + '</br></br>';
+ Gallery.utility.showHtmlNotification(text, 7);
+ } else if ($.isEmptyObject(albumInfo)) {
+ infoButton.hide();
+ } else {
+ infoButton.show();
+ if (albumInfo.inherit !== 'yes' || albumInfo.level === 0) {
+ infoButton.find('span').delay(1000).slideDown();
+ }
+ }
}
};
diff --git a/js/slideshow.js b/js/slideshow.js
index ec7d48ab..428246f0 100644
--- a/js/slideshow.js
+++ b/js/slideshow.js
@@ -25,7 +25,7 @@
* Initialises the slideshow
*
* @param {bool} autoPlay
- * @param {int} interval
+ * @param {number} interval
*/
init: function (autoPlay, interval) {
// FIXME: This should come from the configuration
@@ -73,7 +73,7 @@
* Refreshes the slideshow's data
*
* @param {{name:string, url: string, path: string, fallBack: string}[]} images
- * @param autoPlay
+ * @param {bool} autoPlay
*/
setImages: function (images, autoPlay) {
this._hideImage();
@@ -84,7 +84,7 @@
/**
* Launches the slideshow
*
- * @param index
+ * @param {number} index
*
* @returns {*}
*/
@@ -147,7 +147,7 @@
/**
* Loads the image to show in the slideshow and preloads the next one
*
- * @param preview
+ * @param {Object} preview
*
* @returns {*}
*/
@@ -196,7 +196,7 @@
/**
* Sends the current image as a download
*
- * @param downloadUrl
+ * @param {string} downloadUrl
*
* @returns {boolean}
*/
@@ -253,6 +253,7 @@
/**
* Automatically fades the controls after 3 seconds
+ *
* @private
*/
_initControlsAutoFader: function () {
@@ -282,6 +283,7 @@
/**
* Hides the current image (before loading the next)
+ *
* @private
*/
_hideImage: function () {
diff --git a/js/slideshowcontrols.js b/js/slideshowcontrols.js
index bea5f264..face0753 100644
--- a/js/slideshowcontrols.js
+++ b/js/slideshowcontrols.js
@@ -4,10 +4,10 @@
/**
* Button and key controls for the slideshow
*
- * @param {object} slideshow
+ * @param {Object} slideshow
* @param {*} container
- * @param {object} zoomablePreview
- * @param {int} interval
+ * @param {Object} zoomablePreview
+ * @param {number} interval
* @constructor
*/
var Controls = function (slideshow, container, zoomablePreview, interval) {
@@ -185,6 +185,7 @@
/**
* Starts the slideshow timer
+ *
* @private
*/
_setTimeout: function () {
@@ -197,6 +198,7 @@
/**
* Stops the slideshow timer
+ *
* @private
*/
_clearTimeout: function () {
@@ -210,6 +212,7 @@
/**
* Starts the times slideshow
+ *
* @private
*/
_play: function () {
@@ -220,6 +223,7 @@
/**
* Pauses the timed slideshow
+ *
* @private
*/
_pause: function () {
@@ -230,6 +234,7 @@
/**
* Shows the play or pause button depending on circumstances
+ *
* @private
*/
_playPauseButtonToggle: function () {
@@ -239,6 +244,7 @@
/**
* Shows the next slide
+ *
* @private
*/
_next: function () {
@@ -255,6 +261,7 @@
/**
* Shows the previous slide
+ *
* @private
*/
_previous: function () {
@@ -269,7 +276,7 @@
/**
* Shows a new image in the slideshow and preloads the next in the list
*
- * @param imageId
+ * @param {number} imageId
* @private
*/
_updateSlideshow: function (imageId) {
@@ -281,6 +288,7 @@
/**
* Exits the slideshow by going back in history
+ *
* @private
*/
_exit: function () {
@@ -297,6 +305,7 @@
/**
* Launches fullscreen mode if the browser supports it
+ *
* @private
*/
_fullScreenToggle: function () {
@@ -305,6 +314,7 @@
/**
* Resizes the image to its original size
+ *
* @private
*/
_zoomToOriginal: function () {
@@ -313,6 +323,7 @@
/**
* Fits the image in the browser window
+ *
* @private
*/
_zoomToFit: function () {
diff --git a/js/slideshowzoomablepreview.js b/js/slideshowzoomablepreview.js
index 6ac29a34..5c17be85 100644
--- a/js/slideshowzoomablepreview.js
+++ b/js/slideshowzoomablepreview.js
@@ -4,7 +4,7 @@
/**
* Creates a zoomable preview
*
- * @param container
+ * @param {*} container
* @constructor
*/
var ZoomablePreview = function (container) {
@@ -38,8 +38,8 @@
/**
* Launches the Bigshot zoomable preview
*
- * @param image
- * @param currentImage
+ * @param {*} image
+ * @param {number} currentImage
* @param {string} mimeType
*/
startBigshot: function (image, currentImage, mimeType) {
@@ -182,6 +182,7 @@
/**
* Determines whether the image should be shown at its original size or if it should fill
* the screen
+ *
* @private
*/
_zoomDecider: function () {
@@ -196,6 +197,7 @@
/**
* Resets the image to its original zoomed size
+ *
* @private
*/
_resetZoom: function () {
@@ -221,6 +223,7 @@
/**
* Starts the fullscreen previews
+ *
* @private
*/
_fullScreenStart: function () {
@@ -236,6 +239,7 @@
/**
* Stops the fullscreen previews
+ *
* @private
*/
_fullScreenExit: function () {