lexgui 0.1.40 → 0.1.42

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/build/lexgui.js CHANGED
@@ -12,7 +12,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
12
12
  */
13
13
 
14
14
  var LX = global.LX = {
15
- version: "0.1.40",
15
+ version: "0.1.42",
16
16
  ready: false,
17
17
  components: [], // specific pre-build components
18
18
  signals: {} // events and triggers
@@ -501,7 +501,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
501
501
  * @param {Object} options
502
502
  * container: Root location for the gui (default is the document body)
503
503
  * id: Id of the main area
504
- * skip_default_area: Skip creation of main area
504
+ * skipDefaultArea: Skip creation of main area
505
505
  */
506
506
 
507
507
  function init( options = { } )
@@ -557,8 +557,10 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
557
557
  this.ready = true;
558
558
  this.menubars = [ ];
559
559
 
560
- if( !options.skip_default_area )
560
+ if( !options.skipDefaultArea )
561
+ {
561
562
  this.main_area = new Area( { id: options.id ?? 'mainarea' } );
563
+ }
562
564
 
563
565
  return this.main_area;
564
566
  }
@@ -575,16 +577,18 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
575
577
  * draggable: Dialog can be dragged [false]
576
578
  */
577
579
 
578
- function message(text, title, options = {})
580
+ function message( text, title, options = {} )
579
581
  {
580
- if(!text)
581
- throw("No message to show");
582
+ if( !text )
583
+ {
584
+ throw( "No message to show" );
585
+ }
582
586
 
583
587
  options.modal = true;
584
588
 
585
- return new Dialog(title, p => {
586
- p.addTextArea(null, text, null, { disabled: true, fitHeight: true });
587
- }, options);
589
+ return new Dialog( title, p => {
590
+ p.addTextArea( null, text, null, { disabled: true, fitHeight: true } );
591
+ }, options );
588
592
  }
589
593
 
590
594
  LX.message = message;
@@ -664,7 +668,8 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
664
668
  text += text.includes("You must fill the input text.") ? "": "\nYou must fill the input text.";
665
669
  dialog.close();
666
670
  prompt( text, title, callback, options );
667
- }else
671
+ }
672
+ else
668
673
  {
669
674
  if( callback ) callback.call( this, value );
670
675
  dialog.close();
@@ -743,7 +748,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
743
748
  const data = LX.signals[ signalName ];
744
749
 
745
750
  if( !data )
746
- return;
751
+ {
752
+ return;
753
+ }
747
754
 
748
755
  const target = options.target;
749
756
 
@@ -779,13 +786,17 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
779
786
 
780
787
  function addSignal( name, obj, callback )
781
788
  {
782
- obj[name] = callback;
789
+ obj[ name ] = callback;
783
790
 
784
791
  if( !LX.signals[ name ] )
792
+ {
785
793
  LX.signals[ name ] = [];
794
+ }
786
795
 
787
796
  if( LX.signals[ name ].indexOf( obj ) > -1 )
797
+ {
788
798
  return;
799
+ }
789
800
 
790
801
  LX.signals[ name ].push( obj );
791
802
  }
@@ -805,7 +816,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
805
816
  * className: Add class to the element
806
817
  * width: Width of the area element [fit space]
807
818
  * height: Height of the area element [fit space]
808
- * no_append: Create but not append to GUI root [false]
819
+ * skipAppend: Create but not append to GUI root [false]
809
820
  */
810
821
 
811
822
  constructor( options = {} ) {
@@ -845,7 +856,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
845
856
  this.sections = [];
846
857
  this.panels = [];
847
858
 
848
- if( !options.no_append )
859
+ if( !options.skipAppend )
849
860
  {
850
861
  var lexroot = document.getElementById("lexroot");
851
862
  lexroot.appendChild( this.root );
@@ -880,94 +891,97 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
880
891
  makeDraggable( root, options );
881
892
  }
882
893
 
883
- if( options.resizeable ) {
894
+ if( options.resizeable )
895
+ {
884
896
  root.classList.add("resizeable");
885
897
  }
886
898
 
887
899
  if( options.resize )
888
900
  {
889
- this.split_bar = document.createElement("div");
901
+ this.splitBar = document.createElement("div");
890
902
  let type = (overlay == "left") || (overlay == "right") ? "horizontal" : "vertical";
891
- this.type = overlay;;
892
- this.split_bar.className = "lexsplitbar " + type;
903
+ this.type = overlay;
904
+ this.splitBar.className = "lexsplitbar " + type;
893
905
 
894
906
  if( overlay == "right" )
895
907
  {
896
- this.split_bar.style.width = LX.DEFAULT_SPLITBAR_SIZE + "px";
897
- this.split_bar.style.left = -(LX.DEFAULT_SPLITBAR_SIZE / 2.0) + "px";
908
+ this.splitBar.style.width = LX.DEFAULT_SPLITBAR_SIZE + "px";
909
+ this.splitBar.style.left = -(LX.DEFAULT_SPLITBAR_SIZE / 2.0) + "px";
898
910
  }
899
911
  else if( overlay == "left" )
900
912
  {
901
913
  let size = Math.min(document.body.clientWidth - LX.DEFAULT_SPLITBAR_SIZE, this.root.clientWidth);
902
- this.split_bar.style.width = LX.DEFAULT_SPLITBAR_SIZE + "px";
903
- this.split_bar.style.left = size + (LX.DEFAULT_SPLITBAR_SIZE / 2.0) + "px";
914
+ this.splitBar.style.width = LX.DEFAULT_SPLITBAR_SIZE + "px";
915
+ this.splitBar.style.left = size + (LX.DEFAULT_SPLITBAR_SIZE / 2.0) + "px";
904
916
  }
905
917
  else if( overlay == "top" )
906
918
  {
907
919
  let size = Math.min(document.body.clientHeight - LX.DEFAULT_SPLITBAR_SIZE, this.root.clientHeight);
908
- this.split_bar.style.height = LX.DEFAULT_SPLITBAR_SIZE + "px";
909
- this.split_bar.style.top = size + (LX.DEFAULT_SPLITBAR_SIZE / 2.0) + "px";
920
+ this.splitBar.style.height = LX.DEFAULT_SPLITBAR_SIZE + "px";
921
+ this.splitBar.style.top = size + (LX.DEFAULT_SPLITBAR_SIZE / 2.0) + "px";
910
922
  }
911
923
  else if( overlay == "bottom" )
912
924
  {
913
- this.split_bar.style.height = LX.DEFAULT_SPLITBAR_SIZE + "px";
914
- this.split_bar.style.top = -(LX.DEFAULT_SPLITBAR_SIZE / 2.0) + "px";
925
+ this.splitBar.style.height = LX.DEFAULT_SPLITBAR_SIZE + "px";
926
+ this.splitBar.style.top = -(LX.DEFAULT_SPLITBAR_SIZE / 2.0) + "px";
915
927
  }
916
928
 
917
- this.split_bar.addEventListener("mousedown", inner_mousedown);
918
- this.root.appendChild( this.split_bar );
929
+ this.splitBar.addEventListener("mousedown", inner_mousedown);
930
+ this.root.appendChild( this.splitBar );
919
931
 
920
932
  var that = this;
921
- var last_pos = [ 0, 0 ];
933
+ var lastMousePosition = [ 0, 0 ];
922
934
 
923
935
  function inner_mousedown( e )
924
936
  {
925
937
  var doc = that.root.ownerDocument;
926
938
  doc.addEventListener( 'mousemove', inner_mousemove );
927
939
  doc.addEventListener( 'mouseup', inner_mouseup );
928
- last_pos[ 0 ] = e.x;
929
- last_pos[ 1 ] = e.y;
940
+ lastMousePosition[ 0 ] = e.x;
941
+ lastMousePosition[ 1 ] = e.y;
930
942
  e.stopPropagation();
931
943
  e.preventDefault();
932
944
  document.body.classList.add( 'nocursor' );
933
- that.split_bar.classList.add( 'nocursor' );
945
+ that.splitBar.classList.add( 'nocursor' );
934
946
  }
935
947
 
936
948
  function inner_mousemove( e )
937
949
  {
938
950
  switch( that.type ) {
939
951
  case "right":
940
- var dt = ( last_pos[ 0 ] - e.x );
952
+ var dt = ( lastMousePosition[ 0 ] - e.x );
941
953
  var size = ( that.root.offsetWidth + dt );
942
954
  that.root.style.width = size + "px";
943
955
  break;
944
956
  case "left":
945
- var dt = ( last_pos[ 0 ] - e.x );
957
+ var dt = ( lastMousePosition[ 0 ] - e.x );
946
958
  var size = Math.min(document.body.clientWidth - LX.DEFAULT_SPLITBAR_SIZE, (that.root.offsetWidth - dt));
947
959
  that.root.style.width = size + "px";
948
- that.split_bar.style.left = size + LX.DEFAULT_SPLITBAR_SIZE/2 + "px";
960
+ that.splitBar.style.left = size + LX.DEFAULT_SPLITBAR_SIZE/2 + "px";
949
961
  break;
950
962
  case "top":
951
- var dt = ( last_pos[ 1 ] - e.y );
963
+ var dt = ( lastMousePosition[ 1 ] - e.y );
952
964
  var size = Math.min(document.body.clientHeight - LX.DEFAULT_SPLITBAR_SIZE, (that.root.offsetHeight - dt));
953
965
  that.root.style.height = size + "px";
954
- that.split_bar.style.top = size + LX.DEFAULT_SPLITBAR_SIZE/2 + "px";
966
+ that.splitBar.style.top = size + LX.DEFAULT_SPLITBAR_SIZE/2 + "px";
955
967
  break;
956
968
  case "bottom":
957
- var dt = ( last_pos[ 1 ] - e.y );
969
+ var dt = ( lastMousePosition[ 1 ] - e.y );
958
970
  var size = ( that.root.offsetHeight + dt );
959
971
  that.root.style.height = size + "px";
960
972
  break;
961
973
  }
962
974
 
963
- last_pos[ 0 ] = e.x;
964
- last_pos[ 1 ] = e.y;
975
+ lastMousePosition[ 0 ] = e.x;
976
+ lastMousePosition[ 1 ] = e.y;
965
977
  e.stopPropagation();
966
978
  e.preventDefault();
967
979
 
968
980
  // Resize events
969
981
  if( that.onresize )
982
+ {
970
983
  that.onresize( that.root.getBoundingClientRect() );
984
+ }
971
985
  }
972
986
 
973
987
  function inner_mouseup( e )
@@ -976,7 +990,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
976
990
  doc.removeEventListener( 'mousemove', inner_mousemove );
977
991
  doc.removeEventListener( 'mouseup', inner_mouseup );
978
992
  document.body.classList.remove( 'nocursor' );
979
- that.split_bar.classList.remove( 'nocursor' );
993
+ that.splitBar.classList.remove( 'nocursor' );
980
994
  }
981
995
  }
982
996
  }
@@ -990,13 +1004,16 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
990
1004
  attach( content ) {
991
1005
 
992
1006
  // Append to last split section if area has been split
993
- if(this.sections.length) {
994
- this.sections[1].attach( content );
1007
+ if( this.sections.length )
1008
+ {
1009
+ this.sections[ 1 ].attach( content );
995
1010
  return;
996
1011
  }
997
1012
 
998
- if(!content)
999
- throw("no content to attach");
1013
+ if( !content )
1014
+ {
1015
+ throw("no content to attach");
1016
+ }
1000
1017
 
1001
1018
  content.parent = this;
1002
1019
 
@@ -1041,14 +1058,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1041
1058
  }
1042
1059
 
1043
1060
  // Create areas
1044
- var area1 = new Area( { no_append: true, className: "split" + ( options.menubar || options.sidebar ? "" : " origin" ) } );
1045
- var area2 = new Area( { no_append: true, className: "split"} );
1061
+ var area1 = new Area( { skipAppend: true, className: "split" + ( options.menubar || options.sidebar ? "" : " origin" ) } );
1062
+ var area2 = new Area( { skipAppend: true, className: "split" } );
1046
1063
 
1047
1064
  area1.parentArea = this;
1048
1065
  area2.parentArea = this;
1049
1066
 
1050
1067
  let minimizable = options.minimizable ?? false;
1051
- let resize = (options.resize ?? true) || minimizable;
1068
+ let resize = ( options.resize ?? true ) || minimizable;
1052
1069
 
1053
1070
  var data = "0px";
1054
1071
  this.offset = 0;
@@ -1056,19 +1073,19 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1056
1073
  if( resize )
1057
1074
  {
1058
1075
  this.resize = resize;
1059
- this.split_bar = document.createElement( "div" );
1060
- this.split_bar.className = "lexsplitbar " + type;
1076
+ this.splitBar = document.createElement( "div" );
1077
+ this.splitBar.className = "lexsplitbar " + type;
1061
1078
 
1062
1079
  if( type == "horizontal" )
1063
1080
  {
1064
- this.split_bar.style.width = LX.DEFAULT_SPLITBAR_SIZE + "px";
1081
+ this.splitBar.style.width = LX.DEFAULT_SPLITBAR_SIZE + "px";
1065
1082
  }
1066
1083
  else
1067
1084
  {
1068
- this.split_bar.style.height = LX.DEFAULT_SPLITBAR_SIZE + "px";
1085
+ this.splitBar.style.height = LX.DEFAULT_SPLITBAR_SIZE + "px";
1069
1086
  }
1070
1087
 
1071
- this.split_bar.addEventListener( 'mousedown', inner_mousedown );
1088
+ this.splitBar.addEventListener( 'mousedown', inner_mousedown );
1072
1089
 
1073
1090
  data = ( LX.DEFAULT_SPLITBAR_SIZE / 2 ) + "px"; // updates
1074
1091
 
@@ -1085,7 +1102,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1085
1102
  flushCss(area2.root);
1086
1103
  });
1087
1104
 
1088
- this.split_bar.addEventListener("contextmenu", e => {
1105
+ this.splitBar.addEventListener("contextmenu", e => {
1089
1106
  e.preventDefault();
1090
1107
  addContextMenu(null, e, c => {
1091
1108
  c.add("Extend", { disabled: this.split_extended, callback: () => { this.extend() } });
@@ -1116,7 +1133,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1116
1133
  area1.root.style.width = "100%";
1117
1134
  area2.root.style.width = "100%";
1118
1135
 
1119
- if(auto)
1136
+ if( auto )
1120
1137
  {
1121
1138
  area1.root.style.height = "auto";
1122
1139
 
@@ -1150,11 +1167,11 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1150
1167
 
1151
1168
  if( resize )
1152
1169
  {
1153
- this.root.appendChild(this.split_bar);
1170
+ this.root.appendChild(this.splitBar);
1154
1171
  }
1155
1172
 
1156
1173
  this.root.appendChild( area2.root );
1157
- this.sections = [area1, area2];
1174
+ this.sections = [ area1, area2 ];
1158
1175
  this.type = type;
1159
1176
 
1160
1177
  // Update sizes
@@ -1166,34 +1183,34 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1166
1183
  }
1167
1184
 
1168
1185
  var that = this;
1169
- var last_pos = [ 0, 0 ];
1186
+ var lastMousePosition = [ 0, 0 ];
1170
1187
 
1171
1188
  function inner_mousedown( e )
1172
1189
  {
1173
1190
  var doc = that.root.ownerDocument;
1174
1191
  doc.addEventListener( 'mousemove', inner_mousemove );
1175
1192
  doc.addEventListener( 'mouseup', inner_mouseup );
1176
- last_pos[0] = e.x;
1177
- last_pos[1] = e.y;
1193
+ lastMousePosition[0] = e.x;
1194
+ lastMousePosition[1] = e.y;
1178
1195
  e.stopPropagation();
1179
1196
  e.preventDefault();
1180
1197
  document.body.classList.add( 'nocursor' );
1181
- that.split_bar.classList.add( 'nocursor' );
1198
+ that.splitBar.classList.add( 'nocursor' );
1182
1199
  }
1183
1200
 
1184
1201
  function inner_mousemove( e )
1185
1202
  {
1186
1203
  if(that.type == "horizontal")
1187
1204
  {
1188
- that._moveSplit( last_pos[ 0 ] - e.x );
1205
+ that._moveSplit( lastMousePosition[ 0 ] - e.x );
1189
1206
  }
1190
1207
  else
1191
1208
  {
1192
- that._moveSplit( last_pos[ 1 ] - e.y );
1209
+ that._moveSplit( lastMousePosition[ 1 ] - e.y );
1193
1210
  }
1194
1211
 
1195
- last_pos[ 0 ] = e.x;
1196
- last_pos[ 1 ] = e.y;
1212
+ lastMousePosition[ 0 ] = e.x;
1213
+ lastMousePosition[ 1 ] = e.y;
1197
1214
 
1198
1215
  const widgets = that.root.querySelectorAll( ".lexwidget" );
1199
1216
 
@@ -1218,7 +1235,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1218
1235
  doc.removeEventListener( 'mousemove', inner_mousemove );
1219
1236
  doc.removeEventListener( 'mouseup', inner_mouseup );
1220
1237
  document.body.classList.remove( 'nocursor' );
1221
- that.split_bar.classList.remove( 'nocursor' );
1238
+ that.splitBar.classList.remove( 'nocursor' );
1222
1239
  }
1223
1240
 
1224
1241
  return this.sections;
@@ -1651,8 +1668,8 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1651
1668
  _disableSplitResize() {
1652
1669
 
1653
1670
  this.resize = false;
1654
- this.split_bar.remove();
1655
- delete this.split_bar;
1671
+ this.splitBar.remove();
1672
+ delete this.splitBar;
1656
1673
  }
1657
1674
 
1658
1675
  _update() {
@@ -2473,6 +2490,18 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2473
2490
  desc.innerHTML = key;
2474
2491
  entry.appendChild( desc );
2475
2492
 
2493
+ button.addEventListener("mouseenter", () => {
2494
+ setTimeout( () => {
2495
+ desc.style.display = "unset";
2496
+ }, 100 );
2497
+ });
2498
+
2499
+ button.addEventListener("mouseleave", () => {
2500
+ setTimeout( () => {
2501
+ desc.style.display = "none";
2502
+ }, 100 );
2503
+ });
2504
+
2476
2505
  entry.addEventListener("click", () => {
2477
2506
 
2478
2507
  const f = options.callback;
@@ -2823,7 +2852,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
2823
2852
  let isParent = node.children.length > 0;
2824
2853
  let isSelected = this.selected.indexOf( node ) > -1;
2825
2854
 
2826
- if( this.options.only_folders )
2855
+ if( this.options.onlyFolders )
2827
2856
  {
2828
2857
  let has_folders = false;
2829
2858
  node.children.forEach( c => has_folders |= (c.type == 'folder') );
@@ -3202,7 +3231,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3202
3231
  {
3203
3232
  let child = node.children[i];
3204
3233
 
3205
- if( this.options.only_folders && child.type != 'folder')
3234
+ if( this.options.onlyFolders && child.type != 'folder')
3206
3235
  continue;
3207
3236
 
3208
3237
  this._create_item( node, child, level + 1 );
@@ -4093,52 +4122,69 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4093
4122
  * disabled: Make the widget disabled [false]
4094
4123
  * icon: Icon class to show as button value
4095
4124
  * img: Path to image to show as button value
4125
+ * title: Text to show in native Element title
4096
4126
  */
4097
4127
 
4098
4128
  addButton( name, value, callback, options = {} ) {
4099
4129
 
4100
- let widget = this.create_widget(name, Widget.BUTTON, options);
4130
+ let widget = this.create_widget( name, Widget.BUTTON, options );
4131
+
4101
4132
  widget.onGetValue = () => {
4102
4133
  return wValue.innerText;
4103
4134
  };
4135
+
4104
4136
  widget.onSetValue = ( newValue, skipCallback ) => {
4105
4137
  wValue.innerHTML =
4106
4138
  (options.icon ? "<a class='" + options.icon + "'></a>" :
4107
4139
  ( options.img ? "<img src='" + options.img + "'>" : "<span>" + (newValue || "") + "</span>" ));
4108
4140
  };
4109
-
4141
+
4110
4142
  let element = widget.domEl;
4111
4143
 
4112
- var wValue = document.createElement('button');
4113
- if(options.icon || options.img)
4114
- wValue.title = value;
4144
+ var wValue = document.createElement( 'button' );
4145
+ wValue.title = options.title ?? "";
4115
4146
  wValue.className = "lexbutton";
4116
- if(options.selected)
4117
- wValue.classList.add("selected");
4118
- if(options.buttonClass)
4119
- wValue.classList.add(options.buttonClass);
4147
+
4148
+ if( options.selected )
4149
+ {
4150
+ wValue.classList.add( "selected" );
4151
+ }
4152
+
4153
+ if( options.buttonClass )
4154
+ {
4155
+ wValue.classList.add( options.buttonClass );
4156
+ }
4157
+
4120
4158
  wValue.innerHTML =
4121
4159
  (options.icon ? "<a class='" + options.icon + "'></a>" :
4122
4160
  ( options.img ? "<img src='" + options.img + "'>" : "<span>" + (value || "") + "</span>" ));
4123
4161
 
4124
4162
  wValue.style.width = "calc( 100% - " + (options.nameWidth ?? LX.DEFAULT_NAME_WIDTH) + ")";
4125
4163
 
4126
- if(options.disabled)
4127
- wValue.setAttribute("disabled", true);
4164
+ if( options.disabled )
4165
+ {
4166
+ wValue.setAttribute( "disabled", true );
4167
+ }
4128
4168
 
4129
4169
  wValue.addEventListener("click", e => {
4130
- if( options.selectable ) {
4170
+ if( options.selectable )
4171
+ {
4131
4172
  if( options.parent )
4173
+ {
4132
4174
  options.parent.querySelectorAll(".lexbutton.selected").forEach( e => { if(e == wValue) return; e.classList.remove("selected") } );
4175
+ }
4176
+
4133
4177
  wValue.classList.toggle('selected');
4134
4178
  }
4135
- this._trigger( new IEvent(name, value, e), callback );
4179
+
4180
+ this._trigger( new IEvent( name, value, e ), callback );
4136
4181
  });
4137
4182
 
4138
- element.appendChild(wValue);
4183
+ element.appendChild( wValue );
4139
4184
 
4140
4185
  // Remove branch padding and margins
4141
- if(!widget.name) {
4186
+ if( !widget.name )
4187
+ {
4142
4188
  wValue.className += " noname";
4143
4189
  wValue.style.width = "100%";
4144
4190
  }
@@ -6076,7 +6122,8 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6076
6122
 
6077
6123
  addProgress( name, value, options = {} ) {
6078
6124
 
6079
- if(!name) {
6125
+ if( !name )
6126
+ {
6080
6127
  throw("Set Widget Name!");
6081
6128
  }
6082
6129
 
@@ -6107,46 +6154,74 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6107
6154
  progress.max = options.max ?? 1;
6108
6155
  progress.value = value;
6109
6156
 
6110
- if(options.low)
6157
+ if( options.low )
6111
6158
  progress.low = options.low;
6112
- if(options.high)
6159
+ if( options.high )
6113
6160
  progress.high = options.high;
6114
- if(options.optimum)
6161
+ if( options.optimum )
6115
6162
  progress.optimum = options.optimum;
6116
6163
 
6117
- container.appendChild(progress);
6118
- element.appendChild(container);
6164
+ container.appendChild( progress );
6165
+ element.appendChild( container );
6119
6166
 
6120
- if(options.showValue) {
6121
- if(document.getElementById('progressvalue-' + name ))
6167
+ if( options.showValue )
6168
+ {
6169
+ if( document.getElementById('progressvalue-' + name ) )
6170
+ {
6122
6171
  document.getElementById('progressvalue-' + name ).remove();
6172
+ }
6173
+
6123
6174
  let span = document.createElement("span");
6124
6175
  span.id = "progressvalue-" + name;
6125
6176
  span.style.padding = "0px 5px";
6126
6177
  span.innerText = value;
6127
- container.appendChild(span);
6178
+ container.appendChild( span );
6128
6179
  }
6129
6180
 
6130
- if(options.editable) {
6131
- progress.classList.add("editable");
6132
- progress.addEventListener("mousemove", inner_mousemove.bind(this, value));
6133
- progress.addEventListener("mouseup", inner_mouseup.bind(this, progress));
6181
+ if( options.editable )
6182
+ {
6183
+ progress.classList.add( "editable" );
6184
+ progress.addEventListener( "mousedown", inner_mousedown );
6134
6185
 
6135
- function inner_mousemove(value, e) {
6136
-
6137
- if(e.which < 1)
6138
- return;
6139
- let v = this.getValue(name, value);
6140
- v+=e.movementX/100;
6141
- v = v.toFixed(2);
6142
- this.setValue(name, v);
6186
+ var that = this;
6187
+
6188
+ function inner_mousedown( e )
6189
+ {
6190
+ var doc = that.root.ownerDocument;
6191
+ doc.addEventListener( 'mousemove', inner_mousemove );
6192
+ doc.addEventListener( 'mouseup', inner_mouseup );
6193
+ document.body.classList.add( 'noevents' );
6194
+ e.stopImmediatePropagation();
6195
+ e.stopPropagation();
6196
+ }
6197
+
6198
+ function inner_mousemove( e )
6199
+ {
6200
+ let dt = -e.movementX;
6201
+
6202
+ if ( dt != 0 )
6203
+ {
6204
+ let v = that.getValue( name, value );
6205
+ v += e.movementX / 100;
6206
+ v = round( v );
6207
+ that.setValue( name, v );
6143
6208
 
6144
- if(options.callback)
6145
- options.callback(v, e);
6209
+ if( options.callback )
6210
+ {
6211
+ options.callback( v, e );
6212
+ }
6213
+ }
6214
+
6215
+ e.stopPropagation();
6216
+ e.preventDefault();
6146
6217
  }
6147
6218
 
6148
- function inner_mouseup(el) {
6149
- el.removeEventListener("mousemove", inner_mousemove);
6219
+ function inner_mouseup( e )
6220
+ {
6221
+ var doc = that.root.ownerDocument;
6222
+ doc.removeEventListener( 'mousemove', inner_mousemove );
6223
+ doc.removeEventListener( 'mouseup', inner_mouseup );
6224
+ document.body.classList.remove( 'noevents' );
6150
6225
  }
6151
6226
  }
6152
6227
 
@@ -7614,12 +7689,12 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7614
7689
  this.layout = options.layout ?? AssetView.LAYOUT_CONTENT;
7615
7690
  this.contentPage = 1;
7616
7691
 
7617
- if(options.root_path)
7692
+ if( options.rootPath )
7618
7693
  {
7619
- if(options.root_path.constructor !== String)
7694
+ if(options.rootPath.constructor !== String)
7620
7695
  console.warn("Asset Root Path must be a String (now is " + path.constructor.name + ")");
7621
7696
  else
7622
- this.rootPath = options.root_path;
7697
+ this.rootPath = options.rootPath;
7623
7698
  }
7624
7699
 
7625
7700
  let div = document.createElement('div');
@@ -7631,13 +7706,15 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7631
7706
 
7632
7707
  let left, right, contentArea = area;
7633
7708
 
7634
- this.skip_browser = options.skip_browser ?? false;
7635
- this.skip_preview = options.skip_preview ?? false;
7636
- this.only_folders = options.only_folders ?? true;
7637
- this.preview_actions = options.preview_actions ?? [];
7638
- this.context_menu = options.context_menu ?? [];
7709
+ this.skipBrowser = options.skipBrowser ?? false;
7710
+ this.skipPreview = options.skipPreview ?? false;
7711
+ this.useNativeTitle = options.useNativeTitle ?? false;
7712
+ this.onlyFolders = options.onlyFolders ?? true;
7713
+ this.previewActions = options.previewActions ?? [];
7714
+ this.contextMenu = options.contextMenu ?? [];
7715
+ this.onRefreshContent = options.onRefreshContent;
7639
7716
 
7640
- if( !this.skip_browser )
7717
+ if( !this.skipBrowser )
7641
7718
  {
7642
7719
  [left, right] = area.split({ type: "horizontal", sizes: ["15%", "85%"]});
7643
7720
  contentArea = right;
@@ -7646,28 +7723,34 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7646
7723
  right.setLimitBox( 512, 0 );
7647
7724
  }
7648
7725
 
7649
- if( !this.skip_preview )
7650
- [contentArea, right] = contentArea.split({ type: "horizontal", sizes: ["80%", "20%"]});
7726
+ if( !this.skipPreview )
7727
+ {
7728
+ [ contentArea, right ] = contentArea.split({ type: "horizontal", sizes: ["80%", "20%"]});
7729
+ }
7651
7730
 
7652
- this.allowedTypes = options.allowed_types || ["None", "Image", "Mesh", "Script", "JSON", "Clip"];
7731
+ this.allowedTypes = options.allowedTypes || ["None", "Image", "Mesh", "Script", "JSON", "Clip"];
7653
7732
 
7654
7733
  this.prevData = [];
7655
7734
  this.nextData = [];
7656
7735
  this.data = [];
7657
7736
 
7658
- this._processData(this.data, null);
7737
+ this._processData( this.data, null );
7659
7738
 
7660
7739
  this.currentData = this.data;
7661
7740
  this.path = ['@'];
7662
7741
 
7663
- if(!this.skip_browser)
7664
- this._createTreePanel(left);
7742
+ if( !this.skipBrowser )
7743
+ {
7744
+ this._createTreePanel( left );
7745
+ }
7665
7746
 
7666
- this._createContentPanel(contentArea);
7747
+ this._createContentPanel( contentArea );
7667
7748
 
7668
7749
  // Create resource preview panel
7669
- if( !this.skip_preview )
7670
- this.previewPanel = right.addPanel({className: 'lexassetcontentpanel', style: { overflow: 'scroll' }});
7750
+ if( !this.skipPreview )
7751
+ {
7752
+ this.previewPanel = right.addPanel( {className: 'lexassetcontentpanel', style: { overflow: 'scroll' }} );
7753
+ }
7671
7754
  }
7672
7755
 
7673
7756
  /**
@@ -7681,12 +7764,15 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7681
7764
 
7682
7765
  this.data = data;
7683
7766
 
7684
- this._processData(this.data, null);
7767
+ this._processData( this.data, null );
7685
7768
  this.currentData = this.data;
7686
- this.path = ['@'];
7769
+ this.path = [ '@' ];
7770
+
7771
+ if( !this.skipBrowser )
7772
+ {
7773
+ this._createTreePanel( this.area );
7774
+ }
7687
7775
 
7688
- if(!this.skip_browser)
7689
- this._createTreePanel(this.area);
7690
7776
  this._refreshContent();
7691
7777
 
7692
7778
  this.onevent = onevent;
@@ -7696,12 +7782,21 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7696
7782
  * @method clear
7697
7783
  */
7698
7784
  clear() {
7699
- if(this.previewPanel)
7785
+
7786
+ if( this.previewPanel )
7787
+ {
7700
7788
  this.previewPanel.clear();
7701
- if(this.leftPanel)
7789
+ }
7790
+
7791
+ if( this.leftPanel )
7792
+ {
7702
7793
  this.leftPanel.clear();
7703
- if(this.rightPanel)
7704
- this.rightPanel.clear()
7794
+ }
7795
+
7796
+ if( this.rightPanel )
7797
+ {
7798
+ this.rightPanel.clear()
7799
+ }
7705
7800
  }
7706
7801
 
7707
7802
  /**
@@ -7712,14 +7807,16 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7712
7807
 
7713
7808
  if( data.constructor !== Array )
7714
7809
  {
7715
- data['folder'] = parent;
7810
+ data[ 'folder' ] = parent;
7716
7811
  data.children = data.children ?? [];
7717
7812
  }
7718
7813
 
7719
7814
  let list = data.constructor === Array ? data : data.children;
7720
7815
 
7721
7816
  for( var i = 0; i < list.length; ++i )
7722
- this._processData( list[i], data );
7817
+ {
7818
+ this._processData( list[ i ], data );
7819
+ }
7723
7820
  }
7724
7821
 
7725
7822
  /**
@@ -7731,9 +7828,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7731
7828
  this.path.length = 0;
7732
7829
 
7733
7830
  const push_parents_id = i => {
7734
- if(!i) return;
7831
+ if( !i ) return;
7735
7832
  let list = i.children ? i.children : i;
7736
- let c = list[0];
7833
+ let c = list[ 0 ];
7737
7834
  if( !c ) return;
7738
7835
  if( !c.folder ) return;
7739
7836
  this.path.push( c.folder.id ?? '@' );
@@ -7742,19 +7839,22 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7742
7839
 
7743
7840
  push_parents_id( data );
7744
7841
 
7745
- LX.emit("@on_folder_change", this.path.reverse().join('/'));
7842
+ LX.emit( "@on_folder_change", this.path.reverse().join('/') );
7746
7843
  }
7747
7844
 
7748
7845
  /**
7749
7846
  * @method _createTreePanel
7750
7847
  */
7751
7848
 
7752
- _createTreePanel(area) {
7849
+ _createTreePanel( area ) {
7753
7850
 
7754
7851
  if(this.leftPanel)
7852
+ {
7755
7853
  this.leftPanel.clear();
7756
- else {
7757
- this.leftPanel = area.addPanel({className: 'lexassetbrowserpanel'});
7854
+ }
7855
+ else
7856
+ {
7857
+ this.leftPanel = area.addPanel({ className: 'lexassetbrowserpanel' });
7758
7858
  }
7759
7859
 
7760
7860
  // Process data to show in tree
@@ -7763,21 +7863,24 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7763
7863
  children: this.data
7764
7864
  }
7765
7865
 
7766
- this.tree = this.leftPanel.addTree("Content Browser", treeData, {
7866
+ this.tree = this.leftPanel.addTree( "Content Browser", treeData, {
7767
7867
  // icons: tree_icons,
7768
7868
  filter: false,
7769
- only_folders: this.only_folders,
7770
- onevent: (event) => {
7869
+ onlyFolders: this.onlyFolders,
7870
+ onevent: event => {
7771
7871
 
7772
7872
  let node = event.node;
7773
7873
  let value = event.value;
7774
7874
 
7775
- switch(event.type) {
7875
+ switch( event.type )
7876
+ {
7776
7877
  case LX.TreeEvent.NODE_SELECTED:
7777
- if(!event.multiple) {
7878
+ if( !event.multiple )
7879
+ {
7778
7880
  this._enterFolder( node );
7779
7881
  }
7780
- if(!node.parent) {
7882
+ if( !node.parent )
7883
+ {
7781
7884
  this.prevData.push( this.currentData );
7782
7885
  this.currentData = this.data;
7783
7886
  this._refreshContent();
@@ -7799,9 +7902,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7799
7902
  * @method _setContentLayout
7800
7903
  */
7801
7904
 
7802
- _setContentLayout( layout_mode ) {
7905
+ _setContentLayout( layoutMode ) {
7803
7906
 
7804
- this.layout = layout_mode;
7907
+ this.layout = layoutMode;
7805
7908
 
7806
7909
  this._refreshContent();
7807
7910
  }
@@ -7810,15 +7913,18 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7810
7913
  * @method _createContentPanel
7811
7914
  */
7812
7915
 
7813
- _createContentPanel(area) {
7916
+ _createContentPanel( area ) {
7814
7917
 
7815
- if(this.rightPanel)
7918
+ if( this.rightPanel )
7919
+ {
7816
7920
  this.rightPanel.clear();
7817
- else {
7818
- this.rightPanel = area.addPanel({className: 'lexassetcontentpanel'});
7921
+ }
7922
+ else
7923
+ {
7924
+ this.rightPanel = area.addPanel({ className: 'lexassetcontentpanel' });
7819
7925
  }
7820
7926
 
7821
- const on_sort = (value, event) => {
7927
+ const on_sort = ( value, event ) => {
7822
7928
  const cmenu = addContextMenu( "Sort by", event, c => {
7823
7929
  c.add("Name", () => this._sortData('id') );
7824
7930
  c.add("Type", () => this._sortData('type') );
@@ -7828,10 +7934,12 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7828
7934
  } );
7829
7935
  const parent = this.parent.root.parentElement;
7830
7936
  if( parent.classList.contains('lexdialog') )
7937
+ {
7831
7938
  cmenu.root.style.zIndex = (+getComputedStyle( parent ).zIndex) + 1;
7939
+ }
7832
7940
  }
7833
7941
 
7834
- const on_change_view = (value, event) => {
7942
+ const on_change_view = ( value, event ) => {
7835
7943
  const cmenu = addContextMenu( "Layout", event, c => {
7836
7944
  c.add("Content", () => this._setContentLayout( AssetView.LAYOUT_CONTENT ) );
7837
7945
  c.add("");
@@ -7842,36 +7950,40 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7842
7950
  cmenu.root.style.zIndex = (+getComputedStyle( parent ).zIndex) + 1;
7843
7951
  }
7844
7952
 
7845
- const on_change_page = (value, event) => {
7846
- if(!this.allow_next_page)
7953
+ const on_change_page = ( value, event ) => {
7954
+ if( !this.allowNextPage )
7955
+ {
7847
7956
  return;
7848
- const last_page = this.contentPage;
7957
+ }
7958
+ const lastPage = this.contentPage;
7849
7959
  this.contentPage += value;
7850
7960
  this.contentPage = Math.min( this.contentPage, (((this.currentData.length - 1) / AssetView.MAX_PAGE_ELEMENTS )|0) + 1 );
7851
7961
  this.contentPage = Math.max( this.contentPage, 1 );
7852
7962
 
7853
- if( last_page != this.contentPage )
7963
+ if( lastPage != this.contentPage )
7964
+ {
7854
7965
  this._refreshContent();
7966
+ }
7855
7967
  }
7856
7968
 
7857
7969
  this.rightPanel.sameLine();
7858
- this.rightPanel.addDropdown("Filter", this.allowedTypes, this.allowedTypes[0], (v) => this._refreshContent.call(this, null, v), { width: "20%", minWidth: "128px" });
7859
- this.rightPanel.addText(null, this.search_value ?? "", (v) => this._refreshContent.call(this, v, null), { placeholder: "Search assets.." });
7860
- this.rightPanel.addButton(null, "<a class='fa fa-arrow-up-short-wide'></a>", on_sort.bind(this), { className: "micro", title: "Sort" });
7861
- this.rightPanel.addButton(null, "<a class='fa-solid fa-grip'></a>", on_change_view.bind(this), { className: "micro", title: "View" });
7970
+ this.rightPanel.addDropdown( "Filter", this.allowedTypes, this.allowedTypes[ 0 ], v => this._refreshContent.call(this, null, v), { width: "20%", minWidth: "128px" } );
7971
+ this.rightPanel.addText( null, this.searchValue ?? "", v => this._refreshContent.call(this, v, null), { placeholder: "Search assets.." } );
7972
+ this.rightPanel.addButton( null, "<a class='fa fa-arrow-up-short-wide'></a>", on_sort.bind(this), { className: "micro", title: "Sort" } );
7973
+ this.rightPanel.addButton( null, "<a class='fa-solid fa-grip'></a>", on_change_view.bind(this), { className: "micro", title: "View" } );
7862
7974
  // Content Pages
7863
- this.rightPanel.addButton(null, "<a class='fa-solid fa-angles-left'></a>", on_change_page.bind(this, -1), { className: "micro", title: "Previous Page" });
7864
- this.rightPanel.addButton(null, "<a class='fa-solid fa-angles-right'></a>", on_change_page.bind(this, 1), { className: "micro", title: "Next Page" });
7975
+ this.rightPanel.addButton( null, "<a class='fa-solid fa-angles-left'></a>", on_change_page.bind(this, -1), { className: "micro", title: "Previous Page" }) ;
7976
+ this.rightPanel.addButton( null, "<a class='fa-solid fa-angles-right'></a>", on_change_page.bind(this, 1), { className: "micro", title: "Next Page" } );
7865
7977
  this.rightPanel.endLine();
7866
7978
 
7867
- if( !this.skip_browser )
7979
+ if( !this.skipBrowser )
7868
7980
  {
7869
7981
  this.rightPanel.sameLine();
7870
7982
  this.rightPanel.addComboButtons( null, [
7871
7983
  {
7872
7984
  value: "Left",
7873
7985
  icon: "fa-solid fa-left-long",
7874
- callback: (domEl) => {
7986
+ callback: domEl => {
7875
7987
  if(!this.prevData.length) return;
7876
7988
  this.nextData.push( this.currentData );
7877
7989
  this.currentData = this.prevData.pop();
@@ -7882,7 +7994,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7882
7994
  {
7883
7995
  value: "Right",
7884
7996
  icon: "fa-solid fa-right-long",
7885
- callback: (domEl) => {
7997
+ callback: domEl => {
7886
7998
  if(!this.nextData.length) return;
7887
7999
  this.prevData.push( this.currentData );
7888
8000
  this.currentData = this.nextData.pop();
@@ -7893,7 +8005,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7893
8005
  {
7894
8006
  value: "Refresh",
7895
8007
  icon: "fa-solid fa-arrows-rotate",
7896
- callback: (domEl) => { this._refreshContent(); }
8008
+ callback: domEl => { this._refreshContent(); }
7897
8009
  }
7898
8010
  ], { width: "auto", noSelection: true } );
7899
8011
  this.rightPanel.addText(null, this.path.join('/'), null, { disabled: true, signal: "@on_folder_change", style: { fontWeight: "bolder", fontSize: "16px", color: "#aaa" } });
@@ -7905,17 +8017,17 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7905
8017
  this.content.className = "lexassetscontent";
7906
8018
  this.rightPanel.root.appendChild(this.content);
7907
8019
 
7908
- this.content.addEventListener('dragenter', function(e) {
8020
+ this.content.addEventListener('dragenter', function( e ) {
7909
8021
  e.preventDefault();
7910
8022
  this.classList.add('dragging');
7911
8023
  });
7912
- this.content.addEventListener('dragleave', function(e) {
8024
+ this.content.addEventListener('dragleave', function( e ) {
7913
8025
  e.preventDefault();
7914
8026
  this.classList.remove('dragging');
7915
8027
  });
7916
- this.content.addEventListener('drop', (e) => {
8028
+ this.content.addEventListener('drop', ( e ) => {
7917
8029
  e.preventDefault();
7918
- this._processDrop(e);
8030
+ this._processDrop( e );
7919
8031
  });
7920
8032
  this.content.addEventListener('click', function() {
7921
8033
  this.querySelectorAll('.lexassetitem').forEach( i => i.classList.remove('selected') );
@@ -7924,38 +8036,90 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7924
8036
  this._refreshContent();
7925
8037
  }
7926
8038
 
7927
- _refreshContent(search_value, filter) {
8039
+ _refreshContent( searchValue, filter ) {
7928
8040
 
7929
- const is_content_layout = (this.layout == AssetView.LAYOUT_CONTENT); // default
8041
+ const isContentLayout = ( this.layout == AssetView.LAYOUT_CONTENT ); // default
7930
8042
 
7931
- this.filter = filter ?? (this.filter ?? "None");
7932
- this.search_value = search_value ?? (this.search_value ?? "");
8043
+ this.filter = filter ?? ( this.filter ?? "None" );
8044
+ this.searchValue = searchValue ?? (this.searchValue ?? "");
7933
8045
  this.content.innerHTML = "";
7934
- this.content.className = (is_content_layout ? "lexassetscontent" : "lexassetscontent list");
8046
+ this.content.className = (isContentLayout ? "lexassetscontent" : "lexassetscontent list");
7935
8047
  let that = this;
7936
8048
 
7937
8049
  const add_item = function(item) {
7938
8050
 
7939
- const type = item.type.charAt(0).toUpperCase() + item.type.slice(1);
8051
+ const type = item.type.charAt( 0 ).toUpperCase() + item.type.slice( 1 );
7940
8052
  const extension = getExtension( item.id );
7941
- const is_folder = type === "Folder";
8053
+ const isFolder = type === "Folder";
7942
8054
 
7943
8055
  let itemEl = document.createElement('li');
7944
8056
  itemEl.className = "lexassetitem " + item.type.toLowerCase();
7945
- itemEl.title = type + ": " + item.id;
7946
8057
  itemEl.tabIndex = -1;
7947
- that.content.appendChild(itemEl);
8058
+ that.content.appendChild( itemEl );
7948
8059
 
7949
- if(item.selected != undefined) {
8060
+ if( !that.useNativeTitle )
8061
+ {
8062
+ let desc = document.createElement( 'span' );
8063
+ desc.className = 'lexitemdesc';
8064
+ desc.innerHTML = "File: " + item.id + "<br>Type: " + type;
8065
+ that.content.appendChild( desc );
8066
+
8067
+ itemEl.addEventListener("mousemove", e => {
8068
+
8069
+ if( !isContentLayout )
8070
+ {
8071
+ return;
8072
+ }
8073
+
8074
+ const rect = itemEl.getBoundingClientRect();
8075
+ const targetRect = e.target.getBoundingClientRect();
8076
+ const parentRect = desc.parentElement.getBoundingClientRect();
8077
+
8078
+ let localOffsetX = targetRect.x - parentRect.x - ( targetRect.x - rect.x );
8079
+ let localOffsetY = targetRect.y - parentRect.y - ( targetRect.y - rect.y );
8080
+
8081
+ if( e.target.classList.contains( "lexassettitle" ) )
8082
+ {
8083
+ localOffsetY += ( targetRect.y - rect.y );
8084
+ }
8085
+
8086
+ desc.style.left = (localOffsetX + e.offsetX + 12) + "px";
8087
+ desc.style.top = (localOffsetY + e.offsetY) + "px";
8088
+ });
8089
+
8090
+ itemEl.addEventListener("mouseenter", () => {
8091
+ if( isContentLayout )
8092
+ {
8093
+ desc.style.display = "unset";
8094
+ }
8095
+ });
8096
+
8097
+ itemEl.addEventListener("mouseleave", () => {
8098
+ if( isContentLayout )
8099
+ {
8100
+ setTimeout( () => {
8101
+ desc.style.display = "none";
8102
+ }, 100 );
8103
+ }
8104
+ });
8105
+ }
8106
+ else
8107
+ {
8108
+ itemEl.title = type + ": " + item.id;
8109
+ }
8110
+
8111
+ if( item.selected != undefined )
8112
+ {
7950
8113
  let span = document.createElement('span');
7951
8114
  span.className = "lexcheckbox";
7952
8115
  let checkbox_input = document.createElement('input');
7953
8116
  checkbox_input.type = "checkbox";
7954
8117
  checkbox_input.className = "checkbox";
7955
8118
  checkbox_input.checked = item.selected;
7956
- checkbox_input.addEventListener('change', (e, v) => {
8119
+ checkbox_input.addEventListener('change', ( e, v ) => {
7957
8120
  item.selected = !item.selected;
7958
- if(that.onevent) {
8121
+ if( that.onevent )
8122
+ {
7959
8123
  const event = new AssetViewEvent(AssetViewEvent.ASSET_CHECKED, e.shiftKey ? [item] : item );
7960
8124
  event.multiple = !!e.shiftKey;
7961
8125
  that.onevent( event );
@@ -7967,22 +8131,23 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7967
8131
  itemEl.appendChild(span);
7968
8132
 
7969
8133
  }
8134
+
7970
8135
  let title = document.createElement('span');
7971
8136
  title.className = "lexassettitle";
7972
8137
  title.innerText = item.id;
7973
- itemEl.appendChild(title);
8138
+ itemEl.appendChild( title );
7974
8139
 
7975
- if( !that.skip_preview ) {
8140
+ if( !that.skipPreview ) {
7976
8141
 
7977
8142
  let preview = null;
7978
- const has_image = item.src && (['png', 'jpg'].indexOf( getExtension( item.src ) ) > -1 || item.src.includes("data:image/") ); // Support b64 image as src
8143
+ const hasImage = item.src && (['png', 'jpg'].indexOf( getExtension( item.src ) ) > -1 || item.src.includes("data:image/") ); // Support b64 image as src
7979
8144
 
7980
- if( has_image || is_folder || !is_content_layout)
8145
+ if( hasImage || isFolder || !isContentLayout)
7981
8146
  {
7982
8147
  preview = document.createElement('img');
7983
- let real_src = item.unknown_extension ? that.rootPath + "images/file.png" : (is_folder ? that.rootPath + "images/folder.png" : item.src);
7984
- preview.src = (is_content_layout || is_folder ? real_src : that.rootPath + "images/file.png");
7985
- itemEl.appendChild(preview);
8148
+ let real_src = item.unknown_extension ? that.rootPath + "images/file.png" : (isFolder ? that.rootPath + "images/folder.png" : item.src);
8149
+ preview.src = (isContentLayout || isFolder ? real_src : that.rootPath + "images/file.png");
8150
+ itemEl.appendChild( preview );
7986
8151
  }
7987
8152
  else
7988
8153
  {
@@ -8008,7 +8173,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8008
8173
  }
8009
8174
  }
8010
8175
 
8011
- if( !is_folder )
8176
+ if( !isFolder )
8012
8177
  {
8013
8178
  let info = document.createElement('span');
8014
8179
  info.className = "lexassetinfo";
@@ -8020,30 +8185,37 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8020
8185
  e.stopImmediatePropagation();
8021
8186
  e.stopPropagation();
8022
8187
 
8023
- const is_double_click = e.detail == LX.MOUSE_DOUBLE_CLICK;
8188
+ const isDoubleClick = ( e.detail == LX.MOUSE_DOUBLE_CLICK );
8024
8189
 
8025
- if(!is_double_click)
8190
+ if( !isDoubleClick )
8026
8191
  {
8027
- if(!e.shiftKey)
8192
+ if( !e.shiftKey )
8193
+ {
8028
8194
  that.content.querySelectorAll('.lexassetitem').forEach( i => i.classList.remove('selected') );
8195
+ }
8196
+
8029
8197
  this.classList.add('selected');
8030
- if( !that.skip_preview )
8198
+
8199
+ if( !that.skipPreview )
8200
+ {
8031
8201
  that._previewAsset( item );
8202
+ }
8032
8203
  }
8033
- else if(is_folder)
8204
+ else if( isFolder )
8034
8205
  {
8035
8206
  that._enterFolder( item );
8036
8207
  return;
8037
8208
  }
8038
8209
 
8039
- if(that.onevent) {
8040
- const event = new AssetViewEvent(is_double_click ? AssetViewEvent.ASSET_DBLCLICKED : AssetViewEvent.ASSET_SELECTED, e.shiftKey ? [item] : item );
8210
+ if( that.onevent )
8211
+ {
8212
+ const event = new AssetViewEvent(isDoubleClick ? AssetViewEvent.ASSET_DBLCLICKED : AssetViewEvent.ASSET_SELECTED, e.shiftKey ? [item] : item );
8041
8213
  event.multiple = !!e.shiftKey;
8042
8214
  that.onevent( event );
8043
8215
  }
8044
8216
  });
8045
8217
 
8046
- if( that.context_menu )
8218
+ if( that.contextMenu )
8047
8219
  {
8048
8220
  itemEl.addEventListener('contextmenu', function(e) {
8049
8221
  e.preventDefault();
@@ -8051,15 +8223,21 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8051
8223
  const multiple = that.content.querySelectorAll('.selected').length;
8052
8224
 
8053
8225
  LX.addContextMenu( multiple > 1 ? (multiple + " selected") :
8054
- is_folder ? item.id : item.type, e, m => {
8055
- if(multiple <= 1)
8226
+ isFolder ? item.id : item.type, e, m => {
8227
+ if( multiple <= 1 )
8228
+ {
8056
8229
  m.add("Rename");
8057
- if( !is_folder )
8058
- m.add("Clone", that._clone_item.bind(that, item));
8059
- if(multiple <= 1)
8230
+ }
8231
+ if( !isFolder )
8232
+ {
8233
+ m.add("Clone", that._cloneItem.bind( that, item ));
8234
+ }
8235
+ if( multiple <= 1 )
8236
+ {
8060
8237
  m.add("Properties");
8238
+ }
8061
8239
  m.add("");
8062
- m.add("Delete", that._delete_item.bind(that, item));
8240
+ m.add("Delete", that._deleteItem.bind( that, item ));
8063
8241
  });
8064
8242
  });
8065
8243
  }
@@ -8073,21 +8251,23 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8073
8251
 
8074
8252
  const fr = new FileReader();
8075
8253
 
8076
- const filtered_data = this.currentData.filter( _i => {
8254
+ const filteredData = this.currentData.filter( _i => {
8077
8255
  return (this.filter != "None" ? _i.type.toLowerCase() == this.filter.toLowerCase() : true) &&
8078
- _i.id.toLowerCase().includes(this.search_value.toLowerCase())
8256
+ _i.id.toLowerCase().includes(this.searchValue.toLowerCase())
8079
8257
  } );
8080
8258
 
8081
- if(filter || search_value) {
8259
+ if( filter || searchValue )
8260
+ {
8082
8261
  this.contentPage = 1;
8083
8262
  }
8263
+
8084
8264
  // Show all data if using filters
8085
- const start_index = (this.contentPage - 1) * AssetView.MAX_PAGE_ELEMENTS;
8086
- const end_index = Math.min( start_index + AssetView.MAX_PAGE_ELEMENTS, filtered_data.length );
8265
+ const startIndex = (this.contentPage - 1) * AssetView.MAX_PAGE_ELEMENTS;
8266
+ const endIndex = Math.min( startIndex + AssetView.MAX_PAGE_ELEMENTS, filteredData.length );
8087
8267
 
8088
- for( let i = start_index; i < end_index; ++i )
8268
+ for( let i = startIndex; i < endIndex; ++i )
8089
8269
  {
8090
- let item = filtered_data[i];
8270
+ let item = filteredData[ i ];
8091
8271
 
8092
8272
  if( item.path )
8093
8273
  {
@@ -8098,7 +8278,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8098
8278
  item.src = e.currentTarget.result; // This is a base64 string...
8099
8279
  item._path = item.path;
8100
8280
  delete item.path;
8101
- this._refreshContent(search_value, filter);
8281
+ this._refreshContent( searchValue, filter );
8102
8282
  };
8103
8283
  } });
8104
8284
  }else
@@ -8106,15 +8286,21 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8106
8286
  item.domEl = add_item( item );
8107
8287
  }
8108
8288
  }
8109
- this.allow_next_page = filtered_data.length - 1 > AssetView.MAX_PAGE_ELEMENTS;
8110
- LX.emit("@on_page_change", "Page " + this.contentPage + " / " + ((((filtered_data.length - 1) / AssetView.MAX_PAGE_ELEMENTS )|0) + 1));
8289
+
8290
+ this.allowNextPage = filteredData.length - 1 > AssetView.MAX_PAGE_ELEMENTS;
8291
+ LX.emit("@on_page_change", "Page " + this.contentPage + " / " + ((((filteredData.length - 1) / AssetView.MAX_PAGE_ELEMENTS )|0) + 1));
8292
+
8293
+ if( this.onRefreshContent )
8294
+ {
8295
+ this.onRefreshContent( searchValue, filter );
8296
+ }
8111
8297
  }
8112
8298
 
8113
8299
  /**
8114
8300
  * @method _previewAsset
8115
8301
  */
8116
8302
 
8117
- _previewAsset(file) {
8303
+ _previewAsset( file ) {
8118
8304
 
8119
8305
  const is_base_64 = file.src && file.src.includes("data:image/");
8120
8306
 
@@ -8123,34 +8309,37 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8123
8309
 
8124
8310
  if( file.type == 'image' || file.src )
8125
8311
  {
8126
- const has_image = ['png', 'jpg'].indexOf( getExtension( file.src ) ) > -1 || is_base_64;
8127
- if( has_image )
8128
- this.previewPanel.addImage(file.src, { style: { width: "100%" } });
8312
+ const hasImage = ['png', 'jpg'].indexOf( getExtension( file.src ) ) > -1 || is_base_64;
8313
+ if( hasImage )
8314
+ {
8315
+ this.previewPanel.addImage( file.src, { style: { width: "100%" } } );
8316
+ }
8129
8317
  }
8130
8318
 
8131
8319
  const options = { disabled: true };
8132
8320
 
8133
8321
  this.previewPanel.addText("Filename", file.id, null, options);
8134
- if(file._path || file.src ) this.previewPanel.addText("URL", file._path ? file._path : file.src, null, options);
8322
+ if( file.lastModified ) this.previewPanel.addText("Last Modified", new Date( file.lastModified ).toLocaleString(), null, options);
8323
+ if( file._path || file.src ) this.previewPanel.addText("URL", file._path ? file._path : file.src, null, options);
8135
8324
  this.previewPanel.addText("Path", this.path.join('/'), null, options);
8136
8325
  this.previewPanel.addText("Type", file.type, null, options);
8137
- if(file.bytesize) this.previewPanel.addText("Size", (file.bytesize/1024).toPrecision(3) + " KBs", null, options);
8138
- if(file.type == "folder") this.previewPanel.addText("Files", file.children ? file.children.length.toString() : "0", null, options);
8326
+ if( file.bytesize ) this.previewPanel.addText("Size", (file.bytesize/1024).toPrecision(3) + " KBs", null, options);
8327
+ if( file.type == "folder" ) this.previewPanel.addText("Files", file.children ? file.children.length.toString() : "0", null, options);
8139
8328
 
8140
8329
  this.previewPanel.addSeparator();
8141
8330
 
8142
- const preview_actions = [...this.preview_actions];
8331
+ const previewActions = [...this.previewActions];
8143
8332
 
8144
- if( !preview_actions.length )
8333
+ if( !previewActions.length )
8145
8334
  {
8146
8335
  // By default
8147
- preview_actions.push({
8336
+ previewActions.push({
8148
8337
  name: 'Download',
8149
8338
  callback: () => LX.downloadURL(file.src, file.id)
8150
8339
  });
8151
8340
  }
8152
8341
 
8153
- for( let action of preview_actions )
8342
+ for( let action of previewActions )
8154
8343
  {
8155
8344
  if( action.type && action.type !== file.type || action.path && action.path !== this.path.join('/') )
8156
8345
  continue;
@@ -8160,7 +8349,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8160
8349
  this.previewPanel.merge();
8161
8350
  }
8162
8351
 
8163
- _processDrop(e) {
8352
+ _processDrop( e ) {
8164
8353
 
8165
8354
  const fr = new FileReader();
8166
8355
  const num_files = e.dataTransfer.files.length;
@@ -8180,7 +8369,8 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8180
8369
  let item = {
8181
8370
  "id": file.name,
8182
8371
  "src": e.currentTarget.result,
8183
- "extension": ext
8372
+ "extension": ext,
8373
+ "lastModified": file.lastModified
8184
8374
  };
8185
8375
 
8186
8376
  switch(ext)
@@ -8205,7 +8395,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8205
8395
 
8206
8396
  if(i == (num_files - 1)) {
8207
8397
  this._refreshContent();
8208
- if( !this.skip_browser )
8398
+ if( !this.skipBrowser )
8209
8399
  this.tree.refresh();
8210
8400
  }
8211
8401
  };
@@ -8225,10 +8415,10 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8225
8415
  this._refreshContent();
8226
8416
  }
8227
8417
 
8228
- _enterFolder( folder_item ) {
8418
+ _enterFolder( folderItem ) {
8229
8419
 
8230
8420
  this.prevData.push( this.currentData );
8231
- this.currentData = folder_item.children;
8421
+ this.currentData = folderItem.children;
8232
8422
  this.contentPage = 1;
8233
8423
  this._refreshContent();
8234
8424
 
@@ -8236,46 +8426,57 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8236
8426
  this._updatePath(this.currentData);
8237
8427
 
8238
8428
  // Trigger event
8239
- if(this.onevent) {
8240
- const event = new AssetViewEvent(AssetViewEvent.ENTER_FOLDER, folder_item);
8429
+ if( this.onevent )
8430
+ {
8431
+ const event = new AssetViewEvent( AssetViewEvent.ENTER_FOLDER, folderItem );
8241
8432
  this.onevent( event );
8242
8433
  }
8243
8434
  }
8244
8435
 
8245
8436
  _deleteItem( item ) {
8246
8437
 
8247
- const idx = this.currentData.indexOf(item);
8248
- if(idx > -1) {
8249
- this.currentData.splice(idx, 1);
8250
- this._refreshContent(this.search_value, this.filter);
8438
+ const idx = this.currentData.indexOf( item );
8439
+ if(idx < 0)
8440
+ {
8441
+ console.error( "[AssetView Error] Cannot delete. Item not found." );
8442
+ return;
8443
+ }
8251
8444
 
8252
- if(this.onevent) {
8253
- const event = new AssetViewEvent(AssetViewEvent.ASSET_DELETED, item );
8254
- this.onevent( event );
8255
- }
8445
+ this.currentData.splice( idx, 1 );
8446
+ this._refreshContent( this.searchValue, this.filter );
8256
8447
 
8257
- this.tree.refresh();
8258
- this._processData(this.data);
8448
+ if(this.onevent)
8449
+ {
8450
+ const event = new AssetViewEvent( AssetViewEvent.ASSET_DELETED, item );
8451
+ this.onevent( event );
8259
8452
  }
8453
+
8454
+ this.tree.refresh();
8455
+ this._processData( this.data );
8260
8456
  }
8261
8457
 
8262
8458
  _cloneItem( item ) {
8263
8459
 
8264
- const idx = this.currentData.indexOf(item);
8265
- if(idx > -1) {
8266
- delete item.domEl;
8267
- delete item.folder;
8268
- const new_item = deepCopy( item );
8269
- this.currentData.splice(idx, 0, new_item);
8270
- this._refreshContent(this.search_value, this.filter);
8460
+ const idx = this.currentData.indexOf( item );
8461
+ if( idx < 0 )
8462
+ {
8463
+ return;
8464
+ }
8271
8465
 
8272
- if(this.onevent) {
8273
- const event = new AssetViewEvent(AssetViewEvent.ASSET_CLONED, item );
8274
- this.onevent( event );
8275
- }
8466
+ delete item.domEl;
8467
+ delete item.folder;
8468
+ const new_item = deepCopy( item );
8469
+ this.currentData.splice( idx, 0, new_item );
8470
+
8471
+ this._refreshContent( this.searchValue, this.filter );
8276
8472
 
8277
- this._processData(this.data);
8473
+ if( this.onevent )
8474
+ {
8475
+ const event = new AssetViewEvent( AssetViewEvent.ASSET_CLONED, item );
8476
+ this.onevent( event );
8278
8477
  }
8478
+
8479
+ this._processData( this.data );
8279
8480
  }
8280
8481
  }
8281
8482
 
@@ -8293,7 +8494,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8293
8494
  * @param {Object} request object with all the parameters like data (for sending forms), dataType, success, error
8294
8495
  * @param {Function} on_complete
8295
8496
  **/
8296
- request(request) {
8497
+ request( request ) {
8297
8498
 
8298
8499
  var dataType = request.dataType || "text";
8299
8500
  if(dataType == "json") //parse it locally
@@ -8534,6 +8735,10 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8534
8735
  return !!r.length;
8535
8736
  }
8536
8737
 
8738
+ Element.prototype.addClass = function( className ) {
8739
+ if( className ) this.classList.add( className );
8740
+ }
8741
+
8537
8742
  Element.prototype.getComputedSize = function() {
8538
8743
  const cs = getComputedStyle( this );
8539
8744
  return {
@@ -8546,7 +8751,6 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8546
8751
  getTime() { return new Date().getTime() },
8547
8752
  compareThreshold( v, p, n, t ) { return Math.abs(v - p) >= t || Math.abs(v - n) >= t },
8548
8753
  compareThresholdRange( v0, v1, t0, t1 ) { return v0 >= t0 && v0 <= t1 || v1 >= t0 && v1 <= t1 || v0 <= t0 && v1 >= t1},
8549
- clamp (num, min, max) { return Math.min(Math.max(num, min), max) },
8550
8754
  uidGenerator: simple_guidGenerator,
8551
8755
  deleteElement( el ) { if( el ) el.remove(); },
8552
8756
  flushCss(element) {