uil 4.1.0 → 4.2.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 +1 -1
- package/build/uil.js +223 -32
- package/build/uil.min.js +1 -1
- package/build/uil.module.js +256 -33
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<p align="center"><a href="http://lo-th.github.io/uil/"><img src="http://lo-th.github.io/uil/examples/assets/uil.jpg"/></a><br>UIL v4.
|
|
1
|
+
<p align="center"><a href="http://lo-th.github.io/uil/"><img src="http://lo-th.github.io/uil/examples/assets/uil.jpg"/></a><br>UIL v4.2.0</p>
|
|
2
2
|
|
|
3
3
|
uil.js is a lightweight ui for javascript with a complete 3d display support.<br>
|
|
4
4
|
totally customizable, only 6 events, auto resize<br>
|
package/build/uil.js
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
wlock: false,
|
|
22
22
|
current: -1,
|
|
23
23
|
needReZone: true,
|
|
24
|
+
needResize: false,
|
|
24
25
|
isEventsInit: false,
|
|
25
26
|
isLeave: false,
|
|
26
27
|
downTime: 0,
|
|
@@ -133,7 +134,6 @@
|
|
|
133
134
|
R.isEventsInit = false;
|
|
134
135
|
},
|
|
135
136
|
resize: function () {
|
|
136
|
-
R.needReZone = true;
|
|
137
137
|
let i = R.ui.length,
|
|
138
138
|
u;
|
|
139
139
|
|
|
@@ -141,6 +141,9 @@
|
|
|
141
141
|
u = R.ui[i];
|
|
142
142
|
if (u.isGui && !u.isCanvasOnly && u.autoResize) u.calc();
|
|
143
143
|
}
|
|
144
|
+
|
|
145
|
+
R.needReZone = true;
|
|
146
|
+
R.needResize = false;
|
|
144
147
|
},
|
|
145
148
|
out: function () {
|
|
146
149
|
console.log('im am out');
|
|
@@ -160,6 +163,7 @@
|
|
|
160
163
|
handleEvent: function (event) {
|
|
161
164
|
//if(!event.type) return;
|
|
162
165
|
if (R.prevDefault.indexOf(event.type) !== -1) event.preventDefault();
|
|
166
|
+
if (R.needResize) R.resize();
|
|
163
167
|
R.findZone();
|
|
164
168
|
let e = R.e;
|
|
165
169
|
let leave = false;
|
|
@@ -796,8 +800,14 @@
|
|
|
796
800
|
texture: 'M 13 4 L 13 1 1 1 1 4 5 4 5 13 9 13 9 4 13 4 Z',
|
|
797
801
|
object: 'M 10 1 L 7 4 4 1 1 1 1 13 4 13 4 5 7 8 10 5 10 13 13 13 13 1 10 1 Z',
|
|
798
802
|
none: 'M 9 5 L 5 5 5 9 9 9 9 5 Z',
|
|
799
|
-
cursor: 'M 4 7 L 1 10 1 12 2 13 4 13 7 10 9 14 14 0 0 5 4 7 Z'
|
|
803
|
+
cursor: 'M 4 7 L 1 10 1 12 2 13 4 13 7 10 9 14 14 0 0 5 4 7 Z',
|
|
804
|
+
load: 'M 14 8 L 12 8 12 12 2 12 2 8 0 8 0 14 14 14 14 8 M 8 5 L 8 0 6 0 6 5 3 5 7 9 11 5 8 5 Z'
|
|
800
805
|
},
|
|
806
|
+
|
|
807
|
+
rezone() {
|
|
808
|
+
Roots.needReZone = true;
|
|
809
|
+
},
|
|
810
|
+
|
|
801
811
|
getImput: function () {
|
|
802
812
|
return Roots.input ? true : false;
|
|
803
813
|
},
|
|
@@ -1665,6 +1675,7 @@
|
|
|
1665
1675
|
};
|
|
1666
1676
|
} catch (e) {
|
|
1667
1677
|
console.log(e);
|
|
1678
|
+
if (o.callback) o.callback(null);
|
|
1668
1679
|
}
|
|
1669
1680
|
}
|
|
1670
1681
|
|
|
@@ -1927,7 +1938,7 @@
|
|
|
1927
1938
|
|
|
1928
1939
|
this.objectLink = null;
|
|
1929
1940
|
this.isSend = false;
|
|
1930
|
-
this.
|
|
1941
|
+
this.objectKey = null;
|
|
1931
1942
|
this.txt = o.name || '';
|
|
1932
1943
|
this.name = o.rename || this.txt;
|
|
1933
1944
|
this.target = o.target || null; // callback
|
|
@@ -2030,7 +2041,9 @@
|
|
|
2030
2041
|
this.c[0].style.pointerEvents = 'auto';
|
|
2031
2042
|
Roots.add(this);
|
|
2032
2043
|
}
|
|
2044
|
+
}
|
|
2033
2045
|
|
|
2046
|
+
addTransition() {
|
|
2034
2047
|
if (this.baseH && this.transition && this.isUI) {
|
|
2035
2048
|
this.c[0].style.transition = 'height ' + this.transition + 's ease-out';
|
|
2036
2049
|
}
|
|
@@ -2116,7 +2129,7 @@
|
|
|
2116
2129
|
if (this.objectLink === null) return;
|
|
2117
2130
|
if (this.isSend) return;
|
|
2118
2131
|
if (this.isEdit) return;
|
|
2119
|
-
this.setValue(this.objectLink[this.
|
|
2132
|
+
this.setValue(this.objectLink[this.objectKey]);
|
|
2120
2133
|
}
|
|
2121
2134
|
|
|
2122
2135
|
setValue(v) {
|
|
@@ -2164,8 +2177,8 @@
|
|
|
2164
2177
|
v = v || this.value;
|
|
2165
2178
|
if (v instanceof Array && v.length === 1) v = v[0];
|
|
2166
2179
|
this.isSend = true;
|
|
2167
|
-
if (this.objectLink !== null) this.objectLink[this.
|
|
2168
|
-
if (this.callback) this.callback(v, this.
|
|
2180
|
+
if (this.objectLink !== null) this.objectLink[this.objectKey] = v;
|
|
2181
|
+
if (this.callback) this.callback(v, this.objectKey);
|
|
2169
2182
|
this.isSend = false;
|
|
2170
2183
|
}
|
|
2171
2184
|
|
|
@@ -2173,7 +2186,7 @@
|
|
|
2173
2186
|
v = v || this.value;
|
|
2174
2187
|
if (v instanceof Array && v.length === 1) v = v[0];
|
|
2175
2188
|
if (this.endCallback) this.endCallback(v);
|
|
2176
|
-
if (this.objectLink !== null) this.objectLink[this.
|
|
2189
|
+
if (this.objectLink !== null) this.objectLink[this.objectKey] = v;
|
|
2177
2190
|
} // ----------------------
|
|
2178
2191
|
// clear node
|
|
2179
2192
|
// ----------------------
|
|
@@ -2315,9 +2328,9 @@
|
|
|
2315
2328
|
// ----------------------
|
|
2316
2329
|
|
|
2317
2330
|
|
|
2318
|
-
setReferency(obj,
|
|
2331
|
+
setReferency(obj, key) {
|
|
2319
2332
|
this.objectLink = obj;
|
|
2320
|
-
this.
|
|
2333
|
+
this.objectKey = key;
|
|
2321
2334
|
}
|
|
2322
2335
|
|
|
2323
2336
|
display(v = false) {
|
|
@@ -2329,13 +2342,15 @@
|
|
|
2329
2342
|
|
|
2330
2343
|
open() {
|
|
2331
2344
|
if (this.isOpen) return;
|
|
2332
|
-
this.isOpen = true;
|
|
2345
|
+
this.isOpen = true; //Roots.needResize = true
|
|
2346
|
+
|
|
2333
2347
|
if (this.openCallback) this.openCallback();
|
|
2334
2348
|
}
|
|
2335
2349
|
|
|
2336
2350
|
close() {
|
|
2337
2351
|
if (!this.isOpen) return;
|
|
2338
|
-
this.isOpen = false;
|
|
2352
|
+
this.isOpen = false; //Roots.needResize = true
|
|
2353
|
+
|
|
2339
2354
|
if (this.closeCallback) this.closeCallback();
|
|
2340
2355
|
}
|
|
2341
2356
|
|
|
@@ -2550,8 +2565,7 @@
|
|
|
2550
2565
|
|
|
2551
2566
|
if (!o.value && !o.values) {
|
|
2552
2567
|
if (this.c[1] !== undefined) {
|
|
2553
|
-
this.c[1].textContent = '';
|
|
2554
|
-
this.txt = '';
|
|
2568
|
+
this.c[1].textContent = ''; //this.txt = ''
|
|
2555
2569
|
}
|
|
2556
2570
|
}
|
|
2557
2571
|
|
|
@@ -5257,17 +5271,13 @@
|
|
|
5257
5271
|
|
|
5258
5272
|
if (this.objectLink !== null) {
|
|
5259
5273
|
if (this.isVector) {
|
|
5260
|
-
this.objectLink[this.
|
|
5261
|
-
/*this.objectLink[ this.val ].x = v[0];
|
|
5262
|
-
this.objectLink[ this.val ].y = v[1];
|
|
5263
|
-
this.objectLink[ this.val ].z = v[2];
|
|
5264
|
-
if( v[3] ) this.objectLink[ this.val ].w = v[3];*/
|
|
5274
|
+
this.objectLink[this.objectKey].fromArray(v);
|
|
5265
5275
|
} else {
|
|
5266
|
-
this.objectLink[this.
|
|
5276
|
+
this.objectLink[this.objectKey] = v;
|
|
5267
5277
|
}
|
|
5268
5278
|
}
|
|
5269
5279
|
|
|
5270
|
-
if (this.callback) this.callback(v, this.
|
|
5280
|
+
if (this.callback) this.callback(v, this.objectKey);
|
|
5271
5281
|
this.isSend = false;
|
|
5272
5282
|
} // ----------------------
|
|
5273
5283
|
// INPUT
|
|
@@ -5552,7 +5562,7 @@
|
|
|
5552
5562
|
constructor(o = {}) {
|
|
5553
5563
|
super(o);
|
|
5554
5564
|
this.cmode = 0;
|
|
5555
|
-
this.value = o.value
|
|
5565
|
+
this.value = o.value !== undefined ? o.value : '';
|
|
5556
5566
|
this.placeHolder = o.placeHolder || '';
|
|
5557
5567
|
this.allway = o.allway || false;
|
|
5558
5568
|
this.editable = o.edit !== undefined ? o.edit : true;
|
|
@@ -5719,17 +5729,18 @@
|
|
|
5719
5729
|
this.value = o.value || '';
|
|
5720
5730
|
this.isDown = false;
|
|
5721
5731
|
|
|
5722
|
-
this.onActif = o.onActif || function () {};
|
|
5732
|
+
this.onActif = o.onActif || function () {}; //let prefix = o.prefix || '';
|
|
5733
|
+
|
|
5723
5734
|
|
|
5724
|
-
|
|
5725
|
-
this.c[2] = this.dom('div', this.css.txt + this.css.button + ' top:1px; background:' +
|
|
5726
|
-
|
|
5727
|
-
this.c[3] = this.dom('div', this.css.txtselect + 'height:' + (this.h - 4) + 'px; background:' +
|
|
5735
|
+
const cc = this.colors;
|
|
5736
|
+
this.c[2] = this.dom('div', this.css.txt + this.css.button + ' top:1px; background:' + cc.button + '; height:' + (this.h - 2) + 'px; border:' + cc.buttonBorder + '; border-radius:15px; width:30px; left:10px;'); //this.c[2].style.color = this.fontColor;
|
|
5737
|
+
|
|
5738
|
+
this.c[3] = this.dom('div', this.css.txtselect + 'height:' + (this.h - 4) + 'px; background:' + cc.inputBg + '; borderColor:' + cc.inputBorder + '; border-radius:' + this.radius + 'px;');
|
|
5728
5739
|
this.c[3].textContent = this.value;
|
|
5729
5740
|
let fltop = Math.floor(this.h * 0.5) - 7;
|
|
5730
5741
|
this.c[4] = this.dom('path', this.css.basic + 'position:absolute; width:14px; height:14px; left:5px; top:' + fltop + 'px;', {
|
|
5731
5742
|
d: this.svgs['cursor'],
|
|
5732
|
-
fill:
|
|
5743
|
+
fill: cc.text,
|
|
5733
5744
|
stroke: 'none'
|
|
5734
5745
|
});
|
|
5735
5746
|
this.stat = 1;
|
|
@@ -5828,13 +5839,13 @@
|
|
|
5828
5839
|
|
|
5829
5840
|
case 2:
|
|
5830
5841
|
this.s[2].color = cc.textOver;
|
|
5831
|
-
this.s[2].background = cc.
|
|
5842
|
+
this.s[2].background = cc.overoff;
|
|
5832
5843
|
break;
|
|
5833
5844
|
// over
|
|
5834
5845
|
|
|
5835
5846
|
case 3:
|
|
5836
|
-
this.s[2].color = cc.
|
|
5837
|
-
this.s[2].background = cc.
|
|
5847
|
+
this.s[2].color = cc.textOver;
|
|
5848
|
+
this.s[2].background = cc.action;
|
|
5838
5849
|
break;
|
|
5839
5850
|
// down
|
|
5840
5851
|
|
|
@@ -5871,6 +5882,177 @@
|
|
|
5871
5882
|
|
|
5872
5883
|
}
|
|
5873
5884
|
|
|
5885
|
+
class Bitmap extends Proto {
|
|
5886
|
+
constructor(o = {}) {
|
|
5887
|
+
super(o);
|
|
5888
|
+
this.value = o.value || '';
|
|
5889
|
+
this.refTexture = o.texture || null;
|
|
5890
|
+
this.img = null;
|
|
5891
|
+
this.isDown = false;
|
|
5892
|
+
this.neverlock = true;
|
|
5893
|
+
const cc = this.colors;
|
|
5894
|
+
this.c[2] = this.dom('div', this.css.txt + this.css.button + ' top:1px; background:' + cc.button + '; height:' + (this.h - 2) + 'px; border:' + cc.buttonBorder + '; border-radius:15px; width:30px; left:10px;');
|
|
5895
|
+
this.c[3] = this.dom('div', this.css.txtselect + 'height:' + (this.h - 4) + 'px; background:' + cc.inputBg + '; borderColor:' + cc.inputBorder + '; border-radius:' + this.radius + 'px;');
|
|
5896
|
+
this.c[3].textContent = this.value;
|
|
5897
|
+
let fltop = Math.floor(this.h * 0.5) - 7;
|
|
5898
|
+
this.c[4] = this.dom('path', this.css.basic + 'position:absolute; width:14px; height:14px; left:5px; top:' + fltop + 'px;', {
|
|
5899
|
+
d: this.svgs['load'],
|
|
5900
|
+
fill: cc.text,
|
|
5901
|
+
stroke: 'none'
|
|
5902
|
+
});
|
|
5903
|
+
this.stat = 1;
|
|
5904
|
+
this.init();
|
|
5905
|
+
}
|
|
5906
|
+
|
|
5907
|
+
testZone(e) {
|
|
5908
|
+
let l = this.local;
|
|
5909
|
+
if (l.x === -1 && l.y === -1) return '';
|
|
5910
|
+
if (l.x > this.sa && l.x < this.sa + 30) return 'over';
|
|
5911
|
+
return '0';
|
|
5912
|
+
} // ----------------------
|
|
5913
|
+
// EVENTS
|
|
5914
|
+
// ----------------------
|
|
5915
|
+
|
|
5916
|
+
|
|
5917
|
+
mouseup(e) {
|
|
5918
|
+
if (this.isDown) {
|
|
5919
|
+
//this.value = false;
|
|
5920
|
+
this.isDown = false; //this.send();
|
|
5921
|
+
|
|
5922
|
+
return this.mousemove(e);
|
|
5923
|
+
}
|
|
5924
|
+
|
|
5925
|
+
return false;
|
|
5926
|
+
}
|
|
5927
|
+
|
|
5928
|
+
mousedown(e) {
|
|
5929
|
+
let name = this.testZone(e);
|
|
5930
|
+
if (!name) return false;
|
|
5931
|
+
|
|
5932
|
+
if (name === 'over') {
|
|
5933
|
+
this.isDown = true;
|
|
5934
|
+
Files.load({
|
|
5935
|
+
callback: this.changeBitmap.bind(this)
|
|
5936
|
+
});
|
|
5937
|
+
} //this.value = this.values[ name-2 ];
|
|
5938
|
+
//this.send();
|
|
5939
|
+
|
|
5940
|
+
|
|
5941
|
+
return this.mousemove(e);
|
|
5942
|
+
}
|
|
5943
|
+
|
|
5944
|
+
mousemove(e) {
|
|
5945
|
+
let up = false;
|
|
5946
|
+
let name = this.testZone(e); //let sel = false;
|
|
5947
|
+
//console.log(name)
|
|
5948
|
+
|
|
5949
|
+
if (name === 'over') {
|
|
5950
|
+
this.cursor('pointer');
|
|
5951
|
+
up = this.mode(this.isDown ? 3 : 2);
|
|
5952
|
+
} else {
|
|
5953
|
+
up = this.reset();
|
|
5954
|
+
}
|
|
5955
|
+
|
|
5956
|
+
return up;
|
|
5957
|
+
} // ----------------------
|
|
5958
|
+
|
|
5959
|
+
|
|
5960
|
+
changeBitmap(img, fname) {
|
|
5961
|
+
if (img) {
|
|
5962
|
+
this.img = img;
|
|
5963
|
+
this.apply(fname);
|
|
5964
|
+
} else {
|
|
5965
|
+
this.img = null;
|
|
5966
|
+
this.apply('null');
|
|
5967
|
+
}
|
|
5968
|
+
} // ----------------------
|
|
5969
|
+
|
|
5970
|
+
|
|
5971
|
+
apply(v) {
|
|
5972
|
+
v = v || '';
|
|
5973
|
+
|
|
5974
|
+
if (v !== this.value) {
|
|
5975
|
+
this.value = v;
|
|
5976
|
+
this.c[3].textContent = this.value;
|
|
5977
|
+
|
|
5978
|
+
if (this.img !== null) {
|
|
5979
|
+
if (this.objectLink !== null) this.objectLink[this.val] = v;
|
|
5980
|
+
if (this.callback) this.callback(v, this.img, this.name);
|
|
5981
|
+
}
|
|
5982
|
+
}
|
|
5983
|
+
|
|
5984
|
+
this.mode(1);
|
|
5985
|
+
}
|
|
5986
|
+
|
|
5987
|
+
update() {
|
|
5988
|
+
this.mode(3);
|
|
5989
|
+
}
|
|
5990
|
+
|
|
5991
|
+
mode(n) {
|
|
5992
|
+
let change = false;
|
|
5993
|
+
let cc = this.colors;
|
|
5994
|
+
|
|
5995
|
+
if (this.stat !== n) {
|
|
5996
|
+
/*if( n===1 ) this.isActif = false
|
|
5997
|
+
if( n===3 ){
|
|
5998
|
+
if( !this.isActif ){ this.isActif = true; n=4; this.onActif( this ); }
|
|
5999
|
+
else { this.isActif = false; }
|
|
6000
|
+
}
|
|
6001
|
+
if( n===2 && this.isActif ) n = 4;*/
|
|
6002
|
+
this.stat = n;
|
|
6003
|
+
|
|
6004
|
+
switch (n) {
|
|
6005
|
+
case 1:
|
|
6006
|
+
this.s[2].color = cc.text;
|
|
6007
|
+
this.s[2].background = cc.button;
|
|
6008
|
+
break;
|
|
6009
|
+
// base
|
|
6010
|
+
|
|
6011
|
+
case 2:
|
|
6012
|
+
this.s[2].color = cc.textOver;
|
|
6013
|
+
this.s[2].background = cc.overoff;
|
|
6014
|
+
break;
|
|
6015
|
+
// over
|
|
6016
|
+
|
|
6017
|
+
case 3:
|
|
6018
|
+
this.s[2].color = cc.textOver;
|
|
6019
|
+
this.s[2].background = cc.over;
|
|
6020
|
+
break;
|
|
6021
|
+
// down
|
|
6022
|
+
|
|
6023
|
+
case 4:
|
|
6024
|
+
this.s[2].color = cc.textSelect;
|
|
6025
|
+
this.s[2].background = cc.select;
|
|
6026
|
+
break;
|
|
6027
|
+
// actif
|
|
6028
|
+
}
|
|
6029
|
+
|
|
6030
|
+
change = true;
|
|
6031
|
+
}
|
|
6032
|
+
|
|
6033
|
+
return change;
|
|
6034
|
+
}
|
|
6035
|
+
|
|
6036
|
+
reset() {
|
|
6037
|
+
this.cursor();
|
|
6038
|
+
return this.mode(this.isActif ? 4 : 1);
|
|
6039
|
+
}
|
|
6040
|
+
|
|
6041
|
+
text(txt) {
|
|
6042
|
+
this.c[3].textContent = txt;
|
|
6043
|
+
}
|
|
6044
|
+
|
|
6045
|
+
rSize() {
|
|
6046
|
+
super.rSize();
|
|
6047
|
+
let s = this.s;
|
|
6048
|
+
s[2].left = this.sa + 'px';
|
|
6049
|
+
s[3].left = this.sa + 40 + 'px';
|
|
6050
|
+
s[3].width = this.sb - 40 + 'px';
|
|
6051
|
+
s[4].left = this.sa + 8 + 'px';
|
|
6052
|
+
}
|
|
6053
|
+
|
|
6054
|
+
}
|
|
6055
|
+
|
|
5874
6056
|
//import { Proto } from '../core/Proto.js';
|
|
5875
6057
|
class Selector extends Button {
|
|
5876
6058
|
constructor(o = {}) {
|
|
@@ -6526,6 +6708,10 @@
|
|
|
6526
6708
|
n = new Select(o);
|
|
6527
6709
|
break;
|
|
6528
6710
|
|
|
6711
|
+
case 'bitmap':
|
|
6712
|
+
n = new Bitmap(o);
|
|
6713
|
+
break;
|
|
6714
|
+
|
|
6529
6715
|
case 'selector':
|
|
6530
6716
|
n = new Selector(o);
|
|
6531
6717
|
break;
|
|
@@ -6550,6 +6736,7 @@
|
|
|
6550
6736
|
}
|
|
6551
6737
|
|
|
6552
6738
|
if (n !== null) {
|
|
6739
|
+
Roots.needResize = true;
|
|
6553
6740
|
if (ref) n.setReferency(a[0], a[1]);
|
|
6554
6741
|
return n;
|
|
6555
6742
|
}
|
|
@@ -6678,7 +6865,7 @@
|
|
|
6678
6865
|
|
|
6679
6866
|
|
|
6680
6867
|
this.transition = o.transition || Tools.transition;
|
|
6681
|
-
if (this.transition) setTimeout(this.addTransition.bind(this),
|
|
6868
|
+
if (this.transition) setTimeout(this.addTransition.bind(this), 1000);
|
|
6682
6869
|
this.setWidth();
|
|
6683
6870
|
if (this.isCanvas) this.makeCanvas();
|
|
6684
6871
|
Roots.add(this);
|
|
@@ -6697,6 +6884,10 @@
|
|
|
6697
6884
|
this.content.style.transition = 'height ' + this.transition + 's ease-out';
|
|
6698
6885
|
this.bottom.style.transition = 'top ' + this.transition + 's ease-out'; //this.bottom.addEventListener("transitionend", Roots.resize, true);
|
|
6699
6886
|
}
|
|
6887
|
+
|
|
6888
|
+
let i = this.uis.length;
|
|
6889
|
+
|
|
6890
|
+
while (i--) this.uis[i].addTransition();
|
|
6700
6891
|
} // ----------------------
|
|
6701
6892
|
// CANVAS
|
|
6702
6893
|
// ----------------------
|
|
@@ -7131,7 +7322,7 @@
|
|
|
7131
7322
|
|
|
7132
7323
|
}
|
|
7133
7324
|
|
|
7134
|
-
const REVISION = '4.
|
|
7325
|
+
const REVISION = '4.2.0';
|
|
7135
7326
|
|
|
7136
7327
|
exports.Files = Files;
|
|
7137
7328
|
exports.Gui = Gui;
|