lexgui 0.1.40 → 0.1.41
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/components/audio.js +63 -26
- package/build/components/codeeditor.js +4 -4
- package/build/components/imui.js +1 -1
- package/build/components/nodegraph.js +2 -2
- package/build/components/timeline.js +61 -54
- package/build/lexgui.css +43 -0
- package/build/lexgui.js +173 -120
- package/build/lexgui.module.js +175 -121
- package/changelog.md +14 -2
- package/demo.js +5 -3
- package/examples/asset_view.html +10 -7
- 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.41",
|
|
16
16
|
ready: false,
|
|
17
17
|
components: [], // specific pre-build components
|
|
18
18
|
signals: {} // events and triggers
|
|
@@ -2823,7 +2823,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
2823
2823
|
let isParent = node.children.length > 0;
|
|
2824
2824
|
let isSelected = this.selected.indexOf( node ) > -1;
|
|
2825
2825
|
|
|
2826
|
-
if( this.options.
|
|
2826
|
+
if( this.options.onlyFolders )
|
|
2827
2827
|
{
|
|
2828
2828
|
let has_folders = false;
|
|
2829
2829
|
node.children.forEach( c => has_folders |= (c.type == 'folder') );
|
|
@@ -3202,7 +3202,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
3202
3202
|
{
|
|
3203
3203
|
let child = node.children[i];
|
|
3204
3204
|
|
|
3205
|
-
if( this.options.
|
|
3205
|
+
if( this.options.onlyFolders && child.type != 'folder')
|
|
3206
3206
|
continue;
|
|
3207
3207
|
|
|
3208
3208
|
this._create_item( node, child, level + 1 );
|
|
@@ -7614,12 +7614,12 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
7614
7614
|
this.layout = options.layout ?? AssetView.LAYOUT_CONTENT;
|
|
7615
7615
|
this.contentPage = 1;
|
|
7616
7616
|
|
|
7617
|
-
if(options.
|
|
7617
|
+
if( options.rootPath )
|
|
7618
7618
|
{
|
|
7619
|
-
if(options.
|
|
7619
|
+
if(options.rootPath.constructor !== String)
|
|
7620
7620
|
console.warn("Asset Root Path must be a String (now is " + path.constructor.name + ")");
|
|
7621
7621
|
else
|
|
7622
|
-
this.rootPath = options.
|
|
7622
|
+
this.rootPath = options.rootPath;
|
|
7623
7623
|
}
|
|
7624
7624
|
|
|
7625
7625
|
let div = document.createElement('div');
|
|
@@ -7631,13 +7631,13 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
7631
7631
|
|
|
7632
7632
|
let left, right, contentArea = area;
|
|
7633
7633
|
|
|
7634
|
-
this.
|
|
7635
|
-
this.
|
|
7636
|
-
this.
|
|
7637
|
-
this.
|
|
7638
|
-
this.
|
|
7634
|
+
this.skipBrowser = options.skipBrowser ?? false;
|
|
7635
|
+
this.skipPreview = options.skipPreview ?? false;
|
|
7636
|
+
this.onlyFolders = options.onlyFolders ?? true;
|
|
7637
|
+
this.previewActions = options.previewActions ?? [];
|
|
7638
|
+
this.contextMenu = options.contextMenu ?? [];
|
|
7639
7639
|
|
|
7640
|
-
if( !this.
|
|
7640
|
+
if( !this.skipBrowser )
|
|
7641
7641
|
{
|
|
7642
7642
|
[left, right] = area.split({ type: "horizontal", sizes: ["15%", "85%"]});
|
|
7643
7643
|
contentArea = right;
|
|
@@ -7646,28 +7646,34 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
7646
7646
|
right.setLimitBox( 512, 0 );
|
|
7647
7647
|
}
|
|
7648
7648
|
|
|
7649
|
-
if( !this.
|
|
7650
|
-
|
|
7649
|
+
if( !this.skipPreview )
|
|
7650
|
+
{
|
|
7651
|
+
[ contentArea, right ] = contentArea.split({ type: "horizontal", sizes: ["80%", "20%"]});
|
|
7652
|
+
}
|
|
7651
7653
|
|
|
7652
|
-
this.allowedTypes = options.
|
|
7654
|
+
this.allowedTypes = options.allowedTypes || ["None", "Image", "Mesh", "Script", "JSON", "Clip"];
|
|
7653
7655
|
|
|
7654
7656
|
this.prevData = [];
|
|
7655
7657
|
this.nextData = [];
|
|
7656
7658
|
this.data = [];
|
|
7657
7659
|
|
|
7658
|
-
this._processData(this.data, null);
|
|
7660
|
+
this._processData( this.data, null );
|
|
7659
7661
|
|
|
7660
7662
|
this.currentData = this.data;
|
|
7661
7663
|
this.path = ['@'];
|
|
7662
7664
|
|
|
7663
|
-
if(!this.
|
|
7664
|
-
|
|
7665
|
+
if( !this.skipBrowser )
|
|
7666
|
+
{
|
|
7667
|
+
this._createTreePanel( left );
|
|
7668
|
+
}
|
|
7665
7669
|
|
|
7666
|
-
this._createContentPanel(contentArea);
|
|
7670
|
+
this._createContentPanel( contentArea );
|
|
7667
7671
|
|
|
7668
7672
|
// Create resource preview panel
|
|
7669
|
-
if( !this.
|
|
7670
|
-
|
|
7673
|
+
if( !this.skipPreview )
|
|
7674
|
+
{
|
|
7675
|
+
this.previewPanel = right.addPanel( {className: 'lexassetcontentpanel', style: { overflow: 'scroll' }} );
|
|
7676
|
+
}
|
|
7671
7677
|
}
|
|
7672
7678
|
|
|
7673
7679
|
/**
|
|
@@ -7681,12 +7687,15 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
7681
7687
|
|
|
7682
7688
|
this.data = data;
|
|
7683
7689
|
|
|
7684
|
-
this._processData(this.data, null);
|
|
7690
|
+
this._processData( this.data, null );
|
|
7685
7691
|
this.currentData = this.data;
|
|
7686
|
-
this.path = ['@'];
|
|
7692
|
+
this.path = [ '@' ];
|
|
7693
|
+
|
|
7694
|
+
if( !this.skipBrowser )
|
|
7695
|
+
{
|
|
7696
|
+
this._createTreePanel( this.area );
|
|
7697
|
+
}
|
|
7687
7698
|
|
|
7688
|
-
if(!this.skip_browser)
|
|
7689
|
-
this._createTreePanel(this.area);
|
|
7690
7699
|
this._refreshContent();
|
|
7691
7700
|
|
|
7692
7701
|
this.onevent = onevent;
|
|
@@ -7696,12 +7705,18 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
7696
7705
|
* @method clear
|
|
7697
7706
|
*/
|
|
7698
7707
|
clear() {
|
|
7699
|
-
if(this.previewPanel)
|
|
7708
|
+
if( this.previewPanel )
|
|
7709
|
+
{
|
|
7700
7710
|
this.previewPanel.clear();
|
|
7701
|
-
|
|
7711
|
+
}
|
|
7712
|
+
if( this.leftPanel )
|
|
7713
|
+
{
|
|
7702
7714
|
this.leftPanel.clear();
|
|
7703
|
-
|
|
7704
|
-
|
|
7715
|
+
}
|
|
7716
|
+
if( this.rightPanel )
|
|
7717
|
+
{
|
|
7718
|
+
this.rightPanel.clear()
|
|
7719
|
+
}
|
|
7705
7720
|
}
|
|
7706
7721
|
|
|
7707
7722
|
/**
|
|
@@ -7712,14 +7727,16 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
7712
7727
|
|
|
7713
7728
|
if( data.constructor !== Array )
|
|
7714
7729
|
{
|
|
7715
|
-
data['folder'] = parent;
|
|
7730
|
+
data[ 'folder' ] = parent;
|
|
7716
7731
|
data.children = data.children ?? [];
|
|
7717
7732
|
}
|
|
7718
7733
|
|
|
7719
7734
|
let list = data.constructor === Array ? data : data.children;
|
|
7720
7735
|
|
|
7721
7736
|
for( var i = 0; i < list.length; ++i )
|
|
7722
|
-
|
|
7737
|
+
{
|
|
7738
|
+
this._processData( list[ i ], data );
|
|
7739
|
+
}
|
|
7723
7740
|
}
|
|
7724
7741
|
|
|
7725
7742
|
/**
|
|
@@ -7731,9 +7748,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
7731
7748
|
this.path.length = 0;
|
|
7732
7749
|
|
|
7733
7750
|
const push_parents_id = i => {
|
|
7734
|
-
if(!i) return;
|
|
7751
|
+
if( !i ) return;
|
|
7735
7752
|
let list = i.children ? i.children : i;
|
|
7736
|
-
let c = list[0];
|
|
7753
|
+
let c = list[ 0 ];
|
|
7737
7754
|
if( !c ) return;
|
|
7738
7755
|
if( !c.folder ) return;
|
|
7739
7756
|
this.path.push( c.folder.id ?? '@' );
|
|
@@ -7742,19 +7759,22 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
7742
7759
|
|
|
7743
7760
|
push_parents_id( data );
|
|
7744
7761
|
|
|
7745
|
-
LX.emit("@on_folder_change", this.path.reverse().join('/'));
|
|
7762
|
+
LX.emit( "@on_folder_change", this.path.reverse().join('/') );
|
|
7746
7763
|
}
|
|
7747
7764
|
|
|
7748
7765
|
/**
|
|
7749
7766
|
* @method _createTreePanel
|
|
7750
7767
|
*/
|
|
7751
7768
|
|
|
7752
|
-
_createTreePanel(area) {
|
|
7769
|
+
_createTreePanel( area ) {
|
|
7753
7770
|
|
|
7754
7771
|
if(this.leftPanel)
|
|
7772
|
+
{
|
|
7755
7773
|
this.leftPanel.clear();
|
|
7756
|
-
|
|
7757
|
-
|
|
7774
|
+
}
|
|
7775
|
+
else
|
|
7776
|
+
{
|
|
7777
|
+
this.leftPanel = area.addPanel({ className: 'lexassetbrowserpanel' });
|
|
7758
7778
|
}
|
|
7759
7779
|
|
|
7760
7780
|
// Process data to show in tree
|
|
@@ -7766,18 +7786,21 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
7766
7786
|
this.tree = this.leftPanel.addTree("Content Browser", treeData, {
|
|
7767
7787
|
// icons: tree_icons,
|
|
7768
7788
|
filter: false,
|
|
7769
|
-
|
|
7770
|
-
onevent:
|
|
7789
|
+
onlyFolders: this.onlyFolders,
|
|
7790
|
+
onevent: event => {
|
|
7771
7791
|
|
|
7772
7792
|
let node = event.node;
|
|
7773
7793
|
let value = event.value;
|
|
7774
7794
|
|
|
7775
|
-
switch(event.type)
|
|
7795
|
+
switch( event.type )
|
|
7796
|
+
{
|
|
7776
7797
|
case LX.TreeEvent.NODE_SELECTED:
|
|
7777
|
-
if(!event.multiple)
|
|
7798
|
+
if( !event.multiple )
|
|
7799
|
+
{
|
|
7778
7800
|
this._enterFolder( node );
|
|
7779
7801
|
}
|
|
7780
|
-
if(!node.parent)
|
|
7802
|
+
if( !node.parent )
|
|
7803
|
+
{
|
|
7781
7804
|
this.prevData.push( this.currentData );
|
|
7782
7805
|
this.currentData = this.data;
|
|
7783
7806
|
this._refreshContent();
|
|
@@ -7799,9 +7822,9 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
7799
7822
|
* @method _setContentLayout
|
|
7800
7823
|
*/
|
|
7801
7824
|
|
|
7802
|
-
_setContentLayout(
|
|
7825
|
+
_setContentLayout( layoutMode ) {
|
|
7803
7826
|
|
|
7804
|
-
this.layout =
|
|
7827
|
+
this.layout = layoutMode;
|
|
7805
7828
|
|
|
7806
7829
|
this._refreshContent();
|
|
7807
7830
|
}
|
|
@@ -7810,12 +7833,15 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
7810
7833
|
* @method _createContentPanel
|
|
7811
7834
|
*/
|
|
7812
7835
|
|
|
7813
|
-
_createContentPanel(area) {
|
|
7836
|
+
_createContentPanel( area ) {
|
|
7814
7837
|
|
|
7815
|
-
if(this.rightPanel)
|
|
7838
|
+
if( this.rightPanel )
|
|
7839
|
+
{
|
|
7816
7840
|
this.rightPanel.clear();
|
|
7817
|
-
|
|
7818
|
-
|
|
7841
|
+
}
|
|
7842
|
+
else
|
|
7843
|
+
{
|
|
7844
|
+
this.rightPanel = area.addPanel({ className: 'lexassetcontentpanel' });
|
|
7819
7845
|
}
|
|
7820
7846
|
|
|
7821
7847
|
const on_sort = (value, event) => {
|
|
@@ -7843,20 +7869,24 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
7843
7869
|
}
|
|
7844
7870
|
|
|
7845
7871
|
const on_change_page = (value, event) => {
|
|
7846
|
-
if(!this.
|
|
7872
|
+
if( !this.allowNextPage )
|
|
7873
|
+
{
|
|
7847
7874
|
return;
|
|
7848
|
-
|
|
7875
|
+
}
|
|
7876
|
+
const lastPage = this.contentPage;
|
|
7849
7877
|
this.contentPage += value;
|
|
7850
7878
|
this.contentPage = Math.min( this.contentPage, (((this.currentData.length - 1) / AssetView.MAX_PAGE_ELEMENTS )|0) + 1 );
|
|
7851
7879
|
this.contentPage = Math.max( this.contentPage, 1 );
|
|
7852
7880
|
|
|
7853
|
-
if(
|
|
7881
|
+
if( lastPage != this.contentPage )
|
|
7882
|
+
{
|
|
7854
7883
|
this._refreshContent();
|
|
7884
|
+
}
|
|
7855
7885
|
}
|
|
7856
7886
|
|
|
7857
7887
|
this.rightPanel.sameLine();
|
|
7858
7888
|
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.
|
|
7889
|
+
this.rightPanel.addText(null, this.searchValue ?? "", (v) => this._refreshContent.call(this, v, null), { placeholder: "Search assets.." });
|
|
7860
7890
|
this.rightPanel.addButton(null, "<a class='fa fa-arrow-up-short-wide'></a>", on_sort.bind(this), { className: "micro", title: "Sort" });
|
|
7861
7891
|
this.rightPanel.addButton(null, "<a class='fa-solid fa-grip'></a>", on_change_view.bind(this), { className: "micro", title: "View" });
|
|
7862
7892
|
// Content Pages
|
|
@@ -7864,7 +7894,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
7864
7894
|
this.rightPanel.addButton(null, "<a class='fa-solid fa-angles-right'></a>", on_change_page.bind(this, 1), { className: "micro", title: "Next Page" });
|
|
7865
7895
|
this.rightPanel.endLine();
|
|
7866
7896
|
|
|
7867
|
-
if( !this.
|
|
7897
|
+
if( !this.skipBrowser )
|
|
7868
7898
|
{
|
|
7869
7899
|
this.rightPanel.sameLine();
|
|
7870
7900
|
this.rightPanel.addComboButtons( null, [
|
|
@@ -7924,27 +7954,27 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
7924
7954
|
this._refreshContent();
|
|
7925
7955
|
}
|
|
7926
7956
|
|
|
7927
|
-
_refreshContent(
|
|
7957
|
+
_refreshContent( searchValue, filter ) {
|
|
7928
7958
|
|
|
7929
|
-
const
|
|
7959
|
+
const isContentLayout = (this.layout == AssetView.LAYOUT_CONTENT); // default
|
|
7930
7960
|
|
|
7931
7961
|
this.filter = filter ?? (this.filter ?? "None");
|
|
7932
|
-
this.
|
|
7962
|
+
this.searchValue = searchValue ?? (this.searchValue ?? "");
|
|
7933
7963
|
this.content.innerHTML = "";
|
|
7934
|
-
this.content.className = (
|
|
7964
|
+
this.content.className = (isContentLayout ? "lexassetscontent" : "lexassetscontent list");
|
|
7935
7965
|
let that = this;
|
|
7936
7966
|
|
|
7937
7967
|
const add_item = function(item) {
|
|
7938
7968
|
|
|
7939
|
-
const type = item.type.charAt(0).toUpperCase() + item.type.slice(1);
|
|
7969
|
+
const type = item.type.charAt( 0 ).toUpperCase() + item.type.slice( 1 );
|
|
7940
7970
|
const extension = getExtension( item.id );
|
|
7941
|
-
const
|
|
7971
|
+
const isFolder = type === "Folder";
|
|
7942
7972
|
|
|
7943
7973
|
let itemEl = document.createElement('li');
|
|
7944
7974
|
itemEl.className = "lexassetitem " + item.type.toLowerCase();
|
|
7945
7975
|
itemEl.title = type + ": " + item.id;
|
|
7946
7976
|
itemEl.tabIndex = -1;
|
|
7947
|
-
that.content.appendChild(itemEl);
|
|
7977
|
+
that.content.appendChild( itemEl );
|
|
7948
7978
|
|
|
7949
7979
|
if(item.selected != undefined) {
|
|
7950
7980
|
let span = document.createElement('span');
|
|
@@ -7953,9 +7983,10 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
7953
7983
|
checkbox_input.type = "checkbox";
|
|
7954
7984
|
checkbox_input.className = "checkbox";
|
|
7955
7985
|
checkbox_input.checked = item.selected;
|
|
7956
|
-
checkbox_input.addEventListener('change', (e, v) => {
|
|
7986
|
+
checkbox_input.addEventListener('change', ( e, v ) => {
|
|
7957
7987
|
item.selected = !item.selected;
|
|
7958
|
-
if(that.onevent)
|
|
7988
|
+
if( that.onevent )
|
|
7989
|
+
{
|
|
7959
7990
|
const event = new AssetViewEvent(AssetViewEvent.ASSET_CHECKED, e.shiftKey ? [item] : item );
|
|
7960
7991
|
event.multiple = !!e.shiftKey;
|
|
7961
7992
|
that.onevent( event );
|
|
@@ -7970,19 +8001,19 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
7970
8001
|
let title = document.createElement('span');
|
|
7971
8002
|
title.className = "lexassettitle";
|
|
7972
8003
|
title.innerText = item.id;
|
|
7973
|
-
itemEl.appendChild(title);
|
|
8004
|
+
itemEl.appendChild( title );
|
|
7974
8005
|
|
|
7975
|
-
if( !that.
|
|
8006
|
+
if( !that.skipPreview ) {
|
|
7976
8007
|
|
|
7977
8008
|
let preview = null;
|
|
7978
|
-
const
|
|
8009
|
+
const hasImage = item.src && (['png', 'jpg'].indexOf( getExtension( item.src ) ) > -1 || item.src.includes("data:image/") ); // Support b64 image as src
|
|
7979
8010
|
|
|
7980
|
-
if(
|
|
8011
|
+
if( hasImage || isFolder || !isContentLayout)
|
|
7981
8012
|
{
|
|
7982
8013
|
preview = document.createElement('img');
|
|
7983
|
-
let real_src = item.unknown_extension ? that.rootPath + "images/file.png" : (
|
|
7984
|
-
preview.src = (
|
|
7985
|
-
itemEl.appendChild(preview);
|
|
8014
|
+
let real_src = item.unknown_extension ? that.rootPath + "images/file.png" : (isFolder ? that.rootPath + "images/folder.png" : item.src);
|
|
8015
|
+
preview.src = (isContentLayout || isFolder ? real_src : that.rootPath + "images/file.png");
|
|
8016
|
+
itemEl.appendChild( preview );
|
|
7986
8017
|
}
|
|
7987
8018
|
else
|
|
7988
8019
|
{
|
|
@@ -8008,7 +8039,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
8008
8039
|
}
|
|
8009
8040
|
}
|
|
8010
8041
|
|
|
8011
|
-
if( !
|
|
8042
|
+
if( !isFolder )
|
|
8012
8043
|
{
|
|
8013
8044
|
let info = document.createElement('span');
|
|
8014
8045
|
info.className = "lexassetinfo";
|
|
@@ -8020,30 +8051,37 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
8020
8051
|
e.stopImmediatePropagation();
|
|
8021
8052
|
e.stopPropagation();
|
|
8022
8053
|
|
|
8023
|
-
const
|
|
8054
|
+
const isDoubleClick = ( e.detail == LX.MOUSE_DOUBLE_CLICK );
|
|
8024
8055
|
|
|
8025
|
-
if(!
|
|
8056
|
+
if( !isDoubleClick )
|
|
8026
8057
|
{
|
|
8027
|
-
if(!e.shiftKey)
|
|
8058
|
+
if( !e.shiftKey )
|
|
8059
|
+
{
|
|
8028
8060
|
that.content.querySelectorAll('.lexassetitem').forEach( i => i.classList.remove('selected') );
|
|
8061
|
+
}
|
|
8062
|
+
|
|
8029
8063
|
this.classList.add('selected');
|
|
8030
|
-
|
|
8064
|
+
|
|
8065
|
+
if( !that.skipPreview )
|
|
8066
|
+
{
|
|
8031
8067
|
that._previewAsset( item );
|
|
8068
|
+
}
|
|
8032
8069
|
}
|
|
8033
|
-
else if(
|
|
8070
|
+
else if( isFolder )
|
|
8034
8071
|
{
|
|
8035
8072
|
that._enterFolder( item );
|
|
8036
8073
|
return;
|
|
8037
8074
|
}
|
|
8038
8075
|
|
|
8039
|
-
if(that.onevent)
|
|
8040
|
-
|
|
8076
|
+
if( that.onevent )
|
|
8077
|
+
{
|
|
8078
|
+
const event = new AssetViewEvent(isDoubleClick ? AssetViewEvent.ASSET_DBLCLICKED : AssetViewEvent.ASSET_SELECTED, e.shiftKey ? [item] : item );
|
|
8041
8079
|
event.multiple = !!e.shiftKey;
|
|
8042
8080
|
that.onevent( event );
|
|
8043
8081
|
}
|
|
8044
8082
|
});
|
|
8045
8083
|
|
|
8046
|
-
if( that.
|
|
8084
|
+
if( that.contextMenu )
|
|
8047
8085
|
{
|
|
8048
8086
|
itemEl.addEventListener('contextmenu', function(e) {
|
|
8049
8087
|
e.preventDefault();
|
|
@@ -8051,10 +8089,10 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
8051
8089
|
const multiple = that.content.querySelectorAll('.selected').length;
|
|
8052
8090
|
|
|
8053
8091
|
LX.addContextMenu( multiple > 1 ? (multiple + " selected") :
|
|
8054
|
-
|
|
8092
|
+
isFolder ? item.id : item.type, e, m => {
|
|
8055
8093
|
if(multiple <= 1)
|
|
8056
8094
|
m.add("Rename");
|
|
8057
|
-
if( !
|
|
8095
|
+
if( !isFolder )
|
|
8058
8096
|
m.add("Clone", that._clone_item.bind(that, item));
|
|
8059
8097
|
if(multiple <= 1)
|
|
8060
8098
|
m.add("Properties");
|
|
@@ -8073,21 +8111,23 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
8073
8111
|
|
|
8074
8112
|
const fr = new FileReader();
|
|
8075
8113
|
|
|
8076
|
-
const
|
|
8114
|
+
const filteredData = this.currentData.filter( _i => {
|
|
8077
8115
|
return (this.filter != "None" ? _i.type.toLowerCase() == this.filter.toLowerCase() : true) &&
|
|
8078
|
-
_i.id.toLowerCase().includes(this.
|
|
8116
|
+
_i.id.toLowerCase().includes(this.searchValue.toLowerCase())
|
|
8079
8117
|
} );
|
|
8080
8118
|
|
|
8081
|
-
if(filter ||
|
|
8119
|
+
if( filter || searchValue )
|
|
8120
|
+
{
|
|
8082
8121
|
this.contentPage = 1;
|
|
8083
8122
|
}
|
|
8123
|
+
|
|
8084
8124
|
// Show all data if using filters
|
|
8085
|
-
const
|
|
8086
|
-
const
|
|
8125
|
+
const startIndex = (this.contentPage - 1) * AssetView.MAX_PAGE_ELEMENTS;
|
|
8126
|
+
const endIndex = Math.min( startIndex + AssetView.MAX_PAGE_ELEMENTS, filteredData.length );
|
|
8087
8127
|
|
|
8088
|
-
for( let i =
|
|
8128
|
+
for( let i = startIndex; i < endIndex; ++i )
|
|
8089
8129
|
{
|
|
8090
|
-
let item =
|
|
8130
|
+
let item = filteredData[ i ];
|
|
8091
8131
|
|
|
8092
8132
|
if( item.path )
|
|
8093
8133
|
{
|
|
@@ -8098,7 +8138,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
8098
8138
|
item.src = e.currentTarget.result; // This is a base64 string...
|
|
8099
8139
|
item._path = item.path;
|
|
8100
8140
|
delete item.path;
|
|
8101
|
-
this._refreshContent(
|
|
8141
|
+
this._refreshContent( searchValue, filter );
|
|
8102
8142
|
};
|
|
8103
8143
|
} });
|
|
8104
8144
|
}else
|
|
@@ -8106,15 +8146,15 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
8106
8146
|
item.domEl = add_item( item );
|
|
8107
8147
|
}
|
|
8108
8148
|
}
|
|
8109
|
-
this.
|
|
8110
|
-
LX.emit("@on_page_change", "Page " + this.contentPage + " / " + ((((
|
|
8149
|
+
this.allowNextPage = filteredData.length - 1 > AssetView.MAX_PAGE_ELEMENTS;
|
|
8150
|
+
LX.emit("@on_page_change", "Page " + this.contentPage + " / " + ((((filteredData.length - 1) / AssetView.MAX_PAGE_ELEMENTS )|0) + 1));
|
|
8111
8151
|
}
|
|
8112
8152
|
|
|
8113
8153
|
/**
|
|
8114
8154
|
* @method _previewAsset
|
|
8115
8155
|
*/
|
|
8116
8156
|
|
|
8117
|
-
_previewAsset(file) {
|
|
8157
|
+
_previewAsset( file ) {
|
|
8118
8158
|
|
|
8119
8159
|
const is_base_64 = file.src && file.src.includes("data:image/");
|
|
8120
8160
|
|
|
@@ -8123,34 +8163,37 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
8123
8163
|
|
|
8124
8164
|
if( file.type == 'image' || file.src )
|
|
8125
8165
|
{
|
|
8126
|
-
const
|
|
8127
|
-
if(
|
|
8128
|
-
|
|
8166
|
+
const hasImage = ['png', 'jpg'].indexOf( getExtension( file.src ) ) > -1 || is_base_64;
|
|
8167
|
+
if( hasImage )
|
|
8168
|
+
{
|
|
8169
|
+
this.previewPanel.addImage( file.src, { style: { width: "100%" } } );
|
|
8170
|
+
}
|
|
8129
8171
|
}
|
|
8130
8172
|
|
|
8131
8173
|
const options = { disabled: true };
|
|
8132
8174
|
|
|
8133
8175
|
this.previewPanel.addText("Filename", file.id, null, options);
|
|
8134
|
-
if(
|
|
8176
|
+
if( file.lastModified ) this.previewPanel.addText("Last Modified", new Date( file.lastModified ).toLocaleString(), null, options);
|
|
8177
|
+
if( file._path || file.src ) this.previewPanel.addText("URL", file._path ? file._path : file.src, null, options);
|
|
8135
8178
|
this.previewPanel.addText("Path", this.path.join('/'), null, options);
|
|
8136
8179
|
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);
|
|
8180
|
+
if( file.bytesize ) this.previewPanel.addText("Size", (file.bytesize/1024).toPrecision(3) + " KBs", null, options);
|
|
8181
|
+
if( file.type == "folder" ) this.previewPanel.addText("Files", file.children ? file.children.length.toString() : "0", null, options);
|
|
8139
8182
|
|
|
8140
8183
|
this.previewPanel.addSeparator();
|
|
8141
8184
|
|
|
8142
|
-
const
|
|
8185
|
+
const previewActions = [...this.previewActions];
|
|
8143
8186
|
|
|
8144
|
-
if( !
|
|
8187
|
+
if( !previewActions.length )
|
|
8145
8188
|
{
|
|
8146
8189
|
// By default
|
|
8147
|
-
|
|
8190
|
+
previewActions.push({
|
|
8148
8191
|
name: 'Download',
|
|
8149
8192
|
callback: () => LX.downloadURL(file.src, file.id)
|
|
8150
8193
|
});
|
|
8151
8194
|
}
|
|
8152
8195
|
|
|
8153
|
-
for( let action of
|
|
8196
|
+
for( let action of previewActions )
|
|
8154
8197
|
{
|
|
8155
8198
|
if( action.type && action.type !== file.type || action.path && action.path !== this.path.join('/') )
|
|
8156
8199
|
continue;
|
|
@@ -8160,7 +8203,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
8160
8203
|
this.previewPanel.merge();
|
|
8161
8204
|
}
|
|
8162
8205
|
|
|
8163
|
-
_processDrop(e) {
|
|
8206
|
+
_processDrop( e ) {
|
|
8164
8207
|
|
|
8165
8208
|
const fr = new FileReader();
|
|
8166
8209
|
const num_files = e.dataTransfer.files.length;
|
|
@@ -8180,7 +8223,8 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
8180
8223
|
let item = {
|
|
8181
8224
|
"id": file.name,
|
|
8182
8225
|
"src": e.currentTarget.result,
|
|
8183
|
-
"extension": ext
|
|
8226
|
+
"extension": ext,
|
|
8227
|
+
"lastModified": file.lastModified
|
|
8184
8228
|
};
|
|
8185
8229
|
|
|
8186
8230
|
switch(ext)
|
|
@@ -8205,7 +8249,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
8205
8249
|
|
|
8206
8250
|
if(i == (num_files - 1)) {
|
|
8207
8251
|
this._refreshContent();
|
|
8208
|
-
if( !this.
|
|
8252
|
+
if( !this.skipBrowser )
|
|
8209
8253
|
this.tree.refresh();
|
|
8210
8254
|
}
|
|
8211
8255
|
};
|
|
@@ -8225,10 +8269,10 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
8225
8269
|
this._refreshContent();
|
|
8226
8270
|
}
|
|
8227
8271
|
|
|
8228
|
-
_enterFolder(
|
|
8272
|
+
_enterFolder( folderItem ) {
|
|
8229
8273
|
|
|
8230
8274
|
this.prevData.push( this.currentData );
|
|
8231
|
-
this.currentData =
|
|
8275
|
+
this.currentData = folderItem.children;
|
|
8232
8276
|
this.contentPage = 1;
|
|
8233
8277
|
this._refreshContent();
|
|
8234
8278
|
|
|
@@ -8236,27 +8280,33 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
8236
8280
|
this._updatePath(this.currentData);
|
|
8237
8281
|
|
|
8238
8282
|
// Trigger event
|
|
8239
|
-
if(this.onevent)
|
|
8240
|
-
|
|
8283
|
+
if( this.onevent )
|
|
8284
|
+
{
|
|
8285
|
+
const event = new AssetViewEvent( AssetViewEvent.ENTER_FOLDER, folderItem );
|
|
8241
8286
|
this.onevent( event );
|
|
8242
8287
|
}
|
|
8243
8288
|
}
|
|
8244
8289
|
|
|
8245
8290
|
_deleteItem( item ) {
|
|
8246
8291
|
|
|
8247
|
-
const idx = this.currentData.indexOf(item);
|
|
8248
|
-
if(idx
|
|
8249
|
-
|
|
8250
|
-
|
|
8292
|
+
const idx = this.currentData.indexOf( item );
|
|
8293
|
+
if(idx < 0)
|
|
8294
|
+
{
|
|
8295
|
+
console.error( "[AssetView Error] Cannot delete. Item not found." );
|
|
8296
|
+
return;
|
|
8297
|
+
}
|
|
8251
8298
|
|
|
8252
|
-
|
|
8253
|
-
|
|
8254
|
-
this.onevent( event );
|
|
8255
|
-
}
|
|
8299
|
+
this.currentData.splice( idx, 1 );
|
|
8300
|
+
this._refreshContent( this.searchValue, this.filter );
|
|
8256
8301
|
|
|
8257
|
-
|
|
8258
|
-
|
|
8302
|
+
if(this.onevent)
|
|
8303
|
+
{
|
|
8304
|
+
const event = new AssetViewEvent( AssetViewEvent.ASSET_DELETED, item );
|
|
8305
|
+
this.onevent( event );
|
|
8259
8306
|
}
|
|
8307
|
+
|
|
8308
|
+
this.tree.refresh();
|
|
8309
|
+
this._processData( this.data );
|
|
8260
8310
|
}
|
|
8261
8311
|
|
|
8262
8312
|
_cloneItem( item ) {
|
|
@@ -8267,7 +8317,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
8267
8317
|
delete item.folder;
|
|
8268
8318
|
const new_item = deepCopy( item );
|
|
8269
8319
|
this.currentData.splice(idx, 0, new_item);
|
|
8270
|
-
this._refreshContent(this.
|
|
8320
|
+
this._refreshContent(this.searchValue, this.filter);
|
|
8271
8321
|
|
|
8272
8322
|
if(this.onevent) {
|
|
8273
8323
|
const event = new AssetViewEvent(AssetViewEvent.ASSET_CLONED, item );
|
|
@@ -8534,6 +8584,10 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
8534
8584
|
return !!r.length;
|
|
8535
8585
|
}
|
|
8536
8586
|
|
|
8587
|
+
Element.prototype.addClass = function( className ) {
|
|
8588
|
+
if( className ) this.classList.add( className );
|
|
8589
|
+
}
|
|
8590
|
+
|
|
8537
8591
|
Element.prototype.getComputedSize = function() {
|
|
8538
8592
|
const cs = getComputedStyle( this );
|
|
8539
8593
|
return {
|
|
@@ -8546,7 +8600,6 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
|
|
|
8546
8600
|
getTime() { return new Date().getTime() },
|
|
8547
8601
|
compareThreshold( v, p, n, t ) { return Math.abs(v - p) >= t || Math.abs(v - n) >= t },
|
|
8548
8602
|
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
8603
|
uidGenerator: simple_guidGenerator,
|
|
8551
8604
|
deleteElement( el ) { if( el ) el.remove(); },
|
|
8552
8605
|
flushCss(element) {
|