X-Git-Url: https://scm.cri.mines-paristech.fr/git/Portfolio.git/blobdiff_plain/e747d406c2b625e3bc7f91c0837315fc00f807f5..320341dca66e5887ba1da118138693fc161074a0:/skins/photo_film_viewer.js?ds=inline diff --git a/skins/photo_film_viewer.js b/skins/photo_film_viewer.js index ddd73e1..ff8d61e 100644 --- a/skins/photo_film_viewer.js +++ b/skins/photo_film_viewer.js @@ -73,11 +73,16 @@ FilmSlider = function(filmBar, slider, ctxInfos, image, toolbar, breadcrumbs) { 'out' : function(evt){thisSlider.mouseOutHandler(evt);} }; - this.resizeSlider(); + if (browser.isMobile) { + this.rail.className = 'hidden'; + } + else { + this.resizeSlider(); + } this.addEventListeners(); }; - +if (!browser.isMobile) { FilmSlider.prototype.resizeSlider = function(evt) { var filmBarWidth = this.filmBarWidth; if (!filmBarWidth) { return; } @@ -105,6 +110,12 @@ FilmSlider.prototype.resizeSlider = function(evt) { this.initialized = true; } }; +} + +else { + // pas de barre de scroll horizontal pour les tablettes + FilmSlider.prototype.resizeSlider = function(evt) {}; +} FilmSlider.prototype._checkSizeAfterLoad = function(evt) { this._barSizes = []; @@ -148,7 +159,12 @@ FilmSlider.prototype.fitToScreen = function(evt) { FilmSlider.prototype._fitToScreen = function(evt) { var wh = getWindowHeight(); + if (!browser.isMobile) { var rb = getObjectTop(this.rail) + getObjectHeight(this.rail); // rail bottom + } + else { + var rb = getObjectTop(this.filmBar) + getObjectHeight(this.filmBar); // film bottom + } var delta = wh - rb; var sh = getObjectHeight(this.stretchable); var newSize = sh + delta; @@ -261,6 +277,11 @@ FilmSlider.prototype.addEventListeners = function() { else if (browser.isIE6up) { addListener(this.filmBar, 'mousewheel', function(evt){thisSlider.mouseWheelHandler(evt);}); } + if (browser.isMobile) { + this.filmBar.addEventListener('touchstart', function(evt){thisSlider.touchStartHandler(evt);}, false); + this.filmBar.addEventListener('touchmove', function(evt){thisSlider.touchMoveHandler(evt);}, false); + this.filmBar.addEventListener('touchend', function(evt){thisSlider.touchEndHandler(evt);}, false); + } addListener(document, 'keydown', function(evt){thisSlider.keyDownHandler(evt);}); addListener(document, 'keypress', function(evt){thisSlider.keyPressHandler(evt);}); @@ -564,6 +585,21 @@ else if (browser.isIE6up) { }; } +FilmSlider.prototype.touchStartHandler = function(evt) { + this.filmStartX = parseInt(this.film.style.left, 10); + this.touchStartX = evt.pageX; +}; + +FilmSlider.prototype.touchMoveHandler = function(evt) { + var delta = this.touchStartX - evt.pageX; + this.film.style.left = String(this.filmStartX - delta) + 'px'; +}; + +FilmSlider.prototype.touchEndHandler = function(evt) { + this.touchStartX = undefined; +}; + + FilmSlider.prototype.keyDownHandler = function(evt) { evt = getEventObject(evt); switch (evt.keyCode) { @@ -604,13 +640,13 @@ FilmSlider.prototype.populateViewer = function(req) { break; case 'imageattributes' : var link = this.buttons.back_to_portfolio.parentNode; - link.href = element.getAttribute('backToContextUrl'); + link.href = element.getAttribute('back_to_context_url'); link = this.buttons.show_buyable.parentNode; var buyable = element.getAttribute('buyable'); if(buyable === 'True') { link.className = null; } else if(buyable === 'False') { link.className = 'hidden'; } this.image.alt = element.getAttribute('alt'); - this.updateBreadcrumbs(element.getAttribute('lastBcUrl'), + this.updateBreadcrumbs(element.getAttribute('last_bc_url'), element.getAttribute('img_id')); break; }