public
Description: Implements a sortable tree for scriptacolous
Homepage: http://www.artweb-design.de
Clone URL: git://github.com/svenfuchs/scriptaculous-sortabletree.git
Search Repo:
add a droppable 'container' option to constrain which elements accept 
child elements
svenfuchs (author)
Fri May 30 06:14:32 -0700 2008
commit  1551aabfeac91d3ddfc28827be2b972cb83bc0ad
tree    ca13c8bcef9350c7d8c880e4b39e2855e93761f8
parent  6356442011acf2ddf412db35dc8eb7d7dd1647f2
...
104
105
106
 
 
 
107
108
109
...
104
105
106
107
108
109
110
111
112
0
@@ -104,6 +104,9 @@
0
 
0
 <script>
0
   var tree = new SortableTree('tree', {
0
+ droppable: {
0
+ container: ':not(.file)'
0
+ },
0
     onDrop: function(drag, drop, event){
0
       $('log').update($('log').innerHTML + "<p>" + drag.to_params() + "</p>")
0
     }
...
134
135
136
137
 
 
 
 
 
138
139
140
141
142
 
 
 
 
 
 
 
 
143
144
145
...
134
135
136
 
137
138
139
140
141
142
143
144
145
 
146
147
148
149
150
151
152
153
154
155
156
0
@@ -134,12 +134,23 @@ SortableTree.Node = Class.create({
0
   },
0
 
0
   onHover: function(drag, drop, overlap) {    
0
- this.dropPosition = overlap < 0.33 ? 'bottom' : overlap > 0.77 ? 'top' : 'insert';
0
+ if(this.canContainChildren(drop)) {
0
+ this.dropPosition = overlap < 0.33 ? 'bottom' : overlap > 0.77 ? 'top' : 'insert';
0
+ } else {
0
+ this.dropPosition = overlap < 0.5 ? 'bottom' : 'top';
0
+ }
0
     this.mark(drop);
0
     // $('log').update('hovering: ' + drop.tagName + ': ' + drop.id + "<br />" +
0
     // 'classes: ' + drop.className + "<br />" +
0
     //                'dropPosition: ' + this.dropPosition)
0
- },
0
+ },
0
+
0
+ canContainChildren: function(element) {
0
+ if(this.options.droppable.container) {
0
+ return element.match(this.options.droppable.container);
0
+ }
0
+ return true;
0
+ },
0
 
0
   onDrop: function(drag, drop, event) {
0
     drag = this.tree.find(drag);

Comments

    No one has commented yet.