lexgui 0.1.35 → 0.1.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -3
- package/build/lexgui.css +11 -8
- package/build/lexgui.js +274 -171
- package/build/lexgui.module.js +256 -168
- package/changelog.md +12 -1
- package/demo.js +11 -6
- package/package.json +1 -1
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.
|
|
15
|
+
version: "0.1.36",
|
|
16
16
|
ready: false,
|
|
17
17
|
components: [], // specific pre-build components
|
|
18
18
|
signals: {} // events and triggers
|
|
@@ -45,43 +45,43 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
45
45
|
|
|
46
46
|
LX.has = has;
|
|
47
47
|
|
|
48
|
-
function getExtension(s)
|
|
48
|
+
function getExtension( s )
|
|
49
49
|
{
|
|
50
50
|
return s.includes('.') ? s.split('.').pop() : null;
|
|
51
51
|
}
|
|
52
|
-
|
|
52
|
+
|
|
53
53
|
LX.getExtension = getExtension;
|
|
54
|
-
|
|
55
|
-
function deepCopy(o)
|
|
54
|
+
|
|
55
|
+
function deepCopy( o )
|
|
56
56
|
{
|
|
57
57
|
return JSON.parse(JSON.stringify(o))
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
LX.deepCopy = deepCopy;
|
|
61
61
|
|
|
62
|
-
function setThemeColor(
|
|
62
|
+
function setThemeColor( colorName, color )
|
|
63
63
|
{
|
|
64
|
-
var r = document.querySelector(':root');
|
|
65
|
-
r.style.setProperty(
|
|
64
|
+
var r = document.querySelector( ':root' );
|
|
65
|
+
r.style.setProperty( '--' + colorName, color );
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
LX.setThemeColor = setThemeColor;
|
|
69
|
-
|
|
70
|
-
function getThemeColor(
|
|
69
|
+
|
|
70
|
+
function getThemeColor( colorName )
|
|
71
71
|
{
|
|
72
|
-
var r = getComputedStyle(document.querySelector(':root'));
|
|
73
|
-
return r.getPropertyValue(
|
|
72
|
+
var r = getComputedStyle( document.querySelector( ':root' ) );
|
|
73
|
+
return r.getPropertyValue( '--' + colorName );
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
LX.getThemeColor = getThemeColor;
|
|
77
77
|
|
|
78
|
-
function getBase64Image(img) {
|
|
79
|
-
var canvas = document.createElement(
|
|
78
|
+
function getBase64Image( img ) {
|
|
79
|
+
var canvas = document.createElement( 'canvas' );
|
|
80
80
|
canvas.width = img.width;
|
|
81
81
|
canvas.height = img.height;
|
|
82
|
-
var ctx = canvas.getContext(
|
|
83
|
-
ctx.drawImage(img, 0, 0);
|
|
84
|
-
return canvas.toDataURL(
|
|
82
|
+
var ctx = canvas.getContext( '2d' );
|
|
83
|
+
ctx.drawImage( img, 0, 0 );
|
|
84
|
+
return canvas.toDataURL( 'image/png' );
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
LX.getBase64Image = getBase64Image;
|
|
@@ -133,22 +133,26 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
133
133
|
|
|
134
134
|
function doAsync( fn, ms ) {
|
|
135
135
|
if( ASYNC_ENABLED )
|
|
136
|
+
{
|
|
136
137
|
setTimeout( fn, ms ?? 0 );
|
|
138
|
+
}
|
|
137
139
|
else
|
|
140
|
+
{
|
|
138
141
|
fn();
|
|
142
|
+
}
|
|
139
143
|
}
|
|
140
144
|
|
|
141
145
|
// Math classes
|
|
142
146
|
|
|
143
147
|
class vec2 {
|
|
144
148
|
|
|
145
|
-
constructor(x, y) {
|
|
149
|
+
constructor( x, y ) {
|
|
146
150
|
this.x = x ?? 0;
|
|
147
|
-
this.y = y ?? (x ?? 0);
|
|
151
|
+
this.y = y ?? ( x ?? 0 );
|
|
148
152
|
}
|
|
149
153
|
|
|
150
|
-
get xy() { return [ this.x, this.y]; }
|
|
151
|
-
get yx() { return [ this.y, this.x]; }
|
|
154
|
+
get xy() { return [ this.x, this.y ]; }
|
|
155
|
+
get yx() { return [ this.y, this.x ]; }
|
|
152
156
|
|
|
153
157
|
set ( x, y ) { this.x = x; this.y = y; }
|
|
154
158
|
add ( v, v0 = new vec2() ) { v0.set( this.x + v.x, this.y + v.y ); return v0; }
|
|
@@ -156,6 +160,11 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
156
160
|
mul ( v, v0 = new vec2() ) { if( v.constructor == Number ) { v = new vec2( v ) } v0.set( this.x * v.x, this.y * v.y ); return v0; }
|
|
157
161
|
div ( v, v0 = new vec2() ) { if( v.constructor == Number ) { v = new vec2( v ) } v0.set( this.x / v.x, this.y / v.y ); return v0; }
|
|
158
162
|
abs ( v0 = new vec2() ) { v0.set( Math.abs( this.x ), Math.abs( this.y ) ); return v0; }
|
|
163
|
+
dot ( v ) { return this.x * v.x + this.y * v.y; }
|
|
164
|
+
len2 () { return this.dot( this ) }
|
|
165
|
+
len () { return Math.sqrt( this.len2() ); }
|
|
166
|
+
nrm ( v0 = new vec2() ) { v0.set( this.x, this.y ); return v0.mul( 1.0 / this.len(), v0 ); }
|
|
167
|
+
dst ( v ) { return v.sub( this ).len(); }
|
|
159
168
|
};
|
|
160
169
|
|
|
161
170
|
LX.vec2 = vec2;
|
|
@@ -661,16 +670,22 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
661
670
|
|
|
662
671
|
LX.TreeEvent = TreeEvent;
|
|
663
672
|
|
|
664
|
-
function emit(
|
|
673
|
+
function emit( signalName, value, options = {} )
|
|
665
674
|
{
|
|
666
|
-
const data = LX.signals[
|
|
675
|
+
const data = LX.signals[ signalName ];
|
|
667
676
|
|
|
668
677
|
if( !data )
|
|
669
678
|
return;
|
|
670
679
|
|
|
680
|
+
const target = options.target;
|
|
681
|
+
|
|
671
682
|
if( target )
|
|
672
683
|
{
|
|
673
|
-
if(target[
|
|
684
|
+
if( target[ signalName ])
|
|
685
|
+
{
|
|
686
|
+
target[ signalName ].call( target, value );
|
|
687
|
+
}
|
|
688
|
+
|
|
674
689
|
return;
|
|
675
690
|
}
|
|
676
691
|
|
|
@@ -678,13 +693,16 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
678
693
|
{
|
|
679
694
|
if( obj.constructor === Widget )
|
|
680
695
|
{
|
|
681
|
-
obj.set( value );
|
|
696
|
+
obj.set( value, options.skipCallback ?? true );
|
|
682
697
|
|
|
683
|
-
if(obj.options && obj.options.callback)
|
|
684
|
-
|
|
685
|
-
|
|
698
|
+
if( obj.options && obj.options.callback )
|
|
699
|
+
{
|
|
700
|
+
obj.options.callback( value, data );
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
else
|
|
686
704
|
{
|
|
687
|
-
obj[
|
|
705
|
+
obj[ signalName ].call( obj, value );
|
|
688
706
|
}
|
|
689
707
|
}
|
|
690
708
|
}
|
|
@@ -723,13 +741,17 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
723
741
|
*/
|
|
724
742
|
|
|
725
743
|
constructor( options = {} ) {
|
|
726
|
-
|
|
727
|
-
var root = document.createElement('div');
|
|
744
|
+
|
|
745
|
+
var root = document.createElement( 'div' );
|
|
728
746
|
root.className = "lexarea";
|
|
729
|
-
if(options.id)
|
|
747
|
+
if( options.id )
|
|
748
|
+
{
|
|
730
749
|
root.id = options.id;
|
|
731
|
-
|
|
750
|
+
}
|
|
751
|
+
if( options.className )
|
|
752
|
+
{
|
|
732
753
|
root.className += " " + options.className;
|
|
754
|
+
}
|
|
733
755
|
|
|
734
756
|
var width = options.width || "calc( 100% )";
|
|
735
757
|
var height = options.height || "100%";
|
|
@@ -737,10 +759,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
737
759
|
// This has default options..
|
|
738
760
|
this.setLimitBox( options.minWidth, options.minHeight, options.maxWidth, options.maxHeight );
|
|
739
761
|
|
|
740
|
-
if(width.constructor == Number)
|
|
762
|
+
if( width.constructor == Number )
|
|
763
|
+
{
|
|
741
764
|
width += "px";
|
|
742
|
-
|
|
765
|
+
}
|
|
766
|
+
if( height.constructor == Number )
|
|
767
|
+
{
|
|
743
768
|
height += "px";
|
|
769
|
+
}
|
|
744
770
|
|
|
745
771
|
root.style.width = width;
|
|
746
772
|
root.style.height = height;
|
|
@@ -751,115 +777,136 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
751
777
|
this.sections = [];
|
|
752
778
|
this.panels = [];
|
|
753
779
|
|
|
754
|
-
if(!options.no_append)
|
|
780
|
+
if( !options.no_append )
|
|
781
|
+
{
|
|
755
782
|
var lexroot = document.getElementById("lexroot");
|
|
756
783
|
lexroot.appendChild( this.root );
|
|
757
784
|
}
|
|
758
785
|
|
|
759
786
|
let overlay = options.overlay;
|
|
760
787
|
|
|
761
|
-
if(overlay)
|
|
788
|
+
if( overlay )
|
|
762
789
|
{
|
|
763
790
|
this.root.classList.add("overlay-" + overlay);
|
|
764
|
-
|
|
765
|
-
if( options.
|
|
791
|
+
|
|
792
|
+
if( options.left )
|
|
793
|
+
{
|
|
794
|
+
this.root.style.left = options.left;
|
|
795
|
+
}
|
|
796
|
+
else if( options.right )
|
|
797
|
+
{
|
|
798
|
+
this.root.style.right = options.right;
|
|
799
|
+
}
|
|
800
|
+
else if( options.top )
|
|
801
|
+
{
|
|
802
|
+
this.root.style.top = options.top;
|
|
803
|
+
}
|
|
804
|
+
else if( options.bottom )
|
|
805
|
+
{
|
|
806
|
+
this.root.style.bottom = options.bottom;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
const draggable = options.draggable ?? true;
|
|
810
|
+
if( draggable )
|
|
766
811
|
makeDraggable( root );
|
|
767
812
|
|
|
768
813
|
if( options.resizeable ) {
|
|
769
814
|
root.classList.add("resizeable");
|
|
770
815
|
}
|
|
771
816
|
|
|
772
|
-
if(options.resize)
|
|
817
|
+
if( options.resize )
|
|
773
818
|
{
|
|
774
819
|
this.split_bar = document.createElement("div");
|
|
775
|
-
let type = overlay == "left" || overlay == "right" ? "horizontal" : "vertical";
|
|
820
|
+
let type = (overlay == "left") || (overlay == "right") ? "horizontal" : "vertical";
|
|
776
821
|
this.type = overlay;;
|
|
777
822
|
this.split_bar.className = "lexsplitbar " + type;
|
|
778
|
-
|
|
823
|
+
|
|
824
|
+
if( overlay == "right" )
|
|
825
|
+
{
|
|
779
826
|
this.split_bar.style.width = LX.DEFAULT_SPLITBAR_SIZE + "px";
|
|
780
|
-
this.split_bar.style.left = -LX.DEFAULT_SPLITBAR_SIZE/2 + "px";
|
|
827
|
+
this.split_bar.style.left = -(LX.DEFAULT_SPLITBAR_SIZE / 2.0) + "px";
|
|
781
828
|
}
|
|
782
|
-
else if(overlay == "left")
|
|
829
|
+
else if( overlay == "left" )
|
|
830
|
+
{
|
|
783
831
|
let size = Math.min(document.body.clientWidth - LX.DEFAULT_SPLITBAR_SIZE, this.root.clientWidth);
|
|
784
832
|
this.split_bar.style.width = LX.DEFAULT_SPLITBAR_SIZE + "px";
|
|
785
|
-
this.split_bar.style.left = size + LX.DEFAULT_SPLITBAR_SIZE/2 + "px";
|
|
833
|
+
this.split_bar.style.left = size + (LX.DEFAULT_SPLITBAR_SIZE / 2.0) + "px";
|
|
786
834
|
}
|
|
787
|
-
else if
|
|
835
|
+
else if( overlay == "top" )
|
|
836
|
+
{
|
|
788
837
|
let size = Math.min(document.body.clientHeight - LX.DEFAULT_SPLITBAR_SIZE, this.root.clientHeight);
|
|
789
838
|
this.split_bar.style.height = LX.DEFAULT_SPLITBAR_SIZE + "px";
|
|
790
|
-
this.split_bar.style.top = size + LX.DEFAULT_SPLITBAR_SIZE/2 + "px";
|
|
839
|
+
this.split_bar.style.top = size + (LX.DEFAULT_SPLITBAR_SIZE / 2.0) + "px";
|
|
791
840
|
}
|
|
792
|
-
else if(overlay == "bottom")
|
|
841
|
+
else if( overlay == "bottom" )
|
|
842
|
+
{
|
|
793
843
|
this.split_bar.style.height = LX.DEFAULT_SPLITBAR_SIZE + "px";
|
|
794
|
-
this.split_bar.style.top = -LX.DEFAULT_SPLITBAR_SIZE/2 + "px";
|
|
844
|
+
this.split_bar.style.top = -(LX.DEFAULT_SPLITBAR_SIZE / 2.0) + "px";
|
|
795
845
|
}
|
|
796
846
|
|
|
797
847
|
this.split_bar.addEventListener("mousedown", inner_mousedown);
|
|
798
|
-
this.root.appendChild(this.split_bar);
|
|
848
|
+
this.root.appendChild( this.split_bar );
|
|
799
849
|
|
|
800
850
|
var that = this;
|
|
801
|
-
var last_pos = [0,0];
|
|
851
|
+
var last_pos = [ 0, 0 ];
|
|
802
852
|
|
|
803
|
-
function inner_mousedown(e)
|
|
853
|
+
function inner_mousedown( e )
|
|
804
854
|
{
|
|
805
855
|
var doc = that.root.ownerDocument;
|
|
806
|
-
doc.addEventListener(
|
|
807
|
-
doc.addEventListener(
|
|
808
|
-
last_pos[0] = e.x;
|
|
809
|
-
last_pos[1] = e.y;
|
|
856
|
+
doc.addEventListener( 'mousemove', inner_mousemove );
|
|
857
|
+
doc.addEventListener( 'mouseup', inner_mouseup );
|
|
858
|
+
last_pos[ 0 ] = e.x;
|
|
859
|
+
last_pos[ 1 ] = e.y;
|
|
810
860
|
e.stopPropagation();
|
|
811
861
|
e.preventDefault();
|
|
812
|
-
document.body.classList.add(
|
|
813
|
-
that.split_bar.classList.add(
|
|
862
|
+
document.body.classList.add( 'nocursor' );
|
|
863
|
+
that.split_bar.classList.add( 'nocursor' );
|
|
814
864
|
}
|
|
815
865
|
|
|
816
|
-
function inner_mousemove(e)
|
|
866
|
+
function inner_mousemove( e )
|
|
817
867
|
{
|
|
818
|
-
switch(that.type) {
|
|
868
|
+
switch( that.type ) {
|
|
819
869
|
case "right":
|
|
820
|
-
var dt = (last_pos[0] - e.x);
|
|
821
|
-
var size = (that.root.offsetWidth + dt);
|
|
870
|
+
var dt = ( last_pos[ 0 ] - e.x );
|
|
871
|
+
var size = ( that.root.offsetWidth + dt );
|
|
822
872
|
that.root.style.width = size + "px";
|
|
823
873
|
break;
|
|
824
|
-
|
|
825
874
|
case "left":
|
|
826
|
-
var dt = (last_pos[0] - e.x);
|
|
875
|
+
var dt = ( last_pos[ 0 ] - e.x );
|
|
827
876
|
var size = Math.min(document.body.clientWidth - LX.DEFAULT_SPLITBAR_SIZE, (that.root.offsetWidth - dt));
|
|
828
877
|
that.root.style.width = size + "px";
|
|
829
878
|
that.split_bar.style.left = size + LX.DEFAULT_SPLITBAR_SIZE/2 + "px";
|
|
830
879
|
break;
|
|
831
|
-
|
|
832
880
|
case "top":
|
|
833
|
-
var dt = (last_pos[1] - e.y);
|
|
881
|
+
var dt = ( last_pos[ 1 ] - e.y );
|
|
834
882
|
var size = Math.min(document.body.clientHeight - LX.DEFAULT_SPLITBAR_SIZE, (that.root.offsetHeight - dt));
|
|
835
883
|
that.root.style.height = size + "px";
|
|
836
884
|
that.split_bar.style.top = size + LX.DEFAULT_SPLITBAR_SIZE/2 + "px";
|
|
837
885
|
break;
|
|
838
|
-
|
|
839
886
|
case "bottom":
|
|
840
|
-
var dt = (last_pos[1] - e.y);
|
|
841
|
-
var size = (that.root.offsetHeight + dt);
|
|
887
|
+
var dt = ( last_pos[ 1 ] - e.y );
|
|
888
|
+
var size = ( that.root.offsetHeight + dt );
|
|
842
889
|
that.root.style.height = size + "px";
|
|
843
890
|
break;
|
|
844
891
|
}
|
|
845
892
|
|
|
846
|
-
last_pos[0] = e.x;
|
|
847
|
-
last_pos[1] = e.y;
|
|
893
|
+
last_pos[ 0 ] = e.x;
|
|
894
|
+
last_pos[ 1 ] = e.y;
|
|
848
895
|
e.stopPropagation();
|
|
849
896
|
e.preventDefault();
|
|
850
897
|
|
|
851
898
|
// Resize events
|
|
852
|
-
if(that.onresize)
|
|
899
|
+
if( that.onresize )
|
|
853
900
|
that.onresize( that.root.getBoundingClientRect() );
|
|
854
901
|
}
|
|
855
902
|
|
|
856
|
-
function inner_mouseup(e)
|
|
903
|
+
function inner_mouseup( e )
|
|
857
904
|
{
|
|
858
905
|
var doc = that.root.ownerDocument;
|
|
859
|
-
doc.removeEventListener(
|
|
860
|
-
doc.removeEventListener(
|
|
861
|
-
document.body.classList.remove(
|
|
862
|
-
that.split_bar.classList.remove(
|
|
906
|
+
doc.removeEventListener( 'mousemove', inner_mousemove );
|
|
907
|
+
doc.removeEventListener( 'mouseup', inner_mouseup );
|
|
908
|
+
document.body.classList.remove( 'nocursor' );
|
|
909
|
+
that.split_bar.classList.remove( 'nocursor' );
|
|
863
910
|
}
|
|
864
911
|
}
|
|
865
912
|
}
|
|
@@ -1142,7 +1189,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
1142
1189
|
this.propagateEvent("onresize");
|
|
1143
1190
|
}
|
|
1144
1191
|
|
|
1145
|
-
|
|
1192
|
+
/**
|
|
1146
1193
|
* @method extend
|
|
1147
1194
|
* Hide 2nd area split
|
|
1148
1195
|
*/
|
|
@@ -1592,7 +1639,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
1592
1639
|
this.classList.remove("dockingtab");
|
|
1593
1640
|
|
|
1594
1641
|
// Change tabs instance
|
|
1595
|
-
LX.emit( "@on_tab_docked"
|
|
1642
|
+
LX.emit( "@on_tab_docked" );
|
|
1596
1643
|
el.instance = that;
|
|
1597
1644
|
|
|
1598
1645
|
// Show on drop
|
|
@@ -1664,22 +1711,26 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
1664
1711
|
|
|
1665
1712
|
let isSelected = options.selected ?? false;
|
|
1666
1713
|
|
|
1667
|
-
if( isSelected )
|
|
1668
|
-
|
|
1669
|
-
this.
|
|
1714
|
+
if( isSelected )
|
|
1715
|
+
{
|
|
1716
|
+
this.root.querySelectorAll( 'span' ).forEach( s => s.classList.remove( 'selected' ) );
|
|
1717
|
+
this.area.root.querySelectorAll( '.lextabcontent' ).forEach( c => c.style.display = 'none' );
|
|
1670
1718
|
}
|
|
1671
1719
|
|
|
1672
1720
|
isSelected = !Object.keys( this.tabs ).length && !this.folding ? true : isSelected;
|
|
1673
1721
|
|
|
1674
1722
|
let contentEl = content.root ? content.root : content;
|
|
1675
|
-
contentEl.style.display
|
|
1676
|
-
contentEl.
|
|
1723
|
+
contentEl.originalDisplay = contentEl.style.display;
|
|
1724
|
+
contentEl.style.display = isSelected ? contentEl.originalDisplay : "none";
|
|
1725
|
+
contentEl.classList.add( 'lextabcontent' );
|
|
1677
1726
|
|
|
1678
1727
|
// Process icon
|
|
1679
1728
|
if( options.icon )
|
|
1680
1729
|
{
|
|
1681
1730
|
if( options.icon.includes( 'fa-' ) ) // It's fontawesome icon...
|
|
1731
|
+
{
|
|
1682
1732
|
options.icon = "<i class='" + options.icon + "'></i>";
|
|
1733
|
+
}
|
|
1683
1734
|
else // an image..
|
|
1684
1735
|
{
|
|
1685
1736
|
const rootPath = "https://raw.githubusercontent.com/jxarco/lexgui.js/master/";
|
|
@@ -1688,26 +1739,31 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
1688
1739
|
}
|
|
1689
1740
|
|
|
1690
1741
|
// Create tab
|
|
1691
|
-
let tabEl = document.createElement('span');
|
|
1692
|
-
tabEl.dataset["name"] = name;
|
|
1693
|
-
tabEl.className = "lexareatab" + (isSelected ? " selected" : "");
|
|
1694
|
-
tabEl.innerHTML = (options.icon ?? "") + name;
|
|
1695
|
-
tabEl.id = name.replace(/\s/g, '') + Tabs.TAB_ID++;
|
|
1742
|
+
let tabEl = document.createElement( 'span' );
|
|
1743
|
+
tabEl.dataset[ "name" ] = name;
|
|
1744
|
+
tabEl.className = "lexareatab" + ( isSelected ? " selected" : "" );
|
|
1745
|
+
tabEl.innerHTML = ( options.icon ?? "" ) + name;
|
|
1746
|
+
tabEl.id = name.replace( /\s/g, '' ) + Tabs.TAB_ID++;
|
|
1696
1747
|
tabEl.title = options.title;
|
|
1697
1748
|
tabEl.selected = isSelected ?? false;
|
|
1698
1749
|
tabEl.fixed = options.fixed;
|
|
1699
|
-
if(tabEl.selected)
|
|
1700
|
-
this.selected = name;
|
|
1701
1750
|
tabEl.instance = this;
|
|
1702
1751
|
contentEl.id = tabEl.id + "_content";
|
|
1703
1752
|
|
|
1753
|
+
if( tabEl.selected )
|
|
1754
|
+
{
|
|
1755
|
+
this.selected = name;
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1704
1758
|
LX.addSignal( "@on_tab_docked", tabEl, function() {
|
|
1705
|
-
if( this.parentElement.childNodes.length == 1 )
|
|
1706
|
-
|
|
1759
|
+
if( this.parentElement.childNodes.length == 1 )
|
|
1760
|
+
{
|
|
1761
|
+
this.parentElement.childNodes[ 0 ].click(); // single tab!!
|
|
1707
1762
|
}
|
|
1708
1763
|
} );
|
|
1709
1764
|
|
|
1710
1765
|
tabEl.addEventListener("click", e => {
|
|
1766
|
+
|
|
1711
1767
|
e.preventDefault();
|
|
1712
1768
|
e.stopPropagation();
|
|
1713
1769
|
|
|
@@ -1715,25 +1771,27 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
1715
1771
|
{
|
|
1716
1772
|
// For folding tabs
|
|
1717
1773
|
const lastValue = tabEl.selected;
|
|
1718
|
-
tabEl.parentElement.querySelectorAll('span').forEach( s => s.selected = false );
|
|
1774
|
+
tabEl.parentElement.querySelectorAll( 'span' ).forEach( s => s.selected = false );
|
|
1719
1775
|
tabEl.selected = !lastValue;
|
|
1720
1776
|
// Manage selected
|
|
1721
|
-
tabEl.parentElement.querySelectorAll('span').forEach( s => s.classList.remove('selected'));
|
|
1722
|
-
tabEl.classList.toggle('selected', (this.folding && tabEl.selected));
|
|
1777
|
+
tabEl.parentElement.querySelectorAll( 'span' ).forEach( s => s.classList.remove( 'selected' ));
|
|
1778
|
+
tabEl.classList.toggle('selected', ( this.folding && tabEl.selected ));
|
|
1723
1779
|
// Manage visibility
|
|
1724
|
-
tabEl.instance.area.root.querySelectorAll('.lextabcontent').forEach( c => c.style.display = 'none');
|
|
1725
|
-
contentEl.style.display =
|
|
1780
|
+
tabEl.instance.area.root.querySelectorAll( '.lextabcontent' ).forEach( c => c.style.display = 'none' );
|
|
1781
|
+
contentEl.style.display = contentEl.originalDisplay;
|
|
1726
1782
|
tabEl.instance.selected = tabEl.dataset.name;
|
|
1727
1783
|
}
|
|
1728
1784
|
|
|
1729
1785
|
if( this.folding )
|
|
1730
1786
|
{
|
|
1731
1787
|
this.folded = tabEl.selected;
|
|
1732
|
-
this.area.root.classList.toggle('folded', !this.folded);
|
|
1788
|
+
this.area.root.classList.toggle( 'folded', !this.folded );
|
|
1733
1789
|
}
|
|
1734
1790
|
|
|
1735
|
-
if(options.onSelect)
|
|
1791
|
+
if( options.onSelect )
|
|
1792
|
+
{
|
|
1736
1793
|
options.onSelect(e, tabEl.dataset.name);
|
|
1794
|
+
}
|
|
1737
1795
|
|
|
1738
1796
|
if( this.thumb )
|
|
1739
1797
|
{
|
|
@@ -1748,25 +1806,28 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
1748
1806
|
e.preventDefault();
|
|
1749
1807
|
e.stopPropagation();
|
|
1750
1808
|
|
|
1751
|
-
if(options.onContextMenu)
|
|
1809
|
+
if( options.onContextMenu )
|
|
1810
|
+
{
|
|
1752
1811
|
options.onContextMenu( e, tabEl.dataset.name );
|
|
1812
|
+
}
|
|
1753
1813
|
});
|
|
1754
1814
|
|
|
1755
1815
|
tabEl.addEventListener("mouseup", e => {
|
|
1756
1816
|
e.preventDefault();
|
|
1757
1817
|
e.stopPropagation();
|
|
1758
|
-
if( e.button == 1 )
|
|
1759
|
-
|
|
1818
|
+
if( e.button == 1 )
|
|
1819
|
+
{
|
|
1820
|
+
this.delete( tabEl.dataset[ "name" ] );
|
|
1760
1821
|
}
|
|
1761
1822
|
});
|
|
1762
1823
|
|
|
1763
|
-
tabEl.setAttribute('draggable', true);
|
|
1764
|
-
tabEl.addEventListener(
|
|
1824
|
+
tabEl.setAttribute( 'draggable', true );
|
|
1825
|
+
tabEl.addEventListener( 'dragstart', function( e ) {
|
|
1765
1826
|
if( this.parentElement.childNodes.length == 1 ){
|
|
1766
1827
|
e.preventDefault();
|
|
1767
1828
|
return;
|
|
1768
1829
|
}
|
|
1769
|
-
e.dataTransfer.setData(
|
|
1830
|
+
e.dataTransfer.setData( 'source', e.target.id );
|
|
1770
1831
|
});
|
|
1771
1832
|
|
|
1772
1833
|
// Attach content
|
|
@@ -2474,8 +2535,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
2474
2535
|
}
|
|
2475
2536
|
|
|
2476
2537
|
refresh() {
|
|
2477
|
-
|
|
2478
|
-
// if( this.options.callback ) this.options.callback();
|
|
2538
|
+
|
|
2479
2539
|
}
|
|
2480
2540
|
}
|
|
2481
2541
|
|
|
@@ -3704,6 +3764,8 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
3704
3764
|
* placeholder: Add input placeholder
|
|
3705
3765
|
* trigger: Choose onchange trigger (default, input) [default]
|
|
3706
3766
|
* inputWidth: Width of the text input
|
|
3767
|
+
* float: Justify input text content
|
|
3768
|
+
* justifyName: Justify name content
|
|
3707
3769
|
* fitHeight: Height adapts to text
|
|
3708
3770
|
*/
|
|
3709
3771
|
|
|
@@ -3741,6 +3803,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
3741
3803
|
let wValue = document.createElement( 'textarea' );
|
|
3742
3804
|
wValue.value = wValue.iValue = value || "";
|
|
3743
3805
|
wValue.style.width = "100%";
|
|
3806
|
+
wValue.style.textAlign = options.float ?? "";
|
|
3744
3807
|
Object.assign( wValue.style, options.style ?? {} );
|
|
3745
3808
|
|
|
3746
3809
|
if( options.disabled ?? false ) wValue.setAttribute("disabled", true);
|
|
@@ -3817,8 +3880,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
3817
3880
|
* @param {String} value Button name
|
|
3818
3881
|
* @param {Function} callback Callback function on click
|
|
3819
3882
|
* @param {*} options:
|
|
3820
|
-
* icon
|
|
3821
3883
|
* disabled: Make the widget disabled [false]
|
|
3884
|
+
* icon: Icon class to show as button value
|
|
3885
|
+
* img: Path to image to show as button value
|
|
3822
3886
|
*/
|
|
3823
3887
|
|
|
3824
3888
|
addButton( name, value, callback, options = {} ) {
|
|
@@ -4434,6 +4498,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
4434
4498
|
* @param {Array} values By default values in the array
|
|
4435
4499
|
* @param {Function} callback Callback function on change
|
|
4436
4500
|
* @param {*} options:
|
|
4501
|
+
* innerValues (Array): Use dropdown mode and use values as options
|
|
4437
4502
|
*/
|
|
4438
4503
|
|
|
4439
4504
|
addArray( name, values = [], callback, options = {} ) {
|
|
@@ -5355,9 +5420,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
5355
5420
|
* @param {*} options:
|
|
5356
5421
|
* min, max: Min and Max values
|
|
5357
5422
|
* low, optimum, high: Low and High boundary values, Optimum point in the range
|
|
5358
|
-
* showValue:
|
|
5359
|
-
* editable:
|
|
5360
|
-
* callback:
|
|
5423
|
+
* showValue: Show current value
|
|
5424
|
+
* editable: Allow edit value
|
|
5425
|
+
* callback: Function called on change value
|
|
5361
5426
|
*/
|
|
5362
5427
|
|
|
5363
5428
|
addProgress( name, value, options = {} ) {
|
|
@@ -5611,64 +5676,93 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
5611
5676
|
|
|
5612
5677
|
/**
|
|
5613
5678
|
* @method addTabs
|
|
5614
|
-
* @param {Array} tabs Contains objects with {
|
|
5679
|
+
* @param {Array} tabs Contains objects with {
|
|
5680
|
+
* name: Name of the tab (if icon, use as title)
|
|
5681
|
+
* icon: Icon to be used as the tab icon (optional)
|
|
5682
|
+
* onCreate: Func to be called at tab creation
|
|
5683
|
+
* onSelect: Func to be called on select tab (optional)
|
|
5684
|
+
* }
|
|
5615
5685
|
* @param {*} options
|
|
5616
5686
|
* vertical: Use vertical or horizontal tabs (vertical by default)
|
|
5617
5687
|
* showNames: Show tab name only in horizontal tabs
|
|
5618
5688
|
*/
|
|
5619
5689
|
|
|
5620
5690
|
addTabs( tabs, options = {} ) {
|
|
5691
|
+
|
|
5621
5692
|
let root = this.current_branch ? this.current_branch.content : this.root;
|
|
5622
|
-
|
|
5693
|
+
|
|
5694
|
+
if( !this.current_branch )
|
|
5695
|
+
{
|
|
5623
5696
|
console.warn("No current branch!");
|
|
5697
|
+
}
|
|
5624
5698
|
|
|
5625
|
-
if(tabs.constructor != Array)
|
|
5626
|
-
|
|
5699
|
+
if( tabs.constructor != Array )
|
|
5700
|
+
{
|
|
5701
|
+
throw( "Param @tabs must be an Array!" );
|
|
5702
|
+
}
|
|
5627
5703
|
|
|
5628
5704
|
const vertical = options.vertical ?? true;
|
|
5629
|
-
const showNames = !vertical && (options.showNames ?? false);
|
|
5705
|
+
const showNames = !vertical && ( options.showNames ?? false );
|
|
5630
5706
|
|
|
5631
|
-
let container = document.createElement('div');
|
|
5707
|
+
let container = document.createElement( 'div' );
|
|
5632
5708
|
container.className = "lextabscontainer";
|
|
5633
|
-
if( !vertical )
|
|
5709
|
+
if( !vertical )
|
|
5710
|
+
{
|
|
5711
|
+
container.className += " horizontal";
|
|
5712
|
+
}
|
|
5634
5713
|
|
|
5635
|
-
let tabContainer = document.createElement(
|
|
5636
|
-
tabContainer.className =
|
|
5714
|
+
let tabContainer = document.createElement( 'div' );
|
|
5715
|
+
tabContainer.className = 'tabs';
|
|
5637
5716
|
container.appendChild( tabContainer );
|
|
5638
5717
|
root.appendChild( container );
|
|
5639
5718
|
|
|
5640
|
-
for(
|
|
5719
|
+
for( let i = 0; i < tabs.length; ++i )
|
|
5641
5720
|
{
|
|
5642
|
-
const tab = tabs[i];
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
tabEl
|
|
5646
|
-
tabEl.
|
|
5721
|
+
const tab = tabs[ i ];
|
|
5722
|
+
console.assert( tab.name );
|
|
5723
|
+
const isSelected = ( i == 0 );
|
|
5724
|
+
let tabEl = document.createElement( 'div' );
|
|
5725
|
+
tabEl.className = "lextab " + (i == tabs.length - 1 ? "last" : "") + ( isSelected ? "selected" : "" );
|
|
5726
|
+
tabEl.innerHTML = ( showNames ? tab.name : "" ) + "<a class='" + ( tab.icon || "fa fa-hashtag" ) + " " + (showNames ? "withname" : "") + "'></a>";
|
|
5647
5727
|
tabEl.title = tab.name;
|
|
5648
5728
|
|
|
5649
|
-
let infoContainer = document.createElement(
|
|
5650
|
-
infoContainer.id = tab.name.replace(/\s/g, '');
|
|
5729
|
+
let infoContainer = document.createElement( 'div' );
|
|
5730
|
+
infoContainer.id = tab.name.replace( /\s/g, '' );
|
|
5651
5731
|
infoContainer.className = "widgets";
|
|
5652
|
-
|
|
5732
|
+
|
|
5733
|
+
if(!isSelected)
|
|
5734
|
+
{
|
|
5735
|
+
infoContainer.toggleAttribute('hidden', true);
|
|
5736
|
+
}
|
|
5737
|
+
|
|
5653
5738
|
container.appendChild( infoContainer );
|
|
5654
5739
|
|
|
5655
|
-
tabEl.addEventListener(
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
el.
|
|
5740
|
+
tabEl.addEventListener( 'click', e => {
|
|
5741
|
+
|
|
5742
|
+
// Change selected tab
|
|
5743
|
+
tabContainer.querySelectorAll( '.lextab' ).forEach( e => { e.classList.remove( 'selected' ); } );
|
|
5744
|
+
e.target.classList.add( 'selected' );
|
|
5745
|
+
// Hide all tabs content
|
|
5746
|
+
container.querySelectorAll(".widgets").forEach( e => { e.toggleAttribute( 'hidden', true ); } );
|
|
5747
|
+
// Show tab content
|
|
5748
|
+
const el = container.querySelector( '#' + infoContainer.id );
|
|
5749
|
+
el.toggleAttribute( 'hidden' );
|
|
5750
|
+
|
|
5751
|
+
if( tab.onSelect )
|
|
5752
|
+
{
|
|
5753
|
+
tab.onSelect( this, infoContainer );
|
|
5754
|
+
}
|
|
5664
5755
|
});
|
|
5665
5756
|
|
|
5666
|
-
tabContainer.appendChild(tabEl);
|
|
5757
|
+
tabContainer.appendChild( tabEl );
|
|
5667
5758
|
|
|
5668
|
-
|
|
5669
|
-
|
|
5670
|
-
|
|
5671
|
-
|
|
5759
|
+
if( tab.onCreate )
|
|
5760
|
+
{
|
|
5761
|
+
// push to tab space
|
|
5762
|
+
this.queue( infoContainer );
|
|
5763
|
+
tab.onCreate( this, infoContainer );
|
|
5764
|
+
this.clearQueue();
|
|
5765
|
+
}
|
|
5672
5766
|
}
|
|
5673
5767
|
|
|
5674
5768
|
this.addSeparator();
|
|
@@ -5684,14 +5778,19 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
5684
5778
|
class Branch {
|
|
5685
5779
|
|
|
5686
5780
|
constructor( name, options = {} ) {
|
|
5781
|
+
|
|
5687
5782
|
this.name = name;
|
|
5688
5783
|
|
|
5689
|
-
var root = document.createElement('div');
|
|
5784
|
+
var root = document.createElement( 'div' );
|
|
5690
5785
|
root.className = "lexbranch";
|
|
5691
|
-
if(options.id)
|
|
5786
|
+
if( options.id )
|
|
5787
|
+
{
|
|
5692
5788
|
root.id = options.id;
|
|
5693
|
-
|
|
5789
|
+
}
|
|
5790
|
+
if( options.className )
|
|
5791
|
+
{
|
|
5694
5792
|
root.className += " " + options.className;
|
|
5793
|
+
}
|
|
5695
5794
|
|
|
5696
5795
|
root.style.width = "calc(100% - 7px)";
|
|
5697
5796
|
root.style.margin = "0 auto";
|
|
@@ -5702,65 +5801,69 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
5702
5801
|
this.widgets = [];
|
|
5703
5802
|
|
|
5704
5803
|
// create element
|
|
5705
|
-
var title = document.createElement('div');
|
|
5804
|
+
var title = document.createElement( 'div' );
|
|
5706
5805
|
title.className = "lexbranchtitle";
|
|
5707
|
-
|
|
5806
|
+
|
|
5708
5807
|
title.innerHTML = "<a class='fa-solid fa-angle-up switch-branch-button'></a>";
|
|
5709
|
-
if(options.icon)
|
|
5808
|
+
if( options.icon )
|
|
5809
|
+
{
|
|
5710
5810
|
title.innerHTML += "<a class='branchicon " + options.icon + "' style='margin-right: 8px; margin-bottom: -2px;'>";
|
|
5711
5811
|
}
|
|
5712
5812
|
title.innerHTML += name || "Branch";
|
|
5713
5813
|
|
|
5714
|
-
root.appendChild(title);
|
|
5814
|
+
root.appendChild( title );
|
|
5715
5815
|
|
|
5716
|
-
var
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
root.appendChild(
|
|
5720
|
-
this.content =
|
|
5816
|
+
var branchContent = document.createElement( 'div' );
|
|
5817
|
+
branchContent.id = name.replace(/\s/g, '');
|
|
5818
|
+
branchContent.className = "lexbranchcontent";
|
|
5819
|
+
root.appendChild(branchContent);
|
|
5820
|
+
this.content = branchContent;
|
|
5721
5821
|
|
|
5722
5822
|
this._addBranchSeparator();
|
|
5723
5823
|
|
|
5724
|
-
if( options.closed )
|
|
5824
|
+
if( options.closed )
|
|
5825
|
+
{
|
|
5725
5826
|
title.className += " closed";
|
|
5726
5827
|
root.className += " closed";
|
|
5727
5828
|
this.grabber.setAttribute('hidden', true);
|
|
5728
5829
|
doAsync( () => {
|
|
5729
|
-
this.content.setAttribute('hidden', true);
|
|
5730
|
-
}, 15);
|
|
5830
|
+
this.content.setAttribute( 'hidden', true );
|
|
5831
|
+
}, 15 );
|
|
5731
5832
|
}
|
|
5732
5833
|
|
|
5733
|
-
this.onclick = function(e){
|
|
5834
|
+
this.onclick = function( e ) {
|
|
5734
5835
|
e.stopPropagation();
|
|
5735
|
-
this.classList.toggle('closed');
|
|
5736
|
-
this.parentElement.classList.toggle('closed');
|
|
5836
|
+
this.classList.toggle( 'closed' );
|
|
5837
|
+
this.parentElement.classList.toggle( 'closed' );
|
|
5737
5838
|
|
|
5738
|
-
that.content.toggleAttribute('hidden');
|
|
5739
|
-
that.grabber.toggleAttribute('hidden');
|
|
5839
|
+
that.content.toggleAttribute( 'hidden' );
|
|
5840
|
+
that.grabber.toggleAttribute( 'hidden' );
|
|
5740
5841
|
|
|
5741
|
-
LX.emit("@on_branch_closed", this.classList.contains("closed"), that.panel);
|
|
5842
|
+
LX.emit( "@on_branch_closed", this.classList.contains("closed"), { target: that.panel } );
|
|
5742
5843
|
};
|
|
5743
5844
|
|
|
5744
|
-
this.oncontextmenu = function(e) {
|
|
5845
|
+
this.oncontextmenu = function( e ) {
|
|
5745
5846
|
|
|
5746
5847
|
e.preventDefault();
|
|
5747
5848
|
e.stopPropagation();
|
|
5748
5849
|
|
|
5749
5850
|
if( this.parentElement.classList.contains("dialog") )
|
|
5750
|
-
|
|
5751
|
-
|
|
5851
|
+
{
|
|
5852
|
+
return;
|
|
5853
|
+
}
|
|
5854
|
+
|
|
5752
5855
|
addContextMenu("Dock", e, p => {
|
|
5753
5856
|
e.preventDefault();
|
|
5754
5857
|
// p.add('<i class="fa-regular fa-window-maximize">', {id: 'dock_options0'});
|
|
5755
5858
|
// p.add('<i class="fa-regular fa-window-maximize fa-rotate-180">', {id: 'dock_options1'});
|
|
5756
5859
|
// p.add('<i class="fa-regular fa-window-maximize fa-rotate-90">', {id: 'dock_options2'});
|
|
5757
5860
|
// p.add('<i class="fa-regular fa-window-maximize fa-rotate-270">', {id: 'dock_options3'});
|
|
5758
|
-
p.add('Floating', that._on_make_floating.bind(that));
|
|
5861
|
+
p.add( 'Floating', that._on_make_floating.bind( that ) );
|
|
5759
5862
|
}, { icon: "fa-regular fa-window-restore" });
|
|
5760
5863
|
};
|
|
5761
5864
|
|
|
5762
|
-
title.addEventListener(
|
|
5763
|
-
title.addEventListener(
|
|
5865
|
+
title.addEventListener( 'click', this.onclick );
|
|
5866
|
+
title.addEventListener( 'contextmenu', this.oncontextmenu );
|
|
5764
5867
|
}
|
|
5765
5868
|
|
|
5766
5869
|
_on_make_floating() {
|