diff --git a/tools/config.json b/tools/config.json index 8979558..700494b 100644 --- a/tools/config.json +++ b/tools/config.json @@ -78,7 +78,7 @@ "website/o3dv/modeldata.js", "website/o3dv/navigator.js", "website/o3dv/sidebarpanel.js", - "website/o3dv/propertysidebarpanel.js", + "website/o3dv/detailssidebarpanel.js", "website/o3dv/sidebar.js", "website/o3dv/hashhandler.js", "website/o3dv/website.css", diff --git a/website/embed.html b/website/embed.html index a297989..dec526f 100644 --- a/website/embed.html +++ b/website/embed.html @@ -92,7 +92,7 @@ - + diff --git a/website/index.html b/website/index.html index 2c71af3..d7f17ba 100644 --- a/website/index.html +++ b/website/index.html @@ -92,7 +92,7 @@ - + diff --git a/website/o3dv/propertysidebarpanel.js b/website/o3dv/detailssidebarpanel.js similarity index 99% rename from website/o3dv/propertysidebarpanel.js rename to website/o3dv/detailssidebarpanel.js index c27cc62..46001fe 100644 --- a/website/o3dv/propertysidebarpanel.js +++ b/website/o3dv/detailssidebarpanel.js @@ -1,4 +1,4 @@ -OV.PropertySidebarPanel = class extends OV.SidebarPanel +OV.DetailsSidebarPanel = class extends OV.SidebarPanel { constructor (parentDiv) { diff --git a/website/o3dv/sidebar.js b/website/o3dv/sidebar.js index fa4a81b..9c28600 100644 --- a/website/o3dv/sidebar.js +++ b/website/o3dv/sidebar.js @@ -1,6 +1,6 @@ OV.SidebarPanelId = { - Properties : 0 + Details : 0 }; OV.Sidebar = class @@ -12,7 +12,7 @@ OV.Sidebar = class this.titleDiv = null; this.contentDiv = null; this.panels = [ - new OV.PropertySidebarPanel (this.parentDiv) + new OV.DetailsSidebarPanel (this.parentDiv) ]; } @@ -28,12 +28,21 @@ OV.Sidebar = class } } - Show (show) + Show (panelId) { - this.visible = show; - if (this.visible) { + if (panelId !== null) { + this.visible = true; this.parentDiv.show (); + for (let i = 0; i < this.panels.length; i++) { + const panel = this.panels[i]; + if (i === panelId) { + panel.Show (true); + } else { + panel.Show (false); + } + } } else { + this.visible = false; this.parentDiv.hide (); } } @@ -43,6 +52,19 @@ OV.Sidebar = class return this.visible; } + GetVisiblePanelId () + { + if (!this.visible) { + return null; + } + for (let i = 0; i < this.panels.length; i++) { + if (this.panels[i].IsVisible ()) { + return i; + } + } + return null; + } + Resize () { for (let i = 0; i < this.panels.length; i++) { diff --git a/website/o3dv/sidebarpanel.js b/website/o3dv/sidebarpanel.js index d3455c8..1a809c7 100644 --- a/website/o3dv/sidebarpanel.js +++ b/website/o3dv/sidebarpanel.js @@ -3,10 +3,10 @@ OV.SidebarPanel = class constructor (parentDiv) { this.parentDiv = parentDiv; - this.panelDiv = $('
').appendTo (this.parentDiv); + this.panelDiv = $('
').appendTo (this.parentDiv).hide (); this.titleDiv = null; this.contentDiv = null; - this.visible = true; + this.visible = false; } Init (title, callbacks) diff --git a/website/o3dv/website.js b/website/o3dv/website.js index b6ef774..74c9bf5 100644 --- a/website/o3dv/website.js +++ b/website/o3dv/website.js @@ -8,7 +8,7 @@ OV.Website = class this.cookieHandler = new OV.CookieHandler (); this.toolbar = new OV.Toolbar (this.parameters.toolbarDiv); this.sidebar = new OV.Sidebar (this.parameters.sidebarDiv); - this.navigator = new OV.Navigator (this.parameters.navigatorDiv, this.sidebar.GetPanel (OV.SidebarPanelId.Properties)); + this.navigator = new OV.Navigator (this.parameters.navigatorDiv, this.sidebar.GetPanel (OV.SidebarPanelId.Details)); this.viewerSettings = new OV.ViewerSettings (); this.importSettings = new OV.ImportSettings (); this.modelLoader = new OV.ThreeModelLoader (); @@ -81,10 +81,19 @@ OV.Website = class } } - ShowSidebar (show) + ShowSidebar (panelId) { - this.sidebar.Show (show); - this.cookieHandler.SetBoolVal ('ov_show_sidebar', show); + this.sidebar.Show (panelId); + this.cookieHandler.SetBoolVal ('ov_show_sidebar', this.sidebar.IsVisible ()); + } + + ToggleSidebar (panelId) + { + if (this.sidebar.GetVisiblePanelId () !== panelId) { + this.ShowSidebar (panelId); + } else { + this.ShowSidebar (null); + } } ClearModel () @@ -347,7 +356,7 @@ OV.Website = class }); } AddRightButton (this.toolbar, 'details', 'Details panel', true, function () { - obj.ShowSidebar (!obj.sidebar.IsVisible ()); + obj.ToggleSidebar (OV.SidebarPanelId.Details); obj.Resize (); }); @@ -404,12 +413,12 @@ OV.Website = class let obj = this; this.sidebar.Init ({ onClose : function () { - obj.ShowSidebar (false); + obj.ShowSidebar (null); obj.Resize (); } }); let show = this.cookieHandler.GetBoolVal ('ov_show_sidebar', true); - this.ShowSidebar (show); + this.ShowSidebar (show ? OV.SidebarPanelId.Details : null); } InitNavigator ()