Arthur-
There's an example of this at http://bgok.net. The 'feed the chicken'
block at the bottom is draggable and clickable. The link is not
activated if the tile has been moved. If it wasn't moved, the link is
activated.
Here's how I did it with scriptaculous:
In the html, create the draggable element like so:
<code>
<span id="dragMe" onmouseup="if (!tileMoved) window.open('place-you-
are-linking-to', 'window-name')">Text</span>
</code>
In the header, add this javascript:
<code>
<script language="javascript" type="text/javascript"
src="scriptaculous-js-1.7.1_beta1/lib/prototype.js"></script>
<script src="scriptaculous-js-1.7.1_beta1/src/scriptaculous.js?
load=effects,dragdrop" type="text/javascript" language="javascript"></
script>
<script language="javascript" type="text/javascript">
var tileMoved = false;
function makeDraggable(tileDiv) {
new Draggable(tileDiv, {
revert: true,
reverteffect: function(el, yOffset, xOffset) {
// A hack, using reverteffect() to do onDrop processing
tileMoved=false; // Reset tile moved because we've
already
prevented the link
},
starteffect: function(element) {
tileMoved=true; // If we get here, the tile has been
moved
element.style.zIndex = 1000; // A moving tile should be
on top of
everything else
element._opacity = Element.getOpacity(element);
Draggable._dragging[element] = true;
new Effect.Opacity(element, {duration:0.2,
from:element._opacity,
to:0.7});
}
});
}
Event.observe(window, 'load', function() {
makeDraggable("dragMe");
});
</script>
</code>
I've tested this in IE7 and FF2 only.
Cheers,
Ken
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---