X-Git-Url: https://scm.cri.minesparis.psl.eu/git/Portfolio.git/blobdiff_plain/174995bb4169e32216998895a17afb2097cd64ab..e73353500c67453ef9663d67eaeee7dd46c358ee:/skins/photo_film_viewer.js?ds=sidebyside diff --git a/skins/photo_film_viewer.js b/skins/photo_film_viewer.js deleted file mode 100644 index 2ebe6ca..0000000 --- a/skins/photo_film_viewer.js +++ /dev/null @@ -1,668 +0,0 @@ -/* -copyright 2008-2014 Benoit Pin - Centre de recherche en informatique - MINES ParisTech -http://plinn.org -Licence Creative Commons http://creativecommons.org/licenses/by-nc/2.0/ -*/ - -var FilmSlider; - -(function(){ - -var keyLeft = 37, keyRight = 39; -var isTextMime = /^text\/.+/i; -var isAddToSelection = /.*\/add_to_selection$/; -var imgRequestedSize = /size=(\d+)/; -var DEFAULT_IMAGE_SIZES = [500, 600, 800]; - -FilmSlider = function(filmBar, slider, ctxInfos, image, toolbar, breadcrumbs) { - var thisSlider = this; - this.filmBar = filmBar; - var film = filmBar.firstChild; - if (film.nodeType === 3) { film = film.nextSibling; } - this.film = film; - this.slider = slider; - this.rail = slider.parentNode; - this.sliderSpeedRatio = undefined; - this.sliderRatio = undefined; - this.selectedSlide = undefined; - this.selectedSlideInSelection = undefined; - this.cartSlide = document.getElementById('cart_slide'); - this.image = image; - this.stretchable = image.parentNode; - this.viewMode = 'medium'; - - this.buttons = []; - this.toolbar = toolbar; - if (breadcrumbs) { - var bcElements = breadcrumbs.getElementsByTagName('a'); - this.lastBCElement = bcElements[bcElements.length-1]; - var imgSrcParts = image.src.split('/'); - this.lastBCElement.innerHTML = imgSrcParts[imgSrcParts.length-2]; - this.hasBreadcrumbs = true; - } - else { - this.hasBreadcrumbs = false; - } - - var buttons = toolbar.getElementsByTagName('img'); - var b, name, i; - for (i=0 ; i this.winSize.width || - y < 0 || - y > this.winSize.height - ) { - this.mouseUpHandler(evt); - } -}; - -FilmSlider.prototype.thumbnailClickHandler = function(evt) { - var target = getTargetedObject(evt); - while (target.tagName !== 'A' && target !== this.filmBar) { target = target.parentNode; } - if (target.tagName !== 'A') { return; } - else { - if (this.viewMode === 'full') { - this.mosaique.unload(); - this.mosaique = null; - this.viewMode = 'medium'; - } - disableDefault(evt); - disablePropagation(evt); - target.blur(); - history.pushState(target.href, '', target.href); - - var imgBaseUrl = target.href; - var canonicalImgUrl; - if (this.ctxUrlTranslation[0]) { - canonicalImgUrl = imgBaseUrl.replace(this.ctxUrlTranslation[0], - this.ctxUrlTranslation[1]); - } - else { canonicalImgUrl = imgBaseUrl; } - - var ajaxUrl = imgBaseUrl + '/photo_view_ajax'; - var thisFS = this; - - //this.pendingImage.src = canonicalImgUrl + '/getResizedImage?size=600'; - var thumbnail = target.getElementsByTagName('IMG')[0]; - var bestFitSize = this.getBestFitSize(thumbnail.height/thumbnail.width); - this.pendingImage.src = canonicalImgUrl + '/getResizedImage?size=' + bestFitSize; - - // update buttons - var fullScreenLink = this.buttons.full_screen.parentNode; - fullScreenLink.href = canonicalImgUrl + '/zoom_view'; - - var toggleSelectionBtn = this.buttons.toggle_selection; - var toggleSelectionLink = toggleSelectionBtn.parentNode; - this.selectedSlideInSelection = (target.className==='selected'); - if (this.selectedSlideInSelection) { - toggleSelectionBtn.src = portal_url() + '/unselect_flag_btn.gif'; - toggleSelectionBtn.alt = toggleSelectionLink.title = 'Retirer de la sélection'; - toggleSelectionLink.href = canonicalImgUrl + '/remove_to_selection'; - } - else { - toggleSelectionBtn.src = portal_url() + '/select_flag_btn.gif'; - toggleSelectionBtn.alt = toggleSelectionLink.title = 'Ajouter à la sélection'; - toggleSelectionLink.href = canonicalImgUrl + '/add_to_selection'; - } - - var showBuyableButtonLink = this.buttons.show_buyable.parentNode; - showBuyableButtonLink.href = canonicalImgUrl + '/get_slide_buyable_items'; - this.cartSlide.innerHTML = ''; - this.cartSlide.style.visibility='hidden'; - - - var metadataButton = this.buttons.edit_metadata; - if (metadataButton) { - var metadataEditLink = metadataButton.parentNode; - metadataEditLink.href = canonicalImgUrl + '/photo_edit_form'; - } - - - var req = new XMLHttpRequest(); - req.onreadystatechange = function() { - switch (req.readyState) { - case 1 : - showProgressImage(); - break; - case 2 : - try { - if (! isTextMime.exec(req.getResponseHeader('Content-Type'))) { - req.onreadystatechange = null; - req.abort(); - hideProgressImage(); - window.location.href = thisFS._fallBackUrl; - } - } - catch(e){} - break; - case 4 : - hideProgressImage(); - if (req.status === 200) { thisFS.populateViewer(req); } - break; - } - }; - - req.open("GET", ajaxUrl, true); - req.send(null); - - // update old displayed slide className - var className = this.selectedSlide.className; - var classes = className.split(' '); - var newClasses = []; - var name, i; - - for (i=0 ; i