1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2008 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*
* This script is based on the
* jQuery File Tree Plugin,
* developed by Cory S.N. LaViska
* A Beautiful Site (http://abeautifulsite.net/)
* Originally released 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/
*
*/
if(jQuery) (function($){
$.extend($.fn, {
RearrangeTree: function(o, h) {
// Defaults
if( !o ) var o = {};
if( o.script == undefined ) o.script = 'rearrange';
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...';
$("#gAddAlbum").draggable({
helper: 'clone',
containment: "#gRearrange",
opacity: .6,
revert: "invalid"
});
$("#gDeleteItem").droppable({
accept: "a",
hoverClass: "droppable-hover",
drop: function(ev, ui) {
source_element = ui.draggable;
source_parent = source_element.parent();
target = ui.element;
alert(source_element.attr("rel") + "\n" + target.attr("id"));
}
});
$(this).each( function() {
function showTree(c, t) {
$(c).addClass('wait');
$(".jqueryFileTree.start").remove();
$.get(o.script + "/" + t, {}, function(data) {
$(c).find('.start').html('');
$(c).removeClass('wait').append(data);
$(c).find('UL:hidden').slideDown({ duration: o.expandSpeed, easing: o.expandEasing });
$(c).find('UL:hidden').slideDown({ duration: o.expandSpeed, easing: o.expandEasing });
$(c).find('li.directory').droppable({
accept: "#gAddAlbum",
hoverClass: "droppable-hover",
drop: function(ev, ui) {
source_element = ui.draggable;
source_parent = source_element.parent();
target = ui.element;
alert(source_element.attr("rel") + "\n" + target.attr("id"));
}
});
if ($(c).hasClass('treeitem')) {
$(c).find("li a", this.element).draggable({
helper: 'clone',
containment: "#gRearrange",
opacity: .6,
revert: "invalid"
});
}
$(c).find('.directory').droppable({
accept: "a",
greedy: true,
hoverClass: "droppable-hover",
drop: function(ev, ui) {
source_element = ui.draggable;
source_parent = source_element.parent();
target = ui.element;
alert(source_element.attr("rel") + "\n" + target.attr("id"));
}
});
bindTree(c);
});
}
function bindTree(t) {
$(t).find('LI A').bind(o.folderEvent, function() {
if( $(this).parent().hasClass('directory') ) {
if( $(this).parent().hasClass('collapsed') ) {
// Expand
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(); // cleanup
showTree( $(this).parent(), escape($(this).attr('rel')) );
$(this).parent().removeClass('collapsed').addClass('expanded');
} else {
// Collapse
$(this).parent().find('UL').slideUp({ duration: o.collapseSpeed, easing: o.collapseEasing });
$(this).parent().removeClass('expanded').addClass('collapsed');
}
} else {
h($(this).attr('rel'));
}
return false;
});
// Prevent A from triggering the # on non-click events
if( o.folderEvent.toLowerCase != 'click' ) $(t).find('LI A').bind('click', function() { return false; });
}
// Loading message
$(this).html('<ul class="jqueryFileTree start"><li class="wait">' + o.loadMessage + '<li></ul>');
// Get the initial file list
showTree( $(this), "" );
});
}
});
})(jQuery);
|