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



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

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



9
10
11
# File 'lib/twitter-bootstrap-rails-cdn.rb', line 9

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

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



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

def twitter_bootstrap_stylesheet_include_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



13
14
15
# File 'lib/twitter-bootstrap-rails-cdn.rb', line 13

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