-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
executable file
·49 lines (38 loc) · 1.22 KB
/
main.js
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
jQuery(document).ready(function(){
var minTop = 0;
var maxTop = jQuery('.can-body').height()-20;
var minLeft = 0;
var maxLeft = jQuery('.can-body').width()-10;
var minSize = 10;
var maxSize = 30;
function random_number(min,max){
return Math.round(Math.random() * (max - min) + min);
}
function createBubble(){
var output = '<div class="bubble" style="';
var top = random_number(minTop,maxTop);
var left = random_number(minLeft,maxLeft);
var size = random_number(minSize,maxSize);
var sizeTwo = (size/0.9)-2;
if ((left+size)>maxLeft){
left = maxLeft-size;
}
output += 'top:'+top+'px;left:'+left+'px;width:'+size+'px;height:'+sizeTwo+'px;';
var radius = size/2;
output += 'border-radius:'+radius+'px;';
var shadowOffset = size/8;
var shadowSize = size/5;
output += 'box-shadow:inset '+shadowOffset+'px '+shadowOffset+'px '+shadowSize+'px rgba(0,0,0,0.3);';
output += '"></div>';
return output;
}
jQuery('.bubblesThrow').click(function(e){
e.preventDefault();
// CLean bubbles
jQuery('.bubble').remove();
for (var i=1;i<=jQuery('.bubblesNo').val();i++){
//alert(createBubble());
jQuery('.can-body').append(createBubble());
}
});
});