Skip to content

Commit

Permalink
Clientside routing for tour kickoff, swapping from ?tour_id=foo appro…
Browse files Browse the repository at this point in the history
…ach.
  • Loading branch information
dannon committed Feb 4, 2016
1 parent 33ebeb8 commit ab5f153
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 47 deletions.
11 changes: 8 additions & 3 deletions client/galaxy/scripts/apps/analysis.js
Expand Up @@ -100,11 +100,16 @@ window.app = function app( options, bootstrapped ){
'(/)' : 'home',
// TODO: remove annoying 'root' from root urls
'(/)root*' : 'home',
'(/)tours' : 'show_tours',
'(/)tours(/:tour_id)' : 'show_tours',
},

show_tours : function( params ){
centerPanel.display( new Tours.ToursView() );
show_tours : function( tour_id ){
if (tour_id){
Tours.giveTour(tour_id);
}
else{
centerPanel.display( new Tours.ToursView() );
}
},

/** */
Expand Down
2 changes: 1 addition & 1 deletion client/galaxy/scripts/mvc/tours.js
Expand Up @@ -101,7 +101,7 @@ define(['libs/bootstrap-tour'],function(BootstrapTour) {
"<ul>",
'<% _.each(tours, function(tour) { %>',
'<li>',
'<a href="#" class="tourItem" data-tour.id=<%- tour.id %>>',
'<a href="#/tours/<%- tour.id %>" class="tourItem" data-tour.id=<%- tour.id %>>',
'<%- tour.attributes.name || tour.id %>',
'</a>',
' - <%- tour.attributes.description || "No description given." %>',
Expand Down
42 changes: 9 additions & 33 deletions client/galaxy/scripts/onload.js
Expand Up @@ -166,39 +166,15 @@ $(document).ready( function() {
return anchor;
});

try{
// So, depending on what elements your tour is hooked to, this may not
// work on some pages with some rendered content because of view
// rendering delays.
// Another option is to present an icon for 'continue-tour' somewhere?
var urlparms = QUERY_STRING.parse(location.search.slice(1));
if (urlparms.tour_id){
var tour_id = urlparms.tour_id;
delete urlparms.tour_id;
var url = $(location).attr('href');
var repacked_url_args = _.map(Object.getOwnPropertyNames(urlparms), function(k) { return "?" + [k, urlparms[k]].join('='); }).join('&');
url = window.location.href.split('?')[0];
if (repacked_url_args !== "?"){
url = url + repacked_url_args;
}
history.pushState(null, null, url);
TOURS.giveTour(tour_id);
var et = JSON.parse(sessionStorage.getItem('activeGalaxyTour'));
if (et){
et = TOURS.hooked_tour_from_data(et);
if (et && et.steps){
var tour = new Tour(_.extend({
steps: et.steps,
}, TOURS.tour_opts));
tour.init();
tour.restart();
}
else{
var et = JSON.parse(sessionStorage.getItem('activeGalaxyTour'));
if (et){
et = TOURS.hooked_tour_from_data(et);
if (et && et.steps){
var tour = new Tour(_.extend({
steps: et.steps,
}, TOURS.tour_opts));
tour.init();
tour.restart();
}
}
}
}
catch(ex){
console.log("Tour loading failure, you'll need to restart the tour manually." + ex);
}
});
2 changes: 1 addition & 1 deletion static/maps/mvc/tours.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion static/maps/onload.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions static/scripts/bundled/analysis.bundled.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/scripts/bundled/analysis.bundled.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions static/scripts/bundled/libs.bundled.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/scripts/bundled/libs.bundled.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/scripts/mvc/tours.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ab5f153

Please sign in to comment.