From cd282ee58b2893790d06ce40a8b02c65481abbeb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Sat, 2 Aug 2014 10:36:28 +0200 Subject: [PATCH] =?utf8?q?Optimisation=20du=20chargement=20des=20vignettes?= =?utf8?q?=20juxtapos=C3=A9es=20=C3=A0=20celle=20affich=C3=A9e.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- skins/getPhotoContextInfos.py | 1 + skins/photo_film_viewer.js | 39 +++++++++++++++++++++++++++++++++++ skins/photo_layout_macros.pt | 5 +++-- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/skins/getPhotoContextInfos.py b/skins/getPhotoContextInfos.py index 71b4aea..b070a83 100755 --- a/skins/getPhotoContextInfos.py +++ b/skins/getPhotoContextInfos.py @@ -37,6 +37,7 @@ for i, p in enumerate(portfolio.listNearestFolderContents(contentFilter={'portal ,'href': purl ,'thumbSize':size ,'title' : p.Title() + ,'displayed' : p == context ,'className': (selected and 'selected' or '') + ((p == context) and ' displayed' or '') , 'index': i } diff --git a/skins/photo_film_viewer.js b/skins/photo_film_viewer.js index 0a1cab9..3140763 100644 --- a/skins/photo_film_viewer.js +++ b/skins/photo_film_viewer.js @@ -5,6 +5,7 @@ Licence Creative Commons http://creativecommons.org/licenses/by-nc/2.0/ */ var FilmSlider; +var s; (function(){ @@ -16,6 +17,7 @@ var DEFAULT_IMAGE_SIZES = [500, 600, 800]; FilmSlider = function(filmBar, slider, ctxInfos, image, toolbar, breadcrumbs) { var thisSlider = this; + s = this; this.filmBar = filmBar; this.filmBarWidth = getObjectWidth(this.filmBar); var film = filmBar.firstChild; @@ -289,6 +291,7 @@ FilmSlider.prototype.addEventListeners = function() { addListener(this.toolbar, 'click', function(evt){thisSlider.toolbarClickHandler(evt);}); addListener(window, 'load', function(evt){thisSlider.fitToScreen(evt);}); addListener(window, 'load', function(evt){thisSlider._checkSizeAfterLoad(evt);}); + addListener(window, 'load', function(evt){thisSlider.startThumbnailsLoadQueue(evt);}); // dd listeners addListener(this.slider, 'mousedown', this.ddHandlers.down); @@ -727,6 +730,42 @@ FilmSlider.prototype.updateBreadcrumbs = function(url, title) { } }; +FilmSlider.prototype.startThumbnailsLoadQueue = function(evt) { + var thumbnails = this.film.getElementsByTagName('img'); + this.thumbnailsLoadingOrder = []; + var leftSize = this.center; + var rightSize = thumbnails.length - this.center - 1; + var i; + for (i=1 ; i<=Math.min(leftSize, rightSize) ; i++) { + this.thumbnailsLoadingOrder.push(thumbnails[this.center + i]); + this.thumbnailsLoadingOrder.push(thumbnails[this.center - i]); + } + if (leftSize > rightSize) { + for (i = this.center - rightSize - 1 ; i >= 0 ; i--) { + console.log(i); + this.thumbnailsLoadingOrder.push(thumbnails[i]); + } + } + else if (leftSize < rightSize) { + for (i = this.center + leftSize ; i < thumbnails.length ; i++) { + this.thumbnailsLoadingOrder.push(thumbnails[i]); + } + } + var next = this.thumbnailsLoadingOrder.shift(); + var self = this; + addListener(next, 'load', function(evt){self._loadNextThumb(evt);}); + next.src = next.parentNode.href + '/getThumbnail'; +}; + +FilmSlider.prototype._loadNextThumb = function(evt) { + var next = this.thumbnailsLoadingOrder.shift(); + if (!next) {return;} + var self = this; + addListener(next, 'load', function(evt){self._loadNextThumb(evt);}); + next.src = next.parentNode.href + '/getThumbnail'; +}; + + FilmSlider.prototype.startSlideShow = function() { this.slideShowSlide = this.pendingSlideShowSlide = this.selectedSlide; return this.slideShowSlide.href; diff --git a/skins/photo_layout_macros.pt b/skins/photo_layout_macros.pt index 0dccaa0..21616da 100644 --- a/skins/photo_layout_macros.pt +++ b/skins/photo_layout_macros.pt @@ -133,14 +133,15 @@
- +