X-Git-Url: https://svn.cri.ensmp.fr/git/Portfolio.git/blobdiff_plain/ac93b62d919ba13d13ec3f5f2189776093483e53..dc502e53f9f6081d3c2bc4e9991feffcd60c15e1:/skins/photo_film_viewer.js?ds=sidebyside diff --git a/skins/photo_film_viewer.js b/skins/photo_film_viewer.js index 1ad17ce..16ffb88 100644 --- a/skins/photo_film_viewer.js +++ b/skins/photo_film_viewer.js @@ -5,7 +5,7 @@ Licence Creative Commons http://creativecommons.org/licenses/by-nc/2.0/ */ var FilmSlider; - +var s; (function(){ var keyLeft = 37, keyRight = 39; @@ -16,6 +16,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; @@ -146,10 +147,11 @@ FilmSlider.prototype._checkSize = function(evt) { FilmSlider.prototype._checkSizeStability = function(evt) { var self = this; var i; + var checkAgain = function(evt){self._checkSizeStability();}; for (i=0 ; i dispHeight) { + ratio = dispHeight / imgHeight; + imgWidth = imgWidth * ratio; + imgHeight = dispHeight; + } + if (imgWidth > dispWidth) { + ratio = dispWidth / imgWidth; + imgHeight = imgHeight * ratio; + imgWidth = dispWidth; + } + this.image.style.visibility = 'hidden'; this.image.src = this.pendingImage.src; - this.image.width = this.pendingImage.width; - this.image.height = this.pendingImage.height; + this.image.width = imgWidth; + this.image.height = imgHeight; this.image.style.visibility = 'visible'; if (this.selectedSlideInSelection) { this.image.parentNode.className = 'selected'; } else { this.image.parentNode.className = ''; } @@ -696,11 +772,47 @@ FilmSlider.prototype.refreshImage = function() { FilmSlider.prototype.updateBreadcrumbs = function(url, title) { if (this.hasBreadcrumbs) { - this.lastBCElement.href = element.getAttribute('lastBcUrl'); - this.lastBCElement.innerHTML = element.getAttribute('img_id'); + this.lastBCElement.href = url; + this.lastBCElement.innerHTML = title; } }; +FilmSlider.prototype.startThumbnailsLoadQueue = function(evt) { + var thumbnails = this.film.getElementsByTagName('img'); + if (thumbnails.length === 1) { return; } + 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--) { + this.thumbnailsLoadingOrder.push(thumbnails[i]); + } + } + else if (leftSize < rightSize) { + for (i = this.center + leftSize + 1 ; 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 = this.translateImgUrl(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 = this.translateImgUrl(next.parentNode.href) + '/getThumbnail'; +}; + + FilmSlider.prototype.startSlideShow = function() { this.slideShowSlide = this.pendingSlideShowSlide = this.selectedSlide; return this.slideShowSlide.href;