-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
131 lines (106 loc) · 3.66 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><juicy-highlight></title>
<!-- Importing Custom Elements -->
<script src="../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="juicy-highlight.html" />
<style>
html {
min-height: 100%;
}
body {
padding: 2em;
}
ul.playground {
list-style: none;
padding: 0;
}
ul.playground li {
margin: 0 20px 0 0;
float: left;
width: 150px;
height: 150px;
cursor: pointer;
padding: 15px;
}
ul.playground li:nth-child(1) {
background-color: #FFD310;
}
ul.playground li:nth-child(2) {
background-color: #FFB02F;
}
ul.playground li:nth-child(3) {
background-color: #FF7C5E;
}
ul.playground:after {
content: '';
display: block;
clear: both;
}
ul.playground.small {
overflow: auto;
height: 100px;
min-width: 650px;
}
div.playground.small {
width: 500px;
overflow:auto;
}
button#hideAll {
position: relative;
z-index: 100;
}
</style>
</head>
<body>
<h1><juicy-highlight></h1>
<p>See <a href="https://github.com/Juicy/juicy-highlight">README.md</a> for docs</p>
<ul class="playground">
<li>Play with me</li>
<li>Move your mouse here</li>
<li>Click on me</li>
</ul>
<div class="playground small">
<ul class="playground small">
<li>Play with me</li>
<li>Move your mouse here</li>
<li>Click on me</li>
</ul>
</div>
<juicy-highlight id="borderWithOverlay" overlay strokewidth="4" strokecolor="#33579F" strokeoffset="6"></juicy-highlight>
<juicy-highlight id="border" strokewidth="2" strokecolor="#222222" strokeoffset="4"></juicy-highlight>
<button id="hideAll">Hide all overlays</button>
<button id="selectAll">Select all</button>
<script>
var init = function () {
document.querySelector("#border").show(document.querySelectorAll("li"));
window.addEventListener("mouseover", function (ev) {
if (ev.target.nodeName == "LI") {
document.querySelector("#border").show(ev.target);
}
});
window.addEventListener("click", function (ev) {
if (ev.target.nodeName == "LI") {
document.querySelector("#borderWithOverlay").show(ev.target, function (el) {
var rec = el.getBoundingClientRect();
var html = ["<div style='background-color:rgba(230, 67, 94, 0.7); padding:2px; font-size:13px;'>Size: ", rec.width, "x", rec.height, "</div>"].join("");
return html;
});
}
});
document.querySelector("#hideAll").addEventListener("click", function (ev) {
document.querySelector("#border").hide();
document.querySelector("#borderWithOverlay").hide();
});
document.querySelector("#selectAll").addEventListener("click", function (ev) {
document.querySelector("#border").show(document.querySelectorAll("li"));
});
};
document.addEventListener("DOMContentLoaded", function (event) {
setTimeout(init, 100); //Without timeout works in Chrome only.
});
</script>
</body>
</html>