jsgui3-server 0.0.91 → 0.0.93
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/examples/{square_box.js → box/square_box.js} +1 -3
- package/examples/{square_box_client.js → box/square_box_client.js} +4 -1
- package/examples/boxes/square_boxes_client.js +3 -4
- package/examples/grids/grid_1_client.js +133 -0
- package/examples/mx_display/mx_display_1.js +46 -0
- package/examples/mx_display/mx_display_1_client.js +444 -0
- package/package.json +9 -8
- package/server.js +366 -886
- package/old/square_box.js +0 -112
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
const jsgui = require('./square_box_client');
|
|
2
2
|
|
|
3
3
|
const {Demo_UI, Square_Box} = jsgui.controls;
|
|
4
|
-
const Server = require('
|
|
4
|
+
const Server = require('../../server');
|
|
5
5
|
|
|
6
6
|
// Want to exclude this from the client bundle.
|
|
7
7
|
// Some kind of marking to say that it's server-side only?
|
|
8
8
|
|
|
9
9
|
if (require.main === module) {
|
|
10
|
-
|
|
11
10
|
const server = new Server({
|
|
12
11
|
Ctrl: Demo_UI,
|
|
13
12
|
// Giving it the Ctrl and disk path client js should enable to server to get the JS-bundled CSS from the file(s).
|
|
@@ -18,7 +17,6 @@ if (require.main === module) {
|
|
|
18
17
|
'disk_path_client_js': require.resolve('./square_box_client.js')
|
|
19
18
|
//js_client: require.resolve('./square_box.js')
|
|
20
19
|
});
|
|
21
|
-
|
|
22
20
|
// A callback or event for when the bundling has been completed
|
|
23
21
|
// a 'ready' event.
|
|
24
22
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const jsgui = require('jsgui3-client');
|
|
1
|
+
const jsgui = require('jsgui3-client');
|
|
2
2
|
const {controls, Control, mixins} = jsgui;
|
|
3
3
|
const {dragable} = mixins;
|
|
4
4
|
|
|
@@ -73,6 +73,9 @@ class Square_Box extends Control {
|
|
|
73
73
|
|
|
74
74
|
this.on('dragend', e => {
|
|
75
75
|
console.log('square box dragend e', e);
|
|
76
|
+
//this.background.color = '#FF4444';
|
|
77
|
+
//this.color = '#FF4444';
|
|
78
|
+
this.dom.el.style.backgroundColor = '#FF4444';
|
|
76
79
|
});
|
|
77
80
|
|
|
78
81
|
}
|
|
@@ -62,8 +62,10 @@ class Demo_UI extends Control {
|
|
|
62
62
|
// or even box2.color = ... and it would know which color was meant
|
|
63
63
|
// or be able to access the .color reference / property name when asked for.
|
|
64
64
|
|
|
65
|
+
box2.background.color = '#6655CC';
|
|
65
66
|
|
|
66
|
-
|
|
67
|
+
|
|
68
|
+
//box2.dom.attributes.style['background-color'] = '#6655CC';
|
|
67
69
|
this.add(box2);
|
|
68
70
|
|
|
69
71
|
const box3 = new Square_Box({
|
|
@@ -108,13 +110,10 @@ Demo_UI.css = `
|
|
|
108
110
|
|
|
109
111
|
// then if running on the client...?
|
|
110
112
|
|
|
111
|
-
|
|
112
|
-
|
|
113
113
|
//controls.Square_Box = Square_Box;
|
|
114
114
|
// could export jsgui with the updated controls....
|
|
115
115
|
// so that they are in the correct Page Context.?
|
|
116
116
|
|
|
117
|
-
|
|
118
117
|
controls.Demo_UI = Demo_UI;
|
|
119
118
|
controls.Square_Box = Square_Box;
|
|
120
119
|
|
|
@@ -40,6 +40,8 @@ Square_Box.css = `
|
|
|
40
40
|
|
|
41
41
|
// Relies on extracting CSS from JS files.
|
|
42
42
|
|
|
43
|
+
const {press_events} = jsgui.mixins;
|
|
44
|
+
|
|
43
45
|
const Grid = controls.Grid;
|
|
44
46
|
|
|
45
47
|
class Demo_UI extends Control {
|
|
@@ -123,6 +125,106 @@ class Demo_UI extends Control {
|
|
|
123
125
|
console.log('grid.grid_size', grid.grid_size);
|
|
124
126
|
grid.refresh_size();
|
|
125
127
|
|
|
128
|
+
press_events(grid);
|
|
129
|
+
|
|
130
|
+
// the grid press start should contain the cell.
|
|
131
|
+
// that is the specific kind of API improvement that helps the grid with customised specific events.
|
|
132
|
+
|
|
133
|
+
// This is having trouble on iOS with touch events.
|
|
134
|
+
|
|
135
|
+
// Better ways to check which cell is being pressed?
|
|
136
|
+
// Seems like we don't get the new cell upon the touch move event.
|
|
137
|
+
|
|
138
|
+
// Pressing and moving to a different ctrl / cell not working on iOS mobile safari.
|
|
139
|
+
|
|
140
|
+
// Maybe improve grid painting for iOS?
|
|
141
|
+
// Maybe improve the 'move on grid' event handlings?
|
|
142
|
+
|
|
143
|
+
// Maybe press events isn't the best way?
|
|
144
|
+
// Or need better handling of iOS within press events even?
|
|
145
|
+
// Determining grid square by the coordinates would be possible if there is a rendering model.
|
|
146
|
+
// Maybe further work within mixins.
|
|
147
|
+
// Maybe within grid / grid mixins.
|
|
148
|
+
|
|
149
|
+
// More work within Grid to better enable cell retrieval?
|
|
150
|
+
// And then specific work on grid press events?
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
const setup_grid_painting = () => {
|
|
155
|
+
|
|
156
|
+
// ctrl_target maybe is not stable accross all devices and browsers.
|
|
157
|
+
// Could be better to get some lower level things working right....
|
|
158
|
+
|
|
159
|
+
let paint_color = '#000000';
|
|
160
|
+
grid.on('press-start', e => {
|
|
161
|
+
//console.log('grid press-start ', e);
|
|
162
|
+
const {ctrl_target} = e;
|
|
163
|
+
const [x, y] = [ctrl_target.x, ctrl_target.y];
|
|
164
|
+
|
|
165
|
+
// grid.get_cell_at_px_coords([xpx, ypx]);
|
|
166
|
+
// grid.get_cell_at_pos([x, y]);
|
|
167
|
+
|
|
168
|
+
//console.log('[x, y]', [x, y]);
|
|
169
|
+
|
|
170
|
+
// the colour of the cell there at start determines colour of paint brush?
|
|
171
|
+
// will be best to incorporate painting / grid painting code into the mixins?
|
|
172
|
+
// probably only a few lines of code for the right API.
|
|
173
|
+
|
|
174
|
+
if (ctrl_target.dom.attributes.style['background-color'] === '#000000') {
|
|
175
|
+
paint_color = '#FFFFFF';
|
|
176
|
+
} else {
|
|
177
|
+
paint_color = '#000000';
|
|
178
|
+
}
|
|
179
|
+
ctrl_target.dom.attributes.style['background-color'] = paint_color;
|
|
180
|
+
|
|
181
|
+
e.preventDefault();
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
// and that would be a press-grid-move? press-gridcell-move?
|
|
185
|
+
// this is just a place to set up and test different behaviours for grid ui.
|
|
186
|
+
// may have things like area fills, or select area.
|
|
187
|
+
|
|
188
|
+
let lastx, lasty;
|
|
189
|
+
grid.on('press-move', e => {
|
|
190
|
+
|
|
191
|
+
// Not getting the expeced ctrl_target that is right under the movement touch event on iOS.
|
|
192
|
+
// Could we get the specific cell by using its display coords to determine which cell it is over?
|
|
193
|
+
|
|
194
|
+
// Gets the right pixel coords from the event for this.
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
console.log('grid press-move ', e);
|
|
198
|
+
|
|
199
|
+
// Not working right on iOS. Not detecting which cell is directly underneith.
|
|
200
|
+
const {ctrl_target} = e;
|
|
201
|
+
//const {ctrl} = e;
|
|
202
|
+
const [x, y] = [ctrl_target.x, ctrl_target.y];
|
|
203
|
+
|
|
204
|
+
if (x !== lastx || y !== lasty) {
|
|
205
|
+
grid.raise('press-cell-move', e);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
//console.log('[x, y]', [x, y]);
|
|
209
|
+
lastx = x;
|
|
210
|
+
lasty = y;
|
|
211
|
+
|
|
212
|
+
//e.preventDefault();
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
grid.on('press-cell-move', e => {
|
|
216
|
+
const {ctrl_target} = e;
|
|
217
|
+
const [x, y] = [ctrl_target.x, ctrl_target.y];
|
|
218
|
+
//console.log('press-cell-move [x, y]', [x, y]);
|
|
219
|
+
ctrl_target.dom.attributes.style['background-color'] = paint_color;
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
setup_grid_painting();
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
// 'press-move'
|
|
227
|
+
|
|
126
228
|
|
|
127
229
|
// listen for the context events regarding frames, changes, resizing.
|
|
128
230
|
|
|
@@ -132,7 +234,37 @@ class Demo_UI extends Control {
|
|
|
132
234
|
|
|
133
235
|
// A delegated click or other event handler may work nicely (for the cells).
|
|
134
236
|
|
|
237
|
+
// Could use press events to deal with events more smoothly?
|
|
238
|
+
// A grid-events mixin?
|
|
239
|
+
// Want to make high quality and specific code that is outside of the grid js component.
|
|
240
|
+
// More swappable, composable, and upgradable components.
|
|
241
|
+
|
|
242
|
+
// More functionality within the mixins makes sense.
|
|
243
|
+
// Mixins as interfaces too.
|
|
244
|
+
|
|
245
|
+
// grid.enable(Drag_Box)
|
|
246
|
+
// or similar.
|
|
247
|
+
// grid.mx_grid_press_ui possibly.
|
|
248
|
+
// details of ui handling behavious moving out of the controls themselves.
|
|
249
|
+
// more general within the mixins.
|
|
250
|
+
|
|
251
|
+
// grid.on('drag-over') or similar.
|
|
252
|
+
// specialised events within the appropriate mixins.
|
|
253
|
+
// could try them here first though?
|
|
254
|
+
|
|
255
|
+
// a different box-area-select mixin? or just a bit different when on a grid...?
|
|
256
|
+
// may need to repeat code a little, but code will be simple at the app level at least.
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
135
265
|
grid.each_cell(cell => {
|
|
266
|
+
|
|
267
|
+
/*
|
|
136
268
|
cell.on('click', e_click => {
|
|
137
269
|
//console.log('e_click', e_click);
|
|
138
270
|
//console.log('cell', cell);
|
|
@@ -148,6 +280,7 @@ class Demo_UI extends Control {
|
|
|
148
280
|
|
|
149
281
|
|
|
150
282
|
})
|
|
283
|
+
*/
|
|
151
284
|
})
|
|
152
285
|
|
|
153
286
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const jsgui = require('./mx_display_1_client');
|
|
2
|
+
|
|
3
|
+
const {Demo_UI, Square_Box} = jsgui.controls;
|
|
4
|
+
const Server = require('../../server');
|
|
5
|
+
|
|
6
|
+
// Want to exclude this from the client bundle.
|
|
7
|
+
// Some kind of marking to say that it's server-side only?
|
|
8
|
+
|
|
9
|
+
if (require.main === module) {
|
|
10
|
+
|
|
11
|
+
const server = new Server({
|
|
12
|
+
Ctrl: Demo_UI,
|
|
13
|
+
// Giving it the Ctrl and disk path client js should enable to server to get the JS-bundled CSS from the file(s).
|
|
14
|
+
// Putting the JS files through proper parsing and into a syntax tree would be best.
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
//'js_mode': 'debug',
|
|
18
|
+
'disk_path_client_js': require.resolve('./mx_display_1_client.js')
|
|
19
|
+
//js_client: require.resolve('./square_box.js')
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// A callback or event for when the bundling has been completed
|
|
23
|
+
// a 'ready' event.
|
|
24
|
+
|
|
25
|
+
// then start the server....
|
|
26
|
+
// be able to choose the port / ports?
|
|
27
|
+
console.log('waiting for server ready event');
|
|
28
|
+
server.on('ready', () => {
|
|
29
|
+
console.log('server ready');
|
|
30
|
+
|
|
31
|
+
// server start will change to observable?
|
|
32
|
+
|
|
33
|
+
server.start(8080, function (err, cb_start) {
|
|
34
|
+
if (err) {
|
|
35
|
+
throw err;
|
|
36
|
+
} else {
|
|
37
|
+
// Should have build it by now...
|
|
38
|
+
|
|
39
|
+
console.log('server started');
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
}
|