Sha256: 46d10900805ab659be2cdbf7605e251db2197a6e882c046513b440536e412583

Contents?: true

Size: 1.31 KB

Versions: 4

Compression:

Stored size: 1.31 KB

Contents

module ActiveAdmin
  module ViewHelpers
    module ActiveAdminApplicationHelper
      attr_accessor :aa_data

      def arbre_content_for( name, &block )
        if block_given?
          content_for name.to_sym do
            Arbre::Context.new do
              text_node yield
            end.content
          end
        end
      end

      #
      # Injects ActiveAdmin data into the WEB page as a javaScript object
      #
      #
      # @return [string]
      # 
      def active_admin_js_data_tag
        "<script type=\"text/javascript\">window.App || (window.App = {});window.App.ActiveAdmin = #{aa_data.to_json};</script>".html_safe
      end

      def controlller_stylesheet_link_tag
        stylesheet_link_tag params[:controller] if asset_exist?("#{params[:controller]}.css")
      end

      def controller_env_stylesheet_link_tag
        stylesheet_link_tag "#{params[:controller]}-#{Rails.env}" if asset_exist?("#{params[:controller]}-#{Rails.env}.css")
      end

      def controller_javascript_include_tag
        javascript_include_tag params[:controller] if asset_exist?("#{params[:controller]}.js")
      end

      def controller_env_javascript_include_tag
        javascript_include_tag "#{params[:controller]}-#{Rails.env}" if asset_exist?("#{params[:controller]}-#{Rails.env}.js")
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
activeadmin_custom_layout-0.1.9 lib/activeadmin_custom_layout/helpers.rb
activeadmin_custom_layout-0.1.8 lib/activeadmin_custom_layout/helpers.rb
activeadmin_custom_layout-0.1.7 lib/activeadmin_custom_layout/helpers.rb
activeadmin_custom_layout-0.1.6 lib/activeadmin_custom_layout/helpers.rb