diff --git a/app/index.html b/app/index.html index cfd9492e..e6367736 100644 --- a/app/index.html +++ b/app/index.html @@ -162,6 +162,8 @@ diff --git a/app/js/app.js b/app/js/app.js index 53e447b0..b5ef942d 100755 --- a/app/js/app.js +++ b/app/js/app.js @@ -24,6 +24,10 @@ var ExplorerApp = Backbone.View.extend({ } catch(e) {} state[key] = value; }); + if (state.embed) { + $('.navbar').hide(); + $('body').attr('style', 'padding-top: 0px'); + } } var dataset = null; if (state.dataset || state.url) { @@ -53,6 +57,7 @@ var ExplorerApp = Backbone.View.extend({ state: state }); this._setupPermaLink(this.dataExplorer); + this._setupEmbed(this.dataExplorer); // HACK (a bit). Issue is that Backbone will not trigger the route // if you are already at that location so we have to make sure we genuinely switch @@ -63,15 +68,32 @@ var ExplorerApp = Backbone.View.extend({ }, _setupPermaLink: function(explorer) { + var self = this; var $viewLink = this.el.find('.js-share-and-embed-dialog .view-link'); - function makePermaLink(state) { - var qs = recline.View.composeQueryString(state.toJSON()); - return window.location.origin + window.location.pathname + qs; + explorer.state.bind('change', function() { + $viewLink.val(self.makePermaLink(explorer.state)); + }); + $viewLink.val(self.makePermaLink(explorer.state)); + }, + + _setupEmbed: function(explorer) { + var self = this; + var $embedLink = this.el.find('.js-share-and-embed-dialog .view-embed'); + function makeEmbedLink(state) { + var link = self.makePermaLink(state); + link = link + '&embed=true'; + var out = $.mustache('', {link: link}); + return out; } explorer.state.bind('change', function() { - $viewLink.val(makePermaLink(explorer.state)); + $embedLink.val(makeEmbedLink(explorer.state)); }); - $viewLink.val(makePermaLink(explorer.state)); + $embedLink.val(makeEmbedLink(explorer.state)); + }, + + makePermaLink: function(state) { + var qs = recline.View.composeQueryString(state.toJSON()); + return window.location.origin + window.location.pathname + qs; }, // setup the loader menu in top bar