|
1 function glow() { |
|
2 document.getElementById('') |
|
3 } |
|
4 |
|
5 |
|
6 function Tapestry(json,parametres){ |
|
7 this.parametres = { |
|
8 name: null, |
|
9 hauteur: 400, |
|
10 largeur: 900, |
|
11 timelineHaute : "#timelinehaute", |
|
12 relations: null, |
|
13 contenu: function(cellule, element) { |
|
14 |
|
15 var html; |
|
16 var img = new Image(); |
|
17 img.src= element.name; |
|
18 indexx = element.indexx; |
|
19 var wi, hi, wc, hc; |
|
20 |
|
21 wi = img.width; |
|
22 hi = img.height; |
|
23 wc = cellule.offsetWidth ; |
|
24 hc = cellule.offsetHeight ; |
|
25 // r = Math.min(hi/hc, wi/wc); |
|
26 // w = wi/r; |
|
27 // h = hi/r; |
|
28 |
|
29 var posx, posy; |
|
30 posx = (wi-wc)/2; |
|
31 posy = (hi-hc)/2; |
|
32 |
|
33 html = "<img class = 'img' src = \"" + img.src + "\" style=\" width:"+ wc + "px; height:" +hc + "px; margin-top: 0px; margin-left: 0px;\" />"; |
|
34 html += "<p class = 'title' style = \" width:" + wc + "px;\"> Image "+String(indexx)+"</p>"; |
|
35 |
|
36 return html; |
|
37 |
|
38 |
|
39 }}; |
|
40 |
|
41 |
|
42 |
|
43 var object = this; |
|
44 |
|
45 |
|
46 //---------------------------------------------------------------------- |
|
47 // FENETRE DE FOND |
|
48 |
|
49 object.tapestryHtml = d3.select("#timelinehaute") |
|
50 .style('position', 'relative') |
|
51 .style('width', object.parametres.largeur + 'px') |
|
52 .style('height', object.parametres.hauteur + 'px') |
|
53 .style('background-color', 'black'); |
|
54 //.style('overflow','hidden'); |
|
55 |
|
56 object.boutonzoom = d3.select("#timelinebasse").append('div') |
|
57 .style('position', 'relative') |
|
58 .style('width', '200px') |
|
59 .style('height','20px') |
|
60 .style('background-color', 'grey') |
|
61 .style('margin-top', '5px') |
|
62 .html("<p class = 'title' style = \" width:200px;\"> Dezoooooom </p>") |
|
63 .on('mouseover', function(){d3.select(this).style('opacity', 0.8);}) |
|
64 .on('mouseout', function(){d3.select(this).style('opacity', 1);}) |
|
65 .on('click',function(){object.agencerzoom;}) |
|
66 |
|
67 |
|
68 //---------------------------------------------------------------------- |
|
69 // CREATION DES PETITES FENETRES |
|
70 |
|
71 var listeposition = this.getPosition(); |
|
72 var larg,haut; |
|
73 larg = String(this.parametres.largeur/5) + "px"; |
|
74 larg2=String(this.parametres.largeur/10) + "px"; |
|
75 haut = String(this.parametres.hauteur/2 -1) + "px" ; |
|
76 |
|
77 d3.select("#timelinehaute").selectAll("div") |
|
78 .data(donnees).enter().append("div") |
|
79 .attr('class', 'cell') |
|
80 .attr('id', function(index){ |
|
81 if(index==0){return "first";} |
|
82 else if (index==10){return "last";} |
|
83 }) |
|
84 |
|
85 .on('mouseover', function(){d3.select(this).style('opacity', 0.8);}) |
|
86 .on('mouseout', function(){d3.select(this).style('opacity', 1);}) |
|
87 .on('click',function(datum,index){object.agencerzoom(datum,index);}) |
|
88 |
|
89 .style('position', 'absolute') |
|
90 .style('width', function(datum,index){ |
|
91 if(index==0 || index==10){return larg2;} |
|
92 else{return larg;} |
|
93 }) |
|
94 .style('height',haut) |
|
95 .style('background-color', '#32675F') |
|
96 .style('text-align','center') |
|
97 .html(function(datum,index){return object.parametres.contenu(this,datum);}) |
|
98 .style('left', function(datum, index) { |
|
99 return listeposition[index][0]; |
|
100 }) |
|
101 .style('top', function(datum, index) { |
|
102 return listeposition[index][1]; |
|
103 }) |
|
104 // .attr('onmouseover',"this.style(\"stroke\",\"white\");" ) |
|
105 ; |
|
106 |
|
107 |
|
108 |
|
109 }; |
|
110 // Position des fenetres |
|
111 Tapestry.prototype = { |
|
112 |
|
113 getPosition: function(){ |
|
114 var l,h; |
|
115 l= this.parametres.largeur; |
|
116 h= this.parametres.hauteur; |
|
117 var listposition=[[0,0]]; |
|
118 for (var i=0;i<9;i++){ |
|
119 listposition.push([(i*0.5)*l/5,h/2*((i+1)%2)]); |
|
120 } |
|
121 listposition.push([4.5*l/5,0]); |
|
122 //for (var j=0;j<5;j++){ |
|
123 // listposition.push([j*l/5,h/2]); |
|
124 //} |
|
125 return listposition; |
|
126 |
|
127 |
|
128 }, |
|
129 |
|
130 agencerzoom: function(element,indexx){ |
|
131 var object = this; |
|
132 this.tapestryHtml.selectAll("div") |
|
133 .data(donnees[indexx].childs) |
|
134 .html(function(datum,index){return object.parametres.contenu(this,datum);}); |
|
135 this.tapestryHtml.select("first") |
|
136 .data(donnees[indexx-1]) |
|
137 .html(function(datum,index){return object.parametres.contenu(this,datum);}); |
|
138 }, |
|
139 |
|
140 |
|
141 agencerdezoom: function(){ |
|
142 var object = this; |
|
143 this.tapestryHtml.selectAll("div") |
|
144 .data(donnees) |
|
145 .html(function(datum,index){return object.parametres.contenu(this,datum);}); |
|
146 |
|
147 } |
|
148 |
|
149 |
|
150 |
|
151 }; |
|
152 |
|
153 |