Skip to content

Commit 82377d2

Browse files
gimrehristoterezov
authored andcommitted
feat(alwaysontop): add dismiss button and event
1 parent cfa14d0 commit 82377d2

File tree

5 files changed

+62
-2
lines changed

5 files changed

+62
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ alwaysOnTop.on('will-close', handleAlwaysOnTopClose);
8080

8181
`setupAlwaysOnTopRender` return an instance of EventEmitter with the following events:
8282

83+
* _dismissed_ - emitted when the always on top window is explicitly dismissed via its close button
84+
8385
* _will-close_ - emitted right before the always on top window is going to close
8486

8587
#### WiFi Stats

alwaysontop/alwaysontop.css

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,42 @@ video {
1717
margin: 0;
1818
padding: 0;
1919
}
20+
21+
html:hover .dismiss {
22+
opacity: 1;
23+
}
24+
25+
.dismiss {
26+
align-items: center;
27+
background-color: rgba(40, 52, 71, 0.7);
28+
border-radius: 50%;
29+
color: white;
30+
cursor: pointer;
31+
display: flex;
32+
font-size: 20px;
33+
height: 25px;
34+
justify-content: center;
35+
opacity: 0;
36+
position: absolute;
37+
right: 8px;
38+
top: 16px;
39+
transition: opacity .25s linear;
40+
width: 25px;
41+
}
42+
43+
.dismiss:after, .dismiss:before {
44+
display: block;
45+
content: ' ';
46+
height: 2px;
47+
background-color: white;
48+
position: absolute;
49+
width: calc(100% - 12px);
50+
}
51+
52+
.dismiss:after {
53+
transform: rotate(45deg);
54+
}
55+
56+
.dismiss:before {
57+
transform: rotate(-45deg);
58+
}

alwaysontop/alwaysontop.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ const {
55
onload,
66
onbeforeunload,
77
shouldImplementDrag,
8-
getCurrentSize
8+
getCurrentSize,
9+
dismiss
910
} = window.alwaysOnTop;
1011

1112
/**
@@ -15,6 +16,11 @@ const {
1516
*/
1617
let initialSize;
1718

19+
const dismissButton = document.querySelector('.dismiss');
20+
if (dismissButton) {
21+
dismissButton.addEventListener('click', dismiss);
22+
}
23+
1824
window.addEventListener('beforeunload', onbeforeunload);
1925

2026
window.addEventListener('dblclick', ondblclick);

alwaysontop/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module.exports = {
2+
ALWAYSONTOP_DISMISSED: 'dismissed',
23
ALWAYSONTOP_WILL_CLOSE: 'will-close',
34
SIZE: {
45
width: 320,

alwaysontop/render.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { EventEmitter } = require('events');
55
const os = require('os');
66
const path = require('path');
77

8-
const { ALWAYSONTOP_WILL_CLOSE, SIZE } = require('./constants');
8+
const { ALWAYSONTOP_DISMISSED, ALWAYSONTOP_WILL_CLOSE, SIZE } = require('./constants');
99

1010
/**
1111
* Returieves and trying to parse a numeric value from the local storage.
@@ -51,6 +51,7 @@ class AlwaysOnTop extends EventEmitter {
5151
this._onConferenceJoined = this._onConferenceJoined.bind(this);
5252
this._onConferenceLeft = this._onConferenceLeft.bind(this);
5353
this._onIntersection = this._onIntersection.bind(this);
54+
this._dismiss = this._dismiss.bind(this);
5455

5556
this._api = api;
5657
this._jitsiMeetElectronWindow = remote.getCurrentWindow();
@@ -250,6 +251,15 @@ class AlwaysOnTop extends EventEmitter {
250251
this._setupAlwaysOnTopWindow();
251252
}
252253
}
254+
/**
255+
* Dismisses always on top window.
256+
*
257+
* @returns {void}
258+
*/
259+
_dismiss() {
260+
this.emit(ALWAYSONTOP_DISMISSED);
261+
this._closeAlwaysOnTopWindow();
262+
}
253263

254264
/**
255265
* Sets all necessary content (HTML, CSS, JS) to the always on top window.
@@ -262,6 +272,7 @@ class AlwaysOnTop extends EventEmitter {
262272
}
263273
this._alwaysOnTopWindow.alwaysOnTop = {
264274
api: this._api,
275+
dismiss: this._dismiss,
265276
onload: this._updateLargeVideoSrc,
266277
onbeforeunload: () => {
267278
this.emit(ALWAYSONTOP_WILL_CLOSE);
@@ -319,6 +330,7 @@ class AlwaysOnTop extends EventEmitter {
319330
this._alwaysOnTopWindow.document.body.innerHTML = `
320331
<div id="react"></div>
321332
<video autoplay="" id="video" style="transform: none;" muted></video>
333+
<div class="dismiss"></div>
322334
<link rel="stylesheet" href="file://${ cssPath }">
323335
`;
324336

0 commit comments

Comments
 (0)