lexgui 0.1.41 → 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.41",
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;
@@ -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;
6143
6201
 
6144
- if(options.callback)
6145
- options.callback(v, e);
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 );
6208
+
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
 
@@ -7633,9 +7708,11 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7633
7708
 
7634
7709
  this.skipBrowser = options.skipBrowser ?? false;
7635
7710
  this.skipPreview = options.skipPreview ?? false;
7711
+ this.useNativeTitle = options.useNativeTitle ?? false;
7636
7712
  this.onlyFolders = options.onlyFolders ?? true;
7637
7713
  this.previewActions = options.previewActions ?? [];
7638
7714
  this.contextMenu = options.contextMenu ?? [];
7715
+ this.onRefreshContent = options.onRefreshContent;
7639
7716
 
7640
7717
  if( !this.skipBrowser )
7641
7718
  {
@@ -7705,14 +7782,17 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7705
7782
  * @method clear
7706
7783
  */
7707
7784
  clear() {
7785
+
7708
7786
  if( this.previewPanel )
7709
7787
  {
7710
7788
  this.previewPanel.clear();
7711
7789
  }
7790
+
7712
7791
  if( this.leftPanel )
7713
7792
  {
7714
7793
  this.leftPanel.clear();
7715
7794
  }
7795
+
7716
7796
  if( this.rightPanel )
7717
7797
  {
7718
7798
  this.rightPanel.clear()
@@ -7783,7 +7863,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7783
7863
  children: this.data
7784
7864
  }
7785
7865
 
7786
- this.tree = this.leftPanel.addTree("Content Browser", treeData, {
7866
+ this.tree = this.leftPanel.addTree( "Content Browser", treeData, {
7787
7867
  // icons: tree_icons,
7788
7868
  filter: false,
7789
7869
  onlyFolders: this.onlyFolders,
@@ -7844,7 +7924,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7844
7924
  this.rightPanel = area.addPanel({ className: 'lexassetcontentpanel' });
7845
7925
  }
7846
7926
 
7847
- const on_sort = (value, event) => {
7927
+ const on_sort = ( value, event ) => {
7848
7928
  const cmenu = addContextMenu( "Sort by", event, c => {
7849
7929
  c.add("Name", () => this._sortData('id') );
7850
7930
  c.add("Type", () => this._sortData('type') );
@@ -7854,10 +7934,12 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7854
7934
  } );
7855
7935
  const parent = this.parent.root.parentElement;
7856
7936
  if( parent.classList.contains('lexdialog') )
7937
+ {
7857
7938
  cmenu.root.style.zIndex = (+getComputedStyle( parent ).zIndex) + 1;
7939
+ }
7858
7940
  }
7859
7941
 
7860
- const on_change_view = (value, event) => {
7942
+ const on_change_view = ( value, event ) => {
7861
7943
  const cmenu = addContextMenu( "Layout", event, c => {
7862
7944
  c.add("Content", () => this._setContentLayout( AssetView.LAYOUT_CONTENT ) );
7863
7945
  c.add("");
@@ -7868,7 +7950,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7868
7950
  cmenu.root.style.zIndex = (+getComputedStyle( parent ).zIndex) + 1;
7869
7951
  }
7870
7952
 
7871
- const on_change_page = (value, event) => {
7953
+ const on_change_page = ( value, event ) => {
7872
7954
  if( !this.allowNextPage )
7873
7955
  {
7874
7956
  return;
@@ -7885,13 +7967,13 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7885
7967
  }
7886
7968
 
7887
7969
  this.rightPanel.sameLine();
7888
- this.rightPanel.addDropdown("Filter", this.allowedTypes, this.allowedTypes[0], (v) => this._refreshContent.call(this, null, v), { width: "20%", minWidth: "128px" });
7889
- this.rightPanel.addText(null, this.searchValue ?? "", (v) => this._refreshContent.call(this, v, null), { placeholder: "Search assets.." });
7890
- this.rightPanel.addButton(null, "<a class='fa fa-arrow-up-short-wide'></a>", on_sort.bind(this), { className: "micro", title: "Sort" });
7891
- 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" } );
7892
7974
  // Content Pages
7893
- this.rightPanel.addButton(null, "<a class='fa-solid fa-angles-left'></a>", on_change_page.bind(this, -1), { className: "micro", title: "Previous Page" });
7894
- 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" } );
7895
7977
  this.rightPanel.endLine();
7896
7978
 
7897
7979
  if( !this.skipBrowser )
@@ -7901,7 +7983,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7901
7983
  {
7902
7984
  value: "Left",
7903
7985
  icon: "fa-solid fa-left-long",
7904
- callback: (domEl) => {
7986
+ callback: domEl => {
7905
7987
  if(!this.prevData.length) return;
7906
7988
  this.nextData.push( this.currentData );
7907
7989
  this.currentData = this.prevData.pop();
@@ -7912,7 +7994,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7912
7994
  {
7913
7995
  value: "Right",
7914
7996
  icon: "fa-solid fa-right-long",
7915
- callback: (domEl) => {
7997
+ callback: domEl => {
7916
7998
  if(!this.nextData.length) return;
7917
7999
  this.prevData.push( this.currentData );
7918
8000
  this.currentData = this.nextData.pop();
@@ -7923,7 +8005,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7923
8005
  {
7924
8006
  value: "Refresh",
7925
8007
  icon: "fa-solid fa-arrows-rotate",
7926
- callback: (domEl) => { this._refreshContent(); }
8008
+ callback: domEl => { this._refreshContent(); }
7927
8009
  }
7928
8010
  ], { width: "auto", noSelection: true } );
7929
8011
  this.rightPanel.addText(null, this.path.join('/'), null, { disabled: true, signal: "@on_folder_change", style: { fontWeight: "bolder", fontSize: "16px", color: "#aaa" } });
@@ -7935,17 +8017,17 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7935
8017
  this.content.className = "lexassetscontent";
7936
8018
  this.rightPanel.root.appendChild(this.content);
7937
8019
 
7938
- this.content.addEventListener('dragenter', function(e) {
8020
+ this.content.addEventListener('dragenter', function( e ) {
7939
8021
  e.preventDefault();
7940
8022
  this.classList.add('dragging');
7941
8023
  });
7942
- this.content.addEventListener('dragleave', function(e) {
8024
+ this.content.addEventListener('dragleave', function( e ) {
7943
8025
  e.preventDefault();
7944
8026
  this.classList.remove('dragging');
7945
8027
  });
7946
- this.content.addEventListener('drop', (e) => {
8028
+ this.content.addEventListener('drop', ( e ) => {
7947
8029
  e.preventDefault();
7948
- this._processDrop(e);
8030
+ this._processDrop( e );
7949
8031
  });
7950
8032
  this.content.addEventListener('click', function() {
7951
8033
  this.querySelectorAll('.lexassetitem').forEach( i => i.classList.remove('selected') );
@@ -7956,9 +8038,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7956
8038
 
7957
8039
  _refreshContent( searchValue, filter ) {
7958
8040
 
7959
- const isContentLayout = (this.layout == AssetView.LAYOUT_CONTENT); // default
8041
+ const isContentLayout = ( this.layout == AssetView.LAYOUT_CONTENT ); // default
7960
8042
 
7961
- this.filter = filter ?? (this.filter ?? "None");
8043
+ this.filter = filter ?? ( this.filter ?? "None" );
7962
8044
  this.searchValue = searchValue ?? (this.searchValue ?? "");
7963
8045
  this.content.innerHTML = "";
7964
8046
  this.content.className = (isContentLayout ? "lexassetscontent" : "lexassetscontent list");
@@ -7972,11 +8054,62 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7972
8054
 
7973
8055
  let itemEl = document.createElement('li');
7974
8056
  itemEl.className = "lexassetitem " + item.type.toLowerCase();
7975
- itemEl.title = type + ": " + item.id;
7976
8057
  itemEl.tabIndex = -1;
7977
8058
  that.content.appendChild( itemEl );
7978
8059
 
7979
- 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
+ {
7980
8113
  let span = document.createElement('span');
7981
8114
  span.className = "lexcheckbox";
7982
8115
  let checkbox_input = document.createElement('input');
@@ -7998,6 +8131,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
7998
8131
  itemEl.appendChild(span);
7999
8132
 
8000
8133
  }
8134
+
8001
8135
  let title = document.createElement('span');
8002
8136
  title.className = "lexassettitle";
8003
8137
  title.innerText = item.id;
@@ -8090,14 +8224,20 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8090
8224
 
8091
8225
  LX.addContextMenu( multiple > 1 ? (multiple + " selected") :
8092
8226
  isFolder ? item.id : item.type, e, m => {
8093
- if(multiple <= 1)
8227
+ if( multiple <= 1 )
8228
+ {
8094
8229
  m.add("Rename");
8230
+ }
8095
8231
  if( !isFolder )
8096
- m.add("Clone", that._clone_item.bind(that, item));
8097
- if(multiple <= 1)
8232
+ {
8233
+ m.add("Clone", that._cloneItem.bind( that, item ));
8234
+ }
8235
+ if( multiple <= 1 )
8236
+ {
8098
8237
  m.add("Properties");
8238
+ }
8099
8239
  m.add("");
8100
- m.add("Delete", that._delete_item.bind(that, item));
8240
+ m.add("Delete", that._deleteItem.bind( that, item ));
8101
8241
  });
8102
8242
  });
8103
8243
  }
@@ -8146,8 +8286,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8146
8286
  item.domEl = add_item( item );
8147
8287
  }
8148
8288
  }
8289
+
8149
8290
  this.allowNextPage = filteredData.length - 1 > AssetView.MAX_PAGE_ELEMENTS;
8150
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
+ }
8151
8297
  }
8152
8298
 
8153
8299
  /**
@@ -8311,21 +8457,26 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8311
8457
 
8312
8458
  _cloneItem( item ) {
8313
8459
 
8314
- const idx = this.currentData.indexOf(item);
8315
- if(idx > -1) {
8316
- delete item.domEl;
8317
- delete item.folder;
8318
- const new_item = deepCopy( item );
8319
- this.currentData.splice(idx, 0, new_item);
8320
- this._refreshContent(this.searchValue, this.filter);
8460
+ const idx = this.currentData.indexOf( item );
8461
+ if( idx < 0 )
8462
+ {
8463
+ return;
8464
+ }
8465
+
8466
+ delete item.domEl;
8467
+ delete item.folder;
8468
+ const new_item = deepCopy( item );
8469
+ this.currentData.splice( idx, 0, new_item );
8321
8470
 
8322
- if(this.onevent) {
8323
- const event = new AssetViewEvent(AssetViewEvent.ASSET_CLONED, item );
8324
- this.onevent( event );
8325
- }
8471
+ this._refreshContent( this.searchValue, this.filter );
8326
8472
 
8327
- this._processData(this.data);
8473
+ if( this.onevent )
8474
+ {
8475
+ const event = new AssetViewEvent( AssetViewEvent.ASSET_CLONED, item );
8476
+ this.onevent( event );
8328
8477
  }
8478
+
8479
+ this._processData( this.data );
8329
8480
  }
8330
8481
  }
8331
8482
 
@@ -8343,7 +8494,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
8343
8494
  * @param {Object} request object with all the parameters like data (for sending forms), dataType, success, error
8344
8495
  * @param {Function} on_complete
8345
8496
  **/
8346
- request(request) {
8497
+ request( request ) {
8347
8498
 
8348
8499
  var dataType = request.dataType || "text";
8349
8500
  if(dataType == "json") //parse it locally