Skip to content

Commit

Permalink
Add jQuery Masonry
Browse files Browse the repository at this point in the history
  • Loading branch information
Neil Gehani committed Sep 19, 2013
1 parent 4ad366b commit 1783203
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 28 deletions.
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//
//= require jquery
//= require jquery_ujs
//= require jquery.masonry.min.js
//= require bootstrap
//= require turbolinks
//= require_tree .
4 changes: 4 additions & 0 deletions app/assets/javascripts/pins.js.coffee
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

jQuery ->
$('#pins').imagesLoaded ->
$('#pins').masonry itemSelector: ".box"
27 changes: 27 additions & 0 deletions app/assets/stylesheets/styles.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,30 @@ body{
color: $gray;
}
}

/* Required for jQuery Masonry */
/* anything beginning with a . is a class and used in views as class = "blah" */

.box {
margin: 5px;
padding: 5px;
font-size: 11px;
line-height: 1.4em;
float: left;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
box-shadow: 1px 1px 10px #444;
width: 214px;
}

.box img {
width: 100%;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}

.description {
margin: 10px 0 5px;
}
2 changes: 1 addition & 1 deletion app/controllers/pins_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class PinsController < ApplicationController
# GET /pins
# GET /pins.json
def index
@pins = Pin.all
@pins = Pin.order("created_at desc")

respond_to do |format|
format.html # index.html.erb
Expand Down
1 change: 1 addition & 0 deletions app/views/layouts/_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</ul>
<ul class="nav pull-right">
<% if user_signed_in? %>
<li><%= link_to "Add +", new_pin_path %></li>
<li><%= link_to "Edit Profile", edit_user_registration_path %></li>
<li><%= link_to "Logout", destroy_user_session_path, method: :delete %></li>
<% else %>
Expand Down
1 change: 1 addition & 0 deletions app/views/pages/home.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</p>
<p>
<%= link_to "Sign Up Now!", new_user_registration_path, class: "btn btn-primary btn-large" %>
<%= link_to "Sign In", new_user_session_path, class: "btn btn-primary btn-large" %>
</p>
</div>
<% end %>
Expand Down
24 changes: 16 additions & 8 deletions app/views/pins/_pin.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@

<tr>
<td><%= image_tag pin.image(:medium) %></td>
<td><%= pin.description %></td>
<td><%= link_to 'Show', pin %></td>
<div class="box">
<%= link_to (image_tag pin.image(:medium)), pin %>
<p class= "description">
<%= pin.description %>
</p>
<p>
<strong>
<%= link_to 'Show', pin %>
</strong>
</p>
<% if current_user == pin.user %>
<td><%= link_to 'Edit', edit_pin_path(pin) %></td>
<td><%= link_to 'Destroy', pin, method: :delete, data: { confirm: 'Are you sure?' } %></td>
<p>
<%= link_to 'Edit', edit_pin_path(pin) %>
<%= link_to 'Destroy', pin, method: :delete, data: { confirm: 'Are you sure?' } %>
</p>
<% end %>
</tr>
</div>

22 changes: 3 additions & 19 deletions app/views/pins/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
<h1>Listing pins</h1>

<table class="table table-striped">
<thead>
<tr>
<th>Image</th>
<th>Description</th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>

<tbody>
<%= render @pins %>
</tbody>
</table>

<br>
<div id="pins">
<%= render @pins %>
</div>

<%= link_to 'New Pin', new_pin_path %>
13 changes: 13 additions & 0 deletions vendor/assets/javascripts/jquery.isotope.min.js

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions vendor/assets/javascripts/jquery.masonry.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1783203

Please sign in to comment.