{% load i18n %}
<!DOCTYPE HTML>
{% get_current_language as LANGUAGE_CODE %}
<html lang="{{ LANGUAGE_CODE }}">
<head>
    <meta charset="UTF-8">
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
    <meta content="yes" name="apple-mobile-web-app-capable" />
    <meta content="black" name="apple-mobile-web-app-status-bar-style" />
    <meta name="format-detection" content="telephone=no" />
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.css" crossorigin="anonymous">
    <link rel="stylesheet" href="/static/niji/css/main.css"/>
    <title>{{ title }}{% if site_name %}-{{ site_name }}{% endif %}</title>
</head>
<body>

<nav class="navbar navbar-default">
    <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="{% url 'niji:index' %}">{% if site_name %}{{ site_name }}{% else %}NIJI{% endif %}</a>
        </div>
        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
                <li class=""><a href="{% url 'niji:index' %}">Home</a></li>
            </ul>
            <form class="navbar-form navbar-left" role="search" action="{% url 'niji:search_redirect' %}">
                <div class="form-group">
                    <input type="text" id="keywordInput" name="keyword" class="form-control" placeholder="{% trans 'Search' %}">
                </div>
                <button type="submit" id="navSearchBtn" class="btn btn-default">{% trans 'Search' %}</button>
            </form>
        </div><!-- /.navbar-collapse -->
    </div><!-- /.container-fluid -->
</nav>

<div id="main" class="container">
    <div class="row">
        <div class="col-lg-8"> <!-- LEFT -->
            {% block left %}{% endblock %}
        </div><!-- END LEFT -->
        <div class="col-lg-4"> <!-- RIGHT -->
            {% block widgtet_before %}{% endblock %}
            {% if request.user.is_authenticated %}
                {% include 'niji/widgets/authenticated_user_panel.html' %}
            {% else %}
                {% include 'niji/widgets/visitor_user_panel.html' %}
            {% endif %}
            {% include 'niji/widgets/nodes.html' %}
            {% block widget_after %}{% endblock %}
        </div><!-- END RIGHT -->
    </div>
</div>

<script src="//code.jquery.com/jquery-2.2.0.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" crossorigin="anonymous"></script>
<script>
    $(document).ready(function(){
        $('#navSearchBtn').click(function(e){
            e.preventDefault();
            var keyword = $('#keywordInput').val();
            if(keyword){
                window.location = "/search/" + keyword +"/"; // FIXME: Use url tag!
            }
        });
    });
</script>
{% block footer_ext %}{% endblock %}
</body>
</html>
