After talking with Thomas Fuchs, he sent me a patch that was sent to
him by a community member, that allows having a dropmarker placed
onHover, much like netvibes does:
--------------------
I have made two changes to the latest (publicly released) file called
"dragdrop.js" of the scriptaculous library.


Change 1:
I have made one change in the Sortables "onHover" function, i have
moved the mark and umark calls to after the check if the element is
changed, which gives the following code. If i didn't make this change,
the area was marked even though the drop area wasn't changed to an
empty space yet.


  onHover: function(element, dropon, overlap) {
    if(overlap>0.5) {
      if(dropon.previousSibling != element) {
        Sortable.mark(dropon, 'before');
        var oldParentNode = element.parentNode;
        element.style.visibility = "hidden"; // fix gecko rendering
        dropon.parentNode.insertBefore(element, dropon);
        if(dropon.parentNode!=oldParentNode)
          Sortable.options(oldParentNode).onChange(element);
        Sortable.options(dropon.parentNode).onChange(element);
      }
    } else {
      var nextElement = dropon.nextSibling || null;
      if(nextElement != element) {
        Sortable.mark(dropon, 'after');
        var oldParentNode = element.parentNode;
        element.style.visibility = "hidden"; // fix gecko rendering
        dropon.parentNode.insertBefore(element, nextElement);
        if(dropon.parentNode!=oldParentNode)
          Sortable.options(oldParentNode).onChange(element);
        Sortable.options(dropon.parentNode).onChange(element);
      }
    }
  },


Change 2:
The mark function. I changed this function so it is allways called. The
only difference in ghosting and non-ghosting is that when you don't
ghost, like in my example, you will see the dropmarker in full width
and height.


  mark: function(dropon, position) {
    // always mark, see further down
    var sortable = Sortable.options(dropon.parentNode);


    if(!Sortable._marker) {
      Sortable._marker = $('dropmarker') ||
document.createElement('DIV');
      Element.hide(Sortable._marker);
      Element.addClassName(Sortable._marker, 'dropmarker');
      Sortable._marker.style.position = 'absolute';

document.getElementsByTagName("body").item(0).appendChild(Sortable._marker);
    }
    var offsets = Position.cumulativeOffset(dropon);
    Sortable._marker.style.left = offsets[0] + 'px';
    Sortable._marker.style.top = offsets[1] + 'px';


    //
    // If we are not ghosting, we should show the dropmarker in full
width and height of the element
    if (!sortable.ghosting) {
      Sortable._marker.style.width = dropon.clientWidth+'px';
      Sortable._marker.style.height = dropon.clientHeight+'px';
    } else {
      if(position=='after')
        if(sortable.overlap == 'horizontal')
          Sortable._marker.style.left = (offsets[0]+dropon.clientWidth)
+ 'px';
        else
          Sortable._marker.style.top = (offsets[1]+dropon.clientHeight)
+ 'px';
    }
    Element.show(Sortable._marker);
  },


Any comments are appreciated and credit also :)


Regards,


Gilles vd Hoven

---------------------

I have been playing with the script so far. It doesn't seem to do
anything regardless of what you define your dropmarker selector in CSS
to be in Win IE. Seems to work in FF.

My case may be a special one, as I am trying to sort divs and not
lists, so the dropmarker sizes with the above hacks, overlap currently.
I'm assuming this should work for lists just fine.

Regards,
Roy Russo


--~--~---------~--~----~------------~-------~--~----~
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 rubyonrails-spinoffs@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs
-~----------~----~----~----~------~----~------~--~---

Reply via email to