-
Notifications
You must be signed in to change notification settings - Fork 477
/
Copy pathscript.js
92 lines (77 loc) · 2.69 KB
/
script.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
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
var minimize = document.getElementById("minimize");
var square = document.getElementById("square");
var exit = document.getElementById("exit");
var titleBar = document.getElementById("title-bar");
////////////////// Hover listeners //////////////////
minimize.addEventListener('mouseover', function handleMouseOver() {
minimize.style.backgroundColor = 'rgba(0, 0, 0, 0.09765625)';
minimize.style.cursor = 'context-menu';
});
minimize.addEventListener('mouseout', function handleMouseOut() {
minimize.style.backgroundColor = '#d6dae0';
minimize.style.cursor = 'default';
});
square.addEventListener('mouseover', function handleMouseOver() {
square.style.backgroundColor = 'rgba(0, 0, 0, 0.09765625)';
square.style.cursor = 'context-menu';
});
square.addEventListener('mouseout', function handleMouseOut() {
square.style.backgroundColor = '#d6dae0';
square.style.cursor = 'default';
});
exit.addEventListener('mouseover', function handleMouseOver() {
exit.style.backgroundColor = '#E81123';
exit.style.cursor = 'context-menu';
});
exit.addEventListener('mouseout', function handleMouseOut() {
exit.style.backgroundColor = '#d6dae0';
exit.style.cursor = 'default';
});
titleBar.addEventListener('mouseover', function handleMouseOver() {
titleBar.style.cursor = 'context-menu';
});
titleBar.addEventListener('mouseout', function handleMouseOver() {
titleBar.style.cursor = 'default';
});
//////////////// Make window draggable start ////////////////
// Make the DIV element draggable:
var draggable = $('#window');
var title = $('#title-bar');
title.on('mousedown', function(e){
var dr = $(draggable).addClass("drag");
height = dr.outerHeight();
width = dr.outerWidth();
ypos = dr.offset().top + height - e.pageY,
xpos = dr.offset().left + width - e.pageX;
$(document.body).on('mousemove', function(e){
var itop = e.pageY + ypos - height;
var ileft = e.pageX + xpos - width;
if(dr.hasClass("drag")){
dr.offset({top: itop,left: ileft});
}
}).on('mouseup', function(e){
dr.removeClass("drag");
});
});
//////////////// Make window draggable end ////////////////
////////////////// Onclick listeners //////////////////
// X button functionality
$("#exit").click(function(){
$("#window").css("display", "none");
});
// Maximize button functionality
$("#square").click(enlarge);
function enlarge(){
if(square.classList.contains("enlarged")){
$("#window").css("width", "40%");
$("#title-bar-width").css('width', '100%');
$("#content").css("width", "100%");
$("#square").removeClass("enlarged");
}
else{
$("#window").css("width", "70%");
$("#title-bar-width").css('width', '100%');
$("#content").css("width", "100%");
$("#square").addClass("enlarged");
}
}