Module: Spark::ApplicationHelper

Defined in:
app/helpers/spark/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#body_class(classnames = nil) ⇒ Object



31
32
33
34
35
36
37
38
39
40
# File 'app/helpers/spark/application_helper.rb', line 31

def body_class(classnames=nil)
  unless classnames.nil?
    content_for(:body_classes) do 
      [classnames].flatten.join(' ') + ' '
    end
  end
  if classes = content_for(:body_classes)
    classes.strip
  end
end

#ie_11_flex_layout_fixObject



42
43
44
45
46
47
48
49
50
# File 'app/helpers/spark/application_helper.rb', line 42

def ie_11_flex_layout_fix
  user_agent = request.env['HTTP_USER_AGENT'].downcase
  if user_agent.match(/trident/) && user_agent.match(/rv:11/)
    %(<script type="text/javascript">(function(){
      var wrapper = document.querySelector('.app-wrapper')
      wrapper.style.flexBasis = "calc(100vh - "+wrapper.offsetTop+"px)";
    })()</script>).html_safe
  end
end

#is_tree_expanded?(item) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'app/helpers/spark/application_helper.rb', line 12

def is_tree_expanded?( item )
  tree_cookie.present? && !!tree_cookie( item )
end

#ng_attrsObject



16
17
18
19
20
21
22
23
24
25
# File 'app/helpers/spark/application_helper.rb', line 16

def ng_attrs
  attrs = {}

  [:ng_init, :ng_controller].each do |sym|
    attrs[sym] = content_for(sym) if content_for?(sym)
  end

  attrs

end


4
5
6
7
8
9
10
# File 'app/helpers/spark/application_helper.rb', line 4

def tree_cookie
  @_tree_cookie ||= begin
    JSON.parse(cookies[:tree_nav]) if cookies[:tree_nav].present?
  rescue
    nil
  end
end

#yield_if(symbol) {|content_for(symbol)| ... } ⇒ Object

Yields:

  • (content_for(symbol))


27
28
29
# File 'app/helpers/spark/application_helper.rb', line 27

def yield_if(symbol, &block)
  yield content_for(symbol) if content_for?(symbol)
end