Skip to content

Commit

Permalink
Issue #546 - Navigate back in history from the back arrow on issue pa…
Browse files Browse the repository at this point in the history
…ges.

But only if that was the Referer.
  • Loading branch information
Mike Taylor committed Feb 3, 2015
1 parent e2fc478 commit ec2efbc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions webcompat/static/js/lib/issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,27 @@ marked.setOptions({

issues.TitleView = Backbone.View.extend({
el: $('.Issue-title'),
events: {
'click .js-linkBack': 'goBack'
},
template: _.template($('#title-tmpl').html()),
render: function() {
document.title = "Issue " + this.model.get('number') +
": " + this.model.get('title') +
" - webcompat.com";
this.$el.html(this.template(this.model.toJSON()));
return this;
},
goBack: function(e) {
if (!('origin' in location)) {
location.origin = location.protocol + '//' + location.host;
}

This comment has been minimized.

Copy link
@karlcow

karlcow Feb 4, 2015

Member

Just because I need to understand.
Why this part is necessary when the second part seems to be working always?

This comment has been minimized.

Copy link
@miketaylr

miketaylr Feb 4, 2015

Member

location.origin is less confusing/easier to read below, IMO. And this is just for older browsers that don't have it.

// Only go back in history if we came from the /issues page.
if (document.referrer.indexOf(location.origin + '/issues') === 0) {
history.back();
e.preventDefault();
}
}
});

Expand Down
2 changes: 1 addition & 1 deletion webcompat/templates/issue.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<main class="wc-content wc-content--body Issue" role="main">
<h1 class="Issue-title wc-Title--l">
<script type="text/template" id="title-tmpl">
<a class="Issue-linkBack" href="{{ url_for("show_issues") }}" title="All issues">
<a class="Issue-linkBack js-linkBack" href="{{ url_for("show_issues") }}" title="All issues">
<span class="wc-sronly">All Issues</span>
<span class="Issue-linkBack-icon wc-Icon wc-Icon--arrow-left" aria-hidden="true"></span>
</a>
Expand Down

0 comments on commit ec2efbc

Please sign in to comment.