|
30
|
1 |
/* |
|
|
2 |
* This file is part of the TraKERS\Front IDILL package. |
|
|
3 |
* |
|
|
4 |
* (c) IRI <http://www.iri.centrepompidou.fr/> |
|
|
5 |
* |
|
|
6 |
* For the full copyright and license information, please view the LICENSE |
|
|
7 |
* file that was distributed with this source code. |
|
|
8 |
*/ |
|
|
9 |
|
|
|
10 |
/* |
|
|
11 |
* Projet : TraKERS |
|
|
12 |
* Module : Front IDILL |
|
|
13 |
* Fichier : localMosaic.js |
|
|
14 |
* |
|
|
15 |
* Auteur : alexandre.bastien@iri.centrepompidou.fr |
|
|
16 |
* |
|
|
17 |
* Fonctionnalités : Définit la "classe" mosaïque locale (lors d'un zoom sur une mosaïque) et définit des fonctions d'intéractions. |
|
|
18 |
*/ |
|
|
19 |
|
|
|
20 |
/* |
|
|
21 |
* Classe définissant la mosaïque locale. |
|
|
22 |
* Elle sera toujours de la forme 3x3, même si toutes les cases ne seront pas remplies par des snapshots (cas des bords et coins). |
|
|
23 |
*/ |
|
|
24 |
function localMosaic(len, imgToShow, marginWidth) |
|
|
25 |
{ |
|
|
26 |
if(imgToShow % len == 0) |
|
|
27 |
{ |
|
|
28 |
this.length = len; |
|
|
29 |
this.imagesToShow = imgToShow; |
|
|
30 |
this.centerId; |
|
|
31 |
this.urls = []; |
|
|
32 |
this.imgs = []; |
|
|
33 |
this.ids = []; |
|
|
34 |
this.width; |
|
|
35 |
this.height; |
|
|
36 |
this.marginWidth = marginWidth; |
|
|
37 |
this.zoomed; |
|
|
38 |
this.snapshotTop; |
|
|
39 |
this.snapshotLeft; |
|
|
40 |
this.snapshotWidth; |
|
|
41 |
this.snapshotHeight; |
|
|
42 |
} |
|
|
43 |
else |
|
|
44 |
{ |
|
|
45 |
//Affiche un message d'erreur. |
|
|
46 |
} |
|
|
47 |
} |
|
|
48 |
|
|
|
49 |
/* |
|
|
50 |
* Crée la mosaïque locale, qui est une partie de la mosaïque de mosaic.js. |
|
|
51 |
* Il y a le snapshot sur lequel on a zoomé, et les 8 snapshots voisins. |
|
|
52 |
*/ |
|
|
53 |
localMosaic.prototype.createLocalMosaic = function() |
|
|
54 |
{ |
|
|
55 |
var str = ''; |
|
|
56 |
|
|
|
57 |
var t = this.coord1Dto2D(this.centerId); |
|
|
58 |
var localId; |
|
|
59 |
|
|
|
60 |
for(var a = t[1] - 1 ; a < t[1] + 2 ; a++) |
|
|
61 |
for(var b = t[0] - 1 ; b < t[0] + 2 ; b++) |
|
|
62 |
if(a > -1 && a < this.imagesToShow / this.length && b > -1 && b < this.length) |
|
|
63 |
{ |
|
|
64 |
localId = this.coord2Dto1D(a, b); |
|
|
65 |
str += '<div class="snapshotDivs"><img id="snapshot-' + localId + '" class="snapshots" src="snapshots-little/' + this.imgs[localId] + '" /></div>'; |
|
|
66 |
} |
|
|
67 |
else |
|
|
68 |
str += '<div class="blacks"></div>'; |
|
|
69 |
|
|
|
70 |
return str; |
|
|
71 |
} |
|
|
72 |
|
|
|
73 |
/* |
|
|
74 |
* Permet de charger la mosaïque locale. |
|
|
75 |
*/ |
|
|
76 |
localMosaic.prototype.loadLocalMosaic = function(snTop, snLeft, snWidth, snHeight, imgsTab, id) |
|
|
77 |
{ |
|
|
78 |
//On affecte les chemins vers les images à la mosaïque. |
|
|
79 |
this.imgs = imgsTab; |
|
|
80 |
this.centerId = id; |
|
|
81 |
this.snapshotTop = snTop;//*(newPreMPHeight/initMPHeight) - this.zoomedMargin/2 + (initMPHeight - initMPHeight * this.zoomPercentage)/2 + 'px'; |
|
|
82 |
this.previousMPLeft = snLeft; |
|
|
83 |
this.snapshotWidth = snWidth; |
|
|
84 |
this.snapshotHeight = snHeight; |
|
|
85 |
//On met à jour la mosaïque. |
|
|
86 |
$('#mainPanel').html(this.createLocalMosaic(id)); |
|
|
87 |
$('.snapshotDivs').css('width', snWidth).css('height', snHeight).css('margin', this.marginWidth/2); |
|
|
88 |
// var lMosTop = , newZoomLeft = -this.previousZoomedSN.position().left*(newPreMPWidth/initMPWidth) - this.zoomedMargin/2 + (initMPWidth - initMPWidth * this.zoomPercentage)/2 + 'px'; |
|
|
89 |
$('#mainPanel').css('top', 0).css('left', 0); |
|
|
90 |
} |
|
|
91 |
|
|
|
92 |
/* |
|
|
93 |
* Change de 1 à 2 dimensions pour les coordonnées des snapshots dans la mosaïque. |
|
|
94 |
*/ |
|
|
95 |
localMosaic.prototype.coord1Dto2D = function(i) |
|
|
96 |
{ |
|
|
97 |
return [i%length, Math.floor(i/this.length)]; |
|
|
98 |
} |
|
|
99 |
|
|
|
100 |
/* |
|
|
101 |
* Change de 2 à 1 dimension pour les coordonnées des snapshots dans la mosaïque. |
|
|
102 |
*/ |
|
|
103 |
localMosaic.prototype.coord2Dto1D = function(i, j) |
|
|
104 |
{ |
|
|
105 |
return j * this.length + i; |
|
|
106 |
} |