/**********************************************************
Very minorly modified from the example by Tim Taylor
http://tool-man.org/examples/sorting.html
-
+
Added Coordinate.prototype.inside( northwest, southeast );
-
+
Copyright (c) 2005 Tim Taylor Consulting <http://tool-man.org/>
-
+
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
-
+
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Coordinate.prototype.inside = function(northwest, southeast) {
if ((this.x >= northwest.x) && (this.x <= southeast.x) &&
(this.y >= northwest.y) && (this.y <= southeast.y)) {
-
+
return true;
}
return false;
/**********************************************************
Further modified from the example by Tim Taylor
http://tool-man.org/examples/sorting.html
-
+
Changed onMouseMove where it calls group.onDrag and then
adjusts the offset for changes to the DOM. If the item
being moved changed parents it would be off so changed to
get the absolute offset (recursive northwestOffset).
-
+
**********************************************************/
var Drag = {
group.onDragStart = new Function();
group.onDragEnd = new Function();
group.onDrag = new Function();
-
+
// TODO: use element.prototype.myFunc
group.setDragHandle = Drag.setDragHandle;
group.setDragThreshold = Drag.setDragThreshold;
},
setDragHandle : function(handle) {
- if (handle && handle != null)
+ if (handle && handle != null) {
this.handle = handle;
- else
+ } else {
this.handle = this;
+ }
this.handle.group = this;
this.onmousedown = null;
+ // this.onclick = Drag.toggleMe;
+ // this.handle.onclick = Drag.toggleMe;
this.handle.onmousedown = Drag.onMouseDown;
},
+ toggleMe : function(str) {
+ alert('Toggle: ' + str);
+ },
+
setDragThreshold : function(threshold) {
if (isNaN(parseInt(threshold))) return;
group.originalZIndex = group.style.zIndex;
group.initialWindowCoordinate = mouse;
// TODO: need a better name, but don't yet understand how it
- // participates in the magic while dragging
+ // participates in the magic while dragging
group.dragCoordinate = mouse;
Drag.showStatus(mouse, nwPosition, sePosition, nwOffset, seOffset);
// TODO: need better constraint API
if (group.minX != null)
- group.minMouseX = mouse.x - nwPosition.x +
+ group.minMouseX = mouse.x - nwPosition.x +
group.minX - nwOffset.x;
- if (group.maxX != null)
+ if (group.maxX != null)
group.maxMouseX = group.minMouseX + group.maxX - group.minX;
if (group.minY != null)
- group.minMouseY = mouse.y - nwPosition.y +
+ group.minMouseY = mouse.y - nwPosition.y +
group.minY - nwOffset.y;
- if (group.maxY != null)
+ if (group.maxY != null)
group.maxMouseY = group.minMouseY + group.maxY - group.minY;
group.mouseMin = new Coordinate(group.minMouseX, group.minMouseY);
},
showStatus : function(mouse, nwPosition, sePosition, nwOffset, seOffset) {
- /*window.status =
- "mouse: " + mouse.toString() + " " +
- "NW pos: " + nwPosition.toString() + " " +
- "SE pos: " + sePosition.toString() + " " +
+ /*window.status =
+ "mouse: " + mouse.toString() + " " +
+ "NW pos: " + nwPosition.toString() + " " +
+ "SE pos: " + sePosition.toString() + " " +
"NW offset: " + nwOffset.toString() + " " +
"SE offset: " + seOffset.toString();*/
},
// TODO: what we really want to do is find the offset from
// our corner to the mouse coordinate and adjust to keep it
// the same
-
+
// changed to be recursive/use absolute offset for corrections
var offsetBefore = Coordinates.northwestOffset(group, true);
group.onDrag(nwPosition, sePosition, nwOffset, seOffset);
/**********************************************************
Adapted from the sortable lists example by Tim Taylor
http://tool-man.org/examples/sorting.html
- Modified by Tom Westcott : http://www.cyberdummy.co.uk
+ Modified by Tom Westcott : http://www.cyberdummy.co.uk
**********************************************************/
var DragDrop = {
this.lastContainer.nextContainer = list;
this.lastContainer = list;
}
-
+
// these functions are called when an item is draged over
// a container or out of a container bounds. onDragOut
// is also called when the drag ends with an item having
list.onDragOut = new Function();
list.onDragDrop = new Function();
list.group = group;
-
+
var items = list.getElementsByTagName( "li" );
-
+
for (var i = 0; i < items.length; i++) {
DragDrop.makeItemDragable(items[i]);
}
},
-
+
serData : function ( group, theid ) {
var container = DragDrop.firstContainer;
var j = 0;
var string = "";
-
+
while (container != null) {
if(theid != null && container.id != theid) {
container = container.nextContainer;
container = container.nextContainer;
continue;
}
-
+
j ++;
if (j > 1) {
string += ":";
}
string += container.id;
-
+
var items = container.getElementsByTagName( "li" );
string += "(";
for (var i = 0; i < items.length; i++) {
string += items[i].id;
}
string += ")";
-
+
container = container.nextContainer;
}
- return string;
+ return string;
},
makeItemDragable : function(item) {
Drag.makeDraggable(item);
item.setDragThreshold(5);
-
+
// tracks if the item is currently outside all containers
item.isOutside = false;
-
+
item.onDragStart = DragDrop.onDragStart;
item.onDrag = DragDrop.onDrag;
item.onDragEnd = DragDrop.onDragEnd;
+
+ item.setDragHandle(document.getElementById('g' + item.id));
},
onDragStart : function(nwPosition, sePosition, nwOffset, seOffset) {
container.southeast = Coordinates.southeastOffset( container, true );
container = container.nextContainer;
}
-
+
// item starts out over current parent
this.parentNode.onDragOver();
parent_id = this.parentNode.id;
// we're inside this one
container.onDragOver();
this.isOutside = false;
-
+
// since isOutside was true, the current parent is a
// temporary clone of some previous container node and
// it needs to be removed from the document
// we're still not inside the bounds of any container
if (this.isOutside)
return;
-
+
// check if we're outside our parent's bounds
} else if (!(nwOffset.inside( this.parentNode.northwest, this.parentNode.southeast ) ||
seOffset.inside( this.parentNode.northwest, this.parentNode.southeast ))) {
-
+
this.parentNode.onDragOut();
this.isOutside = true;
-
+
// check if we're inside a new container's bounds
var container = DragDrop.firstContainer;
while (container != null) {
return;
}
}
-
+
// if we get here, we're inside some container bounds, so we do
// everything the original dragsort script did to swap us into the
// correct position
-
+
var parent = this.parentNode;
-
+
var item = this;
var next = DragUtils.nextItem(item);
while (next != null && this.offsetTop >= next.offsetTop - 2) {
onDragEnd : function(nwPosition, sePosition, nwOffset, seOffset) {
// if the drag ends and we're still outside all containers
- // it's time to remove ourselves from the document or add
+ // it's time to remove ourselves from the document or add
// to the trash bin
if (this.isOutside) {
var container = DragDrop.firstContainer;
sibling = sibling.previousSibling;
}
return null;
- }
+ }
};
/*************************
* Custom Serendipity code
*************************/
-
+
function pluginMoverInit() {
var list = document.getElementById("left_col");
DragDrop.makeListContainer(list, 'g1');
list.onDragOver = function() { this.style["border"] = "1px solid #4d759b"; };
list.onDragOut = function() { this.style["border"] = "none"; };
-
+
list = document.getElementById("hide_col");
DragDrop.makeListContainer(list, 'g1');
list.onDragOver = function() { this.style["border"] = "1px solid #4d759b"; };
list.onDragOut = function() {this.style["border"] = "none"; };
-
+
list = document.getElementById("right_col");
DragDrop.makeListContainer(list, 'g1');
list.onDragOver = function() { this.style["border"] = "1px solid #4d759b"; };
DragDrop.makeListContainer(list, 'g1');
list.onDragOver = function() { this.style["border"] = "1px solid #4d759b"; };
list.onDragOut = function() { this.style["border"] = "none"; };
-
+
list = document.getElementById("eventh_col");
DragDrop.makeListContainer(list, 'g1');
list.onDragOver = function() { this.style["border"] = "1px solid #4d759b"; };
o.minY = typeof minY != 'undefined' ? minY : null;
o.max = typeof maxX != 'undefined' ? maxX : null;
o.maxY = typeof maxY != 'undefined' ? maxY : null;
-
+
o.xMapper = fXMapper ? fXMapper : null;
o.yMapper = fYMapper ? fYMapper : null;