Revision 386 (by ahitrov, 2013/10/17 15:02:43) Section tree control (parent.pm) optimization.
jQuery 1.9.1, jQuery 1.8.3
jQuery-UI and ajax search (/ajax/document_search.html) for autocomplete
Inline control for pickup and autocomplete (future use control)
Minor improvements and bug fixes
<select name="<% $name %>" class="selects">
%	select_index_tree( $root_sect, 0, $level, $check, \$color, $tree );
</select>
<%args>

	$name => undef
	$check => undef

	$root => 1
	$level => 15

</%args>
<%init>

    my $tree;
    if ( exists $request->{"_section_tree_$root"} ) {
	$tree = $request->{"_section_tree_$root"};
    } else {
	$tree = $keeper->get_section_tree( root_id => $root );
	$request->{"_section_tree_$root"} = $tree;
    }
    my $root_sect = $tree->{root};
    my $color = 0;

    sub select_index_tree {
	my ($sect, $offset, $count_offset, $selected, $cb, $TREE) = @_;
	return	unless ref $sect;
	my $padding = 'padding-left:'.int($offset * 15).'px;';
	my $color = $$cb ? 'background:#f0f0f0;' : '';
	$$cb = $$cb ? 0 : 1;
	my $style = $sect->id == 1 ? ' style="background-color:#606060;color:#ffffff;'.$padding.$color.'"' : ' style="'.$padding.$color.'"';
	my $sel = $selected && $selected == $sect->id ? ' selected' : '';
	$m->out ('<option value="'.$sect->id.'"'.$style.$sel.'>&raquo;&nbsp;'.$sect->name.'</option>'."\n");
	if ( exists $sect->{children} && $offset < $count_offset ) {
		$offset++;
		foreach my $child ( @{$sect->{children}} ) {
			select_index_tree( $child, $offset, $count_offset, $selected, $cb, $TREE );
		}
	}
    }

</%init>