# Module: BivouacHelpers::ScriptAculoUsView
[ "README", "AUTHORS", "COPYING", "lib/bivouac/helpers/view/goh/base.rb", "lib/bivouac/helpers/view/goh/form.rb", "lib/bivouac/helpers/view/goh/html.rb", "lib/bivouac/helpers/view/goh/sound.rb", "lib/bivouac/helpers/view/goh/scriptaculous.rb", "lib/bivouac/helpers/view/goh/javascript.rb", nil].each do
JavaScriptGenerator.view_html
BivouacHelpers.view_html
BivouacHelpers::SoundView.view_html
BivouacHelpers::ScriptAculoUsView.view_html
BivouacHelpers::BaseView.view_html
BivouacHelpers::JavaScriptView.view_html
BivouacHelpers::HtmlView.view_html
BivouacHelpers::FormView.view_html
end

Module BivouacHelpers::ScriptAculoUsView < Object

(in files lib/bivouac/helpers/view/goh/scriptaculous.rb )

bivouac/helpers/view/html

Methods

Public Instance method: draggable_element(element_id, options = {})

Makes the element with the DOM ID specified by element_id draggable.

Example:

  draggable_element("my_image", :revert => true)

You can change the behaviour with various options, see script.aculo.us for more documentation.

    # File lib/bivouac/helpers/view/goh/scriptaculous.rb, line 94
94:     def draggable_element(element_id, options = {})
95:       javascript_tag(draggable_element_js(element_id, options) + ";\n")
96:     end

Public Instance method: drop_receiving_element(element_id, options = {})

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 of the element as parameter.

Example:

  drop_receiving_element("my_cart", :onDrop => {
    :url => R(CartAdd),
    :update => 'drop-info'
  } )

You can change the behaviour with various options, see script.aculo.us for more documentation.

     # File lib/bivouac/helpers/view/goh/scriptaculous.rb, line 115
115:     def drop_receiving_element(element_id, options = {})
116:       javascript_tag(drop_receiving_element_js(element_id, options) + ";\n")
117:     end

Public Instance method: sortable_element( element_id, options = {} )

Makes the element with the DOM ID specified by element_id sortable by drag-and-drop and make an Ajax call whenever the sort order has changed. By default, the action called gets the serialized sortable element as parameters.

See script.aculo.us for avalaible options.

If you wan‘t to use onChange and/or onUpdate you can pass a javascript string or a Hash, if you want to call a remote function.

Example:

  ul( :id => 'my_list' ) do
    li "Google"
    li "Yahoo"
    li "Accoona"
    li "Ask.com"
    li "Baidu"
    li "Exalead"
    li "Voila"
    li "Lycos"
  end
  sortable_element( 'my_list',
    :onChange => {
      :url => R(SaveListOrder),
      :success => visual_effect( :highlight, 'my_list' )
    }
  )
    # File lib/bivouac/helpers/view/goh/scriptaculous.rb, line 54
54:     def sortable_element( element_id, options = {} )
55:       javascript_tag( sortable_element_js( element_id, options ) + ";\n" )
56:     end

Public Instance method: visual_effect(name, element_id = false, js_options = {})

Returns a JavaScript snippet to be used on the Ajax callbacks for starting visual effects.

    # File lib/bivouac/helpers/view/goh/scriptaculous.rb, line 11
11:     def visual_effect(name, element_id = false, js_options = {})
12:       element = element_id ? element_id : "element"
13: 
14:       js_options[:queue] = if js_options[:queue].is_a?(Hash)
15:         '{' + js_options[:queue].map {|k, v| k == :limit ? "#{k}:#{v}" : "#{k}:'#{v}'" }.join(',') + '}'
16:       elsif js_options[:queue]
17:         "'#{js_options[:queue]}'"
18:       end if js_options[:queue]
19: 
20:       if TOGGLE_EFFECTS.include? name.to_sym
21:         %(Effect.toggle(#{element.inspect},'#{name.to_s.gsub(/^toggle_/,'')}',#{options_for_javascript(js_options)}))
22:       else
23:         %(new Effect.#{name.to_s.camelize}('#{element}',#{options_for_javascript(js_options)}))
24:       end
25:     end