{% load i18n sekizai_tags admin_static cms_js_tags cms_admin cms_tags %}{% load url from future %}
{% language request.toolbar.toolbar_language %}
{% addtoblock "js" %}
<script type="text/javascript">
	var _jQuery = window.jQuery || null;
	var _$ = window.$ || null;
</script>
{% endaddtoblock %}
{% addtoblock "js" %}<script type="text/javascript" src="{% static "admin/js/jquery.min.js" %}"></script>{% endaddtoblock %}
{% addtoblock "js" %}<script type="text/javascript" src="{% static "cms/js/libs/class.min.js" %}"></script>{% endaddtoblock %}
{% addtoblock "js" %}<script type="text/javascript" src="{% static "cms/js/plugins/jquery.ui.custom.js" %}"></script>{% endaddtoblock %}
{% addtoblock "js" %}<script type="text/javascript" src="{% static "cms/js/plugins/cms.base.js" %}"></script>{% endaddtoblock %}
{% addtoblock "js" %}<script type="text/javascript" src="{% static "cms/js/plugins/cms.toolbar.js" %}"></script>{% endaddtoblock %}
{% addtoblock "js" %}<script type="text/javascript" src="{% static "cms/js/plugins/cms.placeholders.js" %}"></script>{% endaddtoblock %}

{% addtoblock "css" %}<link rel="stylesheet" type="text/css" href="{% static "cms/css/plugins/cms.toolbar.css" %}" />{% endaddtoblock %}
{% addtoblock "css" %}<link rel="stylesheet" type="text/css" href="{% static "cms/css/plugins/cms.placeholders.css" %}" />{% endaddtoblock %}
{% addtoblock "js" %}
<script type="text/javascript">
(function($) {
// CMS.$ will be passed for $
$(document).ready(function () {
	// initialize toolbar and pass required options
	CMS.API.Toolbar = new CMS.Toolbar('#cms_toolbar', {
		'csrf': '{{ csrf_token }}',
		'authenticated': {% if user.is_authenticated %}true{% else %}false{% endif %},
		'debug': {% if debug %}true{% else %}false{% endif %},
		'settings': {
			'toolbar': 'expanded',
			'mode': 'edit'
		},
		'urls': {
			'settings': '',
			'static': {{ STATIC_URL }}
		},
		'clipboard': '{{ request.toolbar.clipboard.pk }}',
		'lang': {
			'move_warning': {% javascript_string %}{% trans "The selected element can not be moved to the desired location." %}{% end_javascript_string %},
			'delete_request': {% javascript_string %}{% trans "Are you sure you want to delete this plugin?" %}{% end_javascript_string %},
			'cancel': {% javascript_string %}{% trans "Cancel" %}{% end_javascript_string %}
		}
	});



	// initialize placeholder helpers
	CMS.API.Placeholders = new CMS.Placeholders('.cms_placeholder', '.cms_plugin');

	{% if messages %}{% for message in messages %}CMS.API.Toolbar.openMessage('{{ message }}');{% endfor %}{% endif %}

	{% if not request.current_page.publisher_is_draft and request.current_page.publisher_draft.is_dirty and user.is_authenticated  %}
	CMS.API.Toolbar.openMessage('{% trans "This page has unpublished changes." %}', 'center');
	setInterval(function () { CMS.$('.cms_toolbar-item_switch').toggleClass('cms_toolbar-item_switch-highlight'); }, 2000);
	{% endif %}
});
})(CMS.$);
</script>
{% endaddtoblock %}
{% addtoblock "js" %}
<script type="text/javascript">
	window.jQuery = _jQuery;
	window.$ = _$;
</script>
{% endaddtoblock %}
<div id="cms_toolbar" class="cms_reset{% if not user.is_authenticated %} cms_toolbar-auth{% endif %}">
	<!-- start: toolbar -->
	<div class="cms_toolbar">
		<div class="cms_toolbar-left">
			{% include "cms/toolbar/items/logo.html" %}

			{% if not user.is_authenticated %}
			{% include "cms/toolbar/items/login.html" %}
			{% else %}
			<ul class="cms_toolbar-item cms_toolbar-item-navigation">
				{% for item in request.toolbar.get_left_items %}
					{{ item.render }}
				{% endfor %}
			</ul>
			{% endif %}
		</div>

		<div class="cms_toolbar-right">
			{% for item in request.toolbar.get_right_items %}
				{{ item.render }}
			{% endfor %}
			{% if request.toolbar.can_change %}
			<div class="cms_toolbar-item cms_toolbar-item_switch{% if not request.toolbar.edit_mode %} cms_toolbar-item_switch-active{% endif %}">
				<a href="{% if request.toolbar.edit_mode %}?edit_off{% else %}?edit{% endif %}">
					<span class="cms_toolbar-item_switch-on">{% trans "Live" %}</span>
					<span class="cms_toolbar-item_switch-off">{% trans "Draft" %}</span>
				</a>
				<span class="cms_toolbar-item_switch-knob">{% trans "Change" %}</span>
			</div>
			{% endif %}
		</div>
	</div>
	<div class="cms_toolbar-trigger"><a href="#">{% trans "Toggle toolbar" %}</a></div>
	<!-- end: toolbar -->

	<!-- start: sidebar -->
	<div class="cms_sideframe">
		<div class="cms_sideframe-resize"><span class="cms_sideframe-knob"></span></div>
		<div class="cms_sideframe-frame"></div>
		<div class="cms_sideframe-shim"></div>
		<div class="cms_sideframe-btn">
			<div class="cms_sideframe-close"></div>
			<div class="cms_sideframe-hide"></div>
			<div class="cms_sideframe-maximize"></div>
		</div>
		<div class="cms_sideframe-copy"></div>
	</div>
	<!-- end: sidebar -->

	{% if request.toolbar.edit_mode or request.toolbar.build_mode %}
	{% if request.toolbar.get_clipboard_plugins %}
	{% with slot="clipbaord" %}
	<!-- start: clipboard -->
	<div class="cms_clipboard">
		<ul class="cms_clipboard-triggers">
			<!-- maximum of 5 -->
			<!-- delete link -->
			{% for plugin in request.toolbar.get_clipboard_plugins %}
				{% if not plugin.parent_id %}
				<li><a href="#">{{ forloop.index }}</a></li>
				{% endif %}
			{% endfor %}
		</ul>
		{% for plugin in request.toolbar.get_clipboard_plugins %}
		<div class="cms_plugins">{% include "cms/toolbar/plugin.html" with instance=plugin %}</div>
		{% endfor %}
		<ul class="cms_clipboard-containers cms_draggables">
			{% for plugin in request.toolbar.get_clipboard_plugins %}
				{% if forloop.counter <= 5 %}
				{% with show_language="true" %}{% include "cms/toolbar/draggable_item.html" with plugin=plugin %}{% endwith %}
				{% endif %}
			{% endfor %}
		</ul>
		<p class="cms_clipboard-empty"><a href="{% url "admin:cms_page_clear_placeholder" request.toolbar.clipboard.pk %}" data-post='{"csrfmiddlewaretoken": "{{ csrf_token }}"}'>{% trans "Empty Clipboard" %}</a></p>
	</div>
	<!-- end: clipboard -->
	{% endwith %}
	{% endif %}
	{% endif %}

	<!-- start: messages -->
	<div class="cms_messages">
		<div class="cms_messages-close"></div>
		<div class="cms_messages-inner"></div>
	</div>
	<!-- end: messages -->

	<!-- start: modal -->
	<div class="cms_modal">
		<div class="cms_modal-head">
			<span class="cms_modal-title">&nbsp;</span>
			<span class="cms_modal-collapse" title="minimize">-</span>
			<span class="cms_modal-maximize" title="maximize">+</span>
			<span class="cms_modal-close" title="close">x</span>
		</div>
		<div class="cms_modal-body">
			<div class="cms_modal-shim"></div>
			<div class="cms_modal-frame"></div>
		</div>
		<div class="cms_modal-foot">
			<div class="cms_modal-breadcrumb">
				<span class="cms_modal-breadcrumb-title">{% trans "Start" %}</span>
				<span class="cms_modal-breadcrumb-items">&nbsp;</span>
			</div>
			<div class="cms_modal-buttons"></div>
			<div class="cms_modal-resize"></div>
		</div>
	</div>
	<!-- end: modal -->

	<!-- start: placeholder -->
	<div class="cms_placeholders-tooltip">Double-click to edit</div>
	<!-- end: placeholder -->
</div>

{% endlanguage %}
