<?php
    $this->headTitle( $this->translate( '#structure management#' ) );
    $this->partialLoop()->setObjectkey( 'entry' );
    
    $this->headLink()->appendStylesheet( $this->cdnUrl( '/scripts/jstree/themes/default/style.css' ) );
    $this->inlineScript()
    	 ->appendFile( $this->cdnUrl( '/scripts/jstree/jquery.tree.min.js' ) )
    	 ->appendFile( $this->cdnUrl( '/scripts/jstree/plugins/jquery.tree.contextmenu.js' ) );

?>


<p class="clearfix" class="btn-group">
	<a href="#" class="btn" id="jstreeOpenAll"><?= $this->translate('#__label::open_all__#') ?></a>  
	<a href="#" class="btn" id="jstreeCloseAll"><?= $this->translate('#__label::close_all__#') ?></a> 
</p>

<div id="nestedSortable" style="width: 500px">
    <ul class="nestedSortableList"><?php
    $cpt   = 1;
    $depth = 0;
    foreach( $this->structures as $cat ) {
        echo $this->partial(
            'admin-structure/_partials/trashList.phtml',
            array( 'entry' => $cat, 'counter' => $cpt, 'depth' => 0 )
        );

        $cpt++;
    }
    ?></ul>
</div>

<?php $this->inlineScript()->captureStart(); ?>
$(function(){
	$('#nestedSortable a.action').hide();
	
	$("#nestedSortable").tree({
		rules : {
			// only nodes of type root can be top level nodes
			valid_children : [ "root" ]
		},
		types : {
			// all node types inherit the "default" node type
			"default" : {
				deletable : true,
				renameable : false
			},
			"root" : {
				deletable : false,
				draggable : false,
				valid_children : [ "default" ],
				/* icon : { 
					image : "drive.png"
				}*/
			}			
		},
		
		
	});

	$('a#jstreeOpenAll').click(function(){
		$.tree.focused().open_all();
	})
	$('a#jstreeCloseAll').click(function(){
		$.tree.focused().close_all();
	})

	$('a.restoreButton').click(function(e){
		e.preventDefault();
		//console.log(this);
		document.location.href = $(this).attr('href');
	});

	$('a.strike').parents('li').each(function(){
		$(this).removeClass('closed'); 
	});
	
});
<?php $this->inlineScript()->captureEnd(); ?>
	
<style>
 .tree li a.strike{
 	text-decoration: line-through;
 	color: black;
 }
 .tree li a{
 	color: #555;
 }
</style>