Hide the sidebar if it's empty.

When updating the view check to see if the sidebar
contains any visible children elements. If not,
hide it.
This commit is contained in:
John Glover
2013-02-06 12:09:34 +01:00
parent d1a5c0803d
commit f0005bed6c
6 changed files with 24 additions and 12 deletions

View File

@@ -14,7 +14,6 @@
.recline-graph .graph .alert { .recline-graph .graph .alert {
width: 450px; width: 450px;
margin: auto;
} }
.flotr-mouse-value { .flotr-mouse-value {

View File

@@ -193,4 +193,3 @@ div.data-table-cell-content-numeric > a.data-table-cell-edit {
.recline-read-only a.row-header-menu { .recline-read-only a.row-header-menu {
display: none; display: none;
} }

View File

@@ -1,6 +1,5 @@
.recline-data-explorer .data-view-container { .recline-data-explorer .data-view-container {
display: block; display: block;
margin-right: 225px;
} }
.recline-data-explorer .data-view-sidebar { .recline-data-explorer .data-view-sidebar {

View File

@@ -1,11 +1,14 @@
.recline-transform .script { .recline-transform {
margin-right: 10px; overflow: hidden;
} }
.recline-transform .script textarea { .recline-transform .script textarea {
width: 100%; width: 100%;
height: 100px; height: 100px;
font-family: monospace; font-family: monospace;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
} }
.recline-transform h2 { .recline-transform h2 {
@@ -17,10 +20,6 @@
margin-top: -2px; margin-top: -2px;
} }
.recline-transform .preview {
margin-right: 10px;
}
.expression-preview-parsing-status { .expression-preview-parsing-status {
color: #999; color: #999;
} }
@@ -36,4 +35,3 @@
.recline-transform .before-after .after.different { .recline-transform .before-after .after.different {
font-weight: bold; font-weight: bold;
} }

View File

@@ -91,7 +91,7 @@ my.Graph = Backbone.View.extend({
// check we have something to plot // check we have something to plot
if (this.state.get('group') && this.state.get('series')) { if (this.state.get('group') && this.state.get('series')) {
// faff around with width because flot draws axes *outside* of the element width which means graph can get push down as it hits element next to it // faff around with width because flot draws axes *outside* of the element width which means graph can get push down as it hits element next to it
this.$graph.width(this.el.width() - 20); this.$graph.width(this.el.width() - 240);
var series = this.createSeries(); var series = this.createSeries();
var options = this.getGraphOptions(this.state.attributes.graphType); var options = this.getGraphOptions(this.state.attributes.graphType);
this.plot = Flotr.draw(this.$graph.get(0), series, options); this.plot = Flotr.draw(this.$graph.get(0), series, options);

View File

@@ -203,6 +203,7 @@ my.MultiView = Backbone.View.extend({
} else { } else {
this.updateNav(this.pageViews[0].id); this.updateNav(this.pageViews[0].id);
} }
this._showHideSidebar();
this.model.bind('query:start', function() { this.model.bind('query:start', function() {
self.notify({loader: true, persist: true}); self.notify({loader: true, persist: true});
@@ -280,6 +281,20 @@ my.MultiView = Backbone.View.extend({
}, },
// hide the sidebar if empty
_showHideSidebar: function() {
var $dataSidebar = this.el.find('.data-view-sidebar');
var visibleChildren = $dataSidebar.children().filter(function() {
return $(this).css("display") != "none";
}).length;
if (visibleChildren > 0) {
$dataSidebar.show();
} else {
$dataSidebar.hide();
}
},
updateNav: function(pageName) { updateNav: function(pageName) {
this.el.find('.navigation a').removeClass('active'); this.el.find('.navigation a').removeClass('active');
var $el = this.el.find('.navigation a[data-view="' + pageName + '"]'); var $el = this.el.find('.navigation a[data-view="' + pageName + '"]');
@@ -310,6 +325,7 @@ my.MultiView = Backbone.View.extend({
e.preventDefault(); e.preventDefault();
var action = $(e.target).attr('data-action'); var action = $(e.target).attr('data-action');
this['$'+action].toggle(); this['$'+action].toggle();
this._showHideSidebar();
}, },
_onSwitchView: function(e) { _onSwitchView: function(e) {
@@ -317,6 +333,7 @@ my.MultiView = Backbone.View.extend({
var viewName = $(e.target).attr('data-view'); var viewName = $(e.target).attr('data-view');
this.updateNav(viewName); this.updateNav(viewName);
this.state.set({currentView: viewName}); this.state.set({currentView: viewName});
this._showHideSidebar();
}, },
// create a state object for this view and do the job of // create a state object for this view and do the job of