Skip to content

Commit

Permalink
still not right
Browse files Browse the repository at this point in the history
  • Loading branch information
gnmerritt committed Sep 15, 2011
1 parent d7ba511 commit adc855b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
2 changes: 1 addition & 1 deletion _layouts/default.html
Expand Up @@ -47,7 +47,7 @@ <h3>Recent GitHub Activity:</h3>
<footer> </footer>

<script src='http://gitlive.com/githublive.min.js'></script>
<script type="text/javascript" src="js/blog.js" />
<script type="text/javascript" src="/js/blog.js" />
<script>
document.createElement('header');
document.createElement('nav');
Expand Down
3 changes: 2 additions & 1 deletion css/blog.css
Expand Up @@ -15,7 +15,8 @@ nav.left { width:20%; float:left; }
.post .preview.closed { display:none; }
.post .body { clear:both; }
.post .related { }
.post .more { }
.post .more { float:right; }
.post .hide { float:left; cursor:pointer; }

#footer { margin:0 50px; clear:both; }

Expand Down
3 changes: 2 additions & 1 deletion index.markdown
Expand Up @@ -11,7 +11,8 @@ title: gnmerritt.net - Nathan's home on the web
<p class="date">{{ post.date | date: "%A, %d %B %Y"}}</p>
<p class="preview">{{ post.content | strip_html | truncatewords: 75 }}</p>
{% if post.content.size > 75 %}
<p class="more"> <a href="{{ post.id }}.html">Read Full Post...</a></p>
<p class="hide" onclick="gnm.toggleOpen(this)">Toggle Post</p>
<p class="more"><a href="{{ post.id }}.html">...Read Full Post</a></p>
{% endif %}
</article>
{% endfor %}
Expand Down
35 changes: 30 additions & 5 deletions js/blog.js
@@ -1,17 +1,42 @@
// helper methods

function $(element)
{
return document.getElementById(element);
}

function hasClass(ele,cls)
{
return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}

function addClass(ele,cls)
{
if (!this.hasClass(ele,cls)) ele.className += " "+cls;
}

function removeClass(ele,cls)
{
if (hasClass(ele,cls)) {
var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
ele.className=ele.className.replace(reg,' ');
}
}

var gnm =
{
// toggles the 'closed' class on an item, used to show/hide on demand
toggleOpen:function(this)
toggleOpen:function(source)
{
if (this != null)
if (source != null && source.parentNode != null)
{
if (this.hasClass('closed'))
if (hasClass(source.parentNode, 'closed'))
{
this.removeClass('closed');
removeClass(source.parentNode, 'closed');
}
else
{
this.addClass('closed');
addClass(source.parentNode, 'closed');
}
}
},
Expand Down

0 comments on commit adc855b

Please sign in to comment.