summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/MochiKit/Sortable.js
Unidiff
Diffstat (limited to 'frontend/gamma/js/MochiKit/Sortable.js') (more/less context) (show whitespace changes)
-rw-r--r--frontend/gamma/js/MochiKit/Sortable.js12
1 files changed, 6 insertions, 6 deletions
diff --git a/frontend/gamma/js/MochiKit/Sortable.js b/frontend/gamma/js/MochiKit/Sortable.js
index 863b506..ca9db21 100644
--- a/frontend/gamma/js/MochiKit/Sortable.js
+++ b/frontend/gamma/js/MochiKit/Sortable.js
@@ -1,33 +1,33 @@
1/*** 1/***
2Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 2Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
3 Mochi-ized By Thomas Herve (_firstname_@nimail.org) 3 Mochi-ized By Thomas Herve (_firstname_@nimail.org)
4 4
5See scriptaculous.js for full license. 5See scriptaculous.js for full license.
6 6
7***/ 7***/
8 8
9MochiKit.Base._module('Sortable', '1.5', ['Base', 'Iter', 'DOM', 'Position', 'DragAndDrop']); 9MochiKit.Base.module(MochiKit, 'Sortable', '1.5', ['Base', 'Iter', 'DOM', 'Position', 'DragAndDrop']);
10 10
11MochiKit.Base.update(MochiKit.Sortable, { 11MochiKit.Base.update(MochiKit.Sortable, {
12 __export__: false, 12 __export__: false,
13 13
14 /*** 14 /***
15 15
16 Manage sortables. Mainly use the create function to add a sortable. 16 Manage sortables. Mainly use the create function to add a sortable.
17 17
18 ***/ 18 ***/
19 sortables: {}, 19 sortables: {},
20 20
21 _findRootElement: function (element) { 21 _findRootElement: function (element) {
22 while (element.tagName.toUpperCase() != "BODY") { 22 while (element.tagName.toUpperCase() != "BODY") {
23 if (element.id && MochiKit.Sortable.sortables[element.id]) { 23 if (element.id && MochiKit.Sortable.sortables[element.id]) {
24 return element; 24 return element;
25 } 25 }
26 element = element.parentNode; 26 element = element.parentNode;
27 } 27 }
28 }, 28 },
29 29
30 _createElementId: function(element) { 30 _createElementId: function(element) {
31 if (element.id == null || element.id == "") { 31 if (element.id == null || element.id == "") {
32 var d = MochiKit.DOM; 32 var d = MochiKit.DOM;
33 var id; 33 var id;
@@ -158,57 +158,57 @@ MochiKit.Base.update(MochiKit.Sortable, {
158 options_for_draggable.reverteffect = options.reverteffect; 158 options_for_draggable.reverteffect = options.reverteffect;
159 } else if (options.ghosting) { 159 } else if (options.ghosting) {
160 options_for_draggable.reverteffect = function (innerelement) { 160 options_for_draggable.reverteffect = function (innerelement) {
161 innerelement.style.top = 0; 161 innerelement.style.top = 0;
162 innerelement.style.left = 0; 162 innerelement.style.left = 0;
163 }; 163 };
164 } 164 }
165 165
166 if (options.endeffect) { 166 if (options.endeffect) {
167 options_for_draggable.endeffect = options.endeffect; 167 options_for_draggable.endeffect = options.endeffect;
168 } 168 }
169 169
170 if (options.zindex) { 170 if (options.zindex) {
171 options_for_draggable.zindex = options.zindex; 171 options_for_draggable.zindex = options.zindex;
172 } 172 }
173 173
174 // build options for the droppables 174 // build options for the droppables
175 var options_for_droppable = { 175 var options_for_droppable = {
176 overlap: options.overlap, 176 overlap: options.overlap,
177 containment: options.containment, 177 containment: options.containment,
178 hoverclass: options.hoverclass, 178 hoverclass: options.hoverclass,
179 onhover: self.onHover, 179 onhover: self.onHover,
180 tree: options.tree, 180 tree: options.tree,
181 accept: options.accept 181 accept: options.accept
182 } 182 };
183 183
184 var options_for_tree = { 184 var options_for_tree = {
185 onhover: self.onEmptyHover, 185 onhover: self.onEmptyHover,
186 overlap: options.overlap, 186 overlap: options.overlap,
187 containment: options.containment, 187 containment: options.containment,
188 hoverclass: options.hoverclass, 188 hoverclass: options.hoverclass,
189 accept: options.accept 189 accept: options.accept
190 } 190 };
191 191
192 // fix for gecko engine 192 // fix for gecko engine
193 MochiKit.DOM.removeEmptyTextNodes(element); 193 MochiKit.DOM.removeEmptyTextNodes(element);
194 194
195 options.draggables = []; 195 options.draggables = [];
196 options.droppables = []; 196 options.droppables = [];
197 197
198 // drop on empty handling 198 // drop on empty handling
199 if (options.dropOnEmpty || options.tree) { 199 if (options.dropOnEmpty || options.tree) {
200 new MochiKit.DragAndDrop.Droppable(element, options_for_tree); 200 new MochiKit.DragAndDrop.Droppable(element, options_for_tree);
201 options.droppables.push(element); 201 options.droppables.push(element);
202 } 202 }
203 MochiKit.Base.map(function (e) { 203 MochiKit.Base.map(function (e) {
204 // handles are per-draggable 204 // handles are per-draggable
205 var handle = options.handle ? 205 var handle = options.handle ?
206 MochiKit.DOM.getFirstElementByTagAndClassName(null, 206 MochiKit.DOM.getFirstElementByTagAndClassName(null,
207 options.handle, e) : e; 207 options.handle, e) : e;
208 options.draggables.push( 208 options.draggables.push(
209 new MochiKit.DragAndDrop.Draggable(e, 209 new MochiKit.DragAndDrop.Draggable(e,
210 MochiKit.Base.update(options_for_draggable, 210 MochiKit.Base.update(options_for_draggable,
211 {handle: handle}))); 211 {handle: handle})));
212 new MochiKit.DragAndDrop.Droppable(e, options_for_droppable); 212 new MochiKit.DragAndDrop.Droppable(e, options_for_droppable);
213 if (options.tree) { 213 if (options.tree) {
214 e.treeNode = element; 214 e.treeNode = element;
@@ -409,94 +409,94 @@ MochiKit.Base.update(MochiKit.Sortable, {
409 self._marker.style.top = (offsets.y + dropon.clientHeight) + 'px'; 409 self._marker.style.top = (offsets.y + dropon.clientHeight) + 'px';
410 } 410 }
411 } 411 }
412 MochiKit.Style.showElement(self._marker); 412 MochiKit.Style.showElement(self._marker);
413 }, 413 },
414 414
415 _tree: function (element, options, parent) { 415 _tree: function (element, options, parent) {
416 var self = MochiKit.Sortable; 416 var self = MochiKit.Sortable;
417 var children = self.findElements(element, options) || []; 417 var children = self.findElements(element, options) || [];
418 418
419 for (var i = 0; i < children.length; ++i) { 419 for (var i = 0; i < children.length; ++i) {
420 var match = children[i].id.match(options.format); 420 var match = children[i].id.match(options.format);
421 421
422 if (!match) { 422 if (!match) {
423 continue; 423 continue;
424 } 424 }
425 425
426 var child = { 426 var child = {
427 id: encodeURIComponent(match ? match[1] : null), 427 id: encodeURIComponent(match ? match[1] : null),
428 element: element, 428 element: element,
429 parent: parent, 429 parent: parent,
430 children: [], 430 children: [],
431 position: parent.children.length, 431 position: parent.children.length,
432 container: self._findChildrenElement(children[i], options.treeTag.toUpperCase()) 432 container: self._findChildrenElement(children[i], options.treeTag.toUpperCase())
433 } 433 };
434 434
435 /* Get the element containing the children and recurse over it */ 435 /* Get the element containing the children and recurse over it */
436 if (child.container) { 436 if (child.container) {
437 self._tree(child.container, options, child) 437 self._tree(child.container, options, child);
438 } 438 }
439 439
440 parent.children.push (child); 440 parent.children.push (child);
441 } 441 }
442 442
443 return parent; 443 return parent;
444 }, 444 },
445 445
446 /* Finds the first element of the given tag type within a parent element. 446 /* Finds the first element of the given tag type within a parent element.
447 Used for finding the first LI[ST] within a L[IST]I[TEM].*/ 447 Used for finding the first LI[ST] within a L[IST]I[TEM].*/
448 _findChildrenElement: function (element, containerTag) { 448 _findChildrenElement: function (element, containerTag) {
449 if (element && element.hasChildNodes) { 449 if (element && element.hasChildNodes) {
450 containerTag = containerTag.toUpperCase(); 450 containerTag = containerTag.toUpperCase();
451 for (var i = 0; i < element.childNodes.length; ++i) { 451 for (var i = 0; i < element.childNodes.length; ++i) {
452 if (element.childNodes[i].tagName.toUpperCase() == containerTag) { 452 if (element.childNodes[i].tagName.toUpperCase() == containerTag) {
453 return element.childNodes[i]; 453 return element.childNodes[i];
454 } 454 }
455 } 455 }
456 } 456 }
457 return null; 457 return null;
458 }, 458 },
459 459
460 /** @id MochiKit.Sortable.tree */ 460 /** @id MochiKit.Sortable.tree */
461 tree: function (element, options) { 461 tree: function (element, options) {
462 element = MochiKit.DOM.getElement(element); 462 element = MochiKit.DOM.getElement(element);
463 var sortableOptions = MochiKit.Sortable.options(element); 463 var sortableOptions = MochiKit.Sortable.options(element);
464 options = MochiKit.Base.update({ 464 options = MochiKit.Base.update({
465 tag: sortableOptions.tag, 465 tag: sortableOptions.tag,
466 treeTag: sortableOptions.treeTag, 466 treeTag: sortableOptions.treeTag,
467 only: sortableOptions.only, 467 only: sortableOptions.only,
468 name: element.id, 468 name: element.id,
469 format: sortableOptions.format 469 format: sortableOptions.format
470 }, options || {}); 470 }, options || {});
471 471
472 var root = { 472 var root = {
473 id: null, 473 id: null,
474 parent: null, 474 parent: null,
475 children: new Array, 475 children: new Array,
476 container: element, 476 container: element,
477 position: 0 477 position: 0
478 } 478 };
479 479
480 return MochiKit.Sortable._tree(element, options, root); 480 return MochiKit.Sortable._tree(element, options, root);
481 }, 481 },
482 482
483 /** 483 /**
484 * Specifies the sequence for the Sortable. 484 * Specifies the sequence for the Sortable.
485 * @param {Node} element Element to use as the Sortable. 485 * @param {Node} element Element to use as the Sortable.
486 * @param {Object} newSequence New sequence to use. 486 * @param {Object} newSequence New sequence to use.
487 * @param {Object} options Options to use fro the Sortable. 487 * @param {Object} options Options to use fro the Sortable.
488 */ 488 */
489 setSequence: function (element, newSequence, options) { 489 setSequence: function (element, newSequence, options) {
490 var self = MochiKit.Sortable; 490 var self = MochiKit.Sortable;
491 var b = MochiKit.Base; 491 var b = MochiKit.Base;
492 element = MochiKit.DOM.getElement(element); 492 element = MochiKit.DOM.getElement(element);
493 options = b.update(self.options(element), options || {}); 493 options = b.update(self.options(element), options || {});
494 494
495 var nodeMap = {}; 495 var nodeMap = {};
496 b.map(function (n) { 496 b.map(function (n) {
497 var m = n.id.match(options.format); 497 var m = n.id.match(options.format);
498 if (m) { 498 if (m) {
499 nodeMap[m[1]] = [n, n.parentNode]; 499 nodeMap[m[1]] = [n, n.parentNode];
500 } 500 }
501 n.parentNode.removeChild(n); 501 n.parentNode.removeChild(n);
502 }, self.findElements(element, options)); 502 }, self.findElements(element, options));