From 5ac3ed9f15bb1486be3906db70f35c66c541d2a8 Mon Sep 17 00:00:00 2001 From: Olivier Paroz Date: Sun, 5 Jul 2015 19:49:50 +0200 Subject: Fix slideshow template loading race condition * Load the slideshow only when needed on the Files app * Load the slideshow at init time in the Gallery app --- js/galleryfileaction.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'js/galleryfileaction.js') diff --git a/js/galleryfileaction.js b/js/galleryfileaction.js index 53423cdd..9fb5a3ad 100644 --- a/js/galleryfileaction.js +++ b/js/galleryfileaction.js @@ -1,5 +1,5 @@ /* global oc_requesttoken, FileList, SlideShow */ -(function (OC ,OCA, $, oc_requesttoken) { +(function (OC, OCA, $, oc_requesttoken) { "use strict"; var galleryFileAction = { config: null, @@ -108,10 +108,17 @@ } if ($.isEmptyObject(galleryFileAction.slideShow)) { - galleryFileAction.slideShow = new SlideShow($('#slideshow')); - galleryFileAction.slideShow.init(false, null); + galleryFileAction.slideShow = new SlideShow(); + $.when(galleryFileAction.slideShow.init(false, null)) + .then(function () { + galleryFileAction._startSlideshow(images, start); + }); + } else { + galleryFileAction._startSlideshow(images, start); } + }, + _startSlideshow: function (images, start) { galleryFileAction.slideShow.setImages(images); var scrollTop = galleryFileAction.scrollContainer.scrollTop(); @@ -141,7 +148,7 @@ }; window.galleryFileAction = galleryFileAction; -}(OC ,OCA, jQuery, oc_requesttoken)); +}(OC, OCA, jQuery, oc_requesttoken)); $(document).ready(function () { "use strict"; -- cgit v1.2.3