Skip to content

Commit

Permalink
added per-post Uid
Browse files Browse the repository at this point in the history
  • Loading branch information
gnmerritt committed Sep 16, 2011
1 parent a030ef8 commit cd039ee
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
2 changes: 2 additions & 0 deletions css/blog.css
Expand Up @@ -7,6 +7,8 @@ nav.left { width:20%; float:left; }
#content { width:75%; float:left; margin-left:2.5%; border-top:30px; border-bottom:30px; }
#content h4 { text-align: right; }

div.clear { clear:both; }

.post { border:1px inset black; margin:1em; padding:0.5em; }
.post.full { border-style:none; }
.post h3 { float:left; } /* title */
Expand Down
21 changes: 15 additions & 6 deletions index.markdown
Expand Up @@ -6,17 +6,26 @@ title: gnmerritt.net - Nathan's home on the web
<section>

{% for post in site.posts limit:6 %}
<article class="post">
<h3> <a href="{{ post.id }}.html">{{ post.title }}</a></h3>
<p class="date">{{ post.date | date: "%A, %d %B %Y"}}</p>
{% capture postUid %}
{{ post.date | %m%h%d%B%Y }} %}
{% endcapture %}

<p class="preview">{{ post.content | strip_html | truncatewords: 75 }}</p>
<article class="post" id="{{ postUid }}">
<div class="clear">
<h3> <a href="{{ post.id }}.html">{{ post.title }}</a></h3>
<p class="date">{{ post.date | date: "%A, %d %B %Y"}}</p>
</div>
<br />

<p class="preview">{{ post.content | strip_html | truncatewords: 75 }}</p>

<div class="clear">
{% if post.content.size > 75 %}
<p class="hide" onclick="gnm.toggleOpen(this)">Toggle Post</p>
<p class="hide" onclick="gnm.toggleOpen({{ postUid }})">Toggle Post</p>
<p class="more"><a href="{{ post.id }}.html">...Read Full Post</a></p>

{% endif %}
</div>
<br />
</article>
{% endfor %}

Expand Down
19 changes: 10 additions & 9 deletions js/blog.js
@@ -1,21 +1,21 @@
// helper methods

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

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

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

function removeClass(ele,cls)
Element.prototype.removeClass:function(cls)
{
if (hasClass(ele,cls)) {
var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
Expand All @@ -26,17 +26,18 @@ function removeClass(ele,cls)
var gnm =
{
// toggles the 'closed' class on an item, used to show/hide on demand
toggleOpen:function(source)
toggleOpen:function(elemId)
{
if (source != null && source.parentNode != null)
var source = $(elemId);
if (source != null)
{
if (hasClass(source.parentNode, 'closed'))
if (source.hasClass('closed'))
{
removeClass(source.parentNode, 'closed');
source.removeClass('closed');
}
else
{
addClass(source.parentNode, 'closed');
source.addClass('closed');
}
}
},
Expand Down

0 comments on commit cd039ee

Please sign in to comment.