From d79becdf21fd85432eceead107c37ccb5dea33c1 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Wed, 21 May 2008 14:46:30 +0200 Subject: revised conventions and minor details in scriptaculous_helper.rb --- .../action_view/helpers/scriptaculous_helper.rb | 166 ++++++++++----------- 1 file changed, 82 insertions(+), 84 deletions(-) diff --git a/actionpack/lib/action_view/helpers/scriptaculous_helper.rb b/actionpack/lib/action_view/helpers/scriptaculous_helper.rb index f948ddc6b0..658480c016 100644 --- a/actionpack/lib/action_view/helpers/scriptaculous_helper.rb +++ b/actionpack/lib/action_view/helpers/scriptaculous_helper.rb @@ -26,9 +26,9 @@ module ActionView # :url => { :action => "reload" }, # :complete => visual_effect(:highlight, "posts", :duration => 0.5) # - # If no element_id is given, it assumes "element" which should be a local + # If no +element_id+ is given, it assumes "element" which should be a local # variable in the generated JavaScript execution context. This can be - # used for example with drop_receiving_element: + # used for example with +drop_receiving_element+: # # <%= drop_receiving_element (...), :loading => visual_effect(:fade) %> # @@ -79,60 +79,60 @@ module ActionView # # Additional +options+ are: # - # :format:: A regular expression to determine what to send - # as the serialized id to the server (the default - # is /^[^_]*_(.*)$/). - # - # :constraint:: Whether to constrain the dragging to either :horizontal - # or :vertical (or false to make it unconstrained). - # - # :overlap:: Calculate the item overlap in the :horizontal or - # :vertical direction. - # - # :tag:: Which children of the container element to treat as - # sortable (default is li). - # - # :containment:: Takes an element or array of elements to treat as - # potential drop targets (defaults to the original - # target element). - # - # :only:: A CSS class name or arry of class names used to filter - # out child elements as candidates. - # - # :scroll:: Determines whether to scroll the list during drag - # operations if the list runs past the visual border. - # - # :tree:: Determines whether to treat nested lists as part of the - # main sortable list. This means that you can create multi- - # layer lists, and not only sort items at the same level, - # but drag and sort items between levels. - # - # :hoverclass:: If set, the Droppable will have this additional CSS class - # when an accepted Draggable is hovered over it. - # - # :handle:: Sets whether the element should only be draggable by an - # embedded handle. The value may be a string referencing a - # CSS class value (as of script.aculo.us V1.5). The first - # child/grandchild/etc. element found within the element - # that has this CSS class value will be used as the handle. - # - # :ghosting:: Clones the element and drags the clone, leaving the original - # in place until the clone is dropped (default is false). - # - # :dropOnEmpty:: If set to true, the Sortable container will be made into - # a Droppable, that can receive a Draggable (as according to - # the containment rules) as a child element when there are no - # more elements inside (default is false). - # - # :onChange:: Called whenever the sort order changes while dragging. When - # dragging from one Sortable to another, the callback is - # called once on each Sortable. Gets the affected element as - # its parameter. - # - # :onUpdate:: Called when the drag ends and the Sortable's order is - # changed in any way. When dragging from one Sortable to - # another, the callback is called once on each Sortable. Gets - # the container as its parameter. + # * :format - A regular expression to determine what to send + # as the serialized id to the server (the default + # is /^[^_]*_(.*)$/). + # + # * :constraint - Whether to constrain the dragging to either :horizontal + # or :vertical (or false to make it unconstrained). + # + # * :overlap - Calculate the item overlap in the :horizontal or + # :vertical direction. + # + # * :tag - Which children of the container element to treat as + # sortable (default is li). + # + # * :containment - Takes an element or array of elements to treat as + # potential drop targets (defaults to the original + # target element). + # + # * :only - A CSS class name or arry of class names used to filter + # out child elements as candidates. + # + # * :scroll - Determines whether to scroll the list during drag + # operations if the list runs past the visual border. + # + # * :tree - Determines whether to treat nested lists as part of the + # main sortable list. This means that you can create multi- + # layer lists, and not only sort items at the same level, + # but drag and sort items between levels. + # + # * :hoverclass - If set, the Droppable will have this additional CSS class + # when an accepted Draggable is hovered over it. + # + # * :handle - Sets whether the element should only be draggable by an + # embedded handle. The value may be a string referencing a + # CSS class value (as of script.aculo.us V1.5). The first + # child/grandchild/etc. element found within the element + # that has this CSS class value will be used as the handle. + # + # * :ghosting - Clones the element and drags the clone, leaving the original + # in place until the clone is dropped (default is false). + # + # * :dropOnEmpty - If true the Sortable container will be made into + # a Droppable, that can receive a Draggable (as according to + # the containment rules) as a child element when there are no + # more elements inside (default is false). + # + # * :onChange - Called whenever the sort order changes while dragging. When + # dragging from one Sortable to another, the callback is + # called once on each Sortable. Gets the affected element as + # its parameter. + # + # * :onUpdate - Called when the drag ends and the Sortable's order is + # changed in any way. When dragging from one Sortable to + # another, the callback is called once on each Sortable. Gets + # the container as its parameter. # # See http://script.aculo.us for more documentation. def sortable_element(element_id, options = {}) @@ -170,8 +170,8 @@ module ActionView end # Makes the element with the DOM ID specified by +element_id+ receive - # dropped draggable elements (created by draggable_element). - # and make an AJAX call By default, the action called gets the DOM ID + # dropped draggable elements (created by +draggable_element+). + # and make an AJAX call. By default, the action called gets the DOM ID # of the element as parameter. # # Example: @@ -182,32 +182,30 @@ module ActionView # http://script.aculo.us for more documentation. # # Some of these +options+ include: - # :accept:: Set this to a string or an array of strings describing the - # allowable CSS classes that the draggable_element must have in order - # to be accepted by this drop_receiving_element. - # - # :confirm:: Adds a confirmation dialog. - # - # Example: - # :confirm => "Are you sure you want to do this?" - # - # :hoverclass:: If set, the drop_receiving_element will have this additional CSS class - # when an accepted draggable_element is hovered over it. - # - # :onDrop:: Called when a draggable_element is dropped onto this element. - # Override this callback with a javascript expression to - # change the default drop behavour. - # - # Example: - # :onDrop => "function(draggable_element, droppable_element, event) { alert('I like bananas') }" - # - # This callback gets three parameters: - # The Draggable element, the Droppable element and the - # Event object. You can extract additional information about the - # drop - like if the Ctrl or Shift keys were pressed - from the Event object. - # - # :with:: A JavaScript expression specifying the parameters for the XMLHttpRequest. - # Any expressions should return a valid URL query string. + # * :accept - Set this to a string or an array of strings describing the + # allowable CSS classes that the +draggable_element+ must have in order + # to be accepted by this +drop_receiving_element+. + # + # * :confirm - Adds a confirmation dialog. Example: + # + # :confirm => "Are you sure you want to do this?" + # + # * :hoverclass - If set, the +drop_receiving_element+ will have this additional CSS class + # when an accepted +draggable_element+ is hovered over it. + # + # * :onDrop - Called when a +draggable_element+ is dropped onto this element. + # Override this callback with a JavaScript expression to + # change the default drop behavour. Example: + # + # :onDrop => "function(draggable_element, droppable_element, event) { alert('I like bananas') }" + # + # This callback gets three parameters: + # The Draggable element, the Droppable element and the + # Event object. You can extract additional information about the + # drop - like if the Ctrl or Shift keys were pressed - from the Event object. + # + # * :with - A JavaScript expression specifying the parameters for the XMLHttpRequest. + # Any expressions should return a valid URL query string. def drop_receiving_element(element_id, options = {}) javascript_tag(drop_receiving_element_js(element_id, options).chop!) end -- cgit v1.2.3