<div class="repository-info">
  <% if repository.checkout_description.present? %>
  <div class="wiki<%= ' bottomline' if protocols.present? %>"><%= textilizable repository.checkout_description %></div>
  <% end %>
  <% if protocols.present? %>
  <div id="checkout_box">
    <ul id="checkout_protocols">
    <% protocols.each do |p| -%>
      <li>
        <a <%= 'class="selected"' if p == default_protocol %> id="checkout_protocol_<%= p.protocol.to_s.underscore %>" data-permission="<%= p.access_rw(User.current) %>" href="<%= URI.escape p.url(checkout_path) %>"><%=h p.protocol %></a>
      </li>
    <% end -%>
    </ul>
    <%= text_field_tag :checkout_url, h(default_protocol.full_command(checkout_path)), :readonly => true %>
    <%- if Setting.checkout_use_zero_clipboard? %>
    <div id="clipboard_container" title="<%= l(:label_copy_to_clipboard) %>" style="display: none;">
       <div id="clipboard_button"><%= image_tag 'paste.png', :plugin => 'redmine_checkout' %></div>
    </div>
    <% end -%>

    <p>
    <% if User.current.logged? %>
      <% if repository.is_external? %>
      <%=l :label_access_type_all, :type => l(:label_access_read_only) %>
      <% else %>
      <% if default_protocol %><%=l :label_access_type, :type => l(default_protocol.access_label(User.current)) %><% end %>
      <% end %>
    <% else %>
      &nbsp;
    <% end %>
    </p>

    <% javascript_tag do %>
      var checkout_access   = $H({<%= protocols.inject([]){|r,p| r << "'checkout_protocol_#{p.protocol.to_s.underscore}': '#{l(p.access_label(User.current))}'"}.join(', ') %>});
      var checkout_commands = $H({<%= protocols.inject([]){|r,p| r << "'checkout_protocol_#{p.protocol.to_s.underscore}': '#{escape_javascript(p.full_command(checkout_path))}'"}.join(', ') %>});
      <%- if Setting.checkout_use_zero_clipboard? %>ZeroClipboard.setMoviePath( '<%= image_path('ZeroClipboard.swf', :plugin => 'redmine_checkout') %>' );<% end %>
    <% end %>
  </div>
  <% end%>
  <% if repository.is_external? %>
    <div style="clear: left">
    </div>
    <p class="topline" style="padding-top: 1em"><%= l(:text_repository_external, :location => repository.external_url) %></p>
  <% end %>
</div>
<div style="clear: left"></div>

<% content_for :header_tags do %>
  <%= stylesheet_link_tag 'checkout', :plugin => 'redmine_checkout' %>
  <%= javascript_include_tag 'checkout', :plugin => 'redmine_checkout' %>
  <%= (javascript_include_tag 'ZeroClipboard', :plugin => 'redmine_checkout') if Setting.checkout_use_zero_clipboard? %>
<% end %>
