Skip to content

Commit

Permalink
Add pin always on top button
Browse files Browse the repository at this point in the history
a "might have" feature 😅
  • Loading branch information
Yukaii committed Mar 24, 2017
1 parent a0b4000 commit 9aca856
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
12 changes: 12 additions & 0 deletions app.css
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,15 @@ navbar.unsupported {
#navbar-container .control-buttons>*:hover {
color: #c1c1c1;
}

#navbar-container .control-buttons > .pin-window {
margin-right: 5px;
font-size: 0.9em;
padding-bottom: 2px;
transform: rotate(-45deg);
transition: transform .5s;
}

#navbar-container .control-buttons > .pin-window.pinned {
transform: rotate(0);
}
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ <h4 class="modal-title">Customize HackMD server</h4>
<navbar>
<div id="navbar-container">
<div class="control-buttons">
<div class="pin-window"><i class="fa fa-map-pin" aria-hidden="true"></i></div>
<div class="home">HOME</div>
<div class="refresh">REFRESH</div>
<div class="navigate-back" style="margin: 0 1em;">&#x3C;</div>
Expand Down
19 changes: 15 additions & 4 deletions renderer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { ipcRenderer, remote, clipboard } = require('electron')
const { BrowserWindow, Menu } = remote
const { Menu } = remote

const os = remote.require('os')
const path = remote.require('path')
Expand Down Expand Up @@ -88,21 +88,32 @@ window.onload = () => {
}

document.querySelector('#navbar-container .minimize-window').onclick = () => {
const win = BrowserWindow.getFocusedWindow()
const win = remote.getCurrentWindow()
win.minimize()
}

document.querySelector('#navbar-container .toggle-window').onclick = () => {
const win = BrowserWindow.getFocusedWindow()
const win = remote.getCurrentWindow()
if (win.isMaximized()) {
win.unmaximize()
} else {
win.maximize()
}
}

$('#navbar-container .pin-window').click(function () {
const win = remote.getCurrentWindow()
if (win.isAlwaysOnTop()) {
win.setAlwaysOnTop(false)
$(this).removeClass('pinned')
} else {
win.setAlwaysOnTop(true)
$(this).addClass('pinned')
}
})

document.querySelector('#navbar-container .close-window').onclick = () => {
const win = BrowserWindow.getFocusedWindow()
const win = remote.getCurrentWindow()
win.close()
}

Expand Down

0 comments on commit 9aca856

Please sign in to comment.