Module: Spark::ApplicationHelper
- Defined in:
- app/helpers/spark/application_helper.rb
Instance Method Summary collapse
- #body_class(classnames = nil) ⇒ Object
- #ie_11_flex_layout_fix ⇒ Object
- #is_tree_expanded?(item) ⇒ Boolean
- #ng_attrs ⇒ Object
- #tree_cookie ⇒ Object
- #yield_if(symbol) {|content_for(symbol)| ... } ⇒ Object
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_fix ⇒ Object
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
12 13 14 |
# File 'app/helpers/spark/application_helper.rb', line 12 def ( item ) .present? && !!( item ) end |
#ng_attrs ⇒ Object
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 |
#tree_cookie ⇒ Object
4 5 6 7 8 9 10 |
# File 'app/helpers/spark/application_helper.rb', line 4 def @_tree_cookie ||= begin JSON.parse([:tree_nav]) if [:tree_nav].present? rescue nil end end |
#yield_if(symbol) {|content_for(symbol)| ... } ⇒ Object
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 |