I was wondering if anyone can help me with the jQuery file tree ( jQuery file tree )
I was wondering if / how it would be possible to set some kind of variable that would tell the file tree to open a specific folder at boot time. (e.g. folder / images / fruit / will be opened by default)
Here is the code to call filetree:
$('#container_id').fileTree({
root: '/images/'
}, function(file) {
alert(file);
});
And here is the filetree.js file:
if(jQuery) (function($){
$.extend($.fn, {
fileTree: function(o, h) {
if( !o ) var o = {};
if( o.root == undefined ) o.root = '/';
if( o.script == undefined ) o.script = 'jqueryFileTree.php';
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...';
$(this).each( function() {
function showTree(c, t) {
$(c).addClass('wait');
$(".jqueryFileTree.start").remove();
$.post(o.script, { dir: t }, function(data) {
$(c).find('.start').html('');
$(c).removeClass('wait').append(data);
if( o.root == t ) $(c).find('ul:hidden').show(); else $(c).find('ul:hidden').slideDown({ duration: o.expandSpeed, easing: o.expandEasing });
bindTree(c);
});
}
function bindTree(t) {
$(t).find('li a').bind(o.folderEvent, function() {
if( $(this).parent().hasClass('directory') ) {
if( $(this).parent().hasClass('collapsed') ) {
if( !o.multiFolder ) {
$(this).parent().parent().find('ul').slideUp({ duration: o.collapseSpeed, easing: o.collapseEasing });
$(this).parent().parent().find('li.directory').removeClass('expanded').addClass('collapsed');
}
$(this).parent().find('ul').remove();
showTree( $(this).parent(), escape($(this).attr('rel').match( /.*\// )) );
$(this).parent().removeClass('collapsed').addClass('expanded');
} else {
$(this).parent().find('ul').slideUp({ duration: o.collapseSpeed, easing: o.collapseEasing });
$(this).parent().removeClass('expanded').addClass('collapsed');
}
} else {
h($(this).attr('rel'), $(this).attr('name'), $(this).attr('title'), $(this).attr('id'));
}
return false;
});
if( o.folderEvent.toLowerCase != 'click' ) $(t).find('li a').bind('click', function() { return false; });
}
$(this).html('<ul class="jqueryFileTree start"><li class="wait">' + o.loadMessage + '<li></ul>');
showTree( $(this), escape(o.root) );
});
}
});
})(jQuery);
Every time I tried to get along with him, I keep killing him since my javascript is not so good. Any help would be appreciated! :)
source
share