Skip to content

Commit

Permalink
Hash change for comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
iamjpg committed Jan 16, 2012
1 parent 93491e3 commit 7f07f48
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions public/javascripts/application.js
Expand Up @@ -57,7 +57,7 @@ MHN = {
this.lockGetStory = true;

// Set the hash
window.location.hash = "story?id=" + id;
window.location.hash = "comments?id=" + id;
// Set users current scroll pos
this.currentScroll = $("body").scrollTop();
// Animations are fun. Who needs a mobile framework?
Expand Down Expand Up @@ -128,17 +128,21 @@ $(document).ready(function() {
// If the hash is not blank, get the story.
if (window.location.hash != "") {
// RegEx to grab the URL query param.
var url = location.hash.replace(/^.*\=/, '');
var id = location.hash.replace(/^.*\=/, '');
// Fire the method.
if (!MHN.isNumeric(url)) {
MHN.getStory(url);
if (window.location.hash.indexOf("story") > -1) {
MHN.getStory(id);
} else {
MHN.getComments(id);
}
}
// Window Location event listener...so, so handy...
// I could use push state...but I'm not.
jQuery(window.location).change(function() {
// Is the hash blank? That means someone must have hit the back button.
if (window.location.hash === "") {
// Hide that loader
$("#loader").css("display","none");
// Position the content div off the screen.
$('#contentContainer').css("left", 0 - $(window).width());
// Hide the story div
Expand Down
4 changes: 2 additions & 2 deletions public/stylesheets/lib.css
Expand Up @@ -134,7 +134,7 @@ li {
margin-left: 40px;
border-left: 3px solid #dcdcdc;
border-bottom: 1px dotted #dcdcdc;
padding-left: 10px;
padding: 0 0 10px 10px;
}

.commentSecondChild {
Expand All @@ -143,5 +143,5 @@ li {
margin-left: 80px;
border-left: 3px solid #dcdcdc;
border-bottom: 1px dotted #dcdcdc;
padding-left: 10px;
padding: 0 0 10px 10px;
}

0 comments on commit 7f07f48

Please sign in to comment.