Commit f80745b7dbcfa6aa41a37b34ec5a9e461231f7d6
1 parent
321dbb7b
Exists in
master
and in
4 other branches
Handle back & forward events
Showing
4 changed files
with
13 additions
and
16 deletions
Show diff stats
app/assets/javascripts/application.js
@@ -50,9 +50,17 @@ $(document).ready(function(){ | @@ -50,9 +50,17 @@ $(document).ready(function(){ | ||
50 | e.preventDefault(); | 50 | e.preventDefault(); |
51 | } | 51 | } |
52 | }); | 52 | }); |
53 | - | ||
54 | }); | 53 | }); |
55 | 54 | ||
55 | +if (history && history.pushState) { | ||
56 | + $(function() { | ||
57 | + $(window).bind("popstate", function() { | ||
58 | + $.getScript(location.href); | ||
59 | + }); | ||
60 | + | ||
61 | + }); | ||
62 | +} | ||
63 | + | ||
56 | function focusSearch() { | 64 | function focusSearch() { |
57 | $("#search").focus(); | 65 | $("#search").focus(); |
58 | } | 66 | } |
app/controllers/dashboard_controller.rb
@@ -7,7 +7,7 @@ class DashboardController < ApplicationController | @@ -7,7 +7,7 @@ class DashboardController < ApplicationController | ||
7 | 7 | ||
8 | respond_to do |format| | 8 | respond_to do |format| |
9 | format.html | 9 | format.html |
10 | - format.js { no_cache_headers } | 10 | + format.js |
11 | end | 11 | end |
12 | end | 12 | end |
13 | 13 | ||
@@ -18,7 +18,7 @@ class DashboardController < ApplicationController | @@ -18,7 +18,7 @@ class DashboardController < ApplicationController | ||
18 | 18 | ||
19 | respond_to do |format| | 19 | respond_to do |format| |
20 | format.html | 20 | format.html |
21 | - format.js { no_cache_headers } | 21 | + format.js |
22 | end | 22 | end |
23 | end | 23 | end |
24 | 24 | ||
@@ -32,7 +32,7 @@ class DashboardController < ApplicationController | @@ -32,7 +32,7 @@ class DashboardController < ApplicationController | ||
32 | 32 | ||
33 | respond_to do |format| | 33 | respond_to do |format| |
34 | format.html | 34 | format.html |
35 | - format.js { no_cache_headers } | 35 | + format.js |
36 | format.atom { render :layout => false } | 36 | format.atom { render :layout => false } |
37 | end | 37 | end |
38 | end | 38 | end |
app/controllers/refs_controller.rb
@@ -26,10 +26,7 @@ class RefsController < ApplicationController | @@ -26,10 +26,7 @@ class RefsController < ApplicationController | ||
26 | def tree | 26 | def tree |
27 | respond_to do |format| | 27 | respond_to do |format| |
28 | format.html | 28 | format.html |
29 | - format.js do | ||
30 | - # disable cache to allow back button works | ||
31 | - no_cache_headers | ||
32 | - end | 29 | + format.js |
33 | end | 30 | end |
34 | rescue | 31 | rescue |
35 | return render_404 | 32 | return render_404 |
app/views/refs/_tree.html.haml
@@ -49,11 +49,3 @@ | @@ -49,11 +49,3 @@ | ||
49 | $('select#branch').selectmenu({style:'popup', width:200}); | 49 | $('select#branch').selectmenu({style:'popup', width:200}); |
50 | $('select#tag').selectmenu({style:'popup', width:200}); | 50 | $('select#tag').selectmenu({style:'popup', width:200}); |
51 | }); | 51 | }); |
52 | - | ||
53 | -- if params[:path] && request.xhr? | ||
54 | - :javascript | ||
55 | - $(window).unbind('popstate'); | ||
56 | - $(window).bind('popstate', function() { | ||
57 | - if(location.pathname.search("tree") != -1) { | ||
58 | - $.ajax({type: "GET", url: location.pathname, dataType: "script"})} | ||
59 | - else { location.href = location.pathname;}}); |