<% provide :title do %><%= @poll.name %><% end %>

<div class="polls-show">
  <%= render "poll_header" %>

  <%= render "poll_subnav" %>

  <div class="row margin">
    <div class="small-12 medium-9 column">
      <%= render "callout" %>

      <% if @poll.voted_in_booth?(current_user) %>
        <div class="callout warning">
          <%= t("polls.show.already_voted_in_booth") %>
        </div>
      <% else %>

        <% if current_user && @poll.voted_in_web?(current_user) && !@poll.expired? %>
          <div class="callout warning">
            <%= t("polls.show.already_voted_in_web") %>
          </div>
        <% end %>
      <% end %>

      <% @questions.each do |question| %>
        <%= render 'polls/questions/question', question: question, token: @token %>
      <% end %>

      <% if poll_voter_token(@poll, current_user).empty? %>
        <div class="callout token-message js-token-message" style="display: none">
          <%= t('poll_questions.show.voted_token') %>
        </div>
      <% end %>
    </div>
  </div>

  <div class="expanded poll-more-info">
    <div class="row margin">
      <div class="small-12 medium-9 column">
        <h3><%= t("polls.show.more_info_title") %></h3>
        <%= safe_html_with_links simple_format(@poll.description) %>
      </div>

      <% if false %>
        <aside class="small-12 medium-3 column">
          <div class="sidebar-divider"></div>
          <h2><%= t("polls.show.documents") %></h2>
        </aside>
      <% end %>
    </div>
  </div>

  <div class="expanded poll-more-info-answers">
    <div class="row padding">

      <% @poll_questions_answers.each do |answer| %>
        <div class="small-12 medium-6 column end answer <%= cycle('first', '') %>" id="answer_<%= answer.id %>">

          <% if answer.description.present? %>
            <h3><%= answer.title %></h3>
          <% end %>

          <% if answer.images.any? %>
            <%= render "gallery", answer: answer %>
          <% end %>

          <% if answer.description.present? %>
            <div class="margin-top">
              <div id="answer_description_<%= answer.id %>" class="answer-description short" data-toggler="short">
                <%= safe_html_with_links simple_format(answer.description) %>
              </div>
              <div class="margin">
                <a id="read_more_<%= answer.id %>"
                   data-toggle="answer_description_<%= answer.id %> read_more_<%= answer.id %> read_less_<%= answer.id %>"
                   data-toggler="hide">
                  <%= t("polls.show.read_more", answer: answer.title) %>
                </a>
                <a id="read_less_<%= answer.id %>"
                   data-toggle="answer_description_<%= answer.id %> read_more_<%= answer.id %> read_less_<%= answer.id %>"
                   data-toggler="hide"
                   class="hide">
                  <%= t("polls.show.read_less", answer: answer.title) %>
                </a>
              </div>
            </div>
          <% end %>

          <% if answer.documents.present? %>
            <div class="document-link">
              <p>
                <span class="icon-document"></span>&nbsp;
                <strong><%= t("polls.show.documents") %></strong>
              </p>

              <% answer.documents.each do |document| %>
                  <%= link_to document.title,
                              document.attachment.url,
                              target: "_blank",
                              rel: "nofollow" %><br>
              <% end %>
            </div>
          <% end %>

          <% if answer.videos.present? %>
            <div class="video-link">
              <p>
                <span class="icon-video"></span>&nbsp;
                <strong><%= t("polls.show.videos") %></strong>
              </p>

              <% answer.videos.each do |video| %>
                  <%= link_to video.title,
                              video.url,
                              target: "_blank",
                              rel: "nofollow" %><br>
              <% end %>
            </div>
          <% end %>
        </div>
      <% end %>
    </div>

  </div>

  <div class="tabs-content" data-tabs-content="polls_tabs">
    <%= render "filter_subnav" %>

    <div class="tabs-panel is-active" id="tab-comments">
      <%= render "comments" %>
    </div>
  </div>
</div>
