Permalink
Browse files

Push random joke permalinks to history so users can use back/forward …

…buttons when going through random jokels.
  • Loading branch information...
1 parent 1f98f7b commit 43e8611e25dc69e53e34afd6560704a66970ed70 @sylturner committed Dec 15, 2012
@@ -33,7 +33,8 @@ def show
generate_title @joke.question
respond_to do |format|
- format.html # show.html.erb
+ format.html
+ format.js { render :layout => false }
format.xml { render :xml => @joke }
format.json { render :json => @joke }
end
@@ -49,10 +49,10 @@
<%= render :partial => "shared/votes", :locals => {:joke => joke, :upvote_path => upvote_joke_path(joke), :downvote_path => downvote_joke_path(joke), :id => "joke_#{joke.id}"} %>
| <%= link_to "Fork this joke", new_joke_alternate_punchline_path(joke), :method => :get, :remote => true, :title => "Create an alternate punchline", :class => "fork" %>
|
- <a href="#" id="tags">Tags</a>
+ <a id="tags" class="fake_link">Tags</a>
|
- <a href="#" id="permalink">Permalink</a>
- | <a href="#" id="share-link">Share</a>
+ <a id="permalink" class="fake_link">Permalink</a>
+ | <a id="share-link" class="fake_link">Share</a>
</span>
<span class="share-bar-right">
<span class="inline-joke-edit">
@@ -1,8 +1 @@
-$("#loading").remove();
-$("#joke").html("");
-$("#joke").html("<%= escape_javascript(render :partial => 'joke', :locals=>{:joke => @joke, :refresh => true, :min => false, :sequence => false}) %>");
-$("#joke").slideDown("fast");
-$("#joke").ready(function(){
- $('#click-for-punchline, #question').click(enable_joke_stuff);
- document.title = "<%= @title %>";
-});
+<%= render :partial => "shared/joke", :locals => {:refresh => true} %>
@@ -0,0 +1 @@
+<%= render :partial => "shared/joke", :locals => {:refresh => false}%>
@@ -0,0 +1,8 @@
+$("#loading").remove();
+$("#joke").html("");
+$("#joke").html("<%= escape_javascript(render :partial => 'home/joke', :locals=>{:joke => @joke, :refresh => refresh, :min => false, :sequence => false}) %>");
+$("#joke").slideDown("fast");
+$("#joke").ready(function(){
+ $('#click-for-punchline, #question').click(enable_joke_stuff);
+ document.title = "<%= @title %>";
+});
@@ -288,4 +288,14 @@ function enableKiosk(delayTime)
$( "#kioskDelay" ).text( newValue );
}
});
-}
+}
+window.addEventListener("popstate", function(e) {
+ if(location.pathname != "/"){
+ var path = location.pathname;
+ $.ajax({
+ type: "GET",
+ url: path,
+ dataType: "script"
+ });
+ }
+});
@@ -552,3 +552,7 @@ a img {
.reassignSelect{
display:none;
}
+
+.fake_link{
+ cursor: pointer;
+}

2 comments on commit 43e8611

Nice!

Owner

sylturner replied Dec 16, 2012

Thought you'd like that. Hopefully it's not too janky.

Please sign in to comment.