{% extends "admin/change_list.html" %}
{% load admin_list i18n admin_tree_list_tags %}
{% block extrahead %}
    {{ block.super }}
    <script type="text/javascript">
    (function($) {
        $(document).ready(function()  {
            var srchString = document.getElementById('grp-changelist-search').value;
            if (srchString == '')
                treeTable = $("#result_list").treeTable({initialState : "{{ EDITOR_TREE_INITIAL_STATE }}"});
            else
                treeTable = $("#result_list").treeTable({initialState : "expanded"});
        function toggleChildren(index, value) {
            var row = value.parentNode.parentNode;
            if (row.className.match(/child-of-node-\d+/)) {
                value.checked = /child-of-node-(\d+)/.exec(row.className);
            }
            if($(row).hasClass("parent")) {
                $("table.treeTable tbody tr.child-of-" + row.id + " input").each(toggleChildren);
            }
            $("tr input.action-select").actions();
        };
        $('.action-select').each(
            function(){
                $(this).bind('click', function(event){
                    // Get the tr from checkbox -> td -> tr
                    var row = event.currentTarget.parentNode.parentNode;
                    $("table.treeTable tbody tr.child-of-" + row.id + " input").each(toggleChildren);
                });
            });
        });
    })(django.jQuery);
    </script>
    <style type="text/css">
    #result_list.treeTable .expander {
        margin-left: -10px !important;
        padding-right: 13px !important;
        padding-left: 0px !important;
    }
    #result_list.treeTable .action-select {
        margin-left: 7px;
    }
    </style>
{% endblock %}
{% block result_list %}
    {% result_tree_list cl %}
    {% if action_form and actions_on_bottom and cl.full_result_count %}{% admin_actions %}{% endif %}
{% endblock %}
