Sha256: 5b1e0e91b7ec2976bbc925d09ad49586b44e7d855713aea3909b99b31bffe220

Contents?: true

Size: 1.81 KB

Versions: 2

Compression:

Stored size: 1.81 KB

Contents

module Netzke
  module Railz
    module ActionViewExt
      # Implementation of Ext-specific helpers
      module Ext #:nodoc:

        protected

          def netzke_ext_css_include(theme)
            # ExtJS base
            res = stylesheet_link_tag("/extjs/resources/css/ext-all")

            # ExtJS theming
            res << "\n" << stylesheet_link_tag("/extjs/resources/css/xtheme-#{theme}") unless theme.to_sym == :default

            # Netzke-related (dynamically generated by NetzkeController)
            res << "\n" << stylesheet_link_tag("/netzke/ext")

            res << "\n" << stylesheet_link_tag(Netzke::Core.external_ext_css)

            res
          end

          def netzke_ext_js_include
            res = []

            # ExtJS
            res << (ENV['RAILS_ENV'] == 'development' ? javascript_include_tag("/extjs/adapter/ext/ext-base-debug", "/extjs/ext-all-debug") : javascript_include_tag("/extjs/adapter/ext/ext-base", "/extjs/ext-all"))

            # Netzke (dynamically generated)
            res << javascript_include_tag("/netzke/ext")

            res.join("\n")
          end

          def netzke_ext_js
            res = []
            res << content_for(:netzke_js_classes)
            res << "\n"

            res << "Ext.onReady(function(){"
            res << content_for(:netzke_on_ready)
            res << "});"

            javascript_tag res.join("\n")
          end

          # (Experimental) Embeds a "pure" (non-Netzke) Ext component into the view, e.g.:
          #     <%= ext :my_panel, :xtype => :panel, :html => "Simple Panel"
          def ext(name, config = {}) #:doc:
            comp = Netzke::ExtComponent.new(name, config)
            content_for :netzke_on_ready, raw("#{comp.js_component_render}")
            raw(comp.js_component_html)
          end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
netzke-core-0.6.6 lib/netzke/railz/action_view_ext/ext.rb
netzke-core-0.6.5 lib/netzke/railz/action_view_ext/ext.rb