Module: TwitterBootstrap::Rails::Cdn::ActionViewExtensions

Defined in:
lib/twitter-bootstrap-rails-cdn.rb

Constant Summary collapse

OFFLINE =
( ::Rails.env.development? or ::Rails.env.test? )
DEFAULT_HOST =
:netdna
BOOTSTRAP_VERSIONS =
[ '3.0.0', '2.3.2' ]

Instance Method Summary collapse

Instance Method Details

#twitter_bootstrap_javascript_include_tag(host, options = {}, html_options = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/twitter-bootstrap-rails-cdn.rb', line 19

def twitter_bootstrap_javascript_include_tag(host, options = {}, html_options = {})
  local = twitter_bootstrap_javascript_url(:local, options)

  if OFFLINE and !options[:force]
    javascript_include_tag(local, html_options)
  else
    [ 
      javascript_include_tag(twitter_bootstrap_javascript_url(host, options), html_options),
      javascript_tag("typeof $().modal == 'function' "+
        "|| document.write(unescape('#{javascript_include_tag(local, html_options).gsub('<','%3C')}'))")
    ].join("\n").html_safe
  end
end

#twitter_bootstrap_javascript_url(host = DEFAULT_HOST, options = {}) ⇒ Object



11
12
13
# File 'lib/twitter-bootstrap-rails-cdn.rb', line 11

def twitter_bootstrap_javascript_url(host = DEFAULT_HOST, options = {})
  twitter_bootstrap_url(:js, host, options)
end


33
34
35
36
37
38
39
40
41
# File 'lib/twitter-bootstrap-rails-cdn.rb', line 33

def twitter_bootstrap_stylesheet_link_tag(host, options = {}, html_options = {})
  local = twitter_bootstrap_stylesheet_url(:local, options)

  if OFFLINE and !options[:force]
    stylesheet_link_tag(local, html_options)
  else
    stylesheet_link_tag(twitter_bootstrap_stylesheet_url(host, options), html_options)
  end
end

#twitter_bootstrap_stylesheet_url(host = DEFAULT_HOST, options = {}) ⇒ Object



15
16
17
# File 'lib/twitter-bootstrap-rails-cdn.rb', line 15

def twitter_bootstrap_stylesheet_url(host = DEFAULT_HOST, options = {})
  twitter_bootstrap_url(:css, host, options)
end