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
path: root/js
diff options
context:
space:
mode:
authorOlivier Paroz <github@oparoz.com>2015-06-26 04:19:34 +0300
committerOlivier Paroz <github@oparoz.com>2015-06-26 04:19:34 +0300
commitbc5c176fb25bdaf0d74f3576d425c69262ab86d8 (patch)
tree18659bba8d2834096f9fcb5991978ecacd8fac01 /js
parent1b32faf94c023ecb43a05823b6dfa8d76cd9bf37 (diff)
Make native SVG support optional
Also made the app quicker by removing an HTTP request :)
Diffstat (limited to 'js')
-rw-r--r--js/app.js13
-rw-r--r--js/gallery.js17
-rw-r--r--js/galleryconfig.js23
-rw-r--r--js/galleryfileaction.js17
4 files changed, 34 insertions, 36 deletions
diff --git a/js/app.js b/js/app.js
index ba377a3e..0c3068cd 100644
--- a/js/app.js
+++ b/js/app.js
@@ -21,16 +21,9 @@ $(document).ready(function () {
$.getJSON(Gallery.utility.buildGalleryUrl('config', '', {}))
.then(function (config) {
Gallery.config = new Gallery.Config(config);
- $.getJSON(Gallery.utility.buildGalleryUrl('mediatypes', '', {}))
- .then(function (mediaTypes) {
- //console.log('mediaTypes', mediaTypes);
- Gallery.mediaTypes = mediaTypes;
- })
- .then(function () {
- Gallery.getFiles().then(function () {
- window.onhashchange();
- });
- });
+ Gallery.getFiles().then(function () {
+ window.onhashchange();
+ });
});
$('#openAsFileListButton').click(function () {
diff --git a/js/gallery.js b/js/gallery.js
index fb4079ed..6ae54ed6 100644
--- a/js/gallery.js
+++ b/js/gallery.js
@@ -1,6 +1,5 @@
/* global OC, $, t, Album, GalleryImage, SlideShow, oc_requesttoken */
var Gallery = {};
-Gallery.mediaTypes = {};
Gallery.images = [];
Gallery.currentAlbum = null;
Gallery.config = {};
@@ -11,20 +10,6 @@ Gallery.appName = 'galleryplus';
Gallery.token = undefined;
/**
- * Returns a list of supported media types
- *
- * @returns {string}
- */
-Gallery.getMediaTypes = function () {
- var types = '';
- for (var i = 0, keys = Object.keys(Gallery.mediaTypes); i < keys.length; i++) {
- types += keys[i] + ';';
- }
-
- return types.slice(0, -1);
-};
-
-/**
* Builds a map of the albums located in the current folder
*
* @param {string} path
@@ -84,7 +69,7 @@ Gallery.getFiles = function () {
}
var params = {
location: currentLocation,
- mediatypes: Gallery.getMediaTypes(),
+ mediatypes: Gallery.config.getMediaTypes(),
features: Gallery.config.galleryFeatures,
etag: albumEtag
};
diff --git a/js/galleryconfig.js b/js/galleryconfig.js
index b76bd670..ae8d57a8 100644
--- a/js/galleryconfig.js
+++ b/js/galleryconfig.js
@@ -7,11 +7,14 @@
* @constructor
*/
var Config = function (config) {
- this.galleryFeatures = this.setGalleryFeatures(config);
+ this.galleryFeatures = this.setGalleryFeatures(config.features);
+ this.mediaTypes = config.mediatypes;
};
Config.prototype = {
galleryFeatures: [],
+ mediaTypes: {},
+ cachedMediaTypesString: '',
albumPermissions: null,
albumInfo: null,
albumSorting: null,
@@ -39,6 +42,24 @@
},
/**
+ * Returns the list of supported media types in a string
+ *
+ * @returns {string}
+ */
+ getMediaTypes: function () {
+ if (this.cachedMediaTypesString === '') {
+ var types = '';
+ for (var i = 0, keys = Object.keys(this.mediaTypes); i < keys.length; i++) {
+ types += keys[i] + ';';
+ }
+
+ this.cachedMediaTypesString = types.slice(0, -1);
+ }
+
+ return this.cachedMediaTypesString;
+ },
+
+ /**
* Stores the configuration about the current album
*
* @param albumConfig
diff --git a/js/galleryfileaction.js b/js/galleryfileaction.js
index 30a71a81..7ff9d3bf 100644
--- a/js/galleryfileaction.js
+++ b/js/galleryfileaction.js
@@ -63,10 +63,10 @@ var galleryFileAction = {
var height = Math.floor(screen.height * window.devicePixelRatio);
/* Find value of longest edge. */
- var longEdge = Math.max( width, height );
+ var longEdge = Math.max(width, height);
/* Find the next larger image size. */
- if ( longEdge % 100 !== 0 ){
+ if (longEdge % 100 !== 0) {
longEdge = ( longEdge + 100 ) - ( longEdge % 100 );
}
@@ -118,14 +118,13 @@ $(document).ready(function () {
return true;
}
- var url = galleryFileAction.buildGalleryUrl('config', '', {});
+ // We're also asking for a list of supported media types.
+ // Media files are retrieved through the Files context
+ var url = galleryFileAction.buildGalleryUrl('config', '', {slideshow: 1});
$.getJSON(url).then(function (config) {
- if (config) {
- galleryFileAction.config = config;
+ if (!$.isEmptyObject(config.features)) {
+ galleryFileAction.config = config.features;
}
- url = galleryFileAction.buildGalleryUrl('mediatypes', '', {slideshow: 1});
- // We're asking for a list of supported media types.
- // Media files are retrieved through the Files context
- $.getJSON(url, {}, galleryFileAction.register);
+ galleryFileAction.register(config.mediatypes);
});
});