module Apotomo::Rails::ViewHelper

url_for_event

= url_for_event(:paginate, :page => 2)
#=> http://apotomo.de/mouse/process_event_request?type=paginate&source=mouse&page=2

widget_id

= widget_id
#=> :mouse

children

- children.each do |kid|
  = render_widget kid

Public Instance Methods

js_generator() click to toggle source

Returns the app JavaScript generator.

# File lib/apotomo/rails/view_helper.rb, line 21
def js_generator
  Apotomo.js_generator
end
multipart_form_to_event(type, options={}, html_options={}, &block) click to toggle source

Creates a form that submits itself via an iFrame and executes the response in the parent window. This is needed to upload files via AJAX.

Better call #form_to_event :multipart => true and stay forward-compatible.

# File lib/apotomo/rails/view_helper.rb, line 29
def multipart_form_to_event(type, options={}, html_options={}, &block)
  options.reverse_merge!      :apotomo_iframe => true
  html_options.reverse_merge! :target         => :apotomo_iframe, :multipart => true

  # i hate rails:
  concat('<iframe id="apotomo_iframe" name="apotomo_iframe" style="display: none;"></iframe>'.html_safe) << form_tag(url_for_event(type, options), html_options, &block)
end
widget_div(*args, &block) click to toggle source

Wraps your widget content in a div. See widget_tag.

# File lib/apotomo/rails/view_helper.rb, line 38
def widget_div(*args, &block)
  widget_tag(:div, *args, &block)
end
widget_tag(tag, options={}, &block) click to toggle source

Wraps your widget content in a tag tag and sets the id. Feel free to pass additional html options.

- widget_tag :span do
  %p I'm wrapped

will render

<span id="mouse">
  <p>I'm wrapped</p>
</span>

Note that you can set the id and other options manually.

- widget_tag :div, id: "comments", class: "yellow"
# File lib/apotomo/rails/view_helper.rb, line 56
def widget_tag(tag, options={}, &block)
  options.reverse_merge!(:id => widget_id)

  content_tag(tag, options, &block)
end