I've been doing a lot of rewriting of the dragdrop.js code. Maybe it
will be accepted or maybe I'll be the only one using it. But it is my
first project in JavaScript so a few JavaScript details are a little
fuzzy for me.

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

I think "onChange:    Prototype.emptyFunction" just makes it so that
if the user does not supply a function for onChange then there is a
default. That means the script won't crash when it tries to call
onChange and nothing was explicity specified by the user.

On the other hand, if the user specifies onChange then the user
specified onChange will replace the default emptyFunction. In this
case the user onChange will be called when there is a change.

In Sortables, the default options are updated with the user supplied
options in this line

    Object.extend(options, arguments[1] || {});

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

By the way, JavaScript is not so cool. Why don't they imbed ruby into
browsers? :)

Peter



On 2/7/06, Varun Mehta <[EMAIL PROTECTED]> wrote:
>
>
>
> In Sortables, we have a function onHover:
>
>
>
>   onHover: function(element, dropon, overlap) {
>
>     if(overlap>0.5) {
>
>       Sortable.mark(dropon, 'before');
>
>       if(dropon.previousSibling != element) {
>
>         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 {
>
>       Sortable.mark(dropon, 'after');
>
>       var nextElement = dropon.nextSibling || null;
>
>       if(nextElement != element) {
>
>         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);
>
>       }
>
>     }
>
>   },
>
>
>
> I was not able to understand what go these lines of code do? Cos onChange is
>
> onChange:    Prototype.emptyFunction,
>
>
>
> And the emptyFunction is
>
>
>
>   emptyFunction: function() {},
>
>
>
> So I'm kinda lost, can anyone help me understand the same? Thanks in advance
>
>
>
> Regards
>  Varun Mehta
_______________________________________________
Rails-spinoffs mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to