Sha256: 094cdf662c7ea4713cca0fdda793ea127e131b11ac7be77b7fa74d806d311ef8

Contents?: true

Size: 1.71 KB

Versions: 11

Compression:

Stored size: 1.71 KB

Contents

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
      delegate :children, :url_for_event, :widget_id, :to => :controller
      
      # Returns the app JavaScript generator.
      def js_generator
        Apotomo.js_generator
      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)
        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
      
      # Wraps your content in a +div+ and sets the id. Feel free to pass additional html options.
      #
      # Example:
      #
      #   - widget_div do
      #     %p I'm wrapped
      #
      # will render
      #
      #   <div id="mouse">
      #     <p>I'm wrapped</p>
      #   </div>
      def widget_div(options={}, &block)
        options.reverse_merge!(:id => widget_id) 
        content_tag(:div, options, &block)
      end
    end  
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
apotomo-1.2.4 lib/apotomo/rails/view_helper.rb
apotomo-1.2.3 lib/apotomo/rails/view_helper.rb
apotomo-1.2.2 lib/apotomo/rails/view_helper.rb
apotomo-1.2.1 lib/apotomo/rails/view_helper.rb
apotomo-1.2.0 lib/apotomo/rails/view_helper.rb
apotomo-1.1.4 lib/apotomo/rails/view_helper.rb
apotomo-1.1.3 lib/apotomo/rails/view_helper.rb
apotomo-1.1.2 lib/apotomo/rails/view_helper.rb
apotomo-1.1.1 lib/apotomo/rails/view_helper.rb
apotomo-1.1.0 lib/apotomo/rails/view_helper.rb
apotomo-1.1.0.rc1 lib/apotomo/rails/view_helper.rb