{% extends "admin/change_list.html" %}
{% load i18n admin_static admin_list cms_admin cms_js_tags %}

{% block title %}{% trans "List of pages" %}{% endblock %}
{% block bodyclass %}change-list{% endblock %}

{% if not is_popup %}{% block breadcrumbs %}
<div class="breadcrumbs">
	<a href="../../">{% trans "Home" %}</a> &rsaquo;
	<a href="../">{{ app_label|capfirst|escape }}</a> &rsaquo; {{ opts.verbose_name_plural|capfirst|escape }}
</div>
{% endblock %}{% endif %}

{% block coltype %}flex{% endblock %}
{% block extrastyle %}
{{ block.super }}
<link rel="stylesheet" type="text/css" href="{% static "cms/css/cms.base.css" %}" />
<link rel="stylesheet" type="text/css" href="{% static "cms/css/plugins/cms.pagetree.css" %}" />
<link rel="stylesheet" type="text/css" href="{% static "cms/js/jstree/tree_component.css" %}" />
{% if cl.is_filtered %}
<link rel="stylesheet" type="text/css" href="{% static "cms/js/jstree/themes/default/style.css" %}" />
{% endif %}
{% endblock extrastyle %}

{% block extrahead %}
{{ block.super }}
{% block jquery %}<script type="text/javascript" src="{% static "admin/js/jquery.min.js" %}"></script>{% endblock jquery %}
<!-- load jstree -->
<script type="text/javascript" src="{% static "cms/js/jstree/_lib/_all.js" %}"></script>
<script type="text/javascript" src="{% static "cms/js/jstree/tree_component.js" %}"></script>
<!-- load changelist -->
<script type="text/javascript" src="{% static "cms/js/plugins/jquery.ui.custom.js" %}"></script>
<script type="text/javascript" src="{% static "cms/js/plugins/cms.base.js" %}"></script>
<script type="text/javascript" src="{% static "cms/js/plugins/cms.changelist.js" %}"></script>
<script type="text/javascript">
(function($) {
// CMS.$ will be passed for $
$(document).ready(function () {

	// bind csrf token to the header
	CMS.API.Helpers.csrf('{{ csrf_token }}');

	{% if not cl.is_filtered %}
		initTree();
	{% endif %}

	moveSuccess = function(node){
		var msg = $({% javascript_string %}<span class="success">{% trans "Successfully moved" %}</span>{% end_javascript_string %});
		node.append(msg);
		msg.fadeOut(3000);
	};
	moveError = function(node,message){
		if(message && message!="error") {
			var msg = $({% javascript_string %}<span class="success">{% end_javascript_string %}+message+{% javascript_string %}</span>{% end_javascript_string %});
		}
		else {
			var msg = $({% javascript_string %}<span class="success">{% trans "An error occured. Please reload the page" %}</span>{% end_javascript_string %});
		}
		node.append(msg);
	};
	// some settings used by javascript functions
	cmsSettings = {
		cmsPermission: {{ CMS_PERMISSION|js }},
		debug: {{ DEBUG|js }}
	};

});
})(CMS.$);
</script>
{% endblock extrahead %}

{% block content %}

<div id="content-main"{% if cl.is_filtered %} class="activ-filter"{% endif %}>

{% block object-tools %}

	<ul class="object-tools">
		{% if has_recover_permission %}
			<li><a href="recover/" class="recoverlink">{% blocktrans with cl.opts.verbose_name_plural|escape as name %}Recover deleted {{name}}{% endblocktrans %}</a></li>
		{% endif %}
		{% if has_add_permission %}
		<li><a href="add/{% if is_popup %}?_popup=1{% endif %}" class="addlink">{% blocktrans with cl.opts.verbose_name as name %}Add {{ name }}{% endblocktrans %}</a></li>
		{% endif %}
	</ul>

	<div id="loader-message">{% trans "Loading..." %}</div>

{% endblock %}
<div class="module{% if cl.has_filters %} filtered{% endif %}" id="changelist">
{% block search %}

<form action="." method="post">
{% if cl.has_access_to_multiple_sites %}
	<div id="site-selector">{% trans "Pages on:" %}
		<select id="site-select" name="site__exact">
			{% for site in cl.sites %}
			<option {% ifequal site.pk cl.current_site.pk %}selected {% endifequal %}value="{{ site.pk }}">{{ site.name }}</option>
			{% endfor %}
		</select>
		<input type="hidden" id="site-copy" name="copy" />
		{% csrf_token %}
	</div>
{% else %}
	<input type="hidden" id="site-select" value="{{ cl.sites.0.pk }}">
{% endif %}
</form>

{% search_form cl %}
{% endblock %}
{% block date_hierarchy %}{% date_hierarchy cl %}{% endblock %}

{% block filters %}
{% if cl.has_filters %}

<a href="#" id="changelist-filter-button">{% trans "Filter:" %} {% if cl.is_filtered %}{% trans "on" %}{% else %}{% trans "off" %}{% endif %}</a>
<div id="changelist-filter" style="display:none;">
<h2>{% trans 'Filter' %}</h2>
{% for spec in cl.filter_specs %}
	{% clean_admin_list_filter cl spec %}
{% endfor %}
</div>
{% endif %}
{% endblock %}

{% include "admin/cms/page/tree/base_header.html" %}

</div>
</div>

<div id="dialogs"></div>

{% endblock %}