Skip to content

Commit 08403fd

Browse files
committed
initial commit
1 parent ed5cf02 commit 08403fd

File tree

485 files changed

+27855
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

485 files changed

+27855
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Frameless window
2+
3+
A sample application to showcase how you can use `"frame": false` windows to allow total customization of the window's real state. At beginning, the window is open with no titlebar. As long as you check one of the titlebars, it is added to the appropriate position. Notice that the added titlebars are the only parts of the window that allows dragging. This is achieved through a special CSS property applied to what is draggable or non-draggable (by default, the whole window is not draggable): `-webkit-app-region: drag|no-drag;`
4+
5+
**This demo requires node-webkit >= v0.3.0**
6+
7+
## Screen shot
8+
9+
![screenshot](http://ww1.sinaimg.cn/large/6556d357tw1dxuhssppffj.jpg)
10+
11+
## APIs
12+
13+
* [Window](https://github.com/nwjs/nw.js/wiki/Window)
14+
* [Frameless Window](https://github.com/nwjs/nw.js/wiki/Frameless-Window)
15+

bottom-titlebar.png

2.95 KB
Loading

button_close.png

326 Bytes
Loading

button_close_hover.png

405 Bytes
Loading

frameless_window.html

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<html>
2+
<head>
3+
<title>Frameless Window</title>
4+
5+
<link rel="stylesheet" type="text/css" href="style.css" />
6+
<script src="titlebar.js"></script>
7+
<script src="frameless_window.js"></script>
8+
</head>
9+
10+
<body>
11+
<div id="content">
12+
<div id="inner-content">
13+
14+
Select the titlebar to enable:
15+
<br/>
16+
17+
<input type="checkbox" id="top-box">Top Titlebar
18+
<br/>
19+
<input type="checkbox" id="bottom-box">Bottom Titlebar
20+
<br/>
21+
<input type="checkbox" id="left-box">Left Titlebar
22+
<br/>
23+
<input type="checkbox" id="right-box">Right Titlebar
24+
<br/>
25+
<br/>
26+
27+
<button id="close-window-button">Close Window</button>
28+
<br/>
29+
<button id="minimize-window-button">Minimize</button>
30+
<br/>
31+
<button id="maximize-window-button">Maximize</button>
32+
<br/>
33+
<button id="unmaximize-window-button">Unmaximize</button>
34+
<br/>
35+
<button id="open-inspector-button">Open Developer Tools</button>
36+
37+
<div id="time"></div>
38+
39+
</div>
40+
</div>
41+
</body>
42+
</html>

frameless_window.js

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
var gui = require("nw.gui");
2+
3+
// Extend application menu for Mac OS
4+
if (process.platform == "darwin") {
5+
var menu = new gui.Menu({type: "menubar"});
6+
menu.createMacBuiltin && menu.createMacBuiltin(window.document.title);
7+
gui.Window.get().menu = menu;
8+
}
9+
10+
function updateCheckbox() {
11+
var top_checkbox = document.getElementById("top-box");
12+
var bottom_checkbox = document.getElementById("bottom-box");
13+
var left_checkbox = document.getElementById("left-box");
14+
var right_checkbox = document.getElementById("right-box");
15+
if (top_checkbox.checked || bottom_checkbox.checked) {
16+
left_checkbox.disabled = true;
17+
right_checkbox.disabled = true;
18+
} else if (left_checkbox.checked || right_checkbox.checked) {
19+
top_checkbox.disabled = true;
20+
bottom_checkbox.disabled = true;
21+
} else {
22+
left_checkbox.disabled = false;
23+
right_checkbox.disabled = false;
24+
top_checkbox.disabled = false;
25+
bottom_checkbox.disabled = false;
26+
}
27+
}
28+
29+
function initCheckbox(checkboxId, titlebar_name, titlebar_icon_url, titlebar_text) {
30+
var elem = document.getElementById(checkboxId);
31+
if (!elem)
32+
return;
33+
elem.onclick = function() {
34+
if (document.getElementById(checkboxId).checked)
35+
addTitlebar(titlebar_name, titlebar_icon_url, titlebar_text);
36+
else
37+
removeTitlebar(titlebar_name);
38+
focusTitlebars(true);
39+
40+
updateContentStyle();
41+
updateCheckbox();
42+
}
43+
}
44+
45+
window.onfocus = function() {
46+
console.log("focus");
47+
focusTitlebars(true);
48+
};
49+
50+
window.onblur = function() {
51+
console.log("blur");
52+
focusTitlebars(false);
53+
};
54+
55+
window.onresize = function() {
56+
updateContentStyle();
57+
};
58+
59+
window.onload = function() {
60+
61+
initCheckbox("top-box", "top-titlebar", "top-titlebar.png", "Top Titlebar");
62+
initCheckbox("bottom-box", "bottom-titlebar", "bottom-titlebar.png", "Bottom Titlebar");
63+
initCheckbox("left-box", "left-titlebar", "left-titlebar.png", "Left Titlebar");
64+
initCheckbox("right-box", "right-titlebar", "right-titlebar.png", "Right Titlebar");
65+
66+
document.getElementById("close-window-button").onclick = function() {
67+
window.close();
68+
};
69+
70+
document.querySelector('#minimize-window-button').onclick = function () {
71+
gui.Window.get().minimize();
72+
};
73+
74+
document.querySelector('#maximize-window-button').onclick = function () {
75+
gui.Window.get().maximize();
76+
};
77+
document.querySelector('#unmaximize-window-button').onclick = function () {
78+
gui.Window.get().unmaximize();
79+
};
80+
81+
document.querySelector('#open-inspector-button').onclick = function () {
82+
var win = gui.Window.get();
83+
if (win.isDevToolsOpen()) {
84+
win.closeDevTools();
85+
this.innerText = "Open Developer Tools";
86+
} else {
87+
win.showDevTools();
88+
this.innerText = "Close Developer Tools";
89+
}
90+
};
91+
92+
updateContentStyle();
93+
gui.Window.get().show();
94+
};
95+
96+
97+
//
98+
// HERE GOES NEW CODE NWJS ISSUE #7715
99+
//
100+
101+
const pathToGitRepo = '/Users/jan/Documents/Projects/Pragma-git/pragma-git';
102+
103+
const simpleGit = require('simple-git'); // npm install simple-git
104+
105+
const delayInMs = 1000;
106+
window.setInterval( _update, delayInMs ); // continuously call _update
107+
108+
async function _update(){
109+
110+
var startTime = performance.now();
111+
112+
var isRepo;
113+
await simpleGit( pathToGitRepo ).checkIsRepo(onCheckIsRepo);
114+
function onCheckIsRepo(err, checkResult) {
115+
isRepo = checkResult
116+
console.log(' ');
117+
console.log(`_update took ${ performance.now() - startTime} ms (at onCheckIsRepo)`);
118+
document.getElementById('time').innerText = `_update took ${ performance.now() - startTime} ms (at onCheckIsRepo)`;
119+
}
120+
121+
122+
}

icon_128.png

15.6 KB
Loading

left-titlebar.png

2.93 KB
Loading

node_modules/.bin/sgit

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/window-size

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)