lib/apotomo/rails/view_helper.rb in apotomo-1.0.1 vs lib/apotomo/rails/view_helper.rb in apotomo-1.0.2

- old
+ new

@@ -5,35 +5,11 @@ # Returns the app JavaScript generator. def js_generator Apotomo.js_generator end - - - # Generates the JavaScript code to report an event of <tt>type</tt> to Apotomo with AJAX. - # As always per default the event source is the currently rendered widget. - # Internally this method just uses <tt>remote_function</tt> for JS output. - # - # Example: - # - # <%= image_tag "cheese.png", :onMouseover => trigger_event(:mouseAlarm) %> - # - # will trigger the event <tt>:mouseAlarm</tt> when moving the mouse over the cheese image. - def trigger_event(type, options={}) - js_generator.xhr(url_for_event(type, options)) - end - - # Creates a form tag that triggers an event via AJAX when submitted. - # See StatefulWidget::address_for_event for options. - # - # The values of form elements are available via StatefulWidget#param. - def form_to_event(type, options={}, html_options={}, &block) - return multipart_form_to_event(type, options, html_options, &block) if options.delete(:multipart) - - form_remote_tag({:url => url_for_event(type, options), :html => html_options}, &block) - end - + # 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 <tt>#form_to_event :multipart => true</tt> and stay forward-compatible. def multipart_form_to_event(type, options={}, html_options={}, &block) @@ -51,19 +27,14 @@ # # 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={}) - @cell.url_for_event(type, options) + controller.url_for_event(type, options) end ### TODO: test me. - def update_url(fragment) - 'SWFAddress.setValue("' + fragment + '");' - end - - ### TODO: test me. ### DISCUSS: rename to rendered_children ? def content @rendered_children.collect{|e| e.last}.join("\n").html_safe end @@ -91,10 +62,10 @@ content_tag(:div, options, &block) end # Returns the widget id you passed in a has_widgets block. def widget_id - @cell.name + controller.name end end end end