Module: Netzke::Core::Stylesheets::ClassMethods

Defined in:
lib/netzke/core/stylesheets.rb

Instance Method Summary collapse

Instance Method Details

#client_styles(&block) ⇒ Object

Configures JS class



12
13
14
# File 'lib/netzke/core/stylesheets.rb', line 12

def client_styles &block
  block.call(css_config)
end

#css_code(cached = []) ⇒ Object

All CSS code needed for this class including the one from the ancestor component



28
29
30
31
32
33
34
35
36
37
# File 'lib/netzke/core/stylesheets.rb', line 28

def css_code(cached = [])
  res = ""

  # include the base-class javascript if doing JS inheritance
  res << superclass.css_code << "\n" if !client_class_config.extending_extjs_component? && !cached.include?(superclass.name)

  res << css_included << "\n"

  res
end

#css_configObject



16
17
18
# File 'lib/netzke/core/stylesheets.rb', line 16

def css_config
  @_css_config ||= Netzke::Core::CssConfig.new(self)
end

#css_includedObject

Returns all extra CSS code (as string) required by this component’s class



21
22
23
24
25
# File 'lib/netzke/core/stylesheets.rb', line 21

def css_included
  # Prevent re-including code that was already included by the parent
  # (thus, only include those JS files when include_js was defined in the current class, not in its ancestors)
  ((singleton_methods(false).map(&:to_sym).include?(:include_css) ? include_css : [] ) + css_config.required_files).inject(""){ |r, path| r + File.new(path).read + "\n"}
end