{% load seahub_tags avatar_tags group_avatar_tags i18n %}
{% load url from future %}

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{% block sub_title %}{% endblock %}{{ site_title }}</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="keywords" content="{% trans "File Collaboration Team Organization" %}" />
<link rel="icon" type="image/x-icon" href="{{ MEDIA_URL }}img/favicon.png?t=1398068110" />
<!--[if IE]>
<link rel="shortcut icon" href="{{ MEDIA_URL }}img/favicon.png?t=1398068110"/>
<![endif]-->
<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/seahub.css?t=1398068110" />
{% block extra_style %}{% endblock %}
{% if branding_css != '' %}<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}{{ branding_css }}" />{% endif %}
</head>

<body>
    <div id="wrapper" class="{{ LANGUAGE_CODE }}">
        {% block info_bar_message %}
        {% if request.user.is_authenticated and request.cur_note %}
        <div id="info-bar">
            <p id="info-bar-info">{{ request.cur_note.message|urlize|url_target_blank }}</p>
            <img src="{{ MEDIA_URL }}img/del.png" class="close" data="{{ request.cur_note.id }}" />
        </div>
        {% endif %}
        {% endblock info_bar_message %}

        <div id="header">
            <div id="header-inner">
                {% block notice_panel %}{% endblock %}
                <a href="{{ SITE_ROOT }}" id="logo" class="fleft">
                    {% if seacloud_mode %}
                    <img src="{{ MEDIA_URL }}img/seacloud_logo.png?t=1398068110" title="Seacloud" alt="logo" width="186" height="31" />
                    {% else %}
                    <img src="{{ MEDIA_URL }}{{ logo_path }}" title="Seafile" alt="logo" width="{{logo_width}}" height="{{logo_height}}" />
                    {% endif %}
                </a>
                {% block nav %}{% endblock %}

                {% if request.user.is_authenticated %}
                <div class="fright">
                {% if has_file_search %}
                    {% include 'snippets/search_form.html' %}
                {% endif %}

                <div data-cturl="{% url 'unseen_notices_count' %}" data-pgurl="{% url 'user_notification_list' %}" id="msg-count" title="{% trans "unread notices" %}" class="fleft">
                    <img src="{{ MEDIA_URL }}img/bell.png" alt="" />
                    <span class="num hide">0</span>
                </div>

                <div id="account" class="fright">
                    <div id="my-info" data-url="{% url 'space_and_traffic' %}">
                        {% avatar request.user 36 %} <span class="icon-caret-down vam"></span>
                    </div>
                    <div id="user-info-popup" class="top-info-popup hide">
                        <div class="item ovhd">
                            {% avatar request.user 36 %}
                            <div class="txt">
                                {{ request.user.username|email2nickname }} <br />
                                {{ request.user.username}}
                            </div>
                        </div>
                        <div id="space-traffic">
                            <img src="{{MEDIA_URL}}img/loading-icon.gif" alt="" class="loading-tip" />
                        </div>
                        <a class="item" href="{{ SITE_ROOT }}profile/">{% trans "Settings" %}</a>
                        <a href="{{ SITE_ROOT }}accounts/logout/" class="item" id="logout">{% trans "Log out" %}</a>
                    </div>
                    {% if request.user.is_staff %}
                    <div class="manage">
                        {% block sys_admin %}<a href="{% url 'sys_useradmin' %}" title="{% trans "System Admin" %}" class="a"><img src="{{ MEDIA_URL }}img/admin_in.png" alt="" /></a>{% endblock %}
                    </div>
                    {% endif %}
                </div>
            </div>
                {% endif %}
            </div>
        </div>

        <div id="main" class="clear">
            <div id="title-panel" class="w100 ovhd">
                {% block title_panel %}{% endblock %}
            </div>
            <div id="left-panel">
                {% block left_panel %}{% endblock %}
            </div>
            <div id="right-panel">
                {% block right_panel %}{% endblock %}
            </div>
            <div id="main-panel" class="clear w100 ovhd">
                {% if messages %}
                {% autoescape off %}
                <ul class="messages hide">
                    {% for message in messages %}
                    <li class="{{ message.tags }}">{{ message }}</li>
                    {% endfor %}
                </ul>
                {% endautoescape %}
                {% endif %}

                {% block main_panel %} {% endblock %}
            </div>
            <div id="confirm-popup" class="hide">
                <div id="confirm-con"></div>
                <button id="confirm-yes" class="btn">{% trans "Yes"%}</button>
                <button class="simplemodal-close btn">{% trans "No"%}</button>
            </div>
        </div>

        {% include 'footer.html' %}
</div><!-- wrapper -->

<script type="text/javascript" src="{{ MEDIA_URL }}js/jq.min.js?t=1398068110"></script>
<script type="text/javascript" src="{{ MEDIA_URL }}js/base.js?t=1398068110"></script>
<script type="text/javascript">
$.jstree._themes = '{{ MEDIA_URL }}js/themes/';
function ajaxErrorHandler(xhr, textStatus, errorThrown) {
    if (xhr.responseText) {
        feedback(jQuery.parseJSON(xhr.responseText).error, 'error');
    } else {
        feedback("{% trans "Failed. Please check the network." %}", 'error');
    }    
}
{% if request.user.is_authenticated %}
{% if request.cur_note %}
$('#info-bar .close').click(function() {
    $('#info-bar').addClass('hide');
    if (navigator.cookieEnabled) {
        var date = new Date(),
            cookies = document.cookie.split('; '),
            info_id_exist = false,
            new_info_id = $(this).attr('data') + '_';
        date.setTime(date.getTime() + 14*24*60*60*1000);
        new_info_id += '; expires=' + date.toGMTString() + '; path=' + '{{ SITE_ROOT }}';
        for (var i = 0, len = cookies.length; i < len; i++) {
            if (cookies[i].split('=')[0] == 'info_id') {
                info_id_exist = true;
                document.cookie = 'info_id=' + cookies[i].split('=')[1] + new_info_id;
                break;
            }
        }
        if (!info_id_exist) {
            document.cookie = 'info_id=' + new_info_id;
        }
    }
});
{% endif %}

{% if grps %}
$(function() {
    $('#top-nav-grp').after('<div id="top-nav-grp-info" class="top-info-popup hide"></div>').click(function() {
        var grp_nav = $(this),
            popup = $('#top-nav-grp-info');
        
        if (!$.trim(popup.html())) {
            var popup_con = '<ul id="top-nav-grp-list">';
                {% for grp in grps %}
            popup_con += '<li class="item" data-url="{% url "group_info" grp.id %}" title="{{ grp.group_name }}"> {% grp_avatar grp.id 36 %} <span class="vam">{{ grp.group_name|truncatechars:14 }}</span> <a href="{% url 'group_discuss' grp.id %}" title="{% trans "Discussion" %}" class="a vh fright"><img src="{{MEDIA_URL}}img/msgs.png" alt="" /></a> </li>';
                {% endfor %}
            popup_con += '</ul>';
            popup_con += '<a href="{% url 'group_list' %}" class="item all-grp">{% trans "All Groups" %}</a>';
            popup.html(popup_con);
            $('.item', popup).hover(
                function() {
                    $(this).addClass('hl').children('.a').removeClass('vh');
                },
                function() {
                    $(this).removeClass('hl').children('.a').addClass('vh');
                }
            )
            .click(function() {
                location.href = $(this).data('url'); 
            }); 
        }

        popup.css({'right': (grp_nav.outerWidth() - popup.outerWidth())/6 * 5});
        popup.toggleClass('hide');
        return false;
    });
});
{% endif %}

{% if has_file_search %}
    {% include 'snippets/search_js.html' %}
{% endif %}

{% endif %}
</script>
{% block extra_script %}{% endblock %}
{% include 'snippets/font_icon_support_for_some_browsers.html' %}
</body>
</html>
