ajma
2006-Nov-11 09:41 UTC
Script.aculo.us : how to programatically forcing an item to move up in a sortable list?
Hello, I have a Script.aculo.us question. I''m using a sortable list so that users can drag and drop to arrange a list. I would also like for users to be able to click a little "up" button to make an item move upwards. I would like the move upwards to have the same animation as if it were clicked and dragged. As someone who''s new to Script.aculo.us, I don''t even know where to begin looking on how to do this. Can someone help me? Thanks, Andrew. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Christophe Porteneuve
2006-Nov-11 10:06 UTC
Re: Script.aculo.us : how to programatically forcing an item to move up in a sortable list?
Hey Andrew, ajma a écrit :> I would also like for users to be able to click a little "up" button to > make an item move upwards. I would like the move upwards to have the > same animation as if it were clicked and dragged. > > As someone who''s new to Script.aculo.us, I don''t even know where to > begin looking on how to do this. Can someone help me?I do believe it''s just a matter of putting it one tick up in the DOM, something like (both directions allowed, ''thought you might need it): function moveItem(item, direction) { item = $(item); direction = direction || ''up''; if (!item[''down'' == direction ? ''nextSibling'' : ''previousSibling'']) return false; if (''down'' == direction) item.parentNode.insertBefore(item.nextSibling, item); else item.parentNode.insertBefore(item, item.previousSibling); return true; } ''should work. -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
ajma
2006-Nov-11 10:35 UTC
Re: Script.aculo.us : how to programatically forcing an item to move up in a sortable list?
Thanks for the reply Christophe. Your code does the moving like I''m looking for, but I''m also looking for some code which would have some animation of the item noticebally travelling upwards (as if the user were dragging it). Is this something that might be easily achieved as well? --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Christophe Porteneuve
2006-Nov-11 10:42 UTC
Re: Script.aculo.us : how to programatically forcing an item to move up in a sortable list?
ajma a écrit :> Thanks for the reply Christophe. > > Your code does the moving like I''m looking for, but I''m also looking > for some code which would have some animation of the item noticebally > travelling upwards (as if the user were dragging it). > > Is this something that might be easily achieved as well?I wouldn''t quite say "easily". Doing this in a reasonably cross-browser way is tricky, as the internals of script.aculo.us'' dragdrop.js demonstrate. Maybe there''s some way to derive from this code, but I''m not quite sure. ''sounds like a lot of work to me. Maybe just highlighting or pulsating the moved element would be enough? -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
ajma
2006-Nov-11 19:09 UTC
Re: Script.aculo.us : how to programatically forcing an item to move up in a sortable list?
Yeah, maybe I''ll just that. I was hoping someone had a solution that wouldn''t be too tough by leveraging script.aculo.us, but I guess not. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Jerod Venema
2006-Nov-12 03:43 UTC
Re: Script.aculo.us : how to programatically forcing an item to move up in a sortable list?
Try using the code above, in combination with the Effect.Move Instead of just doing the immediate insert, do the Effect.Move (using position information from the next/previous sibling), and in the afterFinish function, insert the element in its new position. You should get the animation that way. -Jerod On 11/11/06, ajma <ajmaonline-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Yeah, maybe I''ll just that. I was hoping someone had a solution that > wouldn''t be too tough by leveraging script.aculo.us, but I guess not. > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Mark Holton
2006-Nov-12 05:03 UTC
Re: Script.aculo.us : how to programatically forcing an item to move up in a sortable list?
I don''t have anything to add technically, just that I have a project where this would be a nice UI implementation. It would be great if someone can put up a version on the wiki that works. cheers, Mark On 11/11/06, Jerod Venema <jvenema-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Try using the code above, in combination with the Effect.Move > > Instead of just doing the immediate insert, do the Effect.Move (using > position information from the next/previous sibling), and in the afterFinish > function, insert the element in its new position. You should get the > animation that way. > > -Jerod > > > On 11/11/06, ajma <ajmaonline-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Yeah, maybe I''ll just that. I was hoping someone had a solution that > > wouldn''t be too tough by leveraging script.aculo.us, but I guess not. > > > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---