// jQuery File Tree Plugin // La source de cette librairie a été adapté // // Version 1.01 // // Cory S.N. LaViska // A Beautiful Site (http://abeautifulsite.net/) // 24 March 2008 // // Visit http://abeautifulsite.net/notebook.php?article=58 for more information // // Usage: jq12('.fileTreeDemo').fileTree( options, callback ) // // Options: root - root folder to display; default = / // script - location of the serverside AJAX file to use; default = jqueryFileTree.php // folderEvent - event to trigger expand/collapse; default = click // expandSpeed - default = 500 (ms); use -1 for no animation // collapseSpeed - default = 500 (ms); use -1 for no animation // expandEasing - easing function to use on expand (optional) // collapseEasing - easing function to use on collapse (optional) // multiFolder - whether or not to limit the browser to one subfolder at a time // loadMessage - Message to display while initial tree loads (can be HTML) // // History: // // 1.01 - updated to work with foreign characters in directory/file names (12 April 2008) // 1.00 - released (24 March 2008) // // TERMS OF USE // // jQuery File Tree is licensed under a Creative Commons License and is copyrighted (C)2008 by Cory S.N. LaViska. // For details, visit http://creativecommons.org/licenses/by/3.0/us/ // jq12.fn.fileTree = function(o, h) { // Defaults if( !o ) var o = {}; if( o.root == undefined ) o.root = '/'; if( o.script == undefined ) o.script = 'kb_file_tree.fl'; if( o.folderEvent == undefined ) o.folderEvent = 'click'; if( o.expandSpeed == undefined ) o.expandSpeed= 500; if( o.collapseSpeed == undefined ) o.collapseSpeed= 500; if( o.expandEasing == undefined ) o.expandEasing = null; if( o.collapseEasing == undefined ) o.collapseEasing = null; if( o.multiFolder == undefined ) o.multiFolder = true; if( o.loadMessage == undefined ) o.loadMessage = 'Loading...'; if( o.folderCallback == undefined ) o.folderCallback = null; if( o.after == undefined ) o.after = null; jq12(this).each( function() { function showTree(c, t) { jq12(c).addClass('wait'); jq12(".jqueryFileTree.start").remove(); jq12.post(o.script, { dir: t }, function(data) { jq12(c).find('.start').html(''); jq12(c).removeClass('wait').append(data); if( o.root == t ) jq12(c).find('UL:hidden').show(); else jq12(c).find('UL:hidden').slideDown({ duration: o.expandSpeed, easing: o.expandEasing }); bindTree(c); o.after(data); }); } function bindTree(t) { jq12(t).find('LI A').bind(o.folderEvent, function() { if( jq12(this).parent().hasClass('directory') ) { if( jq12(this).parent().hasClass('collapsed') ) { // Expand if( !o.multiFolder ) { jq12(this).parent().parent().find('UL').slideUp({ duration: o.collapseSpeed, easing: o.collapseEasing }); jq12(this).parent().parent().find('LI.directory').removeClass('expanded').addClass('collapsed'); } jq12(this).parent().find('UL').remove(); // cleanup //showTree( jq12(this).parent(), escape(jq12(this).attr('rel')) ); showTree( jq12(this).parent(), jq12(this).attr('rel') ); jq12(this).parent().removeClass('collapsed').addClass('expanded'); o.folderCallback(jq12(this).attr('rel')); } else { // Collapse jq12(this).parent().find('UL').slideUp({ duration: o.collapseSpeed, easing: o.collapseEasing }); jq12(this).parent().removeClass('expanded').addClass('collapsed'); } } else { h(jq12(this).attr('rel')); } return false; }); // Prevent A from triggering the # on non-click events if( o.folderEvent.toLowerCase != 'click' ) jq12(t).find('LI A').bind('click', function() { return false; }); } // Loading message jq12(this).html(''); // Get the initial file list showTree( jq12(this), escape(o.root) ); }); };