From a355c6d3700c45cf0d318dd604746b535d0424c2 Mon Sep 17 00:00:00 2001 From: Olivier Paroz Date: Sat, 12 Sep 2015 13:24:29 +0200 Subject: Make background toggle button optional Fixes #226 --- js/galleryfileaction.js | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'js/galleryfileaction.js') diff --git a/js/galleryfileaction.js b/js/galleryfileaction.js index 8b140961..b08b9b62 100644 --- a/js/galleryfileaction.js +++ b/js/galleryfileaction.js @@ -2,7 +2,7 @@ (function ($, OC, OCA, oc_requesttoken) { "use strict"; var galleryFileAction = { - config: null, + features: [], mediaTypes: {}, scrollContainer: null, slideShow: null, @@ -51,6 +51,25 @@ } }, + /** + * Prepares the features array + * + * @param configFeatures + * @returns {Array} + */ + buildFeaturesList: function (configFeatures) { + var features = []; + var feature = null; + if (!$.isEmptyObject(configFeatures)) { + for (var i = 0, keys = Object.keys(configFeatures); i < keys.length; i++) { + feature = keys[i]; + features.push(feature); + } + } + + window.galleryFileAction.features = features; + }, + /** * Builds an array containing all the images we can show in the slideshow * @@ -114,10 +133,13 @@ if ($.isEmptyObject(galleryFileAction.slideShow)) { galleryFileAction.slideShow = new SlideShow(); - $.when(galleryFileAction.slideShow.init(false, null)) - .then(function () { - galleryFileAction._startSlideshow(images, start); - }); + $.when(galleryFileAction.slideShow.init( + false, + null, + window.galleryFileAction.features + )).then(function () { + galleryFileAction._startSlideshow(images, start); + }); } else { galleryFileAction._startSlideshow(images, start); } @@ -177,9 +199,7 @@ $(document).ready(function () { // The list of media files is retrieved when the user clicks on a row var url = window.galleryFileAction.buildGalleryUrl('config', '', {extramediatypes: 1}); $.getJSON(url).then(function (config) { - if (!$.isEmptyObject(config.features)) { - window.galleryFileAction.config = config.features; - } + window.galleryFileAction.buildFeaturesList(config.features); window.galleryFileAction.register(config.mediatypes); }); }); -- cgit v1.2.3