Sha256: e97fd68445e7a907c27cd0ccf96082ba57460bd07bed1c8fad5f3c159ac3e997

Contents?: true

Size: 790 Bytes

Versions: 3

Compression:

Stored size: 790 Bytes

Contents

module TurbolinksAnimateHelper

    def turbolinks_animate animation
        @turbolinks_animate_animation = animation.is_a?(Hash) ? animation.to_json : animation
    end

    def turbolinks_animate_body options = {}, &block
        default_options = {
            class: '',
            data: {}
        }
        options = default_options.merge options
        if @turbolinks_animate_animation
            options[:class] += ( options[:class].length > 0 ? ' turbolinks-animate' : 'turbolinks-animate' )
            options[:data][:turbolinks_animate_animation] = @turbolinks_animate_animation
        end
        if block_given?
            content_tag 'body', capture(&block), options
        else
            content_tag 'body', options
        end
    end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
turbolinks-animate-1.3.0 app/helpers/turbolinks_animate_helper.rb
turbolinks-animate-1.2.0 app/helpers/turbolinks_animate_helper.rb
turbolinks-animate-1.1.0 app/helpers/turbolinks_animate_helper.rb