-
Notifications
You must be signed in to change notification settings - Fork 0
/
frame.js
102 lines (80 loc) · 1.99 KB
/
frame.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
93
94
95
96
97
98
99
100
101
102
const remote = require('electron').remote;
const currentWindow = remote.getCurrentWindow();
insertLinkCss = function()
{
let head = document.getElementsByTagName('head')[0],
link = element('link');
link.rel = 'stylesheet';
link.href= './css/frame.css';
head.appendChild(link);
}
createFrame = function()
{
insertLinkCss();
let fr = frame();
fr.appendChild(favicon());
fr.appendChild(pageTitle());
fr.appendChild(btnGroup());
document.body.appendChild(fr);
};
frame = function()
{
let frame = element('div');
frame.id = 'frame';
frame.setAttribute('draggable','true');
return frame;
}
favicon = function()
{
let icon = element('img');
icon.src = '../favicon.png';
icon.alt = 'Gramense';
icon.id = 'favicon';
return icon;
}
pageTitle = function()
{
let title = element('h1');
title.innerHTML = 'Criador de promoções';
return title;
}
btnGroup = function()
{
let btnGp = element('div');
let btnMin= createButton('../Minimize.svg'),
btnMax= createButton('../Maximized.svg'),
btnCls= createButton('../Close.svg');
btnGp.classList.add('frame-btn');
btnMin.addEventListener('click', () => { currentWindow.minimize(); });
btnMax.addEventListener('click', () => {
if(!currentWindow.isMaximized())
currentWindow.maximize();
else
currentWindow.unmaximize();
});
btnCls.addEventListener('click', () => { currentWindow.close(); });
btnGp.appendChild(btnMin);
btnGp.appendChild(btnMax);
btnGp.appendChild(btnCls);
return btnGp;
}
createButton= function(image)
{
let btn = element('button'),
img = element('img');
img.src = image;
btn.appendChild(img);
return btn;
}
function element(tag)
{
return document.createElement(tag);
}
Element.prototype.css = function (styles)
{
for(let [attr,val] of Object.entries(styles))
{
this.style[attr] = val;
}
}
createFrame();