Skip to content
Jiwoks edited this page Dec 17, 2012 · 3 revisions

JAOFileTree is a file tree plugin for jQuery

Usage

  1. Insert a container in your html code:
<div id="jao"></div>
  1. Initialize the file tree
jQuery(document).ready(function($) {
      $('#jao').jaofiletree();
});

Configure the plugin

You can pass some parameters to the plugins

jQuery(document).ready(function($) {
      $('#jao').jaofiletree({
           'onclick': function(elem,type,file){
                      alert('You clicked on '+file);
           },
           'usecheckboxes'   : false
      });
});

Parameters

Setting Default Description
root ’/’ Default root directory
script ‘connectors/jaoconnector.php’ server side script called to get file list
showroot ‘root’ Name of the root directory to show, if null not showing root directory
onclick function(elem,type,file){} function called when an element has been clicked. elem is the jQuery element, type contains ‘dir’ or ‘file’ according to file type, file contains the path to the file
oncheck function(elem,checked,type,file){} function called when an element has been clicked. elem is the jQuery element, checked is true or false according to checkbox state, type contains ‘dir’ or ‘file’ according to file type, file contains the path to the file
usecheckboxes true if true a checkbox if shown before the file name, if ‘dir’ checkbox is only before directories, if ‘file’ checkbox is only before files, if false there is no checkbox
expandSpeed 500 speed of the animation when folder is expanded
collapseSpeed 500 speed of the animation when folder is closed
expandEasing null animation used when folder is expanded
collapseEasing null animation used when folder is closed
canselect true whether or not you can select files and directories

Methods

You can call some methods to interact with the plugin

jQuery('#jao').jaofiletree('getCheck');
Will return an array of files or directories checked.
Method Parameters Return value Description
open directory to open none Open a visible directory in the file tree
close directory to close none Close a visible directory in the file tree
getchecked none array of objects Return all the checked files and directories
getselected none array of object Return the selected element

Events

JAOFileTree comes with event handling

jQuery('#jao').bind('afteropen',function(){//do what you want});
Event triggered Event
afteropen Event triggered after a folder has been openned
afterclose Event triggered after a folder has been closed
afterupdate Event triggered after a folder has been openned or clodes
check Event triggered after a checkbox has been checked
uncheck Event triggered after a checkbox has been unchecked