diff -r 45c889eae324 -r 2c7fc855eba8 front_idill/src/mosaic/js/mosaic.js --- a/front_idill/src/mosaic/js/mosaic.js Fri Apr 27 14:38:23 2012 +0200 +++ b/front_idill/src/mosaic/js/mosaic.js Fri May 11 11:04:06 2012 +0200 @@ -143,7 +143,9 @@ mosaic.prototype.preZoom = function(snapshot) { if(this.fullscreen) + { return; + } //Mosaïque. var mosaic = this; //Dimensions de la mosaïque. @@ -160,10 +162,16 @@ //Si un zoom est déjà en cours, on ne zoom sur rien d'autre en attendant que ce snapshot ai dézoomé en cas de mouseleave. if(this.zoomed) + { if($('#preZoomContainer-' + currentId) != $(this) && this.previousZoomedSN != '' && this.previousId != '') + { this.preUnzoom(); + } else + { return; + } + } //On indique qu'on a zoomé et on spécifie le snapshot sur lequel on a zoomé. this.zoomed = true; @@ -195,13 +203,21 @@ //CAS PARTICULIER pour la position du snapshot zoomé : les bordures. if(finalDivTop < 0) + { finalDivTop = -margin; + } if(finalDivTop + finalDivHeight > h) + { finalDivTop = h - finalDivHeight; + } if(finalDivLeft < 0) + { finalDivLeft = 0; + } if(finalDivLeft + finalDivWidth + margin*2 > w) + { finalDivLeft = w - finalDivWidth - margin*2; + } ////Code de debug. ////CAUTION//// @@ -234,7 +250,9 @@ $('#prezoomContainer-' + currentId).click(function () { if(this.previousZoomedSN != '') + { mosaic.zoom(); + } }); } @@ -245,7 +263,9 @@ { //Si on n'a pas zoomé, on quitte la fonction. if(!this.zoomed) + { return; + } //On spécifie la marge afin de centrer le prédézoom. var margin = this.marginWidth; @@ -280,7 +300,9 @@ //Si la mosaïque est en pleine écran, pas la peine de zoomer. if(this.fullscreen) + { return; + } //On prend les attributs nécessaires au calculs. var margin = this.marginWidth, len = this.length, imgs = this.imagesToShow; @@ -293,7 +315,7 @@ var initialDivTop = this.previousZoomedSN.position().top, initialDivLeft = this.previousZoomedSN.position().left; //Dimensions et coordonnées finales du div. var finalDivWidth = initialDivWidth * (this.zoomPercentage+1), finalDivHeight = initialDivHeight * (this.zoomPercentage+1); - var newZoomTop = -this.previousZoomedSN.position().top*(newPreMPHeight/initMPHeight) - this.zoomedMargin/2 + (initMPHeight - initMPHeight * this.zoomPercentage)/2 + 'px', newZoomLeft = -this.previousZoomedSN.position().left*(newPreMPWidth/initMPWidth) - this.zoomedMargin/2 + (initMPWidth - initMPWidth * this.zoomPercentage)/2 + 'px'; + var newZoomTop = -this.previousZoomedSN.position().top*(newPreMPHeight/initMPHeight) - this.zoomedMargin/2 + (initMPHeight - initMPHeight * this.zoomPercentage)/2, newZoomLeft = -this.previousZoomedSN.position().left*(newPreMPWidth/initMPWidth) - this.zoomedMargin/2 + (initMPWidth - initMPWidth * this.zoomPercentage)/2; var newSnWidth = initMPWidth * this.zoomPercentage, newSnHeight = initMPHeight * this.zoomPercentage; this.preUnzoom(this); @@ -336,29 +358,94 @@ mos.centerId = zoomedImgId; mos.listenToNeighbours(); mos.currentMode = 'VIDEO'; + + console.log('h : ' + -newZoomLeft + " " + zoomedImg.position().left); + + mos.loadPlayer((zoomedImg.position().top + newZoomTop + mos.MPTop_margin), (zoomedImg.position().left + newZoomLeft), newSnWidth + 1, newSnHeight + 1); + /*mos.unload(); mos.localMos.loadLocalMosaic(newZoomTop, newZoomLeft, newSnWidth, newSnHeight, mos.imgs, tab[1]);*/ }); } /* + * Chargement du player basé sur le metadataplayer. +*/ +mosaic.prototype.loadPlayer = function(newZoomTop, newZoomLeft, newSnWidth, newSnHeight) +{ + //On configure les options de lancement. + IriSP.libFiles.defaultDir = "../lib/"; + IriSP.widgetsDir = "./player/metadataplayer/" + + console.log(newZoomTop + " " + newZoomLeft); + + var _metadata = { + url: 'http://ldt.iri.centrepompidou.fr/ldtplatform/ldt/cljson/id/7c912bce-66b8-11e1-80f6-00145ea4a2be?callback=?', + format: 'ldt' + }; + var _config = { + gui: { + width: newSnWidth, + height: newSnHeight, + container: 'LdtPlayer', + default_options: { + metadata: _metadata + }, + css:'./player/metadataplayer/LdtPlayer-core.css', + widgets: [ + { + type: "Timeline" + } + ] + }, + player:{ + type: 'html5', // player type + video: 'http://media.iri.centrepompidou.fr/video/ldtplatform/body_trail_cctv.mp4', + live: true, + height: newSnHeight, + width: newSnWidth, + autostart: true + } + }; + + //On positionne le player. + $('.LdtPlayer').css( + { + //display: 'none', + position: 'absolute', + 'background-color': '#000000', + top: newZoomTop, + left: newZoomLeft + }); + + //On démarre le player. + var _myPlayer = new IriSP.Metadataplayer(_config, _metadata); + console.log(_myPlayer); +} + +/* * Retour à la taille normale de la mosaïque. */ mosaic.prototype.unzoom = function() { //Si on n'est pas en plein écran, on quitte. if(!this.fullscreen) + { return; + } //On charge les attributs nécessaires aux calculs. var sWidth = this.snapshotWidth, sHeight = this.snapshotHeight; var mpWidth = this.width, mpHeight = this.height; var mos = this; - //On passe le snapshot sur lequel on a zoomé en LD. + //On passe le snapshot sur lequel on a zoomé en SD. var zoomedImg = $('img', this.previousZoomedSN); var src = zoomedImg.attr('src'); zoomedImg.attr('src', src.replace('snapshots/', 'snapshots-little/')); + + $('div').remove('.LdtPlayer'); + $('body').append('
'); //On rend leur opacité aux snapshots. Qui ne sont alors plus grisés. $('.snapshotDivs').animate( @@ -383,7 +470,7 @@ //On revient en mode MOSAIC. mos.currentMode = 'MOSAIC'; //On ne permet plus le déplacement vers les voisins. - $('.snapshotDivs').unbind('mouseenter', mos.changeNeighbourColor); + $('.snapshotDivs').unbind('mouseenter', mos.selectNeighbour); }); } @@ -409,12 +496,17 @@ //Si le voisin du bas est sur la même colonne, on n'est pas sur la bordure du bas. this.neighboursIds[3] = (currentLine < (this.imagesToShow / this.length)) ? (+this.centerId + this.length) : -1; + //ID du cadre voisin. + var preId; + for(var i = 0 ; i < this.neighboursIds.length ; i++) { if(this.neighboursIds[i] != -1) - { + { + preId = '#neighbourFrameBorder-' + this.neighboursIds[i]; //On permet le déplacement vers les voisins. - $('#snapshotDiv-' + this.neighboursIds[i]).mouseenter(mos.changeNeighbourColor); + // $('#snapshotDiv-' + this.neighboursIds[i] + ', ' + preId + '-left,' + preId + '-right,' + preId + '-up,' + preId + '-down').mouseenter(mos.selectNeighbour); + $('#snapshotDiv-' + this.neighboursIds[i]).mouseenter(mos.selectNeighbour); } } } @@ -422,7 +514,7 @@ /* * Change la coloration d'une bordure où on se positionne lors d'une vue en plein écran. */ -mosaic.prototype.changeNeighbourColor = function() +mosaic.prototype.selectNeighbour = function() { ////TEST //$('.test').append(mos.currentMode + " " + $(this).attr('id') + " " + 'snapshotDiv-' + mos.centerId + ','); @@ -430,47 +522,89 @@ //Si on est en mode VIDEO (plein écran) ET si le snapshot pointé est un voisin. if((mos.currentMode == 'VIDEO') && ($(this).attr('id') != 'snapshotDiv-' + mos.centerId)) { - //On crée le div cyan qui va être superposé au voisin. - var cyanDiv = ''; + //On crée le cadre qui va être superposé au voisin. //On le colle au voisin. - $('#mainPanel').append(cyanDiv); - $('#cyan-' + $(this).attr('id')).css('top', $(this).position().top).css('left', $(this).position().left).css('width', $(this).width()).css('height', $(this).height()).css('margin', $(this).css('margin')).animate( + var tab = $(this).attr('id').split('-'); + var snapshotId = tab[1]; + var neighbourFrame = ''; + var marginValue = parseFloat($(this).css('margin')); + + neighbourFrame += '