Joseph Dunn
2007-Aug-12  16:51 UTC
"drag class" for script.aculo.us Draggables and Sortables (patch)
Hi list, I''m using script.aculo.us''s Sortable control in a personal project, and I needed to add a CSS class to my Draggables for the duration of their drag, in order to hide a few elements in the Draggable while dragging. After adding a few lines to dragdrop.js to allow for a "dragclass" option on Draggables and Sortables, I tested my changes and verified that they work. Attached is a diff, in case anyone else would find this functionality useful, or Thomas would consider committing it to trunk. Comments, of course, are welcome. :) Regards, Joseph --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Tom Gregory
2007-Aug-12  20:37 UTC
Re: "drag class" for script.aculo.us Draggables and Sortables (patch)
While it''s neat, and I appreciate your work, what you''re trying to do is pretty easily accomplished with the available callbacks. IM[H]O, it would clutter the option space. But, as I''m not a core dev, my opinion doesn''t count. =) TAG On Aug 12, 2007, at 10:51 AM, Joseph Dunn wrote:> Hi list, > > I''m using script.aculo.us''s Sortable control in a personal project, > and I needed to add a CSS class to my Draggables for the duration of > their drag, in order to hide a few elements in the Draggable while > dragging. After adding a few lines to dragdrop.js to allow for a > "dragclass" option on Draggables and Sortables, I tested my changes > and > verified that they work. Attached is a diff, in case anyone else would > find this functionality useful, or Thomas would consider committing > it to trunk. Comments, of course, are welcome. :) > > Regards, > > Joseph > > > Index: scriptaculous/src/dragdrop.js > ==================================================================> --- scriptaculous/src/dragdrop.js (revision 7308) > +++ scriptaculous/src/dragdrop.js (working copy) > @@ -351,6 +351,10 @@ > this.originalScrollTop = this.options.scroll.scrollTop; > } > } > + > + if(this.options.dragclass) { > + Element.addClassName(this.element, this.options.dragclass); > + } > > Draggables.notify(''onStart'', this, event); > > @@ -414,6 +418,10 @@ > this._clone = null; > } > > + if(this.options.dragclass) { > + Element.removeClassName(this.element, this.options.dragclass); > + } > + > var dropped = false; > if(success) { > dropped = Droppables.fire(event, this.element); > @@ -637,6 +645,7 @@ > only: false, > delay: 0, > hoverclass: null, > + dragclass: null, > ghosting: false, > quiet: false, > scroll: false, > @@ -666,7 +675,8 @@ > delay: options.delay, > ghosting: options.ghosting, > constraint: options.constraint, > - handle: options.handle }; > + handle: options.handle, > + dragclass: options.dragclass }; > > if(options.starteffect) > options_for_draggable.starteffect = options.starteffect;--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Joseph Dunn
2007-Aug-14  18:29 UTC
Re: "drag class" for script.aculo.us Draggables and Sortables (patch)
Ooh, interesting. When I initially had the idea, I wondered if it would be possible with callbacks, but I wasn''t sure how to do it. Could you point me in the right direction as far as finding out more about callbacks? Thanks, Joe On Aug 12, 3:37 pm, Tom Gregory <t...-PGZyUNKar/Q@public.gmane.org> wrote:> While it''s neat, and I appreciate your work, what you''re trying to do > is pretty easily accomplished with the available callbacks. IM[H]O, > it would clutter the option space. But, as I''m not a core dev, my > opinion doesn''t count. =) > > TAG > > On Aug 12, 2007, at 10:51 AM, Joseph Dunn wrote: > > > Hi list, > > > I''m using script.aculo.us''s Sortable control in a personal project, > > and I needed to add a CSS class to my Draggables for the duration of > > their drag, in order to hide a few elements in the Draggable while > > dragging. After adding a few lines to dragdrop.js to allow for a > > "dragclass" option on Draggables and Sortables, I tested my changes > > and > > verified that they work. Attached is a diff, in case anyone else would > > find this functionality useful, or Thomas would consider committing > > it to trunk. Comments, of course, are welcome. :) > > > Regards, > > > Joseph > > > Index: scriptaculous/src/dragdrop.js > > ==================================================================> > --- scriptaculous/src/dragdrop.js (revision 7308) > > +++ scriptaculous/src/dragdrop.js (working copy) > > @@ -351,6 +351,10 @@ > > this.originalScrollTop = this.options.scroll.scrollTop; > > } > > } > > + > > + if(this.options.dragclass) { > > + Element.addClassName(this.element, this.options.dragclass); > > + } > > > Draggables.notify(''onStart'', this, event); > > > @@ -414,6 +418,10 @@ > > this._clone = null; > > } > > > + if(this.options.dragclass) { > > + Element.removeClassName(this.element, this.options.dragclass); > > + } > > + > > var dropped = false; > > if(success) { > > dropped = Droppables.fire(event, this.element); > > @@ -637,6 +645,7 @@ > > only: false, > > delay: 0, > > hoverclass: null, > > + dragclass: null, > > ghosting: false, > > quiet: false, > > scroll: false, > > @@ -666,7 +675,8 @@ > > delay: options.delay, > > ghosting: options.ghosting, > > constraint: options.constraint, > > - handle: options.handle }; > > + handle: options.handle, > > + dragclass: options.dragclass }; > > > if(options.starteffect) > > options_for_draggable.starteffect = options.starteffect;--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Tom Gregory
2007-Aug-14  20:20 UTC
Re: "drag class" for script.aculo.us Draggables and Sortables (patch)
http://wiki.script.aculo.us/scriptaculous/show/Draggable
Specifically, onStart, and onEnd
e.x.:
new Draggable(''product_1'',{
   onStart: function(dragObj, event) {
     dragObj.element.addClassName(''someClass'');
   },
   onEnd: function (dragObj, event) {
     dragObj.element.removeClassName(''someClass''));
   }
});
You may also find a use for Draggable observers.  Search dragdrop.js  
for "addObserver" and "SortableObserver" for examples.
TAG
On Aug 14, 2007, at 12:29 PM, Joseph Dunn wrote:
>
> Ooh, interesting. When I initially had the idea, I wondered if it
> would be possible with callbacks, but I wasn''t sure how to do it.
> Could you point me in the right direction as far as finding out more
> about callbacks? Thanks,
>
> Joe
>
> On Aug 12, 3:37 pm, Tom Gregory <t...-PGZyUNKar/Q@public.gmane.org>
wrote:
>> While it''s neat, and I appreciate your work, what
you''re trying to do
>> is pretty easily accomplished with the available callbacks. IM[H]O,
>> it would clutter the option space.  But, as I''m not a core
dev, my
>> opinion doesn''t count.  =)
>>
>> TAG
>>
>> On Aug 12, 2007, at 10:51 AM, Joseph Dunn wrote:
>>
>>> Hi list,
>>
>>> I''m using script.aculo.us''s Sortable control in a
personal project,
>>> and I needed to add a CSS class to my Draggables for the duration
of
>>> their drag, in order to hide a few elements in the Draggable while
>>> dragging. After adding a few lines to dragdrop.js to allow for a
>>> "dragclass" option on Draggables and Sortables, I tested
my changes
>>> and
>>> verified that they work. Attached is a diff, in case anyone else  
>>> would
>>> find this functionality useful, or Thomas would consider committing
>>> it to trunk. Comments, of course, are welcome. :)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---