-
Notifications
You must be signed in to change notification settings - Fork 3
/
boites.html
192 lines (163 loc) · 5.48 KB
/
boites.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<!DOCTYPE html>
<html>
<head>
<title>Test de boites</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link href="boites.css" media="screen" rel="Stylesheet" type="text/css" />
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="boites.js"></script>
</head>
<body>
<script type="text/javascript">
Array.prototype.remove = function(elem) {
var match = -1;
while( (match = this.indexOf(elem)) > -1 ) {
this.splice(match, 1);
}
};
var get_random_color_degrees = [];
function get_random_color() {
var degree = 0;
for (var i = 0; i < 20; ++i)
{
degree = Math.round(Math.random() * 360);
var j = 0;
for (var j = 0; j < get_random_color_degrees.length; ++j)
if (Math.abs(get_random_color_degrees[j] - degree) <
30-get_random_color_degrees.length)
j = 1000;
if (j == get_random_color_degrees.length)
i = 1000;
}
get_random_color_degrees.push(degree);
var saturation = 80 + Math.round(Math.random() * 4) * 5;
var luminosite = 45 + Math.round(Math.random() * 2) * 5;
return degree+','+saturation+'%,'+luminosite+'%';
}
$(document).ready(function() {
boiboites = new Boxes_layout(document.body, Boxes_DIRECTIONS.VERTICAL);
function bb() {
var box = boiboites.createBox();
box.front.appendChild(document.createTextNode('vive les canards'));
var visualizations = document.createElement('div');
visualizations.className = 'visualizations';
var visualizations_h = document.createElement('h3');
visualizations_h.appendChild(document.createTextNode('Visualisations'));
visualizations.appendChild(visualizations_h);
visualizations.appendChild(document.createTextNode('type de visualisation'));
box.back.appendChild(visualizations);
var options = document.createElement('div');
options.className = 'options';
var options_h = document.createElement('h3');
options_h.appendChild(document.createTextNode('Configuration'));
options.appendChild(options_h);
options.appendChild(document.createTextNode('ceci est un test'));
box.back.appendChild(options);
var data = document.createElement('div');
data.className = 'data';
var data_h = document.createElement('h3');
data_h.appendChild(document.createTextNode('Données'));
data.appendChild(data_h);
data.appendChild(document.createTextNode('liste des données'));
box.back.appendChild(data);
var color = get_random_color();
var dark_color = color.substr(0, color.length-3)+'25%';
var border_line = document.createElement('div');
border_line.className = 'borderLine';
border_line.style.background = "-webkit-gradient(linear, left top, right top, color-stop(0%,hsla("+color+",0.6)), color-stop(55%,hsla("+color+",0.6)), color-stop(100%,hsla("+dark_color+",0.65)))";
border_line.style.background = "-webkit-linear-gradient(left, hsla("+color+",0.6) 0%,hsla("+color+",0.6) 55%,hsla("+dark_color+",0.65) 100%)";
border_line.style.background = "linear-gradient(to right, hsla("+
color+",0.6) 0%,hsla("+color+",0.6) 55%,hsla("+dark_color+",0.65) 100%)";
border_line.style.background = "-moz-linear-gradient(left, hsla("
+color+",0.6) 0%, hsla("+color+",0.6) 55%, hsla("
+dark_color+",0.65) 100%)";
box.back.appendChild(border_line);
box.box.style.background = 'hsl('+color+')';
box.box.id = "box_"+color.slice(1);
return box.box;
}
canvaas = bb();
boiboites.addBox(canvaas);
lapin = new Boxes_container(Boxes_DIRECTIONS.HORIZONTAL);
boiboites.addBox(lapin);
boiboites.addBox(bb(), lapin);
boiboites.addBox(bb(), lapin);
canard = new Boxes_container(Boxes_DIRECTIONS.VERTICAL);
boiboites.addBox(canard, lapin);
boiboites.addBox(bb(), canard);
boiboites.addBox(bb(), canard);
boiboites.addBox(bb(), canard);
setTimeout(function(){boiboites.equilibrate();}, 1);
/*setTimeout(function()
{
lapin = boiboites.newBoite(Boxes_DIRECTIONS.HORIZONTAL);
bb(lapin);
bb(lapin);
setTimeout(function()
{
canard = lapin.newBoite(Boxes_DIRECTIONS.VERTICAL);
bb(canard);
bb(canard);
bb(canard);
}, 1);
}, 1);
setTimeout(function() {boiboites.dessinerDisposition();}, 200);
*/
//didiv = bb();
jbouton = $("#bouton_boite");
var drag_start_x = 0;
var drag_start_y = 0;
var drag = function(e){
jbouton.css({
top: (e.clientY-drag_start_y)+'px',
left: (e.clientX-drag_start_x)+'px'
});
};
jbouton.mousedown(function(e) {
/*boiboites.drag_enabled = false;*/
if (e.offsetX)
{
drag_start_x = e.offsetX;
drag_start_y = e.offsetY;
} else {
var pos = $(e.target).position();
console.log(e.clientX);
drag_start_x = e.clientX - pos.left;
drag_start_y = e.clientY - pos.top;
}
var boite = bb();
boite.style.display = 'none';
boiboites.dragged_box = boite;
document.body.addEventListener('mousemove', drag);
});
var stop_drag = function(e) {
/*boiboites.drag_enabled = true;*/
//boiboites.dragged_box = null;
document.body.removeEventListener('mousemove', drag);
jbouton.animate({
top:'0px',
left: '0px'}, 250);
};
$(document.body).mouseup(stop_drag);
//jbouton.mouseout(stop_drag);
//window.setInterval(bb, 500);
jbouton.hide();
$('#flip').click(function() {
jboxes = $('.boxdiv');
jboxes.addClass('flipped_animation');
setTimeout(function() {
jboxes.removeClass('flipped_animation');
boiboites.toggleFrontMode();
}, 600);
if (boiboites.front)
jbouton.show();
else
jbouton.hide();
});
$('#flip').click();
});
</script>
<div id="bouton_boite" style="display:none;">Nouvelle Boite Magique</div>
<div id="flip">Flip!</div>
</body>
</html>