From f0005bed6cc2233c8a2dc1b8bf936b84296df913 Mon Sep 17 00:00:00 2001 From: John Glover Date: Wed, 6 Feb 2013 12:09:34 +0100 Subject: [PATCH 1/3] 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. --- css/graph.css | 3 +-- css/grid.css | 1 - css/multiview.css | 1 - css/transform.css | 12 +++++------- src/view.graph.js | 2 +- src/view.multiview.js | 17 +++++++++++++++++ 6 files changed, 24 insertions(+), 12 deletions(-) diff --git a/css/graph.css b/css/graph.css index e961f8cb..7b1c085b 100644 --- a/css/graph.css +++ b/css/graph.css @@ -14,7 +14,6 @@ .recline-graph .graph .alert { width: 450px; - margin: auto; } .flotr-mouse-value { @@ -34,4 +33,4 @@ .flotr-legend-color-box { padding: 5px; -} \ No newline at end of file +} diff --git a/css/grid.css b/css/grid.css index 070e2903..caaef192 100644 --- a/css/grid.css +++ b/css/grid.css @@ -193,4 +193,3 @@ div.data-table-cell-content-numeric > a.data-table-cell-edit { .recline-read-only a.row-header-menu { display: none; } - diff --git a/css/multiview.css b/css/multiview.css index 4e7fbf20..06724df8 100644 --- a/css/multiview.css +++ b/css/multiview.css @@ -1,6 +1,5 @@ .recline-data-explorer .data-view-container { display: block; - margin-right: 225px; } .recline-data-explorer .data-view-sidebar { diff --git a/css/transform.css b/css/transform.css index 6c1e9b0e..9d404877 100644 --- a/css/transform.css +++ b/css/transform.css @@ -1,11 +1,14 @@ -.recline-transform .script { - margin-right: 10px; +.recline-transform { + overflow: hidden; } .recline-transform .script textarea { width: 100%; height: 100px; font-family: monospace; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; } .recline-transform h2 { @@ -17,10 +20,6 @@ margin-top: -2px; } -.recline-transform .preview { - margin-right: 10px; -} - .expression-preview-parsing-status { color: #999; } @@ -36,4 +35,3 @@ .recline-transform .before-after .after.different { font-weight: bold; } - diff --git a/src/view.graph.js b/src/view.graph.js index d0371d69..6dcef514 100644 --- a/src/view.graph.js +++ b/src/view.graph.js @@ -91,7 +91,7 @@ my.Graph = Backbone.View.extend({ // check we have something to plot 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 - this.$graph.width(this.el.width() - 20); + this.$graph.width(this.el.width() - 240); var series = this.createSeries(); var options = this.getGraphOptions(this.state.attributes.graphType); this.plot = Flotr.draw(this.$graph.get(0), series, options); diff --git a/src/view.multiview.js b/src/view.multiview.js index 28eb67e7..b8dead8c 100644 --- a/src/view.multiview.js +++ b/src/view.multiview.js @@ -203,6 +203,7 @@ my.MultiView = Backbone.View.extend({ } else { this.updateNav(this.pageViews[0].id); } + this._showHideSidebar(); this.model.bind('query:start', function() { 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) { this.el.find('.navigation a').removeClass('active'); var $el = this.el.find('.navigation a[data-view="' + pageName + '"]'); @@ -310,6 +325,7 @@ my.MultiView = Backbone.View.extend({ e.preventDefault(); var action = $(e.target).attr('data-action'); this['$'+action].toggle(); + this._showHideSidebar(); }, _onSwitchView: function(e) { @@ -317,6 +333,7 @@ my.MultiView = Backbone.View.extend({ var viewName = $(e.target).attr('data-view'); this.updateNav(viewName); this.state.set({currentView: viewName}); + this._showHideSidebar(); }, // create a state object for this view and do the job of From bc3ade4c237dc2c7d2b791ceca48692f59798d7a Mon Sep 17 00:00:00 2001 From: John Glover Date: Mon, 11 Feb 2013 12:10:57 +0100 Subject: [PATCH 2/3] [#309] Fix rendering of fields widget in IE7. --- src/widget.fields.js | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/src/widget.fields.js b/src/widget.fields.js index 645ba055..13078d2f 100644 --- a/src/widget.fields.js +++ b/src/widget.fields.js @@ -38,7 +38,7 @@ my.Fields = Backbone.View.extend({ \ \ \ -
\ +
\
\ {{#facets}} \
\ @@ -57,9 +57,6 @@ my.Fields = Backbone.View.extend({
\ ', - events: { - 'click .js-show-hide': 'onShowHide' - }, initialize: function(model) { var self = this; this.el = $(this.el); @@ -77,6 +74,7 @@ my.Fields = Backbone.View.extend({ self.model.getFieldsSummary(); self.render(); }); + this.el.find('.collapse').collapse(); this.render(); }, render: function() { @@ -91,25 +89,7 @@ my.Fields = Backbone.View.extend({ }); var templated = Mustache.render(this.template, tmplData); this.el.html(templated); - this.el.find('.collapse').collapse('hide'); - }, - onShowHide: function(e) { - e.preventDefault(); - var $target = $(e.target); - // weird collapse class seems to have been removed (can watch this happen - // if you watch dom) but could not work why. Absence of collapse then meant - // we could not toggle. - // This seems to fix the problem. - this.el.find('.accordion-body').addClass('collapse');; - if ($target.text() === '+') { - this.el.find('.collapse').collapse('show'); - $target.text('-'); - } else { - this.el.find('.collapse').collapse('hide'); - $target.text('+'); - } } }); })(jQuery, recline.View); - From bb28ef2347c65c458f7b015c760cb8fdbdd39c49 Mon Sep 17 00:00:00 2001 From: John Glover Date: Mon, 11 Feb 2013 14:27:22 +0100 Subject: [PATCH 3/3] [#309] Small JS fix for IE7. Extra comma in object literal removed. --- src/backend.ckan.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/backend.ckan.js b/src/backend.ckan.js index 62fc91e7..1b59bf8c 100644 --- a/src/backend.ckan.js +++ b/src/backend.ckan.js @@ -76,7 +76,7 @@ this.recline.Backend.Ckan = this.recline.Backend.Ckan || {}; actualQuery.sort = _tmp.join(','); } return actualQuery; - } + }; my.query = function(queryObj, dataset) { if (dataset.endpoint) { @@ -92,7 +92,7 @@ this.recline.Backend.Ckan = this.recline.Backend.Ckan || {}; jqxhr.done(function(results) { var out = { total: results.result.total, - hits: results.result.records, + hits: results.result.records }; dfd.resolve(out); }); @@ -116,7 +116,7 @@ this.recline.Backend.Ckan = this.recline.Backend.Ckan || {}; dataType: 'json' }); return jqxhr; - } + }; return that; }; @@ -130,7 +130,7 @@ this.recline.Backend.Ckan = this.recline.Backend.Ckan || {}; return { resource_id: parts[len-1], endpoint: parts.slice(0,[len-4]).join('/') + '/api' - } + }; }; var CKAN_TYPES_MAP = {