<% #listItem %>
<a name="<% poll.id %>" id="<% poll.id %>"></a>
<tr>
   <td class='uk-text-right'><% poll.votes %></td>
   <td style='max-width: 200px; overflow: hidden;'>
      <% poll.question | stripTags | poll.link %>
   </td>
   <td><% poll.creator %></td>
   <td><% poll.created text %></td>
   <td class='uk-text-right'>
      <% poll.link status <% if <% poll.status %> is open then "<i class='uk-icon-unlock'></i>" else "<i class='uk-icon-lock'></i>" %> %>
   </td>
   <td style='white-space: nowrap;' class='uk-text-right'>
      <a href='' class='av-clipboard-copy' data-text='<% gettext 'Please use the copy command.' %>' data-value="<% poll.macro %>"><i class='uk-icon-clipboard'></i></a><span title='' data-uk-tooltip="{pos: 'left'}">
      <% poll.link delete "<i class='uk-icon-trash-o'></i>" %>
      <% poll.link edit "<i class='uk-icon-pencil'></i>" %>
   </td>
</tr>

<% #header %>
<h1><% poll.question | stripTags %></h1>
<div class='uk-article-meta'>
   <% gettext "Posted by {0} on {1}" <% poll.creator %> <% poll.created short %> %>
</div>

<% #footer %>
<div class='uk-margin-top'>
   <% poll.link edit <% gettext Edit %> class='uk-button' %>
   <% if <% poll.status %> is open then
      <% poll.link status <% gettext Stop %> class='uk-button uk-button-danger' style='color: #fff;' %>
   else
      <% poll.link status <% gettext Run %> class='uk-button uk-button-success' style='color: #fff;' %>
   %>
</div>

<% #main %>
<% if <% param.header %> is true then
   <% poll.skin #header %>
else
   <% poll.question prefix='<div class="pollTitle">' suffix="</div>" %>
%>
<form class='uk-margin-top uk-panel uk-panel-box uk-form uk-form-stacked' method="post" action="<% poll.href %>">
   <% poll.loop skin="$Choice#main" %>
   <div class='uk-margin-top'>
      <button class='uk-button uk-button-primary' type="submit" id="submit" name="submit" value="1">
         <% gettext Vote %>
      </button>
      <% poll.link result <% gettext "Results" %> class='uk-button uk-button-link' %>
   </div>
</form>
<% poll.skin #footer %>

<% #results %>
<% if <% param.header %> is true then
   <% poll.skin #header %>
else
   <% poll.question prefix=<strong> suffix=</strong> %>
%>
<div class='uk-margin-top uk-panel uk-panel-box'>
   <% poll.loop skin="$Choice#result" %>
   <div style='float: left;'>
      <strong><% gettext Total suffix=: %></strong>
      <% ngettext "{0} vote" "{0} votes" <% poll.votes %> %>
   </div>
   <div class='uk-text-right'>
      <% if <% poll.status %> is open then
         <% poll.link main <% gettext 'Add Your Vote' %> class='uk-button uk-button-primary uk-button-mini' style='color: #fff;' %>
      else
         <% gettext "This poll was closed {0} by {1}" <% poll.closed text %> <% poll.modifier %> prefix="<span class='uk-text-muted'>" suffix='</span>' %>
      %>
   </div>
   <% if <% poll.status %> is open then
   %>
</div>
<% poll.skin #footer %>

<% #edit %>
<h1>
   <% response.title %>
   <% poll.link . ' ' class='uk-icon-button uk-icon-link uk-text-middle' %>
</h1>
<div class='uk-article-meta'>
   <% if <% poll.creator %> is null then '' else
      <% gettext 'Created by {0} on {1}' <% poll.creator %> <% poll.created short %> prefix=<div> suffix=</div> %>
   %>
   <% if <% poll.created %> is <% poll.modified %> then '' else
      <% gettext 'Last modified by {0} on {1}' <% poll.modifier %> <% poll.modified short %> prefix=<div> suffix=</div> %>
   %>
</div>
<form class='uk-margin-top uk-form uk-form-stacked' method="post" action="<% response.action %>">
   <div class='uk-form-row'>
      <div class='uk-form-label'><% gettext Question %></div>
      <div class='uk-form-controls'>
         <% poll.input question rows=3 class=uk-width-1-1 %>
      </div>
   </div>
   <legend class='uk-margin-top'><% gettext Choices %></legend>
   <% poll.input choices %>
   <div class="uk-text-small uk-form-row">
      <a href='' id="add">
         <i class='uk-icon-plus'></i>
         <% gettext "Add Choice" %>
      </a>
   </div>
   <fieldset class='uk-margin-top'>
     <legend><% gettext Information %></legend>
      <div class='uk-form-row'>
         <% poll.macro | link 'javascript:' data-value=<% poll.macro %> data-text=<% gettext "Use keyboard shortcut to copy." %> class='av-clipboard-copy' %>
      </div>
   </fieldset>
   <div class='uk-margin-top'>
      <button class='uk-button uk-button-primary' type="submit" name="save" value="<% poll.status default=closed %>">
         <% gettext Save %>
      </button>
      <% if <% poll.status %> is open then '' else
         <% gettext "Save and Run" prefix="<button class='uk-button uk-button-success' type='submit' name='save' value='open'>" suffix=</button> %>
      %>
      <% poll.link delete <% gettext Delete %> class='uk-button' %>
      <a href='' class='cancel uk-button uk-button-link'><% gettext Cancel %></a>
   </div>
</form>
<script type="text/javascript">
$(function() {
   var index = $(".choice").length + 1;
   $("#add").on('click', function (event) {
      event.preventDefault();
      var choice = $(".choice:last").clone();
      choice.find(".uk-form-label").text('#' + index);
      choice.find("input").attr("value", '');
      $(".choice:last").after(choice);
      $(".choice:last").find("input").focus();
      index += 1;
   });
});
</script>
