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.module.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
var LX = {
|
|
11
|
-
version: "0.1.
|
|
11
|
+
version: "0.1.41",
|
|
12
12
|
ready: false,
|
|
13
13
|
components: [], // specific pre-build components
|
|
14
14
|
signals: {} // events and triggers
|
|
@@ -543,7 +543,8 @@ function init( options = { } )
|
|
|
543
543
|
var link = document.createElement( 'link' );
|
|
544
544
|
link.rel = 'stylesheet';
|
|
545
545
|
link.type = 'text/css';
|
|
546
|
-
link.
|
|
546
|
+
link.crossOrigin = 'anonymous';
|
|
547
|
+
link.href = 'https://use.fontawesome.com/releases/v6.7.2/css/all.css';
|
|
547
548
|
head.appendChild( link );
|
|
548
549
|
|
|
549
550
|
// Global vars
|
|
@@ -2821,7 +2822,7 @@ class NodeTree {
|
|
|
2821
2822
|
let isParent = node.children.length > 0;
|
|
2822
2823
|
let isSelected = this.selected.indexOf( node ) > -1 || node.selected;
|
|
2823
2824
|
|
|
2824
|
-
if( this.options.
|
|
2825
|
+
if( this.options.onlyFolders )
|
|
2825
2826
|
{
|
|
2826
2827
|
let has_folders = false;
|
|
2827
2828
|
node.children.forEach( c => has_folders |= (c.type == 'folder') );
|
|
@@ -3200,7 +3201,7 @@ class NodeTree {
|
|
|
3200
3201
|
{
|
|
3201
3202
|
let child = node.children[i];
|
|
3202
3203
|
|
|
3203
|
-
if( this.options.
|
|
3204
|
+
if( this.options.onlyFolders && child.type != 'folder')
|
|
3204
3205
|
continue;
|
|
3205
3206
|
|
|
3206
3207
|
this._create_item( node, child, level + 1 );
|
|
@@ -7620,12 +7621,12 @@ class AssetView {
|
|
|
7620
7621
|
this.layout = options.layout ?? AssetView.LAYOUT_CONTENT;
|
|
7621
7622
|
this.contentPage = 1;
|
|
7622
7623
|
|
|
7623
|
-
if(options.
|
|
7624
|
+
if( options.rootPath )
|
|
7624
7625
|
{
|
|
7625
|
-
if(options.
|
|
7626
|
+
if(options.rootPath.constructor !== String)
|
|
7626
7627
|
console.warn("Asset Root Path must be a String (now is " + path.constructor.name + ")");
|
|
7627
7628
|
else
|
|
7628
|
-
this.rootPath = options.
|
|
7629
|
+
this.rootPath = options.rootPath;
|
|
7629
7630
|
}
|
|
7630
7631
|
|
|
7631
7632
|
let div = document.createElement('div');
|
|
@@ -7637,13 +7638,13 @@ class AssetView {
|
|
|
7637
7638
|
|
|
7638
7639
|
let left, right, contentArea = area;
|
|
7639
7640
|
|
|
7640
|
-
this.
|
|
7641
|
-
this.
|
|
7642
|
-
this.
|
|
7643
|
-
this.
|
|
7644
|
-
this.
|
|
7641
|
+
this.skipBrowser = options.skipBrowser ?? false;
|
|
7642
|
+
this.skipPreview = options.skipPreview ?? false;
|
|
7643
|
+
this.onlyFolders = options.onlyFolders ?? true;
|
|
7644
|
+
this.previewActions = options.previewActions ?? [];
|
|
7645
|
+
this.contextMenu = options.contextMenu ?? [];
|
|
7645
7646
|
|
|
7646
|
-
if( !this.
|
|
7647
|
+
if( !this.skipBrowser )
|
|
7647
7648
|
{
|
|
7648
7649
|
[left, right] = area.split({ type: "horizontal", sizes: ["15%", "85%"]});
|
|
7649
7650
|
contentArea = right;
|
|
@@ -7652,28 +7653,34 @@ class AssetView {
|
|
|
7652
7653
|
right.setLimitBox( 512, 0 );
|
|
7653
7654
|
}
|
|
7654
7655
|
|
|
7655
|
-
if( !this.
|
|
7656
|
-
|
|
7656
|
+
if( !this.skipPreview )
|
|
7657
|
+
{
|
|
7658
|
+
[ contentArea, right ] = contentArea.split({ type: "horizontal", sizes: ["80%", "20%"]});
|
|
7659
|
+
}
|
|
7657
7660
|
|
|
7658
|
-
this.allowedTypes = options.
|
|
7661
|
+
this.allowedTypes = options.allowedTypes || ["None", "Image", "Mesh", "Script", "JSON", "Clip"];
|
|
7659
7662
|
|
|
7660
7663
|
this.prevData = [];
|
|
7661
7664
|
this.nextData = [];
|
|
7662
7665
|
this.data = [];
|
|
7663
7666
|
|
|
7664
|
-
this._processData(this.data, null);
|
|
7667
|
+
this._processData( this.data, null );
|
|
7665
7668
|
|
|
7666
7669
|
this.currentData = this.data;
|
|
7667
7670
|
this.path = ['@'];
|
|
7668
7671
|
|
|
7669
|
-
if(!this.
|
|
7670
|
-
|
|
7672
|
+
if( !this.skipBrowser )
|
|
7673
|
+
{
|
|
7674
|
+
this._createTreePanel( left );
|
|
7675
|
+
}
|
|
7671
7676
|
|
|
7672
|
-
this._createContentPanel(contentArea);
|
|
7677
|
+
this._createContentPanel( contentArea );
|
|
7673
7678
|
|
|
7674
7679
|
// Create resource preview panel
|
|
7675
|
-
if( !this.
|
|
7676
|
-
|
|
7680
|
+
if( !this.skipPreview )
|
|
7681
|
+
{
|
|
7682
|
+
this.previewPanel = right.addPanel( {className: 'lexassetcontentpanel', style: { overflow: 'scroll' }} );
|
|
7683
|
+
}
|
|
7677
7684
|
}
|
|
7678
7685
|
|
|
7679
7686
|
/**
|
|
@@ -7687,12 +7694,15 @@ class AssetView {
|
|
|
7687
7694
|
|
|
7688
7695
|
this.data = data;
|
|
7689
7696
|
|
|
7690
|
-
this._processData(this.data, null);
|
|
7697
|
+
this._processData( this.data, null );
|
|
7691
7698
|
this.currentData = this.data;
|
|
7692
|
-
this.path = ['@'];
|
|
7699
|
+
this.path = [ '@' ];
|
|
7700
|
+
|
|
7701
|
+
if( !this.skipBrowser )
|
|
7702
|
+
{
|
|
7703
|
+
this._createTreePanel( this.area );
|
|
7704
|
+
}
|
|
7693
7705
|
|
|
7694
|
-
if(!this.skip_browser)
|
|
7695
|
-
this._createTreePanel(this.area);
|
|
7696
7706
|
this._refreshContent();
|
|
7697
7707
|
|
|
7698
7708
|
this.onevent = onevent;
|
|
@@ -7702,12 +7712,18 @@ class AssetView {
|
|
|
7702
7712
|
* @method clear
|
|
7703
7713
|
*/
|
|
7704
7714
|
clear() {
|
|
7705
|
-
if(this.previewPanel)
|
|
7715
|
+
if( this.previewPanel )
|
|
7716
|
+
{
|
|
7706
7717
|
this.previewPanel.clear();
|
|
7707
|
-
|
|
7718
|
+
}
|
|
7719
|
+
if( this.leftPanel )
|
|
7720
|
+
{
|
|
7708
7721
|
this.leftPanel.clear();
|
|
7709
|
-
|
|
7722
|
+
}
|
|
7723
|
+
if( this.rightPanel )
|
|
7724
|
+
{
|
|
7710
7725
|
this.rightPanel.clear()
|
|
7726
|
+
}
|
|
7711
7727
|
}
|
|
7712
7728
|
|
|
7713
7729
|
/**
|
|
@@ -7718,14 +7734,16 @@ class AssetView {
|
|
|
7718
7734
|
|
|
7719
7735
|
if( data.constructor !== Array )
|
|
7720
7736
|
{
|
|
7721
|
-
data['folder'] = parent;
|
|
7737
|
+
data[ 'folder' ] = parent;
|
|
7722
7738
|
data.children = data.children ?? [];
|
|
7723
7739
|
}
|
|
7724
7740
|
|
|
7725
7741
|
let list = data.constructor === Array ? data : data.children;
|
|
7726
7742
|
|
|
7727
7743
|
for( var i = 0; i < list.length; ++i )
|
|
7728
|
-
|
|
7744
|
+
{
|
|
7745
|
+
this._processData( list[ i ], data );
|
|
7746
|
+
}
|
|
7729
7747
|
}
|
|
7730
7748
|
|
|
7731
7749
|
/**
|
|
@@ -7737,9 +7755,9 @@ class AssetView {
|
|
|
7737
7755
|
this.path.length = 0;
|
|
7738
7756
|
|
|
7739
7757
|
const push_parents_id = i => {
|
|
7740
|
-
if(!i) return;
|
|
7758
|
+
if( !i ) return;
|
|
7741
7759
|
let list = i.children ? i.children : i;
|
|
7742
|
-
let c = list[0];
|
|
7760
|
+
let c = list[ 0 ];
|
|
7743
7761
|
if( !c ) return;
|
|
7744
7762
|
if( !c.folder ) return;
|
|
7745
7763
|
this.path.push( c.folder.id ?? '@' );
|
|
@@ -7748,19 +7766,22 @@ class AssetView {
|
|
|
7748
7766
|
|
|
7749
7767
|
push_parents_id( data );
|
|
7750
7768
|
|
|
7751
|
-
LX.emit("@on_folder_change", this.path.reverse().join('/'));
|
|
7769
|
+
LX.emit( "@on_folder_change", this.path.reverse().join('/') );
|
|
7752
7770
|
}
|
|
7753
7771
|
|
|
7754
7772
|
/**
|
|
7755
7773
|
* @method _createTreePanel
|
|
7756
7774
|
*/
|
|
7757
7775
|
|
|
7758
|
-
_createTreePanel(area) {
|
|
7776
|
+
_createTreePanel( area ) {
|
|
7759
7777
|
|
|
7760
|
-
if(this.leftPanel)
|
|
7778
|
+
if( this.leftPanel )
|
|
7779
|
+
{
|
|
7761
7780
|
this.leftPanel.clear();
|
|
7762
|
-
|
|
7763
|
-
|
|
7781
|
+
}
|
|
7782
|
+
else
|
|
7783
|
+
{
|
|
7784
|
+
this.leftPanel = area.addPanel({ className: 'lexassetbrowserpanel' });
|
|
7764
7785
|
}
|
|
7765
7786
|
|
|
7766
7787
|
// Process data to show in tree
|
|
@@ -7772,18 +7793,21 @@ class AssetView {
|
|
|
7772
7793
|
this.tree = this.leftPanel.addTree("Content Browser", tree_data, {
|
|
7773
7794
|
// icons: tree_icons,
|
|
7774
7795
|
filter: false,
|
|
7775
|
-
|
|
7776
|
-
onevent:
|
|
7796
|
+
onlyFolders: this.onlyFolders,
|
|
7797
|
+
onevent: event => {
|
|
7777
7798
|
|
|
7778
7799
|
let node = event.node;
|
|
7779
7800
|
let value = event.value;
|
|
7780
7801
|
|
|
7781
|
-
switch(event.type)
|
|
7802
|
+
switch( event.type )
|
|
7803
|
+
{
|
|
7782
7804
|
case LX.TreeEvent.NODE_SELECTED:
|
|
7783
|
-
if(!event.multiple)
|
|
7805
|
+
if( !event.multiple )
|
|
7806
|
+
{
|
|
7784
7807
|
this._enterFolder( node );
|
|
7785
7808
|
}
|
|
7786
|
-
if(!node.parent)
|
|
7809
|
+
if( !node.parent )
|
|
7810
|
+
{
|
|
7787
7811
|
this.prevData.push( this.currentData );
|
|
7788
7812
|
this.currentData = this.data;
|
|
7789
7813
|
this._refreshContent();
|
|
@@ -7805,9 +7829,9 @@ class AssetView {
|
|
|
7805
7829
|
* @method _setContentLayout
|
|
7806
7830
|
*/
|
|
7807
7831
|
|
|
7808
|
-
_setContentLayout(
|
|
7832
|
+
_setContentLayout( layoutMode ) {
|
|
7809
7833
|
|
|
7810
|
-
this.layout =
|
|
7834
|
+
this.layout = layoutMode;
|
|
7811
7835
|
|
|
7812
7836
|
this._refreshContent();
|
|
7813
7837
|
}
|
|
@@ -7816,12 +7840,15 @@ class AssetView {
|
|
|
7816
7840
|
* @method _createContentPanel
|
|
7817
7841
|
*/
|
|
7818
7842
|
|
|
7819
|
-
_createContentPanel(area) {
|
|
7843
|
+
_createContentPanel( area ) {
|
|
7820
7844
|
|
|
7821
|
-
if(this.rightPanel)
|
|
7845
|
+
if( this.rightPanel )
|
|
7846
|
+
{
|
|
7822
7847
|
this.rightPanel.clear();
|
|
7823
|
-
|
|
7824
|
-
|
|
7848
|
+
}
|
|
7849
|
+
else
|
|
7850
|
+
{
|
|
7851
|
+
this.rightPanel = area.addPanel({ className: 'lexassetcontentpanel' });
|
|
7825
7852
|
}
|
|
7826
7853
|
|
|
7827
7854
|
const on_sort = (value, event) => {
|
|
@@ -7849,20 +7876,24 @@ class AssetView {
|
|
|
7849
7876
|
}
|
|
7850
7877
|
|
|
7851
7878
|
const on_change_page = (value, event) => {
|
|
7852
|
-
if(!this.
|
|
7879
|
+
if( !this.allowNextPage )
|
|
7880
|
+
{
|
|
7853
7881
|
return;
|
|
7854
|
-
|
|
7882
|
+
}
|
|
7883
|
+
const lastPage = this.contentPage;
|
|
7855
7884
|
this.contentPage += value;
|
|
7856
7885
|
this.contentPage = Math.min( this.contentPage, (((this.currentData.length - 1) / AssetView.MAX_PAGE_ELEMENTS )|0) + 1 );
|
|
7857
7886
|
this.contentPage = Math.max( this.contentPage, 1 );
|
|
7858
7887
|
|
|
7859
|
-
if(
|
|
7888
|
+
if( lastPage != this.contentPage )
|
|
7889
|
+
{
|
|
7860
7890
|
this._refreshContent();
|
|
7891
|
+
}
|
|
7861
7892
|
}
|
|
7862
7893
|
|
|
7863
7894
|
this.rightPanel.sameLine();
|
|
7864
7895
|
this.rightPanel.addDropdown("Filter", this.allowedTypes, this.allowedTypes[0], (v) => this._refreshContent.call(this, null, v), { width: "20%", minWidth: "128px" });
|
|
7865
|
-
this.rightPanel.addText(null, this.
|
|
7896
|
+
this.rightPanel.addText(null, this.searchValue ?? "", (v) => this._refreshContent.call(this, v, null), { placeholder: "Search assets.." });
|
|
7866
7897
|
this.rightPanel.addButton(null, "<a class='fa fa-arrow-up-short-wide'></a>", on_sort.bind(this), { className: "micro", title: "Sort" });
|
|
7867
7898
|
this.rightPanel.addButton(null, "<a class='fa-solid fa-grip'></a>", on_change_view.bind(this), { className: "micro", title: "View" });
|
|
7868
7899
|
// Content Pages
|
|
@@ -7870,7 +7901,7 @@ class AssetView {
|
|
|
7870
7901
|
this.rightPanel.addButton(null, "<a class='fa-solid fa-angles-right'></a>", on_change_page.bind(this, 1), { className: "micro", title: "Next Page" });
|
|
7871
7902
|
this.rightPanel.endLine();
|
|
7872
7903
|
|
|
7873
|
-
if( !this.
|
|
7904
|
+
if( !this.skipBrowser )
|
|
7874
7905
|
{
|
|
7875
7906
|
this.rightPanel.sameLine();
|
|
7876
7907
|
this.rightPanel.addComboButtons( null, [
|
|
@@ -7930,27 +7961,27 @@ class AssetView {
|
|
|
7930
7961
|
this._refreshContent();
|
|
7931
7962
|
}
|
|
7932
7963
|
|
|
7933
|
-
_refreshContent(
|
|
7964
|
+
_refreshContent( searchValue, filter ) {
|
|
7934
7965
|
|
|
7935
|
-
const
|
|
7966
|
+
const isContentLayout = (this.layout == AssetView.LAYOUT_CONTENT); // default
|
|
7936
7967
|
|
|
7937
7968
|
this.filter = filter ?? (this.filter ?? "None");
|
|
7938
|
-
this.
|
|
7969
|
+
this.searchValue = searchValue ?? (this.searchValue ?? "");
|
|
7939
7970
|
this.content.innerHTML = "";
|
|
7940
|
-
this.content.className = (
|
|
7971
|
+
this.content.className = (isContentLayout ? "lexassetscontent" : "lexassetscontent list");
|
|
7941
7972
|
let that = this;
|
|
7942
7973
|
|
|
7943
7974
|
const add_item = function(item) {
|
|
7944
7975
|
|
|
7945
|
-
const type = item.type.charAt(0).toUpperCase() + item.type.slice(1);
|
|
7976
|
+
const type = item.type.charAt( 0 ).toUpperCase() + item.type.slice( 1 );
|
|
7946
7977
|
const extension = getExtension( item.id );
|
|
7947
|
-
const
|
|
7978
|
+
const isFolder = type === "Folder";
|
|
7948
7979
|
|
|
7949
7980
|
let itemEl = document.createElement('li');
|
|
7950
7981
|
itemEl.className = "lexassetitem " + item.type.toLowerCase();
|
|
7951
7982
|
itemEl.title = type + ": " + item.id;
|
|
7952
7983
|
itemEl.tabIndex = -1;
|
|
7953
|
-
that.content.appendChild(itemEl);
|
|
7984
|
+
that.content.appendChild( itemEl );
|
|
7954
7985
|
|
|
7955
7986
|
if(item.selected != undefined) {
|
|
7956
7987
|
let span = document.createElement('span');
|
|
@@ -7959,9 +7990,10 @@ class AssetView {
|
|
|
7959
7990
|
checkbox_input.type = "checkbox";
|
|
7960
7991
|
checkbox_input.className = "checkbox";
|
|
7961
7992
|
checkbox_input.checked = item.selected;
|
|
7962
|
-
checkbox_input.addEventListener('change', (e, v) => {
|
|
7993
|
+
checkbox_input.addEventListener('change', ( e, v ) => {
|
|
7963
7994
|
item.selected = !item.selected;
|
|
7964
|
-
if(that.onevent)
|
|
7995
|
+
if( that.onevent )
|
|
7996
|
+
{
|
|
7965
7997
|
const event = new AssetViewEvent(AssetViewEvent.ASSET_CHECKED, e.shiftKey ? [item] : item );
|
|
7966
7998
|
event.multiple = !!e.shiftKey;
|
|
7967
7999
|
that.onevent( event );
|
|
@@ -7976,19 +8008,19 @@ class AssetView {
|
|
|
7976
8008
|
let title = document.createElement('span');
|
|
7977
8009
|
title.className = "lexassettitle";
|
|
7978
8010
|
title.innerText = item.id;
|
|
7979
|
-
itemEl.appendChild(title);
|
|
8011
|
+
itemEl.appendChild( title );
|
|
7980
8012
|
|
|
7981
|
-
if( !that.
|
|
8013
|
+
if( !that.skipPreview ) {
|
|
7982
8014
|
|
|
7983
8015
|
let preview = null;
|
|
7984
|
-
const
|
|
8016
|
+
const hasImage = item.src && (['png', 'jpg'].indexOf( getExtension( item.src ) ) > -1 || item.src.includes("data:image/") ); // Support b64 image as src
|
|
7985
8017
|
|
|
7986
|
-
if(
|
|
8018
|
+
if( hasImage || isFolder || !isContentLayout)
|
|
7987
8019
|
{
|
|
7988
8020
|
preview = document.createElement('img');
|
|
7989
|
-
let real_src = item.unknown_extension ? that.rootPath + "images/file.png" : (
|
|
7990
|
-
preview.src = (
|
|
7991
|
-
itemEl.appendChild(preview);
|
|
8021
|
+
let real_src = item.unknown_extension ? that.rootPath + "images/file.png" : (isFolder ? that.rootPath + "images/folder.png" : item.src);
|
|
8022
|
+
preview.src = (isContentLayout || isFolder ? real_src : that.rootPath + "images/file.png");
|
|
8023
|
+
itemEl.appendChild( preview );
|
|
7992
8024
|
}
|
|
7993
8025
|
else
|
|
7994
8026
|
{
|
|
@@ -8014,7 +8046,7 @@ class AssetView {
|
|
|
8014
8046
|
}
|
|
8015
8047
|
}
|
|
8016
8048
|
|
|
8017
|
-
if( !
|
|
8049
|
+
if( !isFolder )
|
|
8018
8050
|
{
|
|
8019
8051
|
let info = document.createElement('span');
|
|
8020
8052
|
info.className = "lexassetinfo";
|
|
@@ -8026,30 +8058,37 @@ class AssetView {
|
|
|
8026
8058
|
e.stopImmediatePropagation();
|
|
8027
8059
|
e.stopPropagation();
|
|
8028
8060
|
|
|
8029
|
-
const
|
|
8061
|
+
const isDoubleClick = ( e.detail == LX.MOUSE_DOUBLE_CLICK );
|
|
8030
8062
|
|
|
8031
|
-
if(!
|
|
8063
|
+
if( !isDoubleClick )
|
|
8032
8064
|
{
|
|
8033
|
-
if(!e.shiftKey)
|
|
8065
|
+
if( !e.shiftKey )
|
|
8066
|
+
{
|
|
8034
8067
|
that.content.querySelectorAll('.lexassetitem').forEach( i => i.classList.remove('selected') );
|
|
8068
|
+
}
|
|
8069
|
+
|
|
8035
8070
|
this.classList.add('selected');
|
|
8036
|
-
|
|
8071
|
+
|
|
8072
|
+
if( !that.skipPreview )
|
|
8073
|
+
{
|
|
8037
8074
|
that._previewAsset( item );
|
|
8075
|
+
}
|
|
8038
8076
|
}
|
|
8039
|
-
else if(
|
|
8077
|
+
else if( isFolder )
|
|
8040
8078
|
{
|
|
8041
8079
|
that._enterFolder( item );
|
|
8042
8080
|
return;
|
|
8043
8081
|
}
|
|
8044
8082
|
|
|
8045
|
-
if(that.onevent)
|
|
8046
|
-
|
|
8083
|
+
if( that.onevent )
|
|
8084
|
+
{
|
|
8085
|
+
const event = new AssetViewEvent(isDoubleClick ? AssetViewEvent.ASSET_DBLCLICKED : AssetViewEvent.ASSET_SELECTED, e.shiftKey ? [item] : item );
|
|
8047
8086
|
event.multiple = !!e.shiftKey;
|
|
8048
8087
|
that.onevent( event );
|
|
8049
8088
|
}
|
|
8050
8089
|
});
|
|
8051
8090
|
|
|
8052
|
-
if( that.
|
|
8091
|
+
if( that.contextMenu )
|
|
8053
8092
|
{
|
|
8054
8093
|
itemEl.addEventListener('contextmenu', function(e) {
|
|
8055
8094
|
e.preventDefault();
|
|
@@ -8057,10 +8096,10 @@ class AssetView {
|
|
|
8057
8096
|
const multiple = that.content.querySelectorAll('.selected').length;
|
|
8058
8097
|
|
|
8059
8098
|
LX.addContextMenu( multiple > 1 ? (multiple + " selected") :
|
|
8060
|
-
|
|
8099
|
+
isFolder ? item.id : item.type, e, m => {
|
|
8061
8100
|
if(multiple <= 1)
|
|
8062
8101
|
m.add("Rename");
|
|
8063
|
-
if( !
|
|
8102
|
+
if( !isFolder )
|
|
8064
8103
|
m.add("Clone", that._clone_item.bind(that, item));
|
|
8065
8104
|
if(multiple <= 1)
|
|
8066
8105
|
m.add("Properties");
|
|
@@ -8079,21 +8118,23 @@ class AssetView {
|
|
|
8079
8118
|
|
|
8080
8119
|
const fr = new FileReader();
|
|
8081
8120
|
|
|
8082
|
-
const
|
|
8121
|
+
const filteredData = this.currentData.filter( _i => {
|
|
8083
8122
|
return (this.filter != "None" ? _i.type.toLowerCase() == this.filter.toLowerCase() : true) &&
|
|
8084
|
-
_i.id.toLowerCase().includes(this.
|
|
8123
|
+
_i.id.toLowerCase().includes(this.searchValue.toLowerCase())
|
|
8085
8124
|
} );
|
|
8086
8125
|
|
|
8087
|
-
if(filter ||
|
|
8126
|
+
if( filter || searchValue )
|
|
8127
|
+
{
|
|
8088
8128
|
this.contentPage = 1;
|
|
8089
8129
|
}
|
|
8130
|
+
|
|
8090
8131
|
// Show all data if using filters
|
|
8091
|
-
const
|
|
8092
|
-
const
|
|
8132
|
+
const startIndex = (this.contentPage - 1) * AssetView.MAX_PAGE_ELEMENTS;
|
|
8133
|
+
const endIndex = Math.min( startIndex + AssetView.MAX_PAGE_ELEMENTS, filteredData.length );
|
|
8093
8134
|
|
|
8094
|
-
for( let i =
|
|
8135
|
+
for( let i = startIndex; i < endIndex; ++i )
|
|
8095
8136
|
{
|
|
8096
|
-
let item =
|
|
8137
|
+
let item = filteredData[ i ];
|
|
8097
8138
|
|
|
8098
8139
|
if( item.path )
|
|
8099
8140
|
{
|
|
@@ -8104,7 +8145,7 @@ class AssetView {
|
|
|
8104
8145
|
item.src = e.currentTarget.result; // This is a base64 string...
|
|
8105
8146
|
item._path = item.path;
|
|
8106
8147
|
delete item.path;
|
|
8107
|
-
this._refreshContent(
|
|
8148
|
+
this._refreshContent( searchValue, filter );
|
|
8108
8149
|
};
|
|
8109
8150
|
} });
|
|
8110
8151
|
}else
|
|
@@ -8112,15 +8153,15 @@ class AssetView {
|
|
|
8112
8153
|
item.domEl = add_item( item );
|
|
8113
8154
|
}
|
|
8114
8155
|
}
|
|
8115
|
-
this.
|
|
8116
|
-
LX.emit("@on_page_change", "Page " + this.contentPage + " / " + ((((
|
|
8156
|
+
this.allowNextPage = filteredData.length - 1 > AssetView.MAX_PAGE_ELEMENTS;
|
|
8157
|
+
LX.emit("@on_page_change", "Page " + this.contentPage + " / " + ((((filteredData.length - 1) / AssetView.MAX_PAGE_ELEMENTS )|0) + 1));
|
|
8117
8158
|
}
|
|
8118
8159
|
|
|
8119
8160
|
/**
|
|
8120
8161
|
* @method _previewAsset
|
|
8121
8162
|
*/
|
|
8122
8163
|
|
|
8123
|
-
_previewAsset(file) {
|
|
8164
|
+
_previewAsset( file ) {
|
|
8124
8165
|
|
|
8125
8166
|
const is_base_64 = file.src && file.src.includes("data:image/");
|
|
8126
8167
|
|
|
@@ -8129,34 +8170,37 @@ class AssetView {
|
|
|
8129
8170
|
|
|
8130
8171
|
if( file.type == 'image' || file.src )
|
|
8131
8172
|
{
|
|
8132
|
-
const
|
|
8133
|
-
if(
|
|
8134
|
-
|
|
8173
|
+
const hasImage = ['png', 'jpg'].indexOf( getExtension( file.src ) ) > -1 || is_base_64;
|
|
8174
|
+
if( hasImage )
|
|
8175
|
+
{
|
|
8176
|
+
this.previewPanel.addImage( file.src, { style: { width: "100%" } } );
|
|
8177
|
+
}
|
|
8135
8178
|
}
|
|
8136
8179
|
|
|
8137
8180
|
const options = { disabled: true };
|
|
8138
8181
|
|
|
8139
8182
|
this.previewPanel.addText("Filename", file.id, null, options);
|
|
8140
|
-
if(
|
|
8183
|
+
if( file.lastModified ) this.previewPanel.addText("Last Modified", new Date( file.lastModified ).toLocaleString(), null, options);
|
|
8184
|
+
if( file._path || file.src ) this.previewPanel.addText("URL", file._path ? file._path : file.src, null, options);
|
|
8141
8185
|
this.previewPanel.addText("Path", this.path.join('/'), null, options);
|
|
8142
8186
|
this.previewPanel.addText("Type", file.type, null, options);
|
|
8143
|
-
if(file.bytesize) this.previewPanel.addText("Size", (file.bytesize/1024).toPrecision(3) + " KBs", null, options);
|
|
8144
|
-
if(file.type == "folder") this.previewPanel.addText("Files", file.children ? file.children.length.toString() : "0", null, options);
|
|
8187
|
+
if( file.bytesize ) this.previewPanel.addText("Size", (file.bytesize/1024).toPrecision(3) + " KBs", null, options);
|
|
8188
|
+
if( file.type == "folder" ) this.previewPanel.addText("Files", file.children ? file.children.length.toString() : "0", null, options);
|
|
8145
8189
|
|
|
8146
8190
|
this.previewPanel.addSeparator();
|
|
8147
8191
|
|
|
8148
|
-
const
|
|
8192
|
+
const previewActions = [...this.previewActions];
|
|
8149
8193
|
|
|
8150
|
-
if( !
|
|
8194
|
+
if( !previewActions.length )
|
|
8151
8195
|
{
|
|
8152
8196
|
// By default
|
|
8153
|
-
|
|
8197
|
+
previewActions.push({
|
|
8154
8198
|
name: 'Download',
|
|
8155
8199
|
callback: () => LX.downloadURL(file.src, file.id)
|
|
8156
8200
|
});
|
|
8157
8201
|
}
|
|
8158
8202
|
|
|
8159
|
-
for( let action of
|
|
8203
|
+
for( let action of previewActions )
|
|
8160
8204
|
{
|
|
8161
8205
|
if( action.type && action.type !== file.type || action.path && action.path !== this.path.join('/') )
|
|
8162
8206
|
continue;
|
|
@@ -8166,7 +8210,7 @@ class AssetView {
|
|
|
8166
8210
|
this.previewPanel.merge();
|
|
8167
8211
|
}
|
|
8168
8212
|
|
|
8169
|
-
_processDrop(e) {
|
|
8213
|
+
_processDrop( e ) {
|
|
8170
8214
|
|
|
8171
8215
|
const fr = new FileReader();
|
|
8172
8216
|
const num_files = e.dataTransfer.files.length;
|
|
@@ -8186,7 +8230,8 @@ class AssetView {
|
|
|
8186
8230
|
let item = {
|
|
8187
8231
|
"id": file.name,
|
|
8188
8232
|
"src": e.currentTarget.result,
|
|
8189
|
-
"extension": ext
|
|
8233
|
+
"extension": ext,
|
|
8234
|
+
"lastModified": file.lastModified
|
|
8190
8235
|
};
|
|
8191
8236
|
|
|
8192
8237
|
switch(ext)
|
|
@@ -8211,7 +8256,7 @@ class AssetView {
|
|
|
8211
8256
|
|
|
8212
8257
|
if(i == (num_files - 1)) {
|
|
8213
8258
|
this._refreshContent();
|
|
8214
|
-
if( !this.
|
|
8259
|
+
if( !this.skipBrowser )
|
|
8215
8260
|
this.tree.refresh();
|
|
8216
8261
|
}
|
|
8217
8262
|
};
|
|
@@ -8231,10 +8276,10 @@ class AssetView {
|
|
|
8231
8276
|
this._refreshContent();
|
|
8232
8277
|
}
|
|
8233
8278
|
|
|
8234
|
-
_enterFolder(
|
|
8279
|
+
_enterFolder( folderItem ) {
|
|
8235
8280
|
|
|
8236
8281
|
this.prevData.push( this.currentData );
|
|
8237
|
-
this.currentData =
|
|
8282
|
+
this.currentData = folderItem.children;
|
|
8238
8283
|
this.contentPage = 1;
|
|
8239
8284
|
this._refreshContent();
|
|
8240
8285
|
|
|
@@ -8242,27 +8287,33 @@ class AssetView {
|
|
|
8242
8287
|
this._updatePath(this.currentData);
|
|
8243
8288
|
|
|
8244
8289
|
// Trigger event
|
|
8245
|
-
if(this.onevent)
|
|
8246
|
-
|
|
8290
|
+
if( this.onevent )
|
|
8291
|
+
{
|
|
8292
|
+
const event = new AssetViewEvent( AssetViewEvent.ENTER_FOLDER, folderItem );
|
|
8247
8293
|
this.onevent( event );
|
|
8248
8294
|
}
|
|
8249
8295
|
}
|
|
8250
8296
|
|
|
8251
8297
|
_deleteItem( item ) {
|
|
8252
8298
|
|
|
8253
|
-
const idx = this.currentData.indexOf(item);
|
|
8254
|
-
if(idx
|
|
8255
|
-
|
|
8256
|
-
|
|
8299
|
+
const idx = this.currentData.indexOf( item );
|
|
8300
|
+
if(idx < 0)
|
|
8301
|
+
{
|
|
8302
|
+
console.error( "[AssetView Error] Cannot delete. Item not found." );
|
|
8303
|
+
return;
|
|
8304
|
+
}
|
|
8257
8305
|
|
|
8258
|
-
|
|
8259
|
-
|
|
8260
|
-
this.onevent( event );
|
|
8261
|
-
}
|
|
8306
|
+
this.currentData.splice( idx, 1 );
|
|
8307
|
+
this._refreshContent( this.searchValue, this.filter );
|
|
8262
8308
|
|
|
8263
|
-
|
|
8264
|
-
|
|
8309
|
+
if(this.onevent)
|
|
8310
|
+
{
|
|
8311
|
+
const event = new AssetViewEvent( AssetViewEvent.ASSET_DELETED, item );
|
|
8312
|
+
this.onevent( event );
|
|
8265
8313
|
}
|
|
8314
|
+
|
|
8315
|
+
this.tree.refresh();
|
|
8316
|
+
this._processData( this.data );
|
|
8266
8317
|
}
|
|
8267
8318
|
|
|
8268
8319
|
_cloneItem( item ) {
|
|
@@ -8273,7 +8324,7 @@ class AssetView {
|
|
|
8273
8324
|
delete item.folder;
|
|
8274
8325
|
const new_item = deepCopy( item );
|
|
8275
8326
|
this.currentData.splice(idx, 0, new_item);
|
|
8276
|
-
this._refreshContent(this.
|
|
8327
|
+
this._refreshContent(this.searchValue, this.filter);
|
|
8277
8328
|
|
|
8278
8329
|
if(this.onevent) {
|
|
8279
8330
|
const event = new AssetViewEvent(AssetViewEvent.ASSET_CLONED, item );
|
|
@@ -8540,6 +8591,10 @@ Element.prototype.hasClass = function( list ) {
|
|
|
8540
8591
|
return !!r.length;
|
|
8541
8592
|
}
|
|
8542
8593
|
|
|
8594
|
+
Element.prototype.addClass = function( className ) {
|
|
8595
|
+
if( className ) this.classList.add( className );
|
|
8596
|
+
}
|
|
8597
|
+
|
|
8543
8598
|
Element.prototype.getComputedSize = function() {
|
|
8544
8599
|
const cs = getComputedStyle( this );
|
|
8545
8600
|
return {
|
|
@@ -8552,7 +8607,6 @@ LX.UTILS = {
|
|
|
8552
8607
|
getTime() { return new Date().getTime() },
|
|
8553
8608
|
compareThreshold( v, p, n, t ) { return Math.abs(v - p) >= t || Math.abs(v - n) >= t },
|
|
8554
8609
|
compareThresholdRange( v0, v1, t0, t1 ) { return v0 >= t0 && v0 <= t1 || v1 >= t0 && v1 <= t1 || v0 <= t0 && v1 >= t1},
|
|
8555
|
-
clamp (num, min, max) { return Math.min(Math.max(num, min), max) },
|
|
8556
8610
|
uidGenerator: simple_guidGenerator,
|
|
8557
8611
|
deleteElement( el ) { if( el ) el.remove(); },
|
|
8558
8612
|
flushCss(element) {
|