-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
36 lines (33 loc) · 1.45 KB
/
script.js
File metadata and controls
36 lines (33 loc) · 1.45 KB
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
var cible;
var offsetX, offsetY;
Windows = document.getElementsByClassName('window');
for (var i = 0; i < Windows.length; i++) {
Windows[i].addEventListener('mousedown', function (e) {
for (var i = 0; i < Windows.length; i++) {
if (e.currentTarget.style.zIndex != Windows.length) {
Windows[i].style.zIndex--;
Windows[i].style.removeProperty("box-shadow");
}
}
e.currentTarget.style.zIndex = Windows.length;
e.currentTarget.style.boxShadow = "0 5pt 20pt #1016";
});
document.getElementsByClassName('border')[i].addEventListener('mousedown', function (e) {
offsetX = e.pageX - e.currentTarget.parentNode.offsetLeft;
offsetY = e.pageY - e.currentTarget.parentNode.offsetTop;
cible = e.currentTarget.parentNode;
document.body.insertAdjacentHTML('beforeend', '<div id="secureDrag" style="z-index:999;position:absolute;top:0;bottom:0;left:0;right:0;background:none;cursor:move;-webkit-user-select:none;"></div>');
});
}
document.body.addEventListener('mousemove', function (e) {
if (cible) {
cible.style.left = e.pageX - offsetX + 'px';
cible.style.top = e.pageY - offsetY + 'px';
}
});
document.body.addEventListener('mouseup', function () {
cible = null;
if (document.getElementById('secureDrag') !== null) {
document.getElementById('secureDrag').outerHTML = null;
}
});