lib/apotomo/rails/view_helper.rb in apotomo-1.0.5 vs lib/apotomo/rails/view_helper.rb in apotomo-1.1.0.rc1
- old
+ new
@@ -1,9 +1,23 @@
module Apotomo
module Rails
+ # == #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
module ViewHelper
- # needs :@controller
+ delegate :children, :url_for_event, :widget_id, :to => :controller
# Returns the app JavaScript generator.
def js_generator
Apotomo.js_generator
end
@@ -18,35 +32,10 @@
# 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
- # Returns the url to trigger a +type+ event from the currently rendered widget.
- # The source can be changed with +:source+. Additional +options+ will be appended to the query string.
- #
- # Note that this method will use the framework's internal routing if available (e.g. #url_for in Rails).
- #
- # Example:
- # url_for_event(:paginate, :page => 2)
- # #=> http://apotomo.de/mouse/process_event_request?type=paginate&source=mouse&page=2
- def url_for_event(type, options={})
- controller.url_for_event(type, options)
- end
-
- ### TODO: test me.
- ### DISCUSS: rename to rendered_children ?
- def content
- @rendered_children.collect{|e| e.last}.join("\n").html_safe
- end
-
- # needs: suppress_javascript
- def widget_javascript(*args, &block)
- return if @suppress_js ### FIXME: implement with ActiveHelper and :locals.
-
- javascript_tag(*args, &block)
- end
-
# Wraps your content in a +div+ and sets the id. Feel free to pass additional html options.
#
# Example:
#
# - widget_div do
@@ -58,14 +47,9 @@
# <p>I'm wrapped</p>
# </div>
def widget_div(options={}, &block)
options.reverse_merge!(:id => widget_id)
content_tag(:div, options, &block)
- end
-
- # Returns the widget id you passed in a has_widgets block.
- def widget_id
- controller.name
end
end
end
end