-
Notifications
You must be signed in to change notification settings - Fork 477
/
Copy pathscript.js
60 lines (52 loc) · 1.75 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
var titleBar = document.getElementById("title-bar");
var exit = document.getElementById("exit");
var max = document.getElementById("maximize");
var min = document.getElementById("minimize");
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
$("#maximize").click(enlarge);
function enlarge(){
if(max.classList.contains("enlarged")){
$("#window").css("width", "40%");
$("#title-bar-width").css('width', '100%').css('width', '+=2px');
$("#content").css("width", "100%");
$("#maximize").removeClass("enlarged");
}
else{
$("#window").css("width", "70%");
$("#title-bar-width").css('width', '100%').css('width', '+=2px');
$("#content").css("width", "100%");
$("#maximize").addClass("enlarged");
}
}