Skip to content

Commit

Permalink
Reworked the template to initialize the correct javascript and use th…
Browse files Browse the repository at this point in the history
…e result_tree_list
  • Loading branch information
Corey Oordt committed Dec 16, 2010
1 parent d027b75 commit 7f0e93f
Showing 1 changed file with 30 additions and 114 deletions.
144 changes: 30 additions & 114 deletions editor/templates/admin/editor/tree_editor.html
Original file line number Diff line number Diff line change
@@ -1,117 +1,33 @@
{% extends "admin/change_list.html" %}
{% load adminmedia admin_list i18n %}

{% load adminmedia admin_list i18n admin_tree_list %}
{% block extrahead %}
{{ block.super }}

<style type="text/css">
.page_marker { display:block; text-align: right; float: left; padding: 1px 2px 0 0; }
tr.cut { border: 2px dashed black; opacity: 0.5; }
</style>

<script type="text/javascript">
/* This represents the current state of the page tree. Would need to be
refreshed if pages are moved or deleted, but for now that is not possible */
var tree_structure = {{ tree_structure|default:"{}" }};

/* After loading the page, show all root nodes */
$(function()
{
{% if is_popup %}
// resize window a bit, the default size is too small for the tree column
window.resizeTo(Math.min(window.outerWidth+300, screen.availWidth), window.outerHeight);
{% endif %}

$('table').hide(); /* hide table until set up */
$('a.paste_target').hide();

expand_sym = '&#9658;'; //'<img alt="+" src="{{ EDITOR_MEDIA_PATH }}img/disclosure-right.png">';
collapse_sym = '&#9660;'; //'<img alt="-" src="{{ EDITOR_MEDIA_PATH }}img/disclosure-down.png">';

tree_structure_clean(); /* reduce structure to actually present items */

root_items = [];
for(k in tree_structure)
{
p = page(k);
if(p.ptr)
{
p.row.hide(); /* default hide */
/* Note all root (ie. has no parent) nodes */
if(!p.parent)
root_items.push(p);
}
}

for(i in root_items)
{
p = root_items[i];
p.row.show();
if(p.open)
open_subtree(p.id);
}

/* yuck :-) */
$('table thead tr th:eq(1)').attr('style', 'width: 450px;');

$('tbody tr').removeClass('row1').removeClass('row2');
$('table').show();
recolor_lines();
});

var cut_item_pk = null;
function cut_item(pk, elem) {
var row = $(elem.parentNode.parentNode);

if(row.hasClass('cut')) {
cut_item_pk = null;
$('a.paste_target').hide();
row.removeClass('cut');
} else {
cut_item_pk = pk;
$('a.paste_target').show();
$('tr').removeClass('cut');
row.addClass('cut').find('a.paste_target').hide();
}

return false;
}

function paste_item(pk, position) {
if(!cut_item_pk)
return false;

$.post('.', {
'__cmd': 'move_node',
'position': position,
'cut_item': cut_item_pk,
'pasted_on': pk
}, function(data) {
if(data == 'OK')
window.location.reload();
else
alert(data);
});

return false;
}

</script>

{{block.super}}
<script type="text/javascript">
(function($) {
$(document).ready(function() {
treeTable = $("#result_list").treeTable({initialState : "expanded"});
function toggleChildren() {
this.checked = event.currentTarget.checked;
var row = this.parentNode.parentNode.parentNode;
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 -> a -> td -> tr
var row = event.currentTarget.parentNode.parentNode.parentNode;
$("table.treeTable tbody tr.child-of-" + row.id + " input").each(toggleChildren);
});
});
});
})(django.jQuery);
</script>
{% endblock %}
{% block result_list %}
{% if action_form and actions_on_top and cl.full_result_count %}{% admin_actions %}{% endif %}
{% result_tree_list cl %}
{% if action_form and actions_on_bottom and cl.full_result_count %}{% admin_actions %}{% endif %}
{% endblock %}


{% comment %}
{% block filters %}
{% if cl.has_filters %}
<div id="changelist-filter">
<h2>{% trans 'Filter' %}</h2>
{% for spec in cl.filter_specs %}{% admin_list_filter cl spec %}{% endfor %}

<h3>Links</h3>
<li class="selected"><a href="#">Dings</a> </li>
</div>
{% endif %}

{% endblock %}
{% endcomment %}

0 comments on commit 7f0e93f

Please sign in to comment.