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.
@@ -21,7 +21,8 @@ const R = {
21
21
  current:-1,
22
22
 
23
23
  needReZone: true,
24
- isEventsInit: false,
24
+ needResize:false,
25
+ isEventsInit: false,
25
26
  isLeave:false,
26
27
 
27
28
  downTime:0,
@@ -179,8 +180,6 @@ const R = {
179
180
 
180
181
  resize: function () {
181
182
 
182
- R.needReZone = true;
183
-
184
183
  let i = R.ui.length, u;
185
184
 
186
185
  while( i-- ){
@@ -190,6 +189,9 @@ const R = {
190
189
 
191
190
  }
192
191
 
192
+ R.needReZone = true;
193
+ R.needResize = false;
194
+
193
195
  },
194
196
 
195
197
  out: function () {
@@ -223,6 +225,8 @@ const R = {
223
225
 
224
226
  if( R.prevDefault.indexOf( event.type ) !== -1 ) event.preventDefault();
225
227
 
228
+ if( R.needResize ) R.resize();
229
+
226
230
  R.findZone();
227
231
 
228
232
  let e = R.e;
@@ -1063,9 +1067,13 @@ const T = {
1063
1067
  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',
1064
1068
  none:'M 9 5 L 5 5 5 9 9 9 9 5 Z',
1065
1069
  cursor:'M 4 7 L 1 10 1 12 2 13 4 13 7 10 9 14 14 0 0 5 4 7 Z',
1070
+ 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',
1066
1071
 
1067
1072
  },
1068
1073
 
1074
+ rezone () {
1075
+ Roots.needReZone = true;
1076
+ },
1069
1077
 
1070
1078
  getImput: function(){
1071
1079
 
@@ -1732,7 +1740,7 @@ class Files {
1732
1740
  let t = [];
1733
1741
 
1734
1742
  switch( type ){
1735
- case 'json':
1743
+ case 'svg':
1736
1744
  t = [ { accept: { 'image/svg+xml': '.svg'} }, ];
1737
1745
  break;
1738
1746
  case 'text':
@@ -1796,14 +1804,20 @@ class Files {
1796
1804
 
1797
1805
  let content = e.target.result;
1798
1806
 
1799
- if( type === 'image' ){
1800
- var img = new Image;
1801
- img.onload = function() {
1802
- if( o.callback ) o.callback( img, fname );
1803
- };
1804
- img.src = content;
1805
- } else {
1806
- if( o.callback ) o.callback( content, fname );
1807
+ switch(type){
1808
+ case 'image':
1809
+ let img = new Image;
1810
+ img.onload = function() {
1811
+ if( o.callback ) o.callback( img, fname );
1812
+ };
1813
+ img.src = content;
1814
+ break;
1815
+ case 'json':
1816
+ if( o.callback ) o.callback( JSON.parse( content ), fname );
1817
+ break;
1818
+ default:
1819
+ if( o.callback ) o.callback( content, fname );
1820
+ break;
1807
1821
  }
1808
1822
 
1809
1823
  };
@@ -1811,6 +1825,7 @@ class Files {
1811
1825
  } catch(e) {
1812
1826
 
1813
1827
  console.log(e);
1828
+ if( o.callback ) o.callback( null );
1814
1829
 
1815
1830
  }
1816
1831
 
@@ -1880,7 +1895,7 @@ class Files {
1880
1895
  // create a FileSystemWritableFileStream to write to
1881
1896
  const file = await handle.createWritable();
1882
1897
 
1883
- let blob = new Blob([ options.data ], { type: option.finalType });
1898
+ let blob = new Blob([ options.data ], { type: options.finalType });
1884
1899
 
1885
1900
  // write our file
1886
1901
  await file.write(blob);
@@ -2178,7 +2193,7 @@ class Proto {
2178
2193
  // for listening object
2179
2194
  this.objectLink = null;
2180
2195
  this.isSend = false;
2181
- this.val = null;
2196
+ this.objectKey = null;
2182
2197
 
2183
2198
  this.txt = o.name || '';
2184
2199
  this.name = o.rename || this.txt;
@@ -2306,10 +2321,16 @@ class Proto {
2306
2321
  }
2307
2322
 
2308
2323
 
2324
+
2325
+
2326
+ }
2327
+
2328
+ addTransition(){
2329
+
2309
2330
  if( this.baseH && this.transition && this.isUI ){
2310
2331
  this.c[0].style.transition = 'height '+this.transition+'s ease-out';
2311
2332
  }
2312
-
2333
+
2313
2334
  }
2314
2335
 
2315
2336
  // from Tools
@@ -2432,7 +2453,7 @@ class Proto {
2432
2453
  if( this.isSend ) return;
2433
2454
  if( this.isEdit ) return;
2434
2455
 
2435
- this.setValue( this.objectLink[ this.val ] );
2456
+ this.setValue( this.objectLink[ this.objectKey ] );
2436
2457
 
2437
2458
  }
2438
2459
 
@@ -2498,8 +2519,8 @@ class Proto {
2498
2519
  if( v instanceof Array && v.length === 1 ) v = v[0];
2499
2520
 
2500
2521
  this.isSend = true;
2501
- if( this.objectLink !== null ) this.objectLink[ this.val ] = v;
2502
- if( this.callback ) this.callback( v, this.val );
2522
+ if( this.objectLink !== null ) this.objectLink[ this.objectKey ] = v;
2523
+ if( this.callback ) this.callback( v, this.objectKey );
2503
2524
  this.isSend = false;
2504
2525
 
2505
2526
  }
@@ -2510,7 +2531,7 @@ class Proto {
2510
2531
  if( v instanceof Array && v.length === 1 ) v = v[0];
2511
2532
 
2512
2533
  if( this.endCallback ) this.endCallback( v );
2513
- if( this.objectLink !== null ) this.objectLink[ this.val ] = v;
2534
+ if( this.objectLink !== null ) this.objectLink[ this.objectKey ] = v;
2514
2535
 
2515
2536
  }
2516
2537
 
@@ -2579,8 +2600,7 @@ class Proto {
2579
2600
 
2580
2601
  rSize() {
2581
2602
 
2582
- if( !this.autoWidth ) return;
2583
-
2603
+ if( !this.autoWidth ) return
2584
2604
  if( !this.isUI ) this.s[0].width = this.w + 'px';
2585
2605
  if( !this.simple ) this.s[1].width = this.sa + 'px';
2586
2606
 
@@ -2657,10 +2677,10 @@ class Proto {
2657
2677
  // object referency
2658
2678
  // ----------------------
2659
2679
 
2660
- setReferency( obj, val ) {
2680
+ setReferency( obj, key ) {
2661
2681
 
2662
2682
  this.objectLink = obj;
2663
- this.val = val;
2683
+ this.objectKey = key;
2664
2684
 
2665
2685
  }
2666
2686
 
@@ -2674,8 +2694,9 @@ class Proto {
2674
2694
 
2675
2695
  open () {
2676
2696
 
2677
- if( this.isOpen ) return;
2697
+ if( this.isOpen ) return
2678
2698
  this.isOpen = true;
2699
+ //Roots.needResize = true
2679
2700
  if( this.openCallback ) this.openCallback();
2680
2701
 
2681
2702
  }
@@ -2684,6 +2705,7 @@ class Proto {
2684
2705
 
2685
2706
  if( !this.isOpen ) return
2686
2707
  this.isOpen = false;
2708
+ //Roots.needResize = true
2687
2709
  if( this.closeCallback ) this.closeCallback();
2688
2710
 
2689
2711
  }
@@ -2932,7 +2954,7 @@ class Button extends Proto {
2932
2954
  if( !o.value && !o.values ){
2933
2955
  if( this.c[1] !== undefined ) {
2934
2956
  this.c[1].textContent = '';
2935
- this.txt = '';
2957
+ //this.txt = ''
2936
2958
  }
2937
2959
  }
2938
2960
  if( !this.txt ) this.p = 0;
@@ -3147,6 +3169,7 @@ class Circular extends Proto {
3147
3169
  this.top = 0;
3148
3170
 
3149
3171
  this.c[0].style.width = this.w +'px';
3172
+ this.c[0].style.display = 'block';
3150
3173
 
3151
3174
  if(this.c[1] !== undefined) {
3152
3175
 
@@ -4756,6 +4779,7 @@ class Joystick extends Proto {
4756
4779
  this.tmp = new V2();
4757
4780
 
4758
4781
  this.interval = null;
4782
+ this.c[0].style.display = 'block';
4759
4783
 
4760
4784
  //this.radius = this.w * 0.5;
4761
4785
  //this.distance = this.radius*0.25;
@@ -4997,6 +5021,7 @@ class Knob extends Proto {
4997
5021
  this.top = 0;
4998
5022
 
4999
5023
  this.c[0].style.width = this.w +'px';
5024
+ this.c[0].style.display = 'block';
5000
5025
 
5001
5026
  if(this.c[1] !== undefined) {
5002
5027
 
@@ -6334,20 +6359,15 @@ class Numeric extends Proto {
6334
6359
 
6335
6360
  if( this.isVector ){
6336
6361
 
6337
- this.objectLink[ this.val ].fromArray( v );
6338
-
6339
- /*this.objectLink[ this.val ].x = v[0];
6340
- this.objectLink[ this.val ].y = v[1];
6341
- this.objectLink[ this.val ].z = v[2];
6342
- if( v[3] ) this.objectLink[ this.val ].w = v[3];*/
6362
+ this.objectLink[ this.objectKey ].fromArray( v );
6343
6363
 
6344
6364
  } else {
6345
- this.objectLink[ this.val ] = v;
6365
+ this.objectLink[ this.objectKey ] = v;
6346
6366
  }
6347
6367
 
6348
6368
  }
6349
6369
 
6350
- if( this.callback ) this.callback( v, this.val );
6370
+ if( this.callback ) this.callback( v, this.objectKey );
6351
6371
 
6352
6372
  this.isSend = false;
6353
6373
 
@@ -6704,7 +6724,7 @@ class TextInput extends Proto {
6704
6724
 
6705
6725
  this.cmode = 0;
6706
6726
 
6707
- this.value = o.value || '';
6727
+ this.value = o.value !== undefined ? o.value : '';
6708
6728
  this.placeHolder = o.placeHolder || '';
6709
6729
 
6710
6730
  this.allway = o.allway || false;
@@ -6947,16 +6967,17 @@ class Select extends Proto {
6947
6967
 
6948
6968
  this.onActif = o.onActif || function(){};
6949
6969
 
6950
- o.prefix || '';
6970
+ //let prefix = o.prefix || '';
6971
+ const cc = this.colors;
6951
6972
 
6952
- 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;' );
6953
- this.c[2].style.color = this.fontColor;
6973
+ 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;' );
6974
+ //this.c[2].style.color = this.fontColor;
6954
6975
 
6955
- 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;' );
6976
+ 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;' );
6956
6977
  this.c[3].textContent = this.value;
6957
6978
 
6958
6979
  let fltop = Math.floor(this.h*0.5)-7;
6959
- this.c[4] = this.dom( 'path', this.css.basic + 'position:absolute; width:14px; height:14px; left:5px; top:'+fltop+'px;', { d:this.svgs[ 'cursor' ], fill:this.fontColor, stroke:'none'});
6980
+ this.c[4] = this.dom( 'path', this.css.basic + 'position:absolute; width:14px; height:14px; left:5px; top:'+fltop+'px;', { d:this.svgs[ 'cursor' ], fill:cc.text, stroke:'none'});
6960
6981
 
6961
6982
  this.stat = 1;
6962
6983
  this.isActif = false;
@@ -7068,8 +7089,8 @@ class Select extends Proto {
7068
7089
  switch( n ){
7069
7090
 
7070
7091
  case 1: this.s[ 2 ].color = cc.text; this.s[ 2 ].background = cc.button; break; // base
7071
- case 2: this.s[ 2 ].color = cc.textOver; this.s[ 2 ].background = cc.over; break; // over
7072
- case 3: this.s[ 2 ].color = cc.textSelect; this.s[ 2 ].background = cc.select; break; // down
7092
+ case 2: this.s[ 2 ].color = cc.textOver; this.s[ 2 ].background = cc.overoff; break; // over
7093
+ case 3: this.s[ 2 ].color = cc.textOver; this.s[ 2 ].background = cc.action; break; // down
7073
7094
  case 4: this.s[ 2 ].color = cc.textSelect; this.s[ 2 ].background = cc.action; break; // actif
7074
7095
 
7075
7096
  }
@@ -7082,6 +7103,209 @@ class Select extends Proto {
7082
7103
 
7083
7104
 
7084
7105
 
7106
+ }
7107
+
7108
+ reset () {
7109
+
7110
+ this.cursor();
7111
+ return this.mode( this.isActif ? 4 : 1 );
7112
+
7113
+ }
7114
+
7115
+ text ( txt ) {
7116
+
7117
+ this.c[3].textContent = txt;
7118
+
7119
+ }
7120
+
7121
+ rSize () {
7122
+
7123
+ super.rSize();
7124
+
7125
+ let s = this.s;
7126
+ s[2].left = this.sa + 'px';
7127
+ s[3].left = (this.sa + 40) + 'px';
7128
+ s[3].width = (this.sb - 40) + 'px';
7129
+ s[4].left = (this.sa+8) + 'px';
7130
+
7131
+ }
7132
+
7133
+ }
7134
+
7135
+ class Bitmap extends Proto {
7136
+
7137
+ constructor( o = {} ) {
7138
+
7139
+ super( o );
7140
+
7141
+ this.value = o.value || '';
7142
+ this.refTexture = o.texture || null;
7143
+ this.img = null;
7144
+
7145
+ this.isDown = false;
7146
+ this.neverlock = true;
7147
+
7148
+
7149
+
7150
+ const cc = this.colors;
7151
+
7152
+ 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;' );
7153
+
7154
+ 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;' );
7155
+ this.c[3].textContent = this.value;
7156
+
7157
+ let fltop = Math.floor(this.h*0.5)-7;
7158
+ this.c[4] = this.dom( 'path', this.css.basic + 'position:absolute; width:14px; height:14px; left:5px; top:'+fltop+'px;', { d:this.svgs[ 'load' ], fill:cc.text, stroke:'none'});
7159
+
7160
+ this.stat = 1;
7161
+
7162
+ this.init();
7163
+
7164
+ }
7165
+
7166
+ testZone ( e ) {
7167
+
7168
+ let l = this.local;
7169
+ if( l.x === -1 && l.y === -1 ) return '';
7170
+ if( l.x > this.sa && l.x < this.sa+30 ) return 'over';
7171
+ return '0'
7172
+
7173
+ }
7174
+
7175
+ // ----------------------
7176
+ // EVENTS
7177
+ // ----------------------
7178
+
7179
+ mouseup ( e ) {
7180
+
7181
+ if( this.isDown ){
7182
+ //this.value = false;
7183
+ this.isDown = false;
7184
+ //this.send();
7185
+ return this.mousemove( e );
7186
+ }
7187
+
7188
+ return false;
7189
+
7190
+ }
7191
+
7192
+ mousedown ( e ) {
7193
+
7194
+ let name = this.testZone( e );
7195
+
7196
+ if( !name ) return false;
7197
+
7198
+ if( name === 'over' ){
7199
+ this.isDown = true;
7200
+ Files.load( { callback:this.changeBitmap.bind(this) } );
7201
+
7202
+ }
7203
+
7204
+
7205
+ //this.value = this.values[ name-2 ];
7206
+ //this.send();
7207
+ return this.mousemove( e );
7208
+
7209
+ }
7210
+
7211
+ mousemove ( e ) {
7212
+
7213
+ let up = false;
7214
+
7215
+ let name = this.testZone( e );
7216
+ //let sel = false;
7217
+
7218
+
7219
+
7220
+ //console.log(name)
7221
+
7222
+ if( name === 'over' ){
7223
+ this.cursor('pointer');
7224
+ up = this.mode( this.isDown ? 3 : 2 );
7225
+ } else {
7226
+ up = this.reset();
7227
+ }
7228
+
7229
+ return up;
7230
+
7231
+ }
7232
+
7233
+ // ----------------------
7234
+
7235
+ changeBitmap( img, fname ){
7236
+
7237
+ if( img ){
7238
+ this.img = img;
7239
+ this.apply( fname );
7240
+ } else {
7241
+ this.img = null;
7242
+ this.apply( 'null' );
7243
+ }
7244
+
7245
+ }
7246
+
7247
+ // ----------------------
7248
+
7249
+ apply ( v ) {
7250
+
7251
+ v = v || '';
7252
+
7253
+ if( v !== this.value ) {
7254
+ this.value = v;
7255
+ this.c[3].textContent = this.value;
7256
+
7257
+ if( this.img !== null ){
7258
+ if( this.objectLink !== null ) this.objectLink[ this.val ] = v;
7259
+ if( this.callback ) this.callback( v, this.img, this.name );
7260
+ }
7261
+
7262
+ }
7263
+
7264
+ this.mode(1);
7265
+
7266
+ }
7267
+
7268
+ update () {
7269
+
7270
+ this.mode( 3 );
7271
+
7272
+ }
7273
+
7274
+ mode ( n ) {
7275
+
7276
+ let change = false;
7277
+ let cc = this.colors;
7278
+
7279
+ if( this.stat !== n ){
7280
+
7281
+ /*if( n===1 ) this.isActif = false
7282
+
7283
+ if( n===3 ){
7284
+ if( !this.isActif ){ this.isActif = true; n=4; this.onActif( this ); }
7285
+ else { this.isActif = false; }
7286
+ }
7287
+
7288
+ if( n===2 && this.isActif ) n = 4;*/
7289
+
7290
+ this.stat = n;
7291
+
7292
+ switch( n ){
7293
+
7294
+ case 1: this.s[ 2 ].color = cc.text; this.s[ 2 ].background = cc.button; break; // base
7295
+ case 2: this.s[ 2 ].color = cc.textOver; this.s[ 2 ].background = cc.overoff; break; // over
7296
+ case 3: this.s[ 2 ].color = cc.textOver; this.s[ 2 ].background = cc.over; break; // down
7297
+ case 4: this.s[ 2 ].color = cc.textSelect; this.s[ 2 ].background = cc.select; break; // actif
7298
+
7299
+ }
7300
+
7301
+ change = true;
7302
+
7303
+ }
7304
+
7305
+ return change;
7306
+
7307
+
7308
+
7085
7309
  }
7086
7310
 
7087
7311
  reset () {
@@ -7578,6 +7802,8 @@ class Pad2D extends Proto {
7578
7802
 
7579
7803
  //console.log(this.range)
7580
7804
 
7805
+ this.c[0].style.display = 'block';
7806
+
7581
7807
 
7582
7808
 
7583
7809
 
@@ -7867,6 +8093,7 @@ const add = function () {
7867
8093
  case 'textInput': case 'string': n = new TextInput(o); break;
7868
8094
  case 'title': case 'text': n = new Title(o); break;
7869
8095
  case 'select': n = new Select(o); break;
8096
+ case 'bitmap': n = new Bitmap(o); break;
7870
8097
  case 'selector': n = new Selector(o); break;
7871
8098
  case 'empty': case 'space': n = new Empty(o); break;
7872
8099
  case 'item': n = new Item(o); break;
@@ -7875,8 +8102,12 @@ const add = function () {
7875
8102
 
7876
8103
  }
7877
8104
 
8105
+
8106
+
7878
8107
  if( n !== null ){
7879
8108
 
8109
+ Roots.needResize = true;
8110
+
7880
8111
  if( ref ) n.setReferency( a[0], a[1] );
7881
8112
  return n;
7882
8113
 
@@ -8060,7 +8291,7 @@ class Gui {
8060
8291
 
8061
8292
  // height transition
8062
8293
  this.transition = o.transition || Tools.transition;
8063
- if( this.transition ) setTimeout( this.addTransition.bind( this ), 0 );
8294
+ if( this.transition ) setTimeout( this.addTransition.bind( this ), 1000 );
8064
8295
 
8065
8296
 
8066
8297
  this.setWidth();
@@ -8090,6 +8321,9 @@ class Gui {
8090
8321
  //this.bottom.addEventListener("transitionend", Roots.resize, true);
8091
8322
  }
8092
8323
 
8324
+ let i = this.uis.length;
8325
+ while( i-- ) this.uis[i].addTransition();
8326
+
8093
8327
  }
8094
8328
 
8095
8329
  // ----------------------
@@ -8672,6 +8906,6 @@ class Gui {
8672
8906
 
8673
8907
  }
8674
8908
 
8675
- const REVISION = '4.0.8';
8909
+ const REVISION = '4.2.0';
8676
8910
 
8677
8911
  export { Files, Gui, Proto, REVISION, Tools, add };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uil",
3
- "version": "4.0.8",
3
+ "version": "4.2.0",
4
4
  "description": "JavaScript gui library",
5
5
  "main": "build/uil.js",
6
6
  "repository": "lo-th/uil",