jsgui3-server 0.0.120 → 0.0.121
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/boxes/square_boxes.js +3 -0
- package/examples/boxes/square_boxes_client.js +5 -1
- package/examples/controls/11) window, mirrored text fields/client.js +31 -273
- package/examples/controls/11b) window, shared Data_Object model mirrored text fields/client.js +84 -366
- package/examples/controls/11c) window, shared Data_Value model mirrored text fields/client.js +2 -2
- package/examples/controls/11d) window, shared model mirrored integer text fields/both.js +17 -0
- package/examples/controls/11d) window, shared model mirrored integer text fields/client.js +65 -396
- package/examples/controls/11d) window, shared model mirrored integer text fields/server.js +4 -116
- package/examples/controls/12) window, Select_Options control/client.js +17 -0
- package/examples/controls/13) window, shared model mirrored lat_long/client.js +933 -0
- package/examples/controls/13) window, shared model mirrored lat_long/server.js +50 -0
- package/examples/controls/14) window, control compositional model/client.js +328 -0
- package/examples/controls/14) window, control compositional model/server.js +118 -0
- package/examples/controls/14a) window, control spec has compositional model/client.js +440 -0
- package/examples/controls/14a) window, control spec has compositional model/server.js +118 -0
- package/examples/controls/15) window, text field/client.js +256 -0
- package/examples/controls/15) window, text field/server.js +39 -0
- package/examples/controls/16) Window([Text_Input])/client.js +266 -0
- package/examples/controls/16) Window([Text_Input])/server.js +109 -0
- package/examples/controls/16a) Window([Text_Input]) Integer data.model.data_type/client.js +494 -0
- package/examples/controls/16a) Window([Text_Input]) Integer data.model.data_type/isomorphic.js +24 -0
- package/examples/controls/16a) Window([Text_Input]) Integer data.model.data_type/server.js +73 -0
- package/examples/controls/2b) two window, context menus/client.js +193 -0
- package/examples/controls/2b) two window, context menus/server.js +114 -0
- package/examples/controls/3) five windows/server.js +0 -1
- package/examples/controls/4) window, tabbed panel/client.js +15 -2
- package/examples/controls/4a) window, tabbed panel with various controls inside/client.js +233 -0
- package/examples/controls/4a) window, tabbed panel with various controls inside/server.js +118 -0
- package/examples/controls/5) window, grid/client.js +289 -9
- package/examples/controls/5) window, grid/server.js +2 -0
- package/examples/controls/8) window, checkbox/client.js +63 -101
- package/package.json +11 -11
- package/publishers/http-webpage-publisher.js +4 -5
- package/resources/jsbuilder/babel/deep_iterate/deep_iterate_babel.js +5 -1
- package/resources/processors/bundlers/js/esbuild/Advanced_JS_Bundler_Using_ESBuild.js +9 -6
- package/resources/processors/bundlers/js/esbuild/Core_JS_Single_File_Minifying_Bundler_Using_ESBuild.js +2 -1
- package/resources/processors/extractors/Extractor.js +3 -1
- package/resources/processors/extractors/js/css_and_js/AST_Node/CSS_And_JS_From_JS_String_Using_AST_Node_Extractor.js +19 -4
package/examples/controls/11b) window, shared Data_Object model mirrored text fields/client.js
CHANGED
|
@@ -36,41 +36,12 @@ class Demo_UI extends Active_HTML_Document {
|
|
|
36
36
|
spec.__type_name = spec.__type_name || 'demo_ui';
|
|
37
37
|
super(spec);
|
|
38
38
|
const {context} = this;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// Create the Data_Model here....
|
|
42
|
-
|
|
43
|
-
// Maybe on pre-activate set its values if it's already been set?
|
|
44
|
-
|
|
45
|
-
// Or better send over info about the Data_Model that gets brought into the Page_Context???
|
|
46
|
-
|
|
47
|
-
// data.model transfer needs to be automatic.
|
|
48
|
-
// Possibly it would be a client-side resource?
|
|
49
|
-
|
|
50
|
-
// Want to make the syntax when composing / defining things as simple as possible.
|
|
51
|
-
|
|
52
|
-
// Simple enough for the moment.
|
|
53
|
-
// Could see about auto-registering?
|
|
54
|
-
// Maybe later on.
|
|
55
|
-
// Simple and explicit code will be best for the moment.
|
|
56
|
-
// Must be concise, then could consider more concise and less explicit (but unambiguous) ways to declare things
|
|
57
|
-
// to do with data and view model interactions.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
// And using a Control_Data class here could help.
|
|
61
|
-
// Then a Control_View class.
|
|
62
|
-
// And the Control_View has its own internal Data. Maybe even a Control_View_Data ???
|
|
63
|
-
|
|
64
39
|
|
|
65
|
-
|
|
66
|
-
// Needs a little bit more work...
|
|
67
|
-
|
|
68
|
-
// Maybe adding the fields to the Data_Object is needed.
|
|
69
|
-
|
|
40
|
+
/*
|
|
70
41
|
|
|
71
42
|
const setup_demo_ui_data_model = () => {
|
|
72
43
|
this.data = {
|
|
73
|
-
model: new
|
|
44
|
+
model: new Data_Value({
|
|
74
45
|
context
|
|
75
46
|
})
|
|
76
47
|
}
|
|
@@ -79,104 +50,11 @@ class Demo_UI extends Active_HTML_Document {
|
|
|
79
50
|
}
|
|
80
51
|
setup_demo_ui_data_model();
|
|
81
52
|
|
|
53
|
+
*/
|
|
82
54
|
|
|
55
|
+
this.data.model.data_type = String;
|
|
83
56
|
|
|
84
57
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
// The app as a whole having a view.data.model ????
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
// Or want defined properties / proxies on the Data_Model?
|
|
92
|
-
// or fields?
|
|
93
|
-
|
|
94
|
-
// want to listen for changes to the data_model.
|
|
95
|
-
|
|
96
|
-
// May need comprehensive changes to a lot of controls.
|
|
97
|
-
// Making this system the standard / default.
|
|
98
|
-
// Getting it working with easy idioms on the top level - don't update the data model on every keystroke.
|
|
99
|
-
|
|
100
|
-
// when setting the bounds of a rect, need to set multiple numbers at once (up to 4).
|
|
101
|
-
|
|
102
|
-
// A ctrl.view.data.model
|
|
103
|
-
// Looks like it's worth making and making use of Control_View and Control_Data classes.
|
|
104
|
-
// Would have / support .model.
|
|
105
|
-
|
|
106
|
-
// The view.data.model would model exactly what data is in the view.
|
|
107
|
-
// It would only get synced to the data.model at appropriate times (like user moving on, or confirming 'ok' or 'go')
|
|
108
|
-
|
|
109
|
-
// 'cancel' and 'go' would be of use in some cases.
|
|
110
|
-
// red (or grey) and then a green (or slightly green) button.
|
|
111
|
-
// a slightly red grey and then a bolder and more colorful green. Would be more color blindness accessible.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
// this.data.model.set('k', 'v')???
|
|
126
|
-
|
|
127
|
-
// create_shared_data_model function...
|
|
128
|
-
// would happen on activate as well as compose.
|
|
129
|
-
|
|
130
|
-
// Or just make sure there is the 'value' field there...?
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
// And have it persisted to the HTML by the server that they both use that same data.model???
|
|
139
|
-
// A bit more lower level code to support more properties / objects being reconstructed client-side would help.
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
// Then when there is a change to that data_model...?
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
// Context would have a built-in data_model?
|
|
152
|
-
// Maybe for HTML apps. Not all Data_Object contexts.
|
|
153
|
-
|
|
154
|
-
// Server_Page_Context also having and using a Data_Model....
|
|
155
|
-
// Would make sense.
|
|
156
|
-
// Same with the Client_Page_Context
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
// Make sure it requires the correct CSS.
|
|
162
|
-
// Though making that 'effortless' on the server may help more.
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
// Maybe can't do this here???
|
|
166
|
-
|
|
167
|
-
// Does not have .body (yet) on the client.
|
|
168
|
-
// simple way to get the client to attach the body of the Active_HTML_Document?
|
|
169
|
-
// maybe with jsgui-data-controls?
|
|
170
|
-
// Though automatically having the .body property available on the client without sending extra HTTP
|
|
171
|
-
// plumbing will help.
|
|
172
|
-
|
|
173
|
-
// .body will not be available before activation.
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
// .body should not be a normal function....?
|
|
177
|
-
// a getter function would be better.
|
|
178
|
-
|
|
179
|
-
|
|
180
58
|
if (typeof this.body.add_class === 'function') {
|
|
181
59
|
this.body.add_class('demo-ui');
|
|
182
60
|
}
|
|
@@ -186,39 +64,19 @@ class Demo_UI extends Active_HTML_Document {
|
|
|
186
64
|
|
|
187
65
|
|
|
188
66
|
const compose = () => {
|
|
189
|
-
// put 20 of them in place.
|
|
190
|
-
|
|
191
|
-
// Then how to arrange them...?
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
// Setting up the shared model in composition would be best....
|
|
195
|
-
// Or maybe during init, pre-activate?
|
|
196
|
-
|
|
197
|
-
// This seems like it will need some lower level integration for ease of use.
|
|
198
|
-
// Would like this to work server-side when setting properties, so should not rely on having this
|
|
199
|
-
// in the 'activate' code.
|
|
200
|
-
|
|
201
|
-
// a 'model' property.
|
|
202
|
-
// maybe two model properties: view.model, data.model.
|
|
203
|
-
|
|
204
|
-
// There could be a 'confirm / cancel' dialog when the view.model has been changed, and the view model can be updated
|
|
205
|
-
|
|
206
|
-
// Also, a single model could enable an undo history.
|
|
207
|
-
|
|
208
|
-
// app.data.model?
|
|
209
|
-
// context.data.model?
|
|
210
67
|
|
|
211
|
-
//
|
|
212
|
-
//
|
|
213
|
-
//
|
|
68
|
+
// Not so sure how to persist the (shared) data_models upon composition.
|
|
69
|
+
// Maybe explicitly reassigning them on activation for the moment.
|
|
70
|
+
// Could actually be necessary right now, but should look into supporting it automatically on
|
|
71
|
+
// a lower level.
|
|
214
72
|
|
|
73
|
+
// Defining shared data models in the composition...
|
|
74
|
+
// Should be able to persist that info to the data-jsgui properties in the HTML.
|
|
75
|
+
// Also may be best to have some very explicit code that generates the app's Data_Model, or the page's Data_Model.
|
|
215
76
|
|
|
77
|
+
// Does seem like persisting the relationships between controls, the inner parts of them, and data_models is important.
|
|
216
78
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
// ctrl.view.model perhaps???
|
|
220
|
-
// ctrl.data.model = context.model perhaps?
|
|
221
|
-
|
|
79
|
+
|
|
222
80
|
|
|
223
81
|
|
|
224
82
|
|
|
@@ -229,58 +87,13 @@ class Demo_UI extends Active_HTML_Document {
|
|
|
229
87
|
title: 'jsgui3-html Shared data.model Mirrored Text_Input controls',
|
|
230
88
|
pos: [5, 5]
|
|
231
89
|
});
|
|
232
|
-
|
|
233
90
|
window.size = [480, 160];
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
// .value
|
|
238
|
-
|
|
239
|
-
// .data.model = context.data.model
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
// set that 'value' to a data model ??? No.
|
|
243
|
-
// set it's 'model' or 'data.model'.
|
|
244
|
-
|
|
245
|
-
// data.model for the moment will be best.
|
|
246
|
-
// That is what we want to bind.
|
|
247
|
-
// View model and data model pair could allow for 'cancel | OK' options to confirm changes.
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
// 'data_model' property.
|
|
251
|
-
// 'dmodel', 'dm' too...?
|
|
252
|
-
// 'vm' possibly?
|
|
253
|
-
|
|
254
|
-
// .v.m shorthand??
|
|
255
|
-
// .d.m too?
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
// or data: {model: obj_data_model}
|
|
260
|
-
|
|
261
|
-
// The data model persistance must not be tricky here.
|
|
262
|
-
// Maybe setting it up at compose is not best???
|
|
263
|
-
// Makes for the nicest syntax here, the 'magic' about jsgui is handing things over to the client
|
|
264
|
-
// in a working way, auto-reconstructing things client-side.
|
|
265
|
-
// Would need to send over info on which Data_Model would be used...
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
// The shared data model should mean that these fields automatically stay in sync (somewhat)
|
|
269
|
-
// A shared view model would mean a more immediate sync.
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
// So Text_Field would need to look at data, data.model from the spec.
|
|
273
|
-
|
|
274
|
-
// Write the code in a few controls first, see what is in common and can be abstracted into a mixin
|
|
275
|
-
// such as control-data-model-sync
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
// Would change the 'value' property by default.
|
|
279
|
-
|
|
280
|
-
const ti1 = new Text_Field({
|
|
91
|
+
|
|
92
|
+
const tf1 = new Text_Field({
|
|
281
93
|
context,
|
|
94
|
+
text: 'A', // label.text???
|
|
95
|
+
// name???
|
|
282
96
|
|
|
283
|
-
text: 'A',
|
|
284
97
|
data: {
|
|
285
98
|
model: this.data.model
|
|
286
99
|
|
|
@@ -292,240 +105,145 @@ class Demo_UI extends Active_HTML_Document {
|
|
|
292
105
|
//label: {
|
|
293
106
|
// text: 'A checkbox'
|
|
294
107
|
//}
|
|
295
|
-
})
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
// Though not sure they get reconstructed with that data model?
|
|
300
|
-
|
|
301
|
-
// Want to make this easy for the app programmer to get right in particular.
|
|
302
|
-
|
|
303
|
-
// May need (much) more work on persisting the data model to the client.
|
|
304
|
-
// Or defining it in a way / place so it can be started isomorphically.
|
|
305
|
-
// Though it may make sense to do more to transfer models from the server to the client, with their data.
|
|
306
|
-
// However, reconstructing models from the (values in) the DOM could make a lot of sense.
|
|
307
|
-
// Having it read the DOM to create its DOM model, then from that its view.data model, then its data model.
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
const ti2 = new Text_Field({
|
|
108
|
+
});
|
|
109
|
+
window.inner.add(tf1);
|
|
110
|
+
const tf2 = new Text_Field({
|
|
317
111
|
context,
|
|
318
112
|
|
|
319
113
|
text: 'B',
|
|
320
114
|
data: {
|
|
321
115
|
model: this.data.model
|
|
322
116
|
}
|
|
323
|
-
|
|
324
|
-
|
|
325
117
|
//label: {
|
|
326
118
|
// text: 'A checkbox'
|
|
327
119
|
//}
|
|
328
120
|
})
|
|
329
121
|
|
|
330
|
-
window.inner.add(
|
|
122
|
+
window.inner.add(tf2);
|
|
331
123
|
|
|
332
124
|
this.body.add(window);
|
|
333
125
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
// ._ctrl_fields should automatically be set up.
|
|
337
|
-
// Also make it so when there are 0 entries in there it won't render the DOM attribute.
|
|
338
|
-
|
|
339
|
-
// First get the MVC properly and explicitly working accross some more controls.
|
|
340
|
-
// If any abstractions come really easily then do that.
|
|
341
|
-
// Maybe a DMVM_Control could be very effective soon.
|
|
342
|
-
|
|
343
|
-
// An 'adjuster' control could possibly have no 'data model' of its own.
|
|
344
|
-
// It could be set up to adjust either a data model, or a view model.
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
126
|
|
|
349
127
|
this._ctrl_fields = this._ctrl_fields || {};
|
|
350
|
-
this._ctrl_fields.
|
|
351
|
-
this._ctrl_fields.
|
|
128
|
+
this._ctrl_fields.tf1 = tf1;
|
|
129
|
+
this._ctrl_fields.tf2 = tf2;
|
|
352
130
|
|
|
353
131
|
|
|
354
132
|
}
|
|
355
|
-
if (!spec.el) {
|
|
356
|
-
compose();
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
activate() {
|
|
360
|
-
if (!this.__active) {
|
|
361
|
-
super.activate();
|
|
362
|
-
const {context, ti1, ti2} = this;
|
|
363
|
-
|
|
364
|
-
console.log('activate Demo_UI');
|
|
365
133
|
|
|
366
|
-
//field(this.data.model, 'value');
|
|
367
|
-
// and events dealing with changes to those tis.
|
|
368
134
|
|
|
369
|
-
|
|
135
|
+
// Only after activate???
|
|
136
|
+
// On a higher level will not need to pay as much attention to activation.
|
|
370
137
|
|
|
371
|
-
// Some kind of tracking of what the event initiator could help?
|
|
372
|
-
// Automatically avoiding feedback somehow???
|
|
373
|
-
// If it gets changed to its current value it does not push the change...?
|
|
374
138
|
|
|
375
139
|
|
|
376
|
-
// a non-dom change???
|
|
377
|
-
// or basically .view.model.change even????
|
|
378
140
|
|
|
379
|
-
|
|
380
|
-
// assign .view.model events ....?
|
|
381
|
-
// doing this on a lower level would help.
|
|
141
|
+
// Both after compose and activate, need to set up the
|
|
382
142
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
// Maybe see about better reconstruction....
|
|
143
|
+
if (!spec.el) {
|
|
144
|
+
compose();
|
|
145
|
+
}
|
|
387
146
|
|
|
388
|
-
//console.log('ti1.data.model', ti1.data.model);
|
|
389
|
-
//console.log('ti2.data.model', ti2.data.model);
|
|
390
147
|
|
|
391
|
-
|
|
148
|
+
}
|
|
392
149
|
|
|
393
|
-
|
|
394
|
-
|
|
150
|
+
setup_inner_listeners() {
|
|
151
|
+
// Post compose or during activate.
|
|
152
|
+
const {tf1, tf2} = this;
|
|
153
|
+
|
|
154
|
+
tf1.data.model.on('change', e => {
|
|
155
|
+
console.log('tf1 data model e', e);
|
|
156
|
+
const {name, old, value} = e;
|
|
157
|
+
if (name === 'value') {
|
|
158
|
+
|
|
159
|
+
}
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
tf2.data.model.on('change', e => {
|
|
163
|
+
console.log('tf2 data model e', e);
|
|
164
|
+
const {name, old, value} = e;
|
|
165
|
+
if (name === 'value') {
|
|
166
|
+
|
|
167
|
+
}
|
|
168
|
+
})
|
|
169
|
+
}
|
|
395
170
|
|
|
396
|
-
|
|
171
|
+
// A lower level way of reconstructing models on the client would help.
|
|
172
|
+
// Eg when a control gets composed, it could be specified that an internal control's
|
|
173
|
+
// view model is the same as, or is synced with this control's view model.
|
|
397
174
|
|
|
398
|
-
|
|
175
|
+
// Do want to handle both syncing as well as using the same JS objects where appropriate.
|
|
176
|
+
// Same objects will be best when one thing really is the other.
|
|
399
177
|
|
|
400
|
-
|
|
401
|
-
// Want decent low/mid level code to send the info to the client so the client can automatically reconstruct it.
|
|
402
|
-
/// Maybe a different function as standard to assign isomorphic things.
|
|
178
|
+
// Eg a Text_Field would have it's view data model value represented using a Text_Input.
|
|
403
179
|
|
|
180
|
+
// Late consider where in the namespacing things like
|
|
181
|
+
// label text, label text font, label icon image url etc can go.
|
|
182
|
+
// It's not the 'core' data model.
|
|
404
183
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
184
|
+
// Maybe presentation model???
|
|
185
|
+
// .ui model does seem convenient and explicit.
|
|
186
|
+
// ctrl.view.ui.label.text.font for example.
|
|
187
|
+
// ctrl.view.ui.label.text.font.size, ctrl.view.ui.label.text.size could be synonyms.
|
|
188
|
+
// Make the mid-level objects work so they provide a nice and flexible top level API.
|
|
408
189
|
|
|
409
|
-
// Just stick to Data_Value for now.
|
|
410
190
|
|
|
411
191
|
|
|
192
|
+
// So within Text_Field, would use _ctrl_fields
|
|
193
|
+
// could also assign / reassign the data models upon activation???
|
|
412
194
|
|
|
413
|
-
|
|
414
|
-
field(dm, 'value');
|
|
415
|
-
ti1.data.model = dm;
|
|
416
|
-
ti2.data.model = dm;
|
|
195
|
+
// Concise code at the high level would be OK for the moment, but really want this on mid level.
|
|
417
196
|
|
|
418
|
-
|
|
419
|
-
// value change even....
|
|
197
|
+
// Or could rely on syncing for the moment....?
|
|
420
198
|
|
|
421
|
-
ti1.assign_data_model_value_change_handler();
|
|
422
|
-
ti2.assign_data_model_value_change_handler();
|
|
423
199
|
|
|
424
200
|
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
201
|
|
|
428
|
-
activate_demo_ui_data_model();
|
|
429
202
|
|
|
430
|
-
|
|
431
203
|
|
|
432
|
-
// Create a new data_model (and view_model?) for both of them?
|
|
433
|
-
// The view_model gets created by default and does not need to be shared (and should not be)
|
|
434
204
|
|
|
435
205
|
|
|
436
206
|
|
|
437
207
|
|
|
438
208
|
|
|
439
|
-
// ti1.value.on('change') ????
|
|
440
|
-
// where the value is an Evented_Class or even Data_Object????
|
|
441
|
-
// and where we can also get the value out of it easily / do so automatically, maybe within other useful functions.
|
|
442
209
|
|
|
443
210
|
|
|
444
|
-
// ti1.model.on('change') ????
|
|
445
|
-
// or .view.model to be most specific for the moment...?
|
|
446
|
-
// and raise those events within the controls on those .view.model objects.
|
|
447
211
|
|
|
448
|
-
// Maybe just try it on Text_Field for the moment.
|
|
449
212
|
|
|
450
213
|
|
|
451
214
|
|
|
452
|
-
|
|
215
|
+
activate() {
|
|
216
|
+
if (!this.__active) {
|
|
217
|
+
super.activate();
|
|
453
218
|
|
|
454
|
-
const old_activate_changes = () => {
|
|
455
219
|
|
|
456
|
-
ti1.model.on('change', e => {
|
|
457
|
-
//console.log('ti1 change e', e);
|
|
458
220
|
|
|
221
|
+
const {context, tf1, tf2} = this;
|
|
459
222
|
|
|
460
|
-
|
|
461
|
-
if (e.value !== e.old) {
|
|
462
|
-
ti2.value = e.value;
|
|
463
|
-
}
|
|
464
|
-
}
|
|
223
|
+
console.log('activate Demo_UI');
|
|
465
224
|
|
|
466
|
-
|
|
467
|
-
|
|
225
|
+
// Want data model syncing and activation done for free.
|
|
468
226
|
|
|
469
|
-
|
|
227
|
+
const already_same_data_models_on_activation = this.data.model === tf1.data.model === tf2.data.model;
|
|
228
|
+
console.log('already_same_data_models_on_activation', already_same_data_models_on_activation);
|
|
470
229
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
//console.log('ti2 change e', e);
|
|
230
|
+
if (!already_same_data_models_on_activation) {
|
|
231
|
+
console.log('Need to reassign the data_models of the two controls [tf1, tf2].');
|
|
474
232
|
|
|
475
|
-
|
|
233
|
+
// Probably need to have the specific code in Text_Field to handle data.model changing.
|
|
476
234
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
}
|
|
235
|
+
tf1.data.model = this.data.model;
|
|
236
|
+
tf2.data.model = this.data.model;
|
|
480
237
|
|
|
481
|
-
|
|
482
|
-
|
|
238
|
+
} else {
|
|
239
|
+
console.log('jsgui3 now supports client-side reconstruction of shared object models on a lower level.')
|
|
483
240
|
}
|
|
484
241
|
|
|
242
|
+
this.setup_inner_listeners();
|
|
485
243
|
|
|
486
244
|
|
|
487
|
-
// listen for change events.
|
|
488
|
-
// would be nice to know which change events originated from the user interacting with that specific HTML element (or ctrl???)
|
|
489
|
-
|
|
490
|
-
// e.from_user === true test.
|
|
491
|
-
|
|
492
|
-
// e.user_initiated_on_this ????
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
//console.log('activate Demo_UI');
|
|
498
|
-
// listen for the context events regarding frames, changes, resizing.
|
|
499
|
-
|
|
500
245
|
context.on('window-resize', e_resize => {
|
|
501
246
|
|
|
502
|
-
// Could see about having some window contents bound through CSS to the size of the window.
|
|
503
|
-
// Though having a framework of adjusting CSS from the JS on-the-fly could work too.
|
|
504
|
-
|
|
505
|
-
// May be done with the 'bind' mixin, or will make more specific mixins to do things like bind
|
|
506
|
-
// a control to the space within another control, space within a specific part of that control.
|
|
507
|
-
|
|
508
|
-
// Or bind to parent size. That should be possible with CSS though.
|
|
509
|
-
// May make some controls make more use of CSS by default
|
|
510
|
-
// Or having an absolutely positioned box model used extensively could avoid some ambiguity, though
|
|
511
|
-
// making use of and supporting generally respected CSS features will help too.
|
|
512
|
-
|
|
513
|
-
//console.log('window-resize', e_resize);
|
|
514
|
-
|
|
515
|
-
// Make all internal controls go absolute in terms of position
|
|
516
|
-
// Remove them from their containers too?
|
|
517
|
-
// Ie their containing divs?
|
|
518
|
-
|
|
519
|
-
// Would be nice to do this really simple with a fn call or very simple piece of code.
|
|
520
|
-
// Like get absolute position, set position to be absolute, move to that position.
|
|
521
|
-
// Maybe something within jsgui3-client helps with this, this is more about what needs to be done on the client.
|
|
522
|
-
// Though recognising perf implications, it's (more) OK to include client-side functionality in jsgui3-html.
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
247
|
});
|
|
530
248
|
|
|
531
249
|
}
|
package/examples/controls/11c) window, shared Data_Value model mirrored text fields/client.js
CHANGED
|
@@ -422,8 +422,8 @@ class Demo_UI extends Active_HTML_Document {
|
|
|
422
422
|
// But then need to get them to reassign their data model change listeners....?
|
|
423
423
|
// value change even....
|
|
424
424
|
|
|
425
|
-
ti1.assign_data_model_value_change_handler();
|
|
426
|
-
ti2.assign_data_model_value_change_handler();
|
|
425
|
+
//ti1.assign_data_model_value_change_handler();
|
|
426
|
+
//ti2.assign_data_model_value_change_handler();
|
|
427
427
|
|
|
428
428
|
|
|
429
429
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const jsgui = require('lang-tools');
|
|
2
|
+
const {Data_Value, Functional_Data_Type} = jsgui;
|
|
3
|
+
const create_demo_ui_data_model = (context) => {
|
|
4
|
+
const res = new Data_Value({
|
|
5
|
+
context,
|
|
6
|
+
data_type: Functional_Data_Type.integer
|
|
7
|
+
});
|
|
8
|
+
if (context) {
|
|
9
|
+
context.register_control(res);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return res;
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
module.exports = {
|
|
16
|
+
create_demo_ui_data_model
|
|
17
|
+
}
|