Skip to content

Commit 9aca856

Browse files
committed
Add pin always on top button
a "might have" feature 😅
1 parent a0b4000 commit 9aca856

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

app.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,15 @@ navbar.unsupported {
7878
#navbar-container .control-buttons>*:hover {
7979
color: #c1c1c1;
8080
}
81+
82+
#navbar-container .control-buttons > .pin-window {
83+
margin-right: 5px;
84+
font-size: 0.9em;
85+
padding-bottom: 2px;
86+
transform: rotate(-45deg);
87+
transition: transform .5s;
88+
}
89+
90+
#navbar-container .control-buttons > .pin-window.pinned {
91+
transform: rotate(0);
92+
}

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ <h4 class="modal-title">Customize HackMD server</h4>
3131
<navbar>
3232
<div id="navbar-container">
3333
<div class="control-buttons">
34+
<div class="pin-window"><i class="fa fa-map-pin" aria-hidden="true"></i></div>
3435
<div class="home">HOME</div>
3536
<div class="refresh">REFRESH</div>
3637
<div class="navigate-back" style="margin: 0 1em;">&#x3C;</div>

renderer.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const { ipcRenderer, remote, clipboard } = require('electron')
2-
const { BrowserWindow, Menu } = remote
2+
const { Menu } = remote
33

44
const os = remote.require('os')
55
const path = remote.require('path')
@@ -88,21 +88,32 @@ window.onload = () => {
8888
}
8989

9090
document.querySelector('#navbar-container .minimize-window').onclick = () => {
91-
const win = BrowserWindow.getFocusedWindow()
91+
const win = remote.getCurrentWindow()
9292
win.minimize()
9393
}
9494

9595
document.querySelector('#navbar-container .toggle-window').onclick = () => {
96-
const win = BrowserWindow.getFocusedWindow()
96+
const win = remote.getCurrentWindow()
9797
if (win.isMaximized()) {
9898
win.unmaximize()
9999
} else {
100100
win.maximize()
101101
}
102102
}
103103

104+
$('#navbar-container .pin-window').click(function () {
105+
const win = remote.getCurrentWindow()
106+
if (win.isAlwaysOnTop()) {
107+
win.setAlwaysOnTop(false)
108+
$(this).removeClass('pinned')
109+
} else {
110+
win.setAlwaysOnTop(true)
111+
$(this).addClass('pinned')
112+
}
113+
})
114+
104115
document.querySelector('#navbar-container .close-window').onclick = () => {
105-
const win = BrowserWindow.getFocusedWindow()
116+
const win = remote.getCurrentWindow()
106117
win.close()
107118
}
108119

0 commit comments

Comments
 (0)