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.
@@ -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
 
@@ -1817,6 +1825,7 @@ class Files {
1817
1825
  } catch(e) {
1818
1826
 
1819
1827
  console.log(e);
1828
+ if( o.callback ) o.callback( null );
1820
1829
 
1821
1830
  }
1822
1831
 
@@ -2184,7 +2193,7 @@ class Proto {
2184
2193
  // for listening object
2185
2194
  this.objectLink = null;
2186
2195
  this.isSend = false;
2187
- this.val = null;
2196
+ this.objectKey = null;
2188
2197
 
2189
2198
  this.txt = o.name || '';
2190
2199
  this.name = o.rename || this.txt;
@@ -2312,10 +2321,16 @@ class Proto {
2312
2321
  }
2313
2322
 
2314
2323
 
2324
+
2325
+
2326
+ }
2327
+
2328
+ addTransition(){
2329
+
2315
2330
  if( this.baseH && this.transition && this.isUI ){
2316
2331
  this.c[0].style.transition = 'height '+this.transition+'s ease-out';
2317
2332
  }
2318
-
2333
+
2319
2334
  }
2320
2335
 
2321
2336
  // from Tools
@@ -2438,7 +2453,7 @@ class Proto {
2438
2453
  if( this.isSend ) return;
2439
2454
  if( this.isEdit ) return;
2440
2455
 
2441
- this.setValue( this.objectLink[ this.val ] );
2456
+ this.setValue( this.objectLink[ this.objectKey ] );
2442
2457
 
2443
2458
  }
2444
2459
 
@@ -2504,8 +2519,8 @@ class Proto {
2504
2519
  if( v instanceof Array && v.length === 1 ) v = v[0];
2505
2520
 
2506
2521
  this.isSend = true;
2507
- if( this.objectLink !== null ) this.objectLink[ this.val ] = v;
2508
- 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 );
2509
2524
  this.isSend = false;
2510
2525
 
2511
2526
  }
@@ -2516,7 +2531,7 @@ class Proto {
2516
2531
  if( v instanceof Array && v.length === 1 ) v = v[0];
2517
2532
 
2518
2533
  if( this.endCallback ) this.endCallback( v );
2519
- if( this.objectLink !== null ) this.objectLink[ this.val ] = v;
2534
+ if( this.objectLink !== null ) this.objectLink[ this.objectKey ] = v;
2520
2535
 
2521
2536
  }
2522
2537
 
@@ -2585,8 +2600,7 @@ class Proto {
2585
2600
 
2586
2601
  rSize() {
2587
2602
 
2588
- if( !this.autoWidth ) return;
2589
-
2603
+ if( !this.autoWidth ) return
2590
2604
  if( !this.isUI ) this.s[0].width = this.w + 'px';
2591
2605
  if( !this.simple ) this.s[1].width = this.sa + 'px';
2592
2606
 
@@ -2663,10 +2677,10 @@ class Proto {
2663
2677
  // object referency
2664
2678
  // ----------------------
2665
2679
 
2666
- setReferency( obj, val ) {
2680
+ setReferency( obj, key ) {
2667
2681
 
2668
2682
  this.objectLink = obj;
2669
- this.val = val;
2683
+ this.objectKey = key;
2670
2684
 
2671
2685
  }
2672
2686
 
@@ -2680,8 +2694,9 @@ class Proto {
2680
2694
 
2681
2695
  open () {
2682
2696
 
2683
- if( this.isOpen ) return;
2697
+ if( this.isOpen ) return
2684
2698
  this.isOpen = true;
2699
+ //Roots.needResize = true
2685
2700
  if( this.openCallback ) this.openCallback();
2686
2701
 
2687
2702
  }
@@ -2690,6 +2705,7 @@ class Proto {
2690
2705
 
2691
2706
  if( !this.isOpen ) return
2692
2707
  this.isOpen = false;
2708
+ //Roots.needResize = true
2693
2709
  if( this.closeCallback ) this.closeCallback();
2694
2710
 
2695
2711
  }
@@ -2938,7 +2954,7 @@ class Button extends Proto {
2938
2954
  if( !o.value && !o.values ){
2939
2955
  if( this.c[1] !== undefined ) {
2940
2956
  this.c[1].textContent = '';
2941
- this.txt = '';
2957
+ //this.txt = ''
2942
2958
  }
2943
2959
  }
2944
2960
  if( !this.txt ) this.p = 0;
@@ -6343,20 +6359,15 @@ class Numeric extends Proto {
6343
6359
 
6344
6360
  if( this.isVector ){
6345
6361
 
6346
- this.objectLink[ this.val ].fromArray( v );
6347
-
6348
- /*this.objectLink[ this.val ].x = v[0];
6349
- this.objectLink[ this.val ].y = v[1];
6350
- this.objectLink[ this.val ].z = v[2];
6351
- if( v[3] ) this.objectLink[ this.val ].w = v[3];*/
6362
+ this.objectLink[ this.objectKey ].fromArray( v );
6352
6363
 
6353
6364
  } else {
6354
- this.objectLink[ this.val ] = v;
6365
+ this.objectLink[ this.objectKey ] = v;
6355
6366
  }
6356
6367
 
6357
6368
  }
6358
6369
 
6359
- if( this.callback ) this.callback( v, this.val );
6370
+ if( this.callback ) this.callback( v, this.objectKey );
6360
6371
 
6361
6372
  this.isSend = false;
6362
6373
 
@@ -6713,7 +6724,7 @@ class TextInput extends Proto {
6713
6724
 
6714
6725
  this.cmode = 0;
6715
6726
 
6716
- this.value = o.value || '';
6727
+ this.value = o.value !== undefined ? o.value : '';
6717
6728
  this.placeHolder = o.placeHolder || '';
6718
6729
 
6719
6730
  this.allway = o.allway || false;
@@ -6956,16 +6967,17 @@ class Select extends Proto {
6956
6967
 
6957
6968
  this.onActif = o.onActif || function(){};
6958
6969
 
6959
- o.prefix || '';
6970
+ //let prefix = o.prefix || '';
6971
+ const cc = this.colors;
6960
6972
 
6961
- 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;' );
6962
- 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;
6963
6975
 
6964
- 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;' );
6965
6977
  this.c[3].textContent = this.value;
6966
6978
 
6967
6979
  let fltop = Math.floor(this.h*0.5)-7;
6968
- 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'});
6969
6981
 
6970
6982
  this.stat = 1;
6971
6983
  this.isActif = false;
@@ -7077,8 +7089,8 @@ class Select extends Proto {
7077
7089
  switch( n ){
7078
7090
 
7079
7091
  case 1: this.s[ 2 ].color = cc.text; this.s[ 2 ].background = cc.button; break; // base
7080
- case 2: this.s[ 2 ].color = cc.textOver; this.s[ 2 ].background = cc.over; break; // over
7081
- 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
7082
7094
  case 4: this.s[ 2 ].color = cc.textSelect; this.s[ 2 ].background = cc.action; break; // actif
7083
7095
 
7084
7096
  }
@@ -7091,6 +7103,209 @@ class Select extends Proto {
7091
7103
 
7092
7104
 
7093
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
+
7094
7309
  }
7095
7310
 
7096
7311
  reset () {
@@ -7878,6 +8093,7 @@ const add = function () {
7878
8093
  case 'textInput': case 'string': n = new TextInput(o); break;
7879
8094
  case 'title': case 'text': n = new Title(o); break;
7880
8095
  case 'select': n = new Select(o); break;
8096
+ case 'bitmap': n = new Bitmap(o); break;
7881
8097
  case 'selector': n = new Selector(o); break;
7882
8098
  case 'empty': case 'space': n = new Empty(o); break;
7883
8099
  case 'item': n = new Item(o); break;
@@ -7886,8 +8102,12 @@ const add = function () {
7886
8102
 
7887
8103
  }
7888
8104
 
8105
+
8106
+
7889
8107
  if( n !== null ){
7890
8108
 
8109
+ Roots.needResize = true;
8110
+
7891
8111
  if( ref ) n.setReferency( a[0], a[1] );
7892
8112
  return n;
7893
8113
 
@@ -8071,7 +8291,7 @@ class Gui {
8071
8291
 
8072
8292
  // height transition
8073
8293
  this.transition = o.transition || Tools.transition;
8074
- if( this.transition ) setTimeout( this.addTransition.bind( this ), 0 );
8294
+ if( this.transition ) setTimeout( this.addTransition.bind( this ), 1000 );
8075
8295
 
8076
8296
 
8077
8297
  this.setWidth();
@@ -8101,6 +8321,9 @@ class Gui {
8101
8321
  //this.bottom.addEventListener("transitionend", Roots.resize, true);
8102
8322
  }
8103
8323
 
8324
+ let i = this.uis.length;
8325
+ while( i-- ) this.uis[i].addTransition();
8326
+
8104
8327
  }
8105
8328
 
8106
8329
  // ----------------------
@@ -8683,6 +8906,6 @@ class Gui {
8683
8906
 
8684
8907
  }
8685
8908
 
8686
- const REVISION = '4.1.0';
8909
+ const REVISION = '4.2.0';
8687
8910
 
8688
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.1.0",
3
+ "version": "4.2.0",
4
4
  "description": "JavaScript gui library",
5
5
  "main": "build/uil.js",
6
6
  "repository": "lo-th/uil",