## The contents of this file are subject to the Common Public Attribution
## License Version 1.0. (the "License"); you may not use this file except in
## compliance with the License. You may obtain a copy of the License at
## http://code.reddit.com/LICENSE. The License is based on the Mozilla Public
## License Version 1.1, but Sections 14 and 15 have been added to cover use of
## software over a computer network and provide for limited attribution for the
## Original Developer. In addition, Exhibit A has been modified to be
## consistent with Exhibit B.
##
## Software distributed under the License is distributed on an "AS IS" basis,
## WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
## the specific language governing rights and limitations under the License.
##
## The Original Code is reddit.
##
## The Original Developer is the Initial Developer.  The Initial Developer of
## the Original Code is reddit Inc.
##
## All portions of the code written by reddit are Copyright (c) 2006-2012
## reddit Inc. All Rights Reserved.
###############################################################################

<%namespace file="utils.html" import="error_field"/>
<%namespace file="captcha.html" import="captchagen"/>

<form onsubmit="return post_form(this, 'share')" method="post"
      id="sharelink_${thing.link_name}"
      class="pretty-form sharelink" action="/post/share"
     ${"" if thing.link_name else "style='display:none'"}>
  <div class="clearleft"><!--IEsux--></div>
    ${error_field("RATELIMIT", "ratelimit")}
    <input type="hidden" name="parent" value="${thing.link_name}"/>
    <table class="sharetable preftable">
      <tr class="">
        <th>
          <label for="share_to_${thing.link_name}">
            ${_("send this link to")}
          </label>
        </th>
        <td>
          <textarea id="share_to_${thing.link_name}" 
                    name="share_to" rows="4" cols="40">
            ${unsafe('&#x0D;&#x0A;'.join(websafe(e) for e in thing.emails))}
          </textarea>
        </td>
        <td class="share-to-errors">
          ${error_field("BAD_EMAILS", "share_to")}
          ${error_field("TOO_MANY_EMAILS", "share_to")}
          ${error_field("NO_EMAILS", "share_to")}
        </td>
      </tr>
      <tr>
        <th>
          <label for="share_from_${thing.link_name}">
            ${_("your name")}
          </label>&nbsp;
          <span class="little gray">
            ${_("(optional)")}
          </span>
        </th>
        <td>
          <input class="real-name" value="${thing.username}"
                 type="text" id="share_from_${thing.link_name}" 
                 name="share_from" />
        </td>
        <td class="share-from-errors">
          ${error_field("TOO_LONG", "share_from" )}
        </td>
      </tr>
      <tr>
        <th>
          <label for="replyto_${thing.link_name}">
            ${_("your email")}
          </label>&nbsp;
          <span class="little gray">
            ${_("(optional)")}
          </span>
        </th>
        <td>
          <input name="replyto" type="text" size="30"
                 id="replyto_${thing.link_name}"
                 value="${thing.email}"/>
        </td>
        <td class="reply-to-errors">
          ${error_field("BAD_EMAILS", "replyto")}
          ${error_field("TOO_MANY_EMAILS", "replyto")}
        </td>
      </tr>
      <tr>
        <th>
          <label for="message_${thing.link_name}">
            ${_("message {share form}")}
          </label>&nbsp;
          <span class="little gray">
            ${_("(optional)")}
          </span>
        </th>
        <td>
          <textarea id="message_${thing.link_name}" 
                    name="message" rows="4" cols="40">
            ${_("%(user)s from http://%(site)s/ has shared a link with you.") % dict(user = c.user.name, site=c.site.domain if c.cname and hasattr(c.site, 'domain') else g.domain)}
          </textarea>
        </td>
        <td class="message-errors">
          ${error_field("TOO_LONG", "message")}
        </td>
      </tr>
      %if thing.captcha:
        ${captchagen('', tabulate = False, size = 30)}
      %endif
      <tr>
        <td>
        </td>
        <td>
          <button type="submit" class="btn">
            ${_("share")}
          </button>
          <button class="btn" 
                  onclick="return cancelShare(this);">
            ${_("cancel")}
          </button>
          <span class="status error"></span>
        </td>
        <td>
        </td>
      </tr>
    </table>
</form>
