Module: BootstrapRailsEngine::ActionViewExtensions
- Defined in:
- lib/bootstrap-rails-engine.rb
Constant Summary collapse
- BOOTSTRAP_VERSION =
"3.0.3"- FONTAWESOME_VERSION =
"4.0.3"- OFFLINE =
(::Rails.env.development? or ::Rails.env.test?)
- CDNS =
{ :bootstrap_js => { :default => "//netdna.bootstrapcdn.com/bootstrap/#{BOOTSTRAP_VERSION}/js/bootstrap.min.js" }, :bootstrap_css => { :default => "//netdna.bootstrapcdn.com/bootstrap/#{BOOTSTRAP_VERSION}/css/bootstrap.min.css" }, :bootstrap_theme_css => { :default => "//netdna.bootstrapcdn.com/bootstrap/#{BOOTSTRAP_VERSION}/css/bootstrap-theme.min.css" }, :fontawesome_css => { :default => "//netdna.bootstrapcdn.com/font-awesome/#{FONTAWESOME_VERSION}/css/font-awesome.min.css" } }
Instance Method Summary collapse
-
#bootstrap_javascript_include_tag(name, options = {}) ⇒ Object
to be used with bootstrap-rails-engine gem.
- #bootstrap_javascript_url(name) ⇒ Object
- #bootstrap_stylesheet_include_tag(name, options = {}) ⇒ Object
- #bootstrap_stylesheet_url(name) ⇒ Object
- #bootstrap_theme_stylesheet_include_tag(name, options = {}) ⇒ Object
- #bootstrap_theme_stylesheet_url(name) ⇒ Object
- #fontawesome_stylesheet_include_tag(name, options = {}) ⇒ Object
- #fontawesome_stylesheet_url(name) ⇒ Object
Instance Method Details
#bootstrap_javascript_include_tag(name, options = {}) ⇒ Object
to be used with bootstrap-rails-engine gem
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/bootstrap-rails-engine.rb', line 39 def bootstrap_javascript_include_tag(name, = {}) .reverse_merge! :local_copy => false bootstrap_j = 'bootstrap/bootstrap' bootstrap_j = bootstrap_j + '.min' if .delete(:compressed) if OFFLINE and !.delete(:force) .delete(:local_copy) # not used in OFFLINE mode return javascript_include_tag(bootstrap_j, ) else local_copy = .delete(:local_copy) j = [ javascript_include_tag(bootstrap_javascript_url(name), ) ] if local_copy j << javascript_tag("typeof $().carousel == 'function' || document.write(unescape('#{javascript_include_tag(bootstrap_j, ).gsub('<','%3C')}'))") end j.join("\n").html_safe end end |
#bootstrap_javascript_url(name) ⇒ Object
22 23 24 |
# File 'lib/bootstrap-rails-engine.rb', line 22 def bootstrap_javascript_url(name) return CDNS[:bootstrap_js][name] end |
#bootstrap_stylesheet_include_tag(name, options = {}) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/bootstrap-rails-engine.rb', line 58 def bootstrap_stylesheet_include_tag(name, = {}) bootstrap_c = 'bootstrap/bootstrap' bootstrap_c = bootstrap_c + '.min' if .delete(:compressed) if OFFLINE and !.delete(:force) return stylesheet_link_tag(bootstrap_c, ) else # Bootstrap do not offer way to check existing [ stylesheet_link_tag(bootstrap_stylesheet_url(name), ), ].join("\n").html_safe end end |
#bootstrap_stylesheet_url(name) ⇒ Object
26 27 28 |
# File 'lib/bootstrap-rails-engine.rb', line 26 def bootstrap_stylesheet_url(name) return CDNS[:bootstrap_css][name] end |
#bootstrap_theme_stylesheet_include_tag(name, options = {}) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/bootstrap-rails-engine.rb', line 71 def bootstrap_theme_stylesheet_include_tag(name, = {}) bootstrap_t = 'bootstrap/bootstrap-theme' bootstrap_t = bootstrap_t + '.min' if .delete(:compressed) if OFFLINE and !.delete(:force) return stylesheet_link_tag(bootstrap_t, ) else # Bootstrap Theme do not offer way to check existing [ stylesheet_link_tag(bootstrap_theme_stylesheet_url(name), ), ].join("\n").html_safe end end |
#bootstrap_theme_stylesheet_url(name) ⇒ Object
30 31 32 |
# File 'lib/bootstrap-rails-engine.rb', line 30 def bootstrap_theme_stylesheet_url(name) return CDNS[:bootstrap_theme_css][name] end |
#fontawesome_stylesheet_include_tag(name, options = {}) ⇒ Object
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/bootstrap-rails-engine.rb', line 84 def fontawesome_stylesheet_include_tag(name, = {}) if OFFLINE and !.delete(:force) # To be used with font-awesome-rails gem. return stylesheet_link_tag('font-awesome', ) else # Fontawesome do not offer way to check existing [ stylesheet_link_tag(fontawesome_stylesheet_url(name), ), ].join("\n").html_safe end end |
#fontawesome_stylesheet_url(name) ⇒ Object
34 35 36 |
# File 'lib/bootstrap-rails-engine.rb', line 34 def fontawesome_stylesheet_url(name) return CDNS[:fontawesome_css][name] end |