{% block aloha %}
  {% if request.user.is_staff %}
  <script type="text/javascript">
    Aloha = {}; Aloha.settings = {};
    Aloha.settings.baseUrl = '{{ MEDIA_URL }}js/aloha/lib/';
    Aloha.settings.locale = 'en';
  </script>

  <script type="text/javascript" src="{{ MEDIA_URL }}js/aloha/lib/aloha.js" data-aloha-plugins="common/format,common/link,common/image,common/list,common/undo,common/paste"></script>
  <script type="text/javascript">
    Aloha.ready(function () {
        Aloha.jQuery('.aloha-editable').aloha();
	$('form.aloha').click(function() {
	    $(this).find('input[name="save-content"]').show();
	});
        $('form.aloha input[name="save-content"]').click(function () {
	    var form = $(this).parent();
	    var hidden_content = $('<input type="hidden" name="content"/>');
	    hidden_content.val(form.find('.aloha-editable').html());
	    form.append(hidden_content);
	    form.submit();
	});
    })
  </script>
  {% endif %}
{% endblock %}
