-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathchild.js
61 lines (39 loc) · 1.28 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
59
60
61
/* globals fin */
'use strict';
/**
* Created by haseebriaz on 03/03/15.
*/
var undockButton = null;
function enableUndock(value) {
document.getElementById('undockButton').style.display = value ? 'block' : 'none';
}
function onDock(message) {
if (message.windowName === window.name) {
enableUndock(true);
}
}
function updateDimentions() {
var win = fin.desktop.Window.getCurrent();
win.getBounds(function(bounds) {
document.getElementById('dimentions').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() {
fin.desktop.InterApplicationBus.publish('undock-window', {
windowName: window.name
});
}
fin.desktop.main(function() {
document.getElementById('title').innerText = window.name;
setInterval(updateDimentions, 100);
undockButton = document.getElementById('undockButton');
undockButton.addEventListener('click', undock);
enableUndock(false);
fin.desktop.InterApplicationBus.subscribe('*', 'window-docked', onDock);
fin.desktop.InterApplicationBus.subscribe('*', 'window-undocked', onUnDock);
});