Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
surya-dev-singh
GitHub Repository: surya-dev-singh/BITB-framwork
Path: blob/main/script.js
500 views
1
var minimize = document.getElementById("minimize");
2
var square = document.getElementById("square");
3
var exit = document.getElementById("exit");
4
var titleBar = document.getElementById("title-bar");
5
6
////////////////// Hover listeners //////////////////
7
minimize.addEventListener('mouseover', function handleMouseOver() {
8
minimize.style.backgroundColor = '#272727';
9
minimize.style.cursor = 'context-menu';
10
});
11
12
minimize.addEventListener('mouseout', function handleMouseOut() {
13
minimize.style.backgroundColor = 'black';
14
minimize.style.cursor = 'default';
15
});
16
17
square.addEventListener('mouseover', function handleMouseOver() {
18
square.style.backgroundColor = '#272727';
19
square.style.cursor = 'context-menu';
20
});
21
22
square.addEventListener('mouseout', function handleMouseOut() {
23
square.style.backgroundColor = 'black';
24
square.style.cursor = 'default';
25
});
26
27
exit.addEventListener('mouseover', function handleMouseOver() {
28
exit.style.backgroundColor = 'red';
29
exit.style.cursor = 'context-menu';
30
});
31
32
exit.addEventListener('mouseout', function handleMouseOut() {
33
exit.style.backgroundColor = 'black';
34
exit.style.cursor = 'default';
35
});
36
37
titleBar.addEventListener('mouseover', function handleMouseOver() {
38
titleBar.style.cursor = 'context-menu';
39
});
40
41
titleBar.addEventListener('mouseout', function handleMouseOver() {
42
titleBar.style.cursor = 'default';
43
});
44
45
46
//////////////// Make window draggable start ////////////////
47
// Make the DIV element draggable:
48
var draggable = $('#window');
49
var title = $('#title-bar');
50
51
title.on('mousedown', function(e){
52
var dr = $(draggable).addClass("drag");
53
height = dr.outerHeight();
54
width = dr.outerWidth();
55
ypos = dr.offset().top + height - e.pageY,
56
xpos = dr.offset().left + width - e.pageX;
57
$(document.body).on('mousemove', function(e){
58
var itop = e.pageY + ypos - height;
59
var ileft = e.pageX + xpos - width;
60
if(dr.hasClass("drag")){
61
dr.offset({top: itop,left: ileft});
62
}
63
}).on('mouseup', function(e){
64
dr.removeClass("drag");
65
});
66
});
67
//////////////// Make window draggable end ////////////////
68
69
70
////////////////// Onclick listeners //////////////////
71
// X button functionality
72
$("#exit").click(function(){
73
$("#window").css("display", "none");
74
});
75
76
// Maximize button functionality
77
$("#square").click(enlarge);
78
79
function enlarge(){
80
if(square.classList.contains("enlarged")){
81
$("#window").css("width", "40%");
82
$("#title-bar-width").css('width', '100%').css('width', '+=2px');
83
$("#content").css("width", "100%");
84
$("#square").removeClass("enlarged");
85
}
86
else{
87
$("#window").css("width", "70%");
88
$("#title-bar-width").css('width', '100%').css('width', '+=2px');
89
$("#content").css("width", "100%");
90
$("#square").addClass("enlarged");
91
}
92
}
93
94
95
//// Pop-up appear on click with delay ////
96
$("#clickme").click(function(){
97
$("#window").fadeIn(300);
98
});
99