{% extends 'TopxiaWebBundle:Settings:layout.html.twig' %}

{% block title %}头像 - {{ parent() }}{% endblock %}
{% set side_nav = 'avatar' %}
{% set script_controller = 'settings/avatar' %}

{% block main %}
  {% embed "TopxiaWebBundle:Bootstrap:panel.html.twig" with {class:'panel-col'} %}
    {% block heading %}头像{% endblock %}
    {% block body %}
      
      {% if fromCourse %}
      <div class="alert alert-info">请设置自定义头像。</div>
      {% endif %}

      <form id="settings-avatar-form" class="form-horizontal" method="post">

        {{ web_macro.flash_messages() }}

        <div class="form-group">
          <div class="col-md-2 control-label"><b>当前头像</b></div>
          <div class="controls col-md-8 controls">
          	<img src="{{ filepath(user.largeAvatar, 'avatar.png') }}">
          </div>
        </div>

        <div class="form-group">
          <div class="col-md-2 control-label">
          </div>
          <div class="controls col-md-8 controls">
            <p class="help-block">你可以上传JPG、GIF或PNG格式的文件，文件大小不能超过<strong>2M</strong>。</p>
          </div>
        </div>

        <div class="form-group">
          <div class="col-md-2 control-label"></div>
          <div class="controls col-md-8 controls">
            <a id="upload-picture-btn" 
            class="btn btn-primary"
            data-upload-token="{{ upload_token('tmp', 'image') }}"
            data-goto-url="{{path('settings_avatar_crop')}}"
            >上传新头像</a>
          </div>
        </div>

        {% if partnerAvatar %}
          <div class="form-group">
            <div class="col-md-2 control-label"><b>论坛头像</b></div>
            <div class="controls col-md-8 controls">
              <img src="{{ partnerAvatar }}" class="mrm">
              <button class="btn btn-default use-partner-avatar" type="button" data-url="{{ path('settings_avatar_fetch_partner') }}" data-goto="{{ path('settings_avatar') }}">使用该头像</button>
            </div>
          </div>
        {% endif %}

      </form>

    {% endblock %}
  {% endembed %}
{% endblock %}