uil 4.0.8 → 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 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.0.8</p>
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'
805
+ },
806
+
807
+ rezone() {
808
+ Roots.needReZone = true;
800
809
  },
810
+
801
811
  getImput: function () {
802
812
  return Roots.input ? true : false;
803
813
  },
@@ -1572,7 +1582,7 @@
1572
1582
  let t = [];
1573
1583
 
1574
1584
  switch (type) {
1575
- case 'json':
1585
+ case 'svg':
1576
1586
  t = [{
1577
1587
  accept: {
1578
1588
  'image/svg+xml': '.svg'
@@ -1643,20 +1653,29 @@
1643
1653
  reader.onload = function (e) {
1644
1654
  let content = e.target.result;
1645
1655
 
1646
- if (type === 'image') {
1647
- var img = new Image();
1656
+ switch (type) {
1657
+ case 'image':
1658
+ let img = new Image();
1648
1659
 
1649
- img.onload = function () {
1650
- if (o.callback) o.callback(img, fname);
1651
- };
1660
+ img.onload = function () {
1661
+ if (o.callback) o.callback(img, fname);
1662
+ };
1652
1663
 
1653
- img.src = content;
1654
- } else {
1655
- if (o.callback) o.callback(content, fname);
1664
+ img.src = content;
1665
+ break;
1666
+
1667
+ case 'json':
1668
+ if (o.callback) o.callback(JSON.parse(content), fname);
1669
+ break;
1670
+
1671
+ default:
1672
+ if (o.callback) o.callback(content, fname);
1673
+ break;
1656
1674
  }
1657
1675
  };
1658
1676
  } catch (e) {
1659
1677
  console.log(e);
1678
+ if (o.callback) o.callback(null);
1660
1679
  }
1661
1680
  }
1662
1681
 
@@ -1705,7 +1724,7 @@
1705
1724
 
1706
1725
  const file = await handle.createWritable();
1707
1726
  let blob = new Blob([options.data], {
1708
- type: option.finalType
1727
+ type: options.finalType
1709
1728
  }); // write our file
1710
1729
 
1711
1730
  await file.write(blob); // close the file and write the contents to disk.
@@ -1919,7 +1938,7 @@
1919
1938
 
1920
1939
  this.objectLink = null;
1921
1940
  this.isSend = false;
1922
- this.val = null;
1941
+ this.objectKey = null;
1923
1942
  this.txt = o.name || '';
1924
1943
  this.name = o.rename || this.txt;
1925
1944
  this.target = o.target || null; // callback
@@ -2022,7 +2041,9 @@
2022
2041
  this.c[0].style.pointerEvents = 'auto';
2023
2042
  Roots.add(this);
2024
2043
  }
2044
+ }
2025
2045
 
2046
+ addTransition() {
2026
2047
  if (this.baseH && this.transition && this.isUI) {
2027
2048
  this.c[0].style.transition = 'height ' + this.transition + 's ease-out';
2028
2049
  }
@@ -2108,7 +2129,7 @@
2108
2129
  if (this.objectLink === null) return;
2109
2130
  if (this.isSend) return;
2110
2131
  if (this.isEdit) return;
2111
- this.setValue(this.objectLink[this.val]);
2132
+ this.setValue(this.objectLink[this.objectKey]);
2112
2133
  }
2113
2134
 
2114
2135
  setValue(v) {
@@ -2156,8 +2177,8 @@
2156
2177
  v = v || this.value;
2157
2178
  if (v instanceof Array && v.length === 1) v = v[0];
2158
2179
  this.isSend = true;
2159
- if (this.objectLink !== null) this.objectLink[this.val] = v;
2160
- if (this.callback) this.callback(v, this.val);
2180
+ if (this.objectLink !== null) this.objectLink[this.objectKey] = v;
2181
+ if (this.callback) this.callback(v, this.objectKey);
2161
2182
  this.isSend = false;
2162
2183
  }
2163
2184
 
@@ -2165,7 +2186,7 @@
2165
2186
  v = v || this.value;
2166
2187
  if (v instanceof Array && v.length === 1) v = v[0];
2167
2188
  if (this.endCallback) this.endCallback(v);
2168
- if (this.objectLink !== null) this.objectLink[this.val] = v;
2189
+ if (this.objectLink !== null) this.objectLink[this.objectKey] = v;
2169
2190
  } // ----------------------
2170
2191
  // clear node
2171
2192
  // ----------------------
@@ -2307,9 +2328,9 @@
2307
2328
  // ----------------------
2308
2329
 
2309
2330
 
2310
- setReferency(obj, val) {
2331
+ setReferency(obj, key) {
2311
2332
  this.objectLink = obj;
2312
- this.val = val;
2333
+ this.objectKey = key;
2313
2334
  }
2314
2335
 
2315
2336
  display(v = false) {
@@ -2321,13 +2342,15 @@
2321
2342
 
2322
2343
  open() {
2323
2344
  if (this.isOpen) return;
2324
- this.isOpen = true;
2345
+ this.isOpen = true; //Roots.needResize = true
2346
+
2325
2347
  if (this.openCallback) this.openCallback();
2326
2348
  }
2327
2349
 
2328
2350
  close() {
2329
2351
  if (!this.isOpen) return;
2330
- this.isOpen = false;
2352
+ this.isOpen = false; //Roots.needResize = true
2353
+
2331
2354
  if (this.closeCallback) this.closeCallback();
2332
2355
  }
2333
2356
 
@@ -2542,8 +2565,7 @@
2542
2565
 
2543
2566
  if (!o.value && !o.values) {
2544
2567
  if (this.c[1] !== undefined) {
2545
- this.c[1].textContent = '';
2546
- this.txt = '';
2568
+ this.c[1].textContent = ''; //this.txt = ''
2547
2569
  }
2548
2570
  }
2549
2571
 
@@ -2727,6 +2749,7 @@
2727
2749
  this.h = o.h || this.w + 10;
2728
2750
  this.top = 0;
2729
2751
  this.c[0].style.width = this.w + 'px';
2752
+ this.c[0].style.display = 'block';
2730
2753
 
2731
2754
  if (this.c[1] !== undefined) {
2732
2755
  this.c[1].style.width = '100%';
@@ -3983,7 +4006,8 @@
3983
4006
  this.multiplicator = o.multiplicator || 1;
3984
4007
  this.pos = new V2();
3985
4008
  this.tmp = new V2();
3986
- this.interval = null; //this.radius = this.w * 0.5;
4009
+ this.interval = null;
4010
+ this.c[0].style.display = 'block'; //this.radius = this.w * 0.5;
3987
4011
  //this.distance = this.radius*0.25;
3988
4012
 
3989
4013
  this.distance = this.diam * 0.5 * 0.25;
@@ -4171,6 +4195,7 @@
4171
4195
  this.h = o.h || this.w + 10;
4172
4196
  this.top = 0;
4173
4197
  this.c[0].style.width = this.w + 'px';
4198
+ this.c[0].style.display = 'block';
4174
4199
 
4175
4200
  if (this.c[1] !== undefined) {
4176
4201
  this.c[1].style.width = '100%';
@@ -5246,17 +5271,13 @@
5246
5271
 
5247
5272
  if (this.objectLink !== null) {
5248
5273
  if (this.isVector) {
5249
- this.objectLink[this.val].fromArray(v);
5250
- /*this.objectLink[ this.val ].x = v[0];
5251
- this.objectLink[ this.val ].y = v[1];
5252
- this.objectLink[ this.val ].z = v[2];
5253
- if( v[3] ) this.objectLink[ this.val ].w = v[3];*/
5274
+ this.objectLink[this.objectKey].fromArray(v);
5254
5275
  } else {
5255
- this.objectLink[this.val] = v;
5276
+ this.objectLink[this.objectKey] = v;
5256
5277
  }
5257
5278
  }
5258
5279
 
5259
- if (this.callback) this.callback(v, this.val);
5280
+ if (this.callback) this.callback(v, this.objectKey);
5260
5281
  this.isSend = false;
5261
5282
  } // ----------------------
5262
5283
  // INPUT
@@ -5541,7 +5562,7 @@
5541
5562
  constructor(o = {}) {
5542
5563
  super(o);
5543
5564
  this.cmode = 0;
5544
- this.value = o.value || '';
5565
+ this.value = o.value !== undefined ? o.value : '';
5545
5566
  this.placeHolder = o.placeHolder || '';
5546
5567
  this.allway = o.allway || false;
5547
5568
  this.editable = o.edit !== undefined ? o.edit : true;
@@ -5708,17 +5729,18 @@
5708
5729
  this.value = o.value || '';
5709
5730
  this.isDown = false;
5710
5731
 
5711
- this.onActif = o.onActif || function () {};
5732
+ this.onActif = o.onActif || function () {}; //let prefix = o.prefix || '';
5733
+
5734
+
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;
5712
5737
 
5713
- o.prefix || '';
5714
- this.c[2] = this.dom('div', this.css.txt + this.css.button + ' top:1px; background:' + this.colors.button + '; height:' + (this.h - 2) + 'px; border:' + this.colors.buttonBorder + '; border-radius:15px; width:30px; left:10px;');
5715
- this.c[2].style.color = this.fontColor;
5716
- this.c[3] = this.dom('div', this.css.txtselect + 'height:' + (this.h - 4) + 'px; background:' + this.colors.inputBg + '; borderColor:' + this.colors.inputBorder + '; border-radius:' + this.radius + 'px;');
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;');
5717
5739
  this.c[3].textContent = this.value;
5718
5740
  let fltop = Math.floor(this.h * 0.5) - 7;
5719
5741
  this.c[4] = this.dom('path', this.css.basic + 'position:absolute; width:14px; height:14px; left:5px; top:' + fltop + 'px;', {
5720
5742
  d: this.svgs['cursor'],
5721
- fill: this.fontColor,
5743
+ fill: cc.text,
5722
5744
  stroke: 'none'
5723
5745
  });
5724
5746
  this.stat = 1;
@@ -5817,13 +5839,13 @@
5817
5839
 
5818
5840
  case 2:
5819
5841
  this.s[2].color = cc.textOver;
5820
- this.s[2].background = cc.over;
5842
+ this.s[2].background = cc.overoff;
5821
5843
  break;
5822
5844
  // over
5823
5845
 
5824
5846
  case 3:
5825
- this.s[2].color = cc.textSelect;
5826
- this.s[2].background = cc.select;
5847
+ this.s[2].color = cc.textOver;
5848
+ this.s[2].background = cc.action;
5827
5849
  break;
5828
5850
  // down
5829
5851
 
@@ -5860,6 +5882,177 @@
5860
5882
 
5861
5883
  }
5862
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
+
5863
6056
  //import { Proto } from '../core/Proto.js';
5864
6057
  class Selector extends Button {
5865
6058
  constructor(o = {}) {
@@ -6250,6 +6443,7 @@
6250
6443
  this.range = (this.max - this.min) * 0.5;
6251
6444
  this.cmode = 0; //console.log(this.range)
6252
6445
 
6446
+ this.c[0].style.display = 'block';
6253
6447
  this.precision = o.precision === undefined ? 2 : o.precision;
6254
6448
  /*this.bounds = {};
6255
6449
  this.bounds.x1 = o.x1 || -1;
@@ -6514,6 +6708,10 @@
6514
6708
  n = new Select(o);
6515
6709
  break;
6516
6710
 
6711
+ case 'bitmap':
6712
+ n = new Bitmap(o);
6713
+ break;
6714
+
6517
6715
  case 'selector':
6518
6716
  n = new Selector(o);
6519
6717
  break;
@@ -6538,6 +6736,7 @@
6538
6736
  }
6539
6737
 
6540
6738
  if (n !== null) {
6739
+ Roots.needResize = true;
6541
6740
  if (ref) n.setReferency(a[0], a[1]);
6542
6741
  return n;
6543
6742
  }
@@ -6666,7 +6865,7 @@
6666
6865
 
6667
6866
 
6668
6867
  this.transition = o.transition || Tools.transition;
6669
- if (this.transition) setTimeout(this.addTransition.bind(this), 0);
6868
+ if (this.transition) setTimeout(this.addTransition.bind(this), 1000);
6670
6869
  this.setWidth();
6671
6870
  if (this.isCanvas) this.makeCanvas();
6672
6871
  Roots.add(this);
@@ -6685,6 +6884,10 @@
6685
6884
  this.content.style.transition = 'height ' + this.transition + 's ease-out';
6686
6885
  this.bottom.style.transition = 'top ' + this.transition + 's ease-out'; //this.bottom.addEventListener("transitionend", Roots.resize, true);
6687
6886
  }
6887
+
6888
+ let i = this.uis.length;
6889
+
6890
+ while (i--) this.uis[i].addTransition();
6688
6891
  } // ----------------------
6689
6892
  // CANVAS
6690
6893
  // ----------------------
@@ -7119,7 +7322,7 @@
7119
7322
 
7120
7323
  }
7121
7324
 
7122
- const REVISION = '4.0.8';
7325
+ const REVISION = '4.2.0';
7123
7326
 
7124
7327
  exports.Files = Files;
7125
7328
  exports.Gui = Gui;