Skip to content

Commit

Permalink
shuffle robot presentation order on the home page and all page. For #40
Browse files Browse the repository at this point in the history
  • Loading branch information
tfoote committed Apr 28, 2017
1 parent 8dac636 commit 3eca3bb
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 4 deletions.
7 changes: 6 additions & 1 deletion _includes/box-item.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<article class="box-item post-{{post.main-class}}" itemscope="itemscope" itemtype="http://schema.org/BlogPosting" itemprop="blogPost">
{% if post.title == site.featured_robot %}
{% assign element_class = 'featured-item' %}
{% else %}
{% assign element_class = 'box-item' %}
{% endif %}
<article class="{{ element_class }} post-{{post.main-class}}" itemscope="itemscope" itemtype="http://schema.org/BlogPosting" itemprop="blogPost">
<span class="ribbon">
{% if post.title == site.featured_robot %}
<a href="{{ post.url | prepend: site.baseurl }}"><span>Featured</span></a>
Expand Down
12 changes: 12 additions & 0 deletions _includes/shuffle-items.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!-- Include after a set of box-items to shuffle them -->

<script type="text/javascript" src="/assets/js/jquery-min.js"></script>

<script type="text/javascript">
var boxes = $(".box-item");
for(var i = 0; i < boxes.length; i++){
var target = Math.floor(Math.random() * boxes.length -1) + 1;
var target2 = Math.floor(Math.random() * boxes.length -1) +1;
boxes.eq(target).before(boxes.eq(target2));
}
</script>
3 changes: 2 additions & 1 deletion all.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
<main class="post-content" id="post" role="main" itemprop="mainContentOfPage" itemscope="itemscope" itemtype="http://schema.org/Blog">
<div style="padding-top: 33px" id="grid" class="row flex-grid">
{% for post in site.posts %}
{% include box-item.html %}
{% include box-item.html %}
{% endfor %}
{% include shuffle-items.html %}
</div>
</main>
2 changes: 1 addition & 1 deletion assets/css/main.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ <H2>Find a robot by category:</H2>
{% for post in site.posts %}
{% include box-item.html %}
{% endfor %}
{% include shuffle-items.html %}
</div>

</main>
2 changes: 1 addition & 1 deletion src/styl/_home.styl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ main
text-transform uppercase
padding 0 rem(15px)

.box-item
.box-item, .featured-item
flex 1 0 300px
margin 0 rem(15px) rem(50px)
display inline-block
Expand Down

0 comments on commit 3eca3bb

Please sign in to comment.