forked from stevewirts/snap-and-dock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchild.js
58 lines (42 loc) · 1.36 KB
/
child.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
/* globals fin */
'use strict';
/**
* Created by haseebriaz on 03/03/15.
*/
function getUndockButton() {
return document.getElementById('undockButton');
}
function enableUndock(value) {
var currentClasses = getUndockButton().classList;
if (value) {
currentClasses.remove('hidden');
} else {
currentClasses.add('hidden');
}
}
function onDock(message) {
if (message.windowName === window.name) {
enableUndock(true);
}
}
function updateDimensions(bounds) {
document.getElementById('dimensions').innerHTML = 'x: ' + bounds.left + ', y: ' + bounds.top + ', width: ' + bounds.width + ', height: ' + bounds.height;
}
function onUnDock(message) {
if (message.windowName === window.name) {
enableUndock(false);
}
}
function undock() {
var currentWindow = fin.desktop.Window.getCurrent();
currentWindow.leaveGroup();
}
fin.desktop.main(function() {
document.getElementById('title').innerText = window.name;
getUndockButton().addEventListener('click', undock);
fin.desktop.InterApplicationBus.subscribe('*', 'window-docked', onDock);
fin.desktop.InterApplicationBus.subscribe('*', 'window-undocked', onUnDock);
var currentWindow = fin.desktop.Window.getCurrent();
currentWindow.getBounds(updateDimensions);
currentWindow.addEventListener('bounds-changing', updateDimensions);
});