[#67,app][s]: embed support.
This commit is contained in:
@@ -162,6 +162,8 @@
|
|||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<h4>Sharable Link to current View</h4>
|
<h4>Sharable Link to current View</h4>
|
||||||
<textarea class="view-link" style="width: 100%; height: 100px;"></textarea>
|
<textarea class="view-link" style="width: 100%; height: 100px;"></textarea>
|
||||||
|
<h4>Embed this View</h4>
|
||||||
|
<textarea class="view-embed" style="width: 100%; height: 200px;"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,10 @@ var ExplorerApp = Backbone.View.extend({
|
|||||||
} catch(e) {}
|
} catch(e) {}
|
||||||
state[key] = value;
|
state[key] = value;
|
||||||
});
|
});
|
||||||
|
if (state.embed) {
|
||||||
|
$('.navbar').hide();
|
||||||
|
$('body').attr('style', 'padding-top: 0px');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var dataset = null;
|
var dataset = null;
|
||||||
if (state.dataset || state.url) {
|
if (state.dataset || state.url) {
|
||||||
@@ -53,6 +57,7 @@ var ExplorerApp = Backbone.View.extend({
|
|||||||
state: state
|
state: state
|
||||||
});
|
});
|
||||||
this._setupPermaLink(this.dataExplorer);
|
this._setupPermaLink(this.dataExplorer);
|
||||||
|
this._setupEmbed(this.dataExplorer);
|
||||||
|
|
||||||
// HACK (a bit). Issue is that Backbone will not trigger the route
|
// 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
|
// 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) {
|
_setupPermaLink: function(explorer) {
|
||||||
|
var self = this;
|
||||||
var $viewLink = this.el.find('.js-share-and-embed-dialog .view-link');
|
var $viewLink = this.el.find('.js-share-and-embed-dialog .view-link');
|
||||||
function makePermaLink(state) {
|
explorer.state.bind('change', function() {
|
||||||
var qs = recline.View.composeQueryString(state.toJSON());
|
$viewLink.val(self.makePermaLink(explorer.state));
|
||||||
return window.location.origin + window.location.pathname + qs;
|
});
|
||||||
|
$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('<iframe src="{{link}}" width="100%" min-height="500px;"></iframe>', {link: link});
|
||||||
|
return out;
|
||||||
}
|
}
|
||||||
explorer.state.bind('change', function() {
|
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
|
// setup the loader menu in top bar
|
||||||
|
|||||||
Reference in New Issue
Block a user