{% extends 'base.html' %} {% load i18n %} {% load mptt_tags %} {% block title %}{% trans "Edit menu" %}{% endblock %} {% block main %}

{{ root.name }}

    {% recursetree menu %}
  1. {{ node.name }}
    {% if not node.is_leaf_node %}
      {{ children }}
    {% endif %}
  2. {% endrecursetree %}
{% csrf_token %}
{% endblock main %} {% block sidebar %}

{% trans "Menu editing" %}

{% trans "Reorder by dragging and dropping up and down, left and right. If the elements are indented, they will belong to a submenu. You can create a large structure doing this, but the best is to keep it simple. The plus and minus is used to create or delete elements. Use the topmost plus to add elements to the main menu." %}

{% endblock %} {% block footer_include %} {% endblock footer_include %} {% block footer_js %} $('ol.nested_sortable').nestedSortable({ disableNesting: 'no-nest', forcePlaceholderSize: true, handle: 'div', helper: 'clone', items: 'li', opacity: 0.6, placeholder: 'placeholder', tabSize: 25, tolerance: 'pointer', toleranceElement: '> div', }); $('#submit_menu').click(function(){ var tree = $('ol.nested_sortable').nestedSortable('toArray', {startDepthCount: 0}); tree = JSON.stringify(tree); $('#mptt_tree').val(tree); }); // add onclick to delete-item-buttons $("span.delete_item").each(function(index){ $(this).click(function(){ var id = $(this).attr('id').split('_'); id = id[2]; $.ajax({ url: '{% url menu-delete %}', type: 'POST', data: 'node_id='+id, success: function(data){ location.reload(); } }); }); }); // add onclick to new-item-buttons $("span.new_item").each(function(index){ $(this).click(function(){ var id = $(this).attr('id').split('_'); id = id[2]; $.ajax({ url: '{% url menu-new %}', type: 'GET', data: 'parent_id='+id, success: function(data){ $("#new_menu_item").html(data); } }); }); }); {% endblock footer_js %}