{% load url from future %}
{% load staticfiles %}

{% if toolbar %}
<div class="navbar navbar-fixed-bottom">
  <div class="navbar-inner">
    <div class="container-fluid">
      <!-- .btn-navbar is used as the toggle for collapsed navbar content -->
      <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </a>

      <a class="brand" href="#">Wheel CMS</a>

      <div class="nav-collapse collapse">
        <ul class="nav">
          <li>
              {% if toolbar.show_attach %}
              <div class="btn-group dropup">
                <a href="#" class="btn btn-warning dropdown-toggle" data-toggle="dropdown">
                  <i class="icon-magnet"></i> Attach
                  <b class="caret"></b>
                </a>
                <ul class="dropdown-menu">
                  {% for type in toolbar.children %}
                    <li><a href="{{instance.get_absolute_url}}create?type={{type.name}}&attach=1">{{type.title}}</a></li>
                  {% endfor %}
                </ul>
              </div>
              {% endif %}
              <div class="btn-group dropup">
              {% if toolbar.show_create %}
                {% with primary=toolbar.primary %}
                  {% if primary %}
                  <a class="btn btn-info"
                     href="{{instance.get_absolute_url}}create?type={{primary.name}}">
                    <i class="icon-plus-sign"></i>
                    Create {{primary.title}}</a>
                  <button class="btn btn-info dropdown-toggle"
                          data-toggle="dropdown">
                    <span class="caret"></span>
                  </button>
                  {% else %}
                  <a href="#" class="btn btn-info" data-toggle="dropdown">
                    <i class="icon-plus-sign"></i> Create
                    <b class="caret"></b>
                  </a>
                  {% endif %}
                {% endwith %}
                <ul class="dropdown-menu">
                  {% for type in toolbar.children %}
                    <li><a href="{{instance.get_absolute_url}}create?type={{type.name}}"><img class="spoke_icon" src="{{type.icon_path}}">{{type.title}}</a></li>
                  {% endfor %}
                </ul>
                {% endif %}
                {% if toolbar.show_translate %}
                <a class="btn btn-info" href="{{instance.get_absolute_url}}edit"><i class="icon-edit"></i> Translate</a>
                {% endif %}
                {% if toolbar.show_update %}
                <a class="btn btn-info" href="{{instance.get_absolute_url}}edit"><i class="icon-edit"></i> Edit</a>
                {% endif %}
                {% if toolbar.show_list %}
                <a class="btn btn-info" href="{{instance.get_absolute_url}}list"><i class="icon-list"></i> Contents</a>
                {% endif %}
                <!-- make the button toggle -->
                {% if toolbar.show_view %}
                <a class="btn btn-info" href="{{instance.get_absolute_url}}"><i class="icon-eye-open"></i> View</a>
                {% endif %}
              </div>
          </li>
        </ul>
      </div>
      {% if toolbar.show_settings %}
      <div class="pull-right">
        <ul class="nav">
          <li><div><a class="btn btn-mini" href="{% url "wheel_config" %}"><i class="icon-wrench"></i> Settings</a></div></li>
        </ul>
      </div>
      {% endif %}
      <div class="pull-right">
        <ul class="nav">
          <li>
            <div class="btn-group dropup">
              <a href="/" data-target="#" class="btn btn-mini dropdown-toggle"
                 data-toggle="dropdown">{{user.email}} <b class="caret"></b>
              </a>
              <ul class="dropdown-menu" role="menu">
                {# <li><a href="/"><i class="icon-cog"></i> Preferences</a></li> #}
                <li><a href="{% url "userena_profile_detail" user.username %}"><i class="icon-user"></i> Profile</a></li>
                <li class="divider"></li>
                <li><a href="{% url "userena_signout" %}"><i class="icon-off"></i> Logout</a></li>
              </ul>
            </div>
          </li>
        </ul>
      </div>
      {% with translations=toolbar.translations %}
        {% if translations %}
        <div class="pull-right">
          <ul class="nav">
            <li>
              <div class="btn-group dropup">
                <a href="/" data-target="#" class="btn btn-mini dropdown-toggle"
                   data-toggle="dropdown"> Current language: {{translations.active.language}} <b class="caret"></b>
                </a>
                <ul class="dropdown-menu" role="menu">
                  {% for translation in translations.translated %}
                    <li><a href="{{translation.action_url}}"><i class="icon-flag"></i> Switch to {{translation.language}}</a></li>
                  {% endfor %}
                  {% for language in translations.untranslated %}
                    <li><a href="{{language.action_url}}"><i class="icon-globe"></i> Create translation {{language.language}}</a></li>
                  {% endfor %}
                </ul>
              </div>
            </li>
          </ul>
        </div>
        {% endif %}
      {% endwith %}
      {% with worklist=toolbar.worklist clipboard=toolbar.clipboard %}
      <div class="pull-right">
        <ul class="nav">
          <li>
           {% if worklist.count %}
           <div class="btn-group dropup">
             <a class="badge badge-important" title="{{worklist.count}} item{{worklist.count|pluralize}} to be reviewed"
                data-toggle="dropdown"><img src="{% static "img/icons/inbox_document.png" %}"></i> {{worklist.count}}</a>
             <ul class="dropdown-menu right">
                {% for item in worklist.items %}
                <li><a href="{{item.get_absolute_url}}edit#collapseadvanced">{{item.title}}</a></li>
                {% endfor %}
             </ul>
           </div>
           {% endif %}
           {% if clipboard.count %}
           <div class="btn-group dropup">
             <a class="badge badge-info" title="{{clipboard.count}} item{{clipboard.count|pluralize}} in clipboard" data-toggle="dropdown"><img src="{% static "img/icons/paste_plain.png" %}"></i> {{clipboard.count}}</a>
             <ul class="dropdown-menu right">
                <li class="disabled"><a>{{clipboard.count}} item(s) to be {{clipboard.copy|yesno:"copied,moved"}}</a></li>
                <li class="divider"></li>
                {% for item in clipboard.items %}
                <li><a href="{{item.get_absolute_url}}edit#collapseadvanced">{{item.title}}</a></li>
                {% endfor %}
                {# clear clipboard, .. ? #}
             </ul>
           </div>
           {% endif %}
         </li>
        </ul>
      </div>
      {% endwith %}
    </div>
  </div>
</div>
{% endif %}
