jsgui3-server 0.0.92 → 0.0.94
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/old/square_box.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
const jsgui = require('jsgui3-html'); // and will replace this with jsgui-client, I presume.
|
|
3
|
-
const {controls, Control, mixins} = jsgui;
|
|
4
|
-
const {dragable} = mixins;
|
|
5
|
-
|
|
6
|
-
class Demo_UI extends Control {
|
|
7
|
-
constructor(spec) {
|
|
8
|
-
spec.__type_name = spec.__type_name || 'demo_ui';
|
|
9
|
-
super(spec);
|
|
10
|
-
const {context} = this;
|
|
11
|
-
this.add_class('demo-ui');
|
|
12
|
-
|
|
13
|
-
const compose = () => {
|
|
14
|
-
const box = new Square_Box({
|
|
15
|
-
context: context
|
|
16
|
-
})
|
|
17
|
-
this.add(box);
|
|
18
|
-
}
|
|
19
|
-
if (!spec.el) {
|
|
20
|
-
compose();
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
activate() {
|
|
24
|
-
if (!this.__active) {
|
|
25
|
-
super.activate();
|
|
26
|
-
const {context} = this;
|
|
27
|
-
|
|
28
|
-
console.log('activate Demo_UI');
|
|
29
|
-
// listen for the context events regarding frames, changes, resizing.
|
|
30
|
-
|
|
31
|
-
context.on('window-resize', e_resize => {
|
|
32
|
-
console.log('window-resize', e_resize);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
controls.Demo_UI = Demo_UI;
|
|
39
|
-
Demo_UI.css = `
|
|
40
|
-
.demo-ui {
|
|
41
|
-
display: flex;
|
|
42
|
-
flex-direction: column;
|
|
43
|
-
justify-content: center;
|
|
44
|
-
align-items: center;
|
|
45
|
-
text-align: center;
|
|
46
|
-
min-height: 100vh;
|
|
47
|
-
}
|
|
48
|
-
`;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
class Square_Box extends Control {
|
|
53
|
-
constructor(spec) {
|
|
54
|
-
spec.__type_name = spec.__type_name || 'square_box';
|
|
55
|
-
super(spec);
|
|
56
|
-
this.add_class('square-box');
|
|
57
|
-
}
|
|
58
|
-
activate() {
|
|
59
|
-
if (!this.__active) {
|
|
60
|
-
super.activate();
|
|
61
|
-
console.log('Activate square box');
|
|
62
|
-
|
|
63
|
-
dragable(this, {
|
|
64
|
-
drag_mode: 'translate'
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
console.log('dragable mixin applied to square');
|
|
68
|
-
this.dragable = true;
|
|
69
|
-
console.log('this.dragable = true;');
|
|
70
|
-
|
|
71
|
-
this.on('dragend', e => {
|
|
72
|
-
console.log('square box dragend e', e);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
Square_Box.css = `
|
|
79
|
-
.square-box {
|
|
80
|
-
background-color: #BB3333;
|
|
81
|
-
width: 220px;
|
|
82
|
-
height: 220px;
|
|
83
|
-
}
|
|
84
|
-
`;
|
|
85
|
-
controls.Square_Box = Square_Box;
|
|
86
|
-
|
|
87
|
-
// need records in the map of controls by name
|
|
88
|
-
|
|
89
|
-
if (require.main === module) {
|
|
90
|
-
const SCS = require('../../single-control-server');
|
|
91
|
-
const server = new SCS({
|
|
92
|
-
Ctrl: Demo_UI,
|
|
93
|
-
|
|
94
|
-
//'js_mode': 'debug',
|
|
95
|
-
|
|
96
|
-
'client_package': require.resolve('./square_box.js')
|
|
97
|
-
//js_client: require.resolve('./square_box.js')
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
// then start the server....
|
|
101
|
-
|
|
102
|
-
// be able to choose the port / ports?
|
|
103
|
-
|
|
104
|
-
server.start(8080, function (err, cb_start) {
|
|
105
|
-
if (err) {
|
|
106
|
-
throw err;
|
|
107
|
-
} else {
|
|
108
|
-
console.log('server started');
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
}
|