-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.html
112 lines (104 loc) · 4.04 KB
/
example.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
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<title>Intercom - Example</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type='text/javascript' src='intercom.js'></script>
<script type='text/javascript'>
$(document).ready(function() {
var tower = {};
Intercom.installOn(tower);
tower.listen('activated', function(which) {
activate(which);
});
tower.listen('deactivated', function(which) {
deactivate(which);
});
$('.plane').each(function(i){
$(this).attr('data-color', 'rgba('+Math.floor(Math.random() * ((255-10)+1) + 10) +','+ Math.floor(Math.random() * ((255-10)+1) + 10)+','+ Math.floor(Math.random() * ((255-10)+1) + 10)+', 0.8)');
$(this).html('<div>plane '+i+'</div>').css({'background': $(this).attr('data-color')});
$(this).on('mousedown', function() {
$(this).css({'background':'white'});
tower.broadcast('activated', $(this).attr('data-color'));
});
$(this).on('mouseup', function() {
$(this).css({'background':$(this).attr('data-color')});
tower.broadcast('deactivated');
})
});
var activate = function(which) {
console.log('active', which);
$('.plane').each(function() {
if(which != $(this).attr('data-color')) {
$(this).css({'background':which});
}
})
};
var deactivate = function(which) {
$('.plane').each(function() {
$(this).css({'background':$(this).attr('data-color')});
})
};
})
</script>
<style>
body { background-color: whitesmoke;}
.plane {
width: 25%;
height: 150px;
text-align: center;
display: flex;
align-content: center;
float: left;
box-sizing: border-box;
cursor: pointer;
border: 5px solid whitesmoke;
border-radius: 10px;
transition: all 0.4s ease;
}
.plane div {
display: flex;
align-self: center;
margin: auto;
text-transform: uppercase;
letter-spacing: 3px;
font-family: arial, helvetica, sans-serif;
}
</style>
</head>
<body class="body">
<div class="plane"></div>
<div class="plane"></div><div class="plane"></div>
<div class="plane"></div><div class="plane"></div>
<div class="plane"></div><div class="plane"></div>
<div class="plane"></div><div class="plane"></div>
<div class="plane"></div><div class="plane"></div>
<div class="plane"></div><div class="plane"></div>
<div class="plane"></div><div class="plane"></div>
<div class="plane"></div><div class="plane"></div>
<div class="plane"></div><div class="plane"></div>
<div class="plane"></div><div class="plane"></div>
<div class="plane"></div><div class="plane"></div>
<div class="plane"></div><div class="plane"></div>
<div class="plane"></div><div class="plane"></div>
<div class="plane"></div><div class="plane"></div>
<div class="plane"></div><div class="plane"></div>
<div class="plane"></div><div class="plane"></div>
<div class="plane"></div><div class="plane"></div>
<div class="plane"></div><div class="plane"></div>
<div class="plane"></div><div class="plane"></div>
<div class="plane"></div><div class="plane"></div>
<div class="plane"></div><div class="plane"></div>
<div class="plane"></div><div class="plane"></div>
<div class="plane"></div><div class="plane"></div>
<div class="plane"></div><div class="plane"></div>
<div class="plane"></div><div class="plane"></div>
<div class="plane"></div><div class="plane"></div>
<div class="plane"></div><div class="plane"></div>
<div class="plane"></div><div class="plane"></div>
<div class="plane"></div><div class="plane"></div>
<div class="plane"></div><div class="plane"></div>
<div class="plane"></div>
</body>
</html>