Skip to content

Commit

Permalink
Set page title to joke with Javascript
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Johansson committed Jun 18, 2011
1 parent 7891ca5 commit 4409011
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<script type="text/javascript">var _sf_startpt=(new Date()).getTime()</script>
<meta charset="utf-8" />
<title>Gotanjoke, #nordicruby</title>
<title><%= truncate(strip_tags(@joke.try(:joke)), :length => 100) || "Gotanjoke, #nordicruby" %></title>
<link rel="stylesheet" href="/stylesheets/tc1.css" type="text/css" media="all">
<meta name="viewport" content = "user-scalable=no, initial-scale=1.0, maximum-scale=1.0, width=device-width">
<meta name="apple-mobile-web-app-capable" content="yes"/>
Expand Down
6 changes: 6 additions & 0 deletions public/javascripts/application.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
TrainChallange = (function(){
var setTitle = function(){
$("article").bind("end.pjax", function(){
$("title").text($("h2#fittext").text().substr(0, 100));
});
};
var setText = function(){
$("#fittext").fitText(1.2);
};
Expand All @@ -18,6 +23,7 @@ TrainChallange = (function(){
setText();
initPjax();
getJoke();
setTitle();
}
};
})();
Expand Down

0 comments on commit 4409011

Please sign in to comment.