uil 1.0.1 → 4.0.0
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/README.md +57 -0
- package/build/uil.js +7040 -4199
- package/build/uil.min.js +6 -4
- package/build/uil.module.js +7200 -2761
- package/examples/js/BufferGeometryUtils.js +921 -0
- package/examples/js/SimplexNoise.js +324 -0
- package/examples/js/controls/OrbitControls.js +1215 -0
- package/examples/js/controls/OrbitControls_.js +1042 -0
- package/examples/js/libs/sea3d.min.js +373 -0
- package/examples/js/libs/three.min.js +6 -0
- package/examples/js/math.js +447 -0
- package/examples/js/objects/Landscape.js +778 -0
- package/examples/js/objects/Lensflare.js +372 -0
- package/examples/js/objects/SuperSky.js +297 -0
- package/examples/js/objects/Water.js +329 -0
- package/package.json +56 -54
- package/src/Uil.js +2 -17
- package/src/Uil_dev.js +15 -0
- package/src/core/Gui.js +601 -299
- package/src/core/Proto.js +490 -220
- package/src/core/Roots.js +864 -0
- package/src/core/Tools.js +591 -140
- package/src/core/V2.js +131 -0
- package/src/core/add.js +52 -57
- package/src/proto/Bool.js +117 -52
- package/src/proto/Button.js +286 -146
- package/src/proto/Circular.js +162 -130
- package/src/proto/Color.js +331 -289
- package/src/proto/Empty.js +15 -0
- package/src/proto/Fps.js +232 -159
- package/src/proto/Graph.js +310 -0
- package/src/proto/Grid.js +297 -0
- package/src/proto/Group.js +334 -160
- package/src/proto/Item.js +120 -0
- package/src/proto/Joystick.js +159 -185
- package/src/proto/Knob.js +210 -91
- package/src/proto/List.js +661 -249
- package/src/proto/Numeric.js +329 -162
- package/src/proto/Pad2D.js +268 -0
- package/src/proto/Rubric.js +0 -0
- package/src/proto/Select.js +178 -0
- package/src/proto/Selector.js +13 -0
- package/src/proto/Slide.js +191 -185
- package/src/proto/TextInput.js +149 -59
- package/src/proto/Title.js +40 -31
package/src/core/Proto.js
CHANGED
|
@@ -1,321 +1,527 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
import { Roots } from './Roots.js';
|
|
3
|
+
import { Tools } from './Tools.js';
|
|
4
|
+
import { V2 } from './V2.js';
|
|
2
5
|
|
|
3
6
|
/**
|
|
4
|
-
* @author
|
|
7
|
+
* @author lth / https://github.com/lo-th
|
|
5
8
|
*/
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
export class Proto {
|
|
8
11
|
|
|
9
|
-
o =
|
|
12
|
+
constructor( o = {} ) {
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
// if is on ui pannel
|
|
13
|
-
this.isUI = o.isUI || false;
|
|
14
|
+
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
// disable mouse controle
|
|
17
|
+
this.lock = o.lock || false;
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
// for button
|
|
20
|
+
this.neverlock = false
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this.h = this.h < 11 ? 11 : this.h;
|
|
22
|
+
// only simple space
|
|
23
|
+
this.isSpace = o.isSpace || false
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
// if is on gui or group
|
|
26
|
+
this.main = o.main || null;
|
|
27
|
+
this.isUI = o.isUI || false;
|
|
28
|
+
this.group = o.group || null;
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
this.parentGroup = null;
|
|
30
|
+
this.isListen = false;
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
|
|
33
|
+
//this.parentGroup = null;
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
//if( o.select !== undefined ) o.selectable = o.select
|
|
36
|
+
this.isSelectable = o.selectable !== undefined ? o.selectable : false
|
|
37
|
+
this.unselectable = o.unselect !== undefined ? o.unselect : this.isSelectable
|
|
35
38
|
|
|
36
|
-
// only for number
|
|
37
|
-
this.isNumber = false;
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
this.mono = false;
|
|
40
|
+
this.ontop = o.ontop ? o.ontop : false; // 'beforebegin' 'afterbegin' 'beforeend' 'afterend'
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
this.isEdit = false;
|
|
42
|
+
this.css = this.main ? this.main.css : Tools.css
|
|
44
43
|
|
|
45
|
-
|
|
46
|
-
this.simple = o.simple || false;
|
|
47
|
-
if( this.simple ) this.sa = 0;
|
|
44
|
+
this.colors = Tools.defineColor( o, this.main ? ( this.group ? this.group.colors : this.main.colors ) : Tools.colors )
|
|
48
45
|
|
|
49
|
-
|
|
50
|
-
//if(o.width !== undefined ) this.width = o.width;
|
|
51
|
-
//if(o.size !== undefined ) this.width = o.size;
|
|
46
|
+
this.svgs = Tools.svgs
|
|
52
47
|
|
|
53
|
-
|
|
48
|
+
this.zone = { x:0, y:0, w:0, h:0 }
|
|
49
|
+
this.local = new V2().neg()
|
|
54
50
|
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
this.isCanvasOnly = false
|
|
52
|
+
this.isSelect = false
|
|
57
53
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if(o.sb !== undefined ) this.sb = o.sb;
|
|
54
|
+
// percent of title
|
|
55
|
+
this.p = o.p !== undefined ? o.p : Tools.size.p;
|
|
61
56
|
|
|
62
|
-
|
|
57
|
+
this.w = this.isUI ? this.main.size.w : Tools.size.w;
|
|
58
|
+
if( o.w !== undefined ) this.w = o.w;
|
|
63
59
|
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
this.h = this.isUI ? this.main.size.h : Tools.size.h;
|
|
61
|
+
if( o.h !== undefined ) this.h = o.h;
|
|
62
|
+
if( !this.isSpace ) this.h = this.h < 11 ? 11 : this.h;
|
|
63
|
+
else this.lock = true
|
|
66
64
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
this.isSend = false;
|
|
65
|
+
|
|
66
|
+
this.autoWidth = o.auto || true;// auto width or flex
|
|
67
|
+
this.isOpen = false// open statu
|
|
71
68
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// Background
|
|
75
|
-
this.bg = this.isUI ? this.main.bg : Tools.colors.background;
|
|
76
|
-
if( o.bg !== undefined ) this.bg = o.bg;
|
|
69
|
+
// radius for toolbox
|
|
70
|
+
this.radius = o.radius || this.colors.radius;
|
|
77
71
|
|
|
78
|
-
|
|
79
|
-
this.titleColor = o.titleColor || Tools.colors.text;
|
|
80
|
-
this.fontColor = o.fontColor || Tools.colors.text;
|
|
81
|
-
this.colorPlus = Tools.ColorLuma( this.fontColor, 0.3 );
|
|
72
|
+
this.transition = o.transition || Tools.transition
|
|
82
73
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
74
|
+
// only for number
|
|
75
|
+
this.isNumber = false;
|
|
76
|
+
this.noNeg = o.noNeg || false;
|
|
77
|
+
this.allEqual = o.allEqual || false;
|
|
78
|
+
|
|
79
|
+
// only most simple
|
|
80
|
+
this.mono = false;
|
|
88
81
|
|
|
89
|
-
|
|
90
|
-
|
|
82
|
+
// stop listening for edit slide text
|
|
83
|
+
this.isEdit = false;
|
|
91
84
|
|
|
92
|
-
|
|
85
|
+
// no title
|
|
86
|
+
this.simple = o.simple || false;
|
|
87
|
+
if( this.simple ) this.sa = 0;
|
|
93
88
|
|
|
94
|
-
// elements
|
|
95
89
|
|
|
96
|
-
|
|
90
|
+
// define obj size
|
|
91
|
+
this.setSize( this.w )
|
|
97
92
|
|
|
98
|
-
|
|
93
|
+
// title size
|
|
94
|
+
if( o.sa !== undefined ) this.sa = o.sa
|
|
95
|
+
if( o.sb !== undefined ) this.sb = o.sb
|
|
96
|
+
if( this.simple ) this.sb = this.w - this.sa
|
|
99
97
|
|
|
100
|
-
|
|
98
|
+
// last number size for slide
|
|
99
|
+
this.sc = o.sc === undefined ? 47 : o.sc
|
|
101
100
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
// for listening object
|
|
102
|
+
this.objectLink = null;
|
|
103
|
+
this.isSend = false;
|
|
104
|
+
this.val = null;
|
|
105
105
|
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
this.txt = o.name || '';
|
|
107
|
+
this.name = o.rename || this.txt;
|
|
108
|
+
this.target = o.target || null;
|
|
108
109
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
this.
|
|
112
|
-
this.
|
|
113
|
-
this.
|
|
114
|
-
this.s[1].color = this.titleColor;
|
|
115
|
-
}
|
|
110
|
+
// callback
|
|
111
|
+
this.callback = o.callback === undefined ? null : o.callback;
|
|
112
|
+
this.endCallback = null;
|
|
113
|
+
this.openCallback = o.openCallback === undefined ? null : o.openCallback;
|
|
114
|
+
this.closeCallback = o.closeCallback === undefined ? null : o.closeCallback;
|
|
116
115
|
|
|
117
|
-
|
|
118
|
-
this.
|
|
119
|
-
|
|
120
|
-
this.s[0][p] = o.pos[p];
|
|
116
|
+
// if no callback take one from group or gui
|
|
117
|
+
if( this.callback === null && this.isUI && this.main.callback !== null ){
|
|
118
|
+
this.callback = this.group ? this.group.callback : this.main.callback;
|
|
121
119
|
}
|
|
122
|
-
this.mono = true;
|
|
123
|
-
}
|
|
124
120
|
|
|
125
|
-
|
|
126
|
-
this.
|
|
127
|
-
|
|
121
|
+
// elements
|
|
122
|
+
this.c = [];
|
|
123
|
+
|
|
124
|
+
// style
|
|
125
|
+
this.s = [];
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
//this.c[0] = Tools.dom( 'div', this.css.basic + this.css.button +'align-self:stretch; position:relative; height:20px; overflow:hidden;'); //float:left;
|
|
129
|
+
//this.c[0] = Tools.dom( 'div', 'order: 1;' ); //
|
|
130
|
+
this.useFlex = this.isUI ? this.main.useFlex : false
|
|
131
|
+
let flexible = this.useFlex ? 'disply:flex; justify-content:center; align-items:center; text-align:center; flex: 1 100%;' : 'float:left;'
|
|
132
|
+
|
|
133
|
+
this.c[0] = Tools.dom( 'div', this.css.basic + flexible + 'position:relative; height:20px;');
|
|
134
|
+
//this.c[0] = Tools.dom( 'div', this.css.basic +'position:relative; height:20px; align-self: auto;');
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
this.s[0] = this.c[0].style
|
|
138
|
+
|
|
139
|
+
// bottom margin
|
|
140
|
+
this.margin = o.margin || 1
|
|
141
|
+
if( this.isUI && this.margin ){
|
|
142
|
+
this.s[0].boxSizing = 'content-box'
|
|
143
|
+
//this.s[0].marginBottom = this.margin + 'px';
|
|
144
|
+
if( this.margin*0.5===Math.floor(this.margin*0.5) ){
|
|
145
|
+
this.s[0].borderTop = (this.margin*0.5) + 'px solid transparent'
|
|
146
|
+
this.s[0].borderBottom = (this.margin*0.5) + 'px solid transparent'
|
|
147
|
+
} else {
|
|
148
|
+
this.s[0].borderBottom = this.margin + 'px solid transparent'
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// with title
|
|
154
|
+
if( !this.simple ){
|
|
155
|
+
this.c[1] = Tools.dom( 'div', this.css.txt )
|
|
156
|
+
this.s[1] = this.c[1].style
|
|
157
|
+
this.c[1].textContent = this.name
|
|
158
|
+
this.s[1].color = this.lock ? this.colors.titleoff : this.colors.title
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if( o.pos ){
|
|
162
|
+
this.s[0].position = 'absolute';
|
|
163
|
+
for(let p in o.pos){
|
|
164
|
+
this.s[0][p] = o.pos[p];
|
|
165
|
+
}
|
|
166
|
+
this.mono = true;
|
|
167
|
+
}
|
|
128
168
|
|
|
129
|
-
};
|
|
130
169
|
|
|
131
|
-
Proto.prototype = {
|
|
132
170
|
|
|
133
|
-
constructor: Proto,
|
|
134
171
|
|
|
135
|
-
|
|
172
|
+
if( o.css ) this.s[0].cssText = o.css;
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
}
|
|
136
176
|
|
|
177
|
+
// ----------------------
|
|
178
|
+
// make the node
|
|
179
|
+
// ----------------------
|
|
180
|
+
|
|
181
|
+
init() {
|
|
137
182
|
|
|
138
|
-
|
|
183
|
+
this.zone.h = this.h;
|
|
184
|
+
this.zone.w = this.w;
|
|
139
185
|
|
|
140
|
-
|
|
141
|
-
|
|
186
|
+
let s = this.s; // style cache
|
|
187
|
+
let c = this.c; // div cach
|
|
142
188
|
|
|
143
189
|
s[0].height = this.h + 'px';
|
|
144
190
|
|
|
145
|
-
if( this.isUI ) s[0].background = this.
|
|
146
|
-
|
|
191
|
+
if( this.isUI ) s[0].background = this.colors.background
|
|
192
|
+
|
|
193
|
+
if(!this.autoWidth && this.useFlex ){
|
|
194
|
+
s[0].flex = '1 0 auto'
|
|
195
|
+
s[0].minWidth = this.minw+'px'
|
|
196
|
+
s[0].textAlign = 'center'
|
|
197
|
+
} else {
|
|
198
|
+
if( this.isUI ) s[0].width = '100%'
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
//if( this.autoHeight ) s[0].transition = 'height 0.01s ease-out';
|
|
147
202
|
if( c[1] !== undefined && this.autoWidth ){
|
|
148
203
|
s[1] = c[1].style;
|
|
149
204
|
s[1].height = (this.h-4) + 'px';
|
|
150
205
|
s[1].lineHeight = (this.h-8) + 'px';
|
|
151
206
|
}
|
|
152
207
|
|
|
153
|
-
|
|
208
|
+
let frag = Tools.frag;
|
|
154
209
|
|
|
155
|
-
for(
|
|
210
|
+
for( let i = 1, lng = c.length; i !== lng; i++ ){
|
|
156
211
|
if( c[i] !== undefined ) {
|
|
157
212
|
frag.appendChild( c[i] );
|
|
158
213
|
s[i] = c[i].style;
|
|
159
214
|
}
|
|
160
215
|
}
|
|
161
216
|
|
|
217
|
+
let pp = this.target !== null ? this.target : ( this.isUI ? this.main.inner : document.body );
|
|
162
218
|
|
|
163
|
-
if( this.
|
|
164
|
-
|
|
165
|
-
} else {
|
|
166
|
-
if( this.isUI ) this.main.inner.appendChild( c[0] );
|
|
167
|
-
else document.body.appendChild( c[0] );
|
|
168
|
-
}
|
|
219
|
+
if( this.ontop ) pp.insertAdjacentElement( 'afterbegin', c[0] );
|
|
220
|
+
else pp.appendChild( c[0] );
|
|
169
221
|
|
|
170
222
|
c[0].appendChild( frag );
|
|
171
223
|
|
|
172
|
-
this.rSize()
|
|
173
|
-
|
|
224
|
+
this.rSize()
|
|
225
|
+
|
|
226
|
+
// ! solo proto
|
|
227
|
+
if( !this.isUI ){
|
|
228
|
+
|
|
229
|
+
this.c[0].style.pointerEvents = 'auto'
|
|
230
|
+
Roots.add( this )
|
|
231
|
+
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
if( this.baseH && this.transition && this.isUI ){
|
|
236
|
+
this.c[0].style.transition = 'height '+this.transition+'s ease-out';
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// from Tools
|
|
242
|
+
|
|
243
|
+
dom( type, css, obj, dom, id ) {
|
|
244
|
+
|
|
245
|
+
return Tools.dom( type, css, obj, dom, id );
|
|
246
|
+
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
setSvg( dom, type, value, id, id2 ) {
|
|
250
|
+
|
|
251
|
+
Tools.setSvg( dom, type, value, id, id2 );
|
|
252
|
+
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
setCss( dom, css ) {
|
|
256
|
+
|
|
257
|
+
Tools.setCss( dom, css );
|
|
258
|
+
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
clamp( value, min, max ) {
|
|
262
|
+
|
|
263
|
+
return Tools.clamp( value, min, max );
|
|
264
|
+
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
getColorRing() {
|
|
268
|
+
|
|
269
|
+
if( !Tools.colorRing ) Tools.makeColorRing();
|
|
270
|
+
return Tools.clone( Tools.colorRing );
|
|
271
|
+
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
getJoystick( model ) {
|
|
275
|
+
|
|
276
|
+
if( !Tools[ 'joystick_'+ model ] ) Tools.makeJoystick( model )
|
|
277
|
+
return Tools.clone( Tools[ 'joystick_'+ model ] )
|
|
278
|
+
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
getCircular( model ) {
|
|
282
|
+
|
|
283
|
+
if( !Tools.circular ) Tools.makeCircular( model )
|
|
284
|
+
return Tools.clone( Tools.circular )
|
|
285
|
+
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
getKnob( model ) {
|
|
289
|
+
|
|
290
|
+
if( !Tools.knob ) Tools.makeKnob( model )
|
|
291
|
+
return Tools.clone( Tools.knob )
|
|
292
|
+
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
getPad2d( model ) {
|
|
296
|
+
|
|
297
|
+
if( !Tools.pad2d ) Tools.makePad( model )
|
|
298
|
+
return Tools.clone( Tools.pad2d )
|
|
299
|
+
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// from Roots
|
|
174
303
|
|
|
175
|
-
|
|
304
|
+
cursor( name ) {
|
|
176
305
|
|
|
177
|
-
|
|
178
|
-
this.c[1].textContent = s;
|
|
179
|
-
},
|
|
306
|
+
Roots.cursor( name );
|
|
180
307
|
|
|
181
|
-
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
/////////
|
|
313
|
+
|
|
314
|
+
update() {}
|
|
315
|
+
|
|
316
|
+
reset() {}
|
|
317
|
+
|
|
318
|
+
/////////
|
|
319
|
+
|
|
320
|
+
getDom() {
|
|
182
321
|
|
|
183
|
-
this.
|
|
184
|
-
|
|
322
|
+
return this.c[0]
|
|
323
|
+
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
uiout() {
|
|
327
|
+
|
|
328
|
+
if( this.lock ) return;
|
|
329
|
+
|
|
330
|
+
if(this.s) this.s[0].background = this.colors.background;
|
|
331
|
+
|
|
332
|
+
}
|
|
185
333
|
|
|
186
|
-
|
|
334
|
+
uiover() {
|
|
187
335
|
|
|
188
|
-
|
|
336
|
+
if( this.lock ) return;
|
|
189
337
|
|
|
190
|
-
|
|
338
|
+
if(this.s) this.s[0].background = this.colors.backgroundOver;
|
|
191
339
|
|
|
192
|
-
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
rename( s ) {
|
|
343
|
+
|
|
344
|
+
if( this.c[1] !== undefined) this.c[1].textContent = s;
|
|
345
|
+
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
listen() {
|
|
349
|
+
|
|
350
|
+
this.isListen = Roots.addListen( this );
|
|
193
351
|
return this;
|
|
194
352
|
|
|
195
|
-
}
|
|
353
|
+
}
|
|
196
354
|
|
|
197
|
-
listening
|
|
355
|
+
listening() {
|
|
198
356
|
|
|
199
|
-
if( this.
|
|
357
|
+
if( this.objectLink === null ) return;
|
|
200
358
|
if( this.isSend ) return;
|
|
201
359
|
if( this.isEdit ) return;
|
|
202
360
|
|
|
203
|
-
this.setValue( this.
|
|
361
|
+
this.setValue( this.objectLink[ this.val ] );
|
|
362
|
+
|
|
363
|
+
}
|
|
204
364
|
|
|
205
|
-
|
|
365
|
+
setValue( v ) {
|
|
206
366
|
|
|
207
|
-
setValue : function( v ){
|
|
208
367
|
if( this.isNumber ) this.value = this.numValue( v );
|
|
368
|
+
//else if( v instanceof Array && v.length === 1 ) v = v[0];
|
|
209
369
|
else this.value = v;
|
|
210
|
-
|
|
211
370
|
this.update();
|
|
212
371
|
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
update: function( ) {
|
|
216
|
-
|
|
217
|
-
},
|
|
372
|
+
}
|
|
218
373
|
|
|
374
|
+
// ----------------------
|
|
219
375
|
// update every change
|
|
376
|
+
// ----------------------
|
|
220
377
|
|
|
221
|
-
onChange
|
|
378
|
+
onChange( f ) {
|
|
222
379
|
|
|
223
|
-
this.
|
|
224
|
-
|
|
380
|
+
if( this.isSpace ) return
|
|
381
|
+
this.callback = f || null
|
|
382
|
+
return this
|
|
225
383
|
|
|
226
|
-
}
|
|
384
|
+
}
|
|
227
385
|
|
|
386
|
+
// ----------------------
|
|
228
387
|
// update only on end
|
|
388
|
+
// ----------------------
|
|
229
389
|
|
|
230
|
-
onFinishChange
|
|
390
|
+
onFinishChange( f ) {
|
|
231
391
|
|
|
232
|
-
this.
|
|
233
|
-
this.
|
|
234
|
-
|
|
392
|
+
if( this.isSpace ) return;
|
|
393
|
+
this.callback = null
|
|
394
|
+
this.endCallback = f
|
|
395
|
+
return this
|
|
235
396
|
|
|
236
|
-
}
|
|
397
|
+
}
|
|
237
398
|
|
|
238
|
-
|
|
239
|
-
|
|
399
|
+
// ----------------------
|
|
400
|
+
// event on open close
|
|
401
|
+
// ----------------------
|
|
240
402
|
|
|
241
|
-
|
|
242
|
-
if( this.callback ) this.callback( v || this.value );
|
|
243
|
-
|
|
244
|
-
this.isSend = false;
|
|
403
|
+
onOpen( f ) {
|
|
245
404
|
|
|
246
|
-
|
|
405
|
+
this.openCallback = f
|
|
406
|
+
return this
|
|
247
407
|
|
|
248
|
-
|
|
408
|
+
}
|
|
249
409
|
|
|
250
|
-
|
|
251
|
-
if( this.parent !== null ) this.parent[ this.val ] = v || this.value;
|
|
410
|
+
onClose( f ) {
|
|
252
411
|
|
|
253
|
-
|
|
412
|
+
this.closeCallback = f
|
|
413
|
+
return this
|
|
254
414
|
|
|
255
|
-
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// ----------------------
|
|
418
|
+
// send back value
|
|
419
|
+
// ----------------------
|
|
420
|
+
|
|
421
|
+
send( v ) {
|
|
422
|
+
|
|
423
|
+
v = v || this.value;
|
|
424
|
+
if( v instanceof Array && v.length === 1 ) v = v[0];
|
|
425
|
+
|
|
426
|
+
this.isSend = true
|
|
427
|
+
if( this.objectLink !== null ) this.objectLink[ this.val ] = v
|
|
428
|
+
if( this.callback ) this.callback( v, this.val )
|
|
429
|
+
this.isSend = false
|
|
430
|
+
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
sendEnd( v ) {
|
|
434
|
+
|
|
435
|
+
v = v || this.value;
|
|
436
|
+
if( v instanceof Array && v.length === 1 ) v = v[0];
|
|
437
|
+
|
|
438
|
+
if( this.endCallback ) this.endCallback( v );
|
|
439
|
+
if( this.objectLink !== null ) this.objectLink[ this.val ] = v;
|
|
440
|
+
|
|
441
|
+
}
|
|
256
442
|
|
|
443
|
+
// ----------------------
|
|
257
444
|
// clear node
|
|
445
|
+
// ----------------------
|
|
258
446
|
|
|
259
|
-
clear
|
|
447
|
+
clear( nofull ) {
|
|
448
|
+
|
|
449
|
+
if( this.isListen ) Roots.removeListen( this );
|
|
260
450
|
|
|
261
|
-
this.clearEvent();
|
|
262
451
|
Tools.clear( this.c[0] );
|
|
263
452
|
|
|
264
|
-
if(
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
453
|
+
if( !nofull ){
|
|
454
|
+
|
|
455
|
+
if( this.target !== null ){
|
|
456
|
+
|
|
457
|
+
if( this.group !== null ) this.group.clearOne( this );
|
|
458
|
+
else this.target.removeChild( this.c[0] );
|
|
459
|
+
|
|
460
|
+
} else {
|
|
461
|
+
|
|
462
|
+
if( this.isUI ) this.main.clearOne( this );
|
|
463
|
+
else document.body.removeChild( this.c[0] );
|
|
464
|
+
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
if( !this.isUI ) Roots.remove( this );
|
|
468
|
+
|
|
269
469
|
}
|
|
270
470
|
|
|
271
471
|
this.c = null;
|
|
272
472
|
this.s = null;
|
|
273
473
|
this.callback = null;
|
|
274
474
|
this.target = null;
|
|
475
|
+
this.isListen = false;
|
|
275
476
|
|
|
276
|
-
}
|
|
477
|
+
}
|
|
277
478
|
|
|
479
|
+
// ----------------------
|
|
278
480
|
// change size
|
|
481
|
+
// ----------------------
|
|
279
482
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
if( !this.autoWidth ) return;
|
|
483
|
+
getWidth() {
|
|
283
484
|
|
|
284
|
-
|
|
485
|
+
let nw = Roots.getWidth( this )
|
|
486
|
+
if(nw) this.w = nw
|
|
285
487
|
|
|
286
|
-
|
|
488
|
+
}
|
|
287
489
|
|
|
490
|
+
setSize( sx ) {
|
|
288
491
|
|
|
289
|
-
|
|
492
|
+
if( !this.autoWidth ) return;
|
|
493
|
+
|
|
494
|
+
this.w = sx;
|
|
290
495
|
|
|
291
496
|
if( this.simple ){
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
this.
|
|
297
|
-
this.sb = ~~ this.width - pp - 20;
|
|
497
|
+
this.sb = this.w - this.sa
|
|
498
|
+
} else {
|
|
499
|
+
let pp = this.w * ( this.p / 100 )
|
|
500
|
+
this.sa = Math.floor( pp + 10 )
|
|
501
|
+
this.sb = Math.floor( this.w - pp - 20 )
|
|
298
502
|
}
|
|
299
503
|
|
|
300
|
-
}
|
|
504
|
+
}
|
|
301
505
|
|
|
302
|
-
rSize
|
|
506
|
+
rSize() {
|
|
303
507
|
|
|
304
508
|
if( !this.autoWidth ) return;
|
|
305
509
|
|
|
306
|
-
this.s[0].width = this.
|
|
510
|
+
if( !this.isUI ) this.s[0].width = this.w + 'px';
|
|
307
511
|
if( !this.simple ) this.s[1].width = this.sa + 'px';
|
|
308
512
|
|
|
309
|
-
}
|
|
513
|
+
}
|
|
310
514
|
|
|
515
|
+
// ----------------------
|
|
311
516
|
// for numeric value
|
|
517
|
+
// ----------------------
|
|
312
518
|
|
|
313
|
-
setTypeNumber
|
|
519
|
+
setTypeNumber( o ) {
|
|
314
520
|
|
|
315
521
|
this.isNumber = true;
|
|
316
522
|
|
|
317
523
|
this.value = 0;
|
|
318
|
-
if(o.value !== undefined){
|
|
524
|
+
if( o.value !== undefined ){
|
|
319
525
|
if( typeof o.value === 'string' ) this.value = o.value * 1;
|
|
320
526
|
else this.value = o.value;
|
|
321
527
|
}
|
|
@@ -324,7 +530,7 @@ Proto.prototype = {
|
|
|
324
530
|
this.max = o.max === undefined ? Infinity : o.max;
|
|
325
531
|
this.precision = o.precision === undefined ? 2 : o.precision;
|
|
326
532
|
|
|
327
|
-
|
|
533
|
+
let s;
|
|
328
534
|
|
|
329
535
|
switch(this.precision){
|
|
330
536
|
case 0: s = 1; break;
|
|
@@ -332,78 +538,142 @@ Proto.prototype = {
|
|
|
332
538
|
case 2: s = 0.01; break;
|
|
333
539
|
case 3: s = 0.001; break;
|
|
334
540
|
case 4: s = 0.0001; break;
|
|
541
|
+
case 5: s = 0.00001; break;
|
|
335
542
|
}
|
|
336
543
|
|
|
337
544
|
this.step = o.step === undefined ? s : o.step;
|
|
338
|
-
|
|
339
545
|
this.range = this.max - this.min;
|
|
340
|
-
|
|
341
546
|
this.value = this.numValue( this.value );
|
|
342
547
|
|
|
343
|
-
}
|
|
548
|
+
}
|
|
344
549
|
|
|
345
|
-
numValue
|
|
550
|
+
numValue( n ) {
|
|
346
551
|
|
|
552
|
+
if( this.noNeg ) n = Math.abs( n );
|
|
347
553
|
return Math.min( this.max, Math.max( this.min, n ) ).toFixed( this.precision ) * 1;
|
|
348
554
|
|
|
349
|
-
}
|
|
555
|
+
}
|
|
556
|
+
|
|
350
557
|
|
|
351
558
|
// ----------------------
|
|
352
|
-
//
|
|
559
|
+
// EVENTS DEFAULT
|
|
353
560
|
// ----------------------
|
|
354
561
|
|
|
355
|
-
|
|
562
|
+
handleEvent( e ) {
|
|
356
563
|
|
|
357
|
-
|
|
358
|
-
while( i-- ){
|
|
359
|
-
c = this.c[i];
|
|
360
|
-
if( c !== undefined ){
|
|
361
|
-
if( c.events !== undefined ){
|
|
362
|
-
j = c.events.length;
|
|
363
|
-
while( j-- ) c.addEventListener( c.events[j], this, false );
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
}
|
|
564
|
+
if( this.lock ) return
|
|
367
565
|
|
|
368
|
-
|
|
566
|
+
if( this.neverlock ) Roots.lock = false
|
|
369
567
|
|
|
370
|
-
|
|
568
|
+
if( !this[e.type] ) return console.error(e.type, 'this type of event no existe !')
|
|
371
569
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
if( c !== undefined ){
|
|
376
|
-
if( c.events !== undefined ){
|
|
377
|
-
j = c.events.length;
|
|
378
|
-
while( j-- ) c.removeEventListener( c.events[j], this, false );
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
}
|
|
570
|
+
return this[e.type](e)
|
|
571
|
+
|
|
572
|
+
}
|
|
382
573
|
|
|
383
|
-
}
|
|
574
|
+
wheel( e ) { return false; }
|
|
575
|
+
|
|
576
|
+
mousedown( e ) { return false; }
|
|
577
|
+
|
|
578
|
+
mousemove( e ) { return false; }
|
|
579
|
+
|
|
580
|
+
mouseup( e ) { return false; }
|
|
581
|
+
|
|
582
|
+
keydown( e ) { return false; }
|
|
583
|
+
|
|
584
|
+
keyup( e ) { return false; }
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
/*dragstart ( e ) { return false; }
|
|
588
|
+
dragover ( e ) { return false; }
|
|
589
|
+
dragenter ( e ) { return false; }
|
|
590
|
+
dragleave ( e ) { return false; }
|
|
591
|
+
dragend ( e ) { return false; }
|
|
592
|
+
drop ( e ) { return false; }*/
|
|
384
593
|
|
|
385
|
-
handleEvent: function( e ) {
|
|
386
|
-
|
|
387
|
-
},
|
|
388
594
|
|
|
389
595
|
// ----------------------
|
|
390
596
|
// object referency
|
|
391
597
|
// ----------------------
|
|
392
598
|
|
|
393
|
-
setReferency
|
|
599
|
+
setReferency( obj, val ) {
|
|
600
|
+
|
|
601
|
+
this.objectLink = obj
|
|
602
|
+
this.val = val
|
|
603
|
+
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
display( v ) {
|
|
607
|
+
|
|
608
|
+
v = v || false
|
|
609
|
+
this.s[0].display = v ? (this.useFlex? 'flex':'block') : 'none'
|
|
610
|
+
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
// ----------------------
|
|
614
|
+
// resize height
|
|
615
|
+
// ----------------------
|
|
616
|
+
|
|
617
|
+
open () {
|
|
618
|
+
|
|
619
|
+
if( this.isOpen ) return;
|
|
620
|
+
this.isOpen = true;
|
|
621
|
+
if( this.openCallback ) this.openCallback()
|
|
622
|
+
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
close () {
|
|
626
|
+
|
|
627
|
+
if( !this.isOpen ) return
|
|
628
|
+
this.isOpen = false
|
|
629
|
+
if( this.closeCallback ) this.closeCallback()
|
|
630
|
+
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
needZone() {
|
|
634
|
+
|
|
635
|
+
Roots.needReZone = true
|
|
636
|
+
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
rezone() {
|
|
640
|
+
|
|
641
|
+
Roots.needReZone = true
|
|
642
|
+
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
// ----------------------
|
|
646
|
+
// INPUT
|
|
647
|
+
// ----------------------
|
|
648
|
+
|
|
649
|
+
select() {
|
|
650
|
+
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
unselect() {
|
|
654
|
+
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
setInput( Input ) {
|
|
658
|
+
|
|
659
|
+
Roots.setInput( Input, this );
|
|
394
660
|
|
|
395
|
-
|
|
396
|
-
this.val = val;
|
|
661
|
+
}
|
|
397
662
|
|
|
398
|
-
|
|
663
|
+
upInput( x, down ) {
|
|
399
664
|
|
|
400
|
-
|
|
665
|
+
return Roots.upInput( x, down );
|
|
401
666
|
|
|
402
|
-
|
|
667
|
+
}
|
|
403
668
|
|
|
404
|
-
|
|
669
|
+
// ----------------------
|
|
670
|
+
// special item
|
|
671
|
+
// ----------------------
|
|
405
672
|
|
|
673
|
+
selected( b ){
|
|
406
674
|
|
|
407
|
-
|
|
675
|
+
this.isSelect = b || false
|
|
676
|
+
|
|
677
|
+
}
|
|
408
678
|
|
|
409
|
-
|
|
679
|
+
}
|