Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

height動的に作らなくしたのでfor文もいらない

  • Loading branch information...
commit a8d5c0da72d644ff488499916bcab008694ce3da 1 parent ebf6e17
@wacky wacky authored
Showing with 19 additions and 35 deletions.
  1. +19 −35 app/assets/javascripts/photos.js
View
54 app/assets/javascripts/photos.js
@@ -66,59 +66,43 @@ function onLoadData(data) {
var html = ''
, i = 0
, length = data.photos.length
- , image;
-
- for(; i<length; i++) {
-
- image = data.photos[i];
-
- var tmpl = _.template(
- '<li class="imageBox">'
+ , image
+ , tmpl = '<% _.each(data, function(image) { %> '
+ + '<li class="imageBox">'
+ '<figure>'
- + '<img class="move" src="<%= filename %>" width="200" data-pos="<%= id %>">'
+ + '<img class="move" src="<%= image.avatar_file_name %>" width="200" data-pos="<%= image.id %>">'
+ '<figcaption>'
+ '</figcaption>'
+ '</figure>'
- + '<p class="picname"><%= name %></p>'
+ + '<p class="picname"><%= image.name %></p>'
+ '<div class="prefecturemenu">'
- + '<span class="prefectureaic typcn" data-pos="<%= id %>"></span>'
- + '<p class="prefecture"><%= pref %></p>'
+ + '<span class="prefectureaic typcn" data-pos="<%= image.id %>"></span>'
+ + '<p class="prefecture"><%= image.prefecture %></p>'
+ '</div>'
+ '<div class="menu">'
+ '<div class="piceyemenu">'
+ '<div class="picmenu">'
- + '<span class="likephoto typcn" data-pos="<%= id %>"></span>'
- + '<span class="likenum"><%= like %></span>'
+ + '<span class="likephoto typcn" data-pos="<%= image.id %>"></span>'
+ + '<span class="likenum"><%= image.like %></span>'
+ '</div>'
+ '<div class="lookmenu">'
- + '<span class="lookphoto typcn" data-pos="<%= id %>"></span>'
- + '<span class="looknum"><%= look %></span>'
+ + '<span class="lookphoto typcn" data-pos="<%= image.id %>"></span>'
+ + '<span class="looknum"><%= image.look %></span>'
+ '</div>'
+ '</div>'
+ '</div>'
- + '</li>'
- );
-
- // Add image HTML to the page.
- $('#tiles').append(
- tmpl({
- 'id' : image.id
- , 'filename': image.avatar_file_name
- , 'name' : image.name
- , 'pref' : image.prefecture
- , 'like' : image.like
- , 'look' : image.look
- }));
- }
+ + '</li><% }); %>';
- // Apply layout.
- applyLayout();
+ // Add image HTML to the page.
+ $('#tiles').append(_.template(tmpl, {data: data.photos}));
- /* $("span").on("click",function(){
+ // Apply layout.
+ applyLayout();
- });*/
+ /* $("span").on("click",function(){
- };
+ });*/
+};
$(document).ready(new function() {
Please sign in to comment.
Something went wrong with that request. Please try again.