metamaps--metamaps/app/views/topics/index.html.erb

41 lines
1.3 KiB
Text

<%#
# @file
# This view shows an index of all topics, or just your topics if you're
# logged in
# TODO: What URL accesses this view?
#%>
<% if @user %><%= @user.name %>'s <% end %>
<% content_for :title, @user.name + "'s Topics | Metamaps" %>
<% else %>
<% content_for :title, "Topics | Metamaps" %>
<% end %>
<h1 class="index"><% if @user %><%= @user.name %>'s <% end %>Topics</h1>
<div class="topics" id="cards">
<% @topics.each do |topic| %>
<%= render topic %>
<% end %>
<% if @topics.empty? %>
<p class="empty"><br>Shucks, there are no topics. <% if authenticated? %><%= link_to "Create some if you want.", console_url %><% end %></p>
<% end %>
</div>
<script>
//bind best_in_place ajax callbacks
$('.topic').find('.best_in_place_metacode')
.bind("ajax:success", function() {
var metacode = $(this).html();
//changing img alt, img src for top card (topic view page)
//and on-canvas card. Also changing image of node
$(this).parent().find('img.icon').attr('alt', metacode);
$(this).parent().find('img.icon').attr('src', imgArray[metacode].src);
});
$('.topic').find('.best_in_place_link').bind("ajax:success", function() {
var link = $(this).html();
$(this).parent().find('.go-link').attr('href', link);
});
</script>