<%#
  # Partial rendering form for a new topic on a map
  # This code is called when viewing a metamap in show.html.erb in the views/maps folder
  #%>
<div class="anypage">
<%= form_for Topic.new, url: topics_url, remote: true do |form| %>
  <div id="metacodeImg">
    <% @m = user.settings.metacodes %>
    <% @metacodes = [] %>
    <% @m.each do |m| %>
      <% @metacodes.push(Metacode.find(m.to_i)) %>
    <% end %>
    <% @metacodes.sort! {|m1,m2| m2.name.downcase <=> m1.name.downcase }.rotate!(-1) %>
    <% @metacodes.each do |metacode| %>
      <img class="cloudcarousel" width="40" height="40" src="/assets/<%= metacode.icon %>" alt="<%= metacode.name %>" title="<%= metacode.name %>"/>
    <% end %>
  </div> 
  <%= form.text_field :name, :maxlength => 140, :placeholder => "title..." %>
  <%= form.hidden_field :metacode, :value => "Action" %>
  <%= form.hidden_field :x, :value => 0 %>
  <%= form.hidden_field :y, :value => 0 %>
  <% if (@map.permission == "commons" && authenticated?) || @map.user == user %>
    <%= form.hidden_field :map, :value => @map.id %>
  <% end %>
  <%= form.hidden_field :grabTopic, :value => "null" %>
  <%= form.hidden_field :addSynapse, :value => false %>
  <div id="metacodeImgTitle"></div>
  <div class="clearfloat"></div>
<% end %>
</div>
